You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/07/01 02:15:54 UTC
svn commit: r959476 [2/2] -
/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/
Added: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/_RequestParameterValuesMap.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/_RequestParameterValuesMap.java?rev=959476&view=auto
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/_RequestParameterValuesMap.java (added)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/_RequestParameterValuesMap.java Thu Jul 1 00:15:53 2010
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.test.mock;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletRequest;
+
+/**
+ * ServletRequest multi-value parameters as Map.
+ *
+ * @author Anton Koinov (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472618 $ $Date: 2006-11-08 15:06:54 -0500 (Mié, 08 Nov 2006) $
+ */
+class _RequestParameterValuesMap extends _AbstractAttributeMap
+{
+ private final ServletRequest _servletRequest;
+
+ _RequestParameterValuesMap(ServletRequest servletRequest)
+ {
+ _servletRequest = servletRequest;
+ }
+
+ protected Object getAttribute(String key)
+ {
+ return _servletRequest.getParameterValues(key);
+ }
+
+ protected void setAttribute(String key, Object value)
+ {
+ throw new UnsupportedOperationException(
+ "Cannot set ServletRequest ParameterValues");
+ }
+
+ protected void removeAttribute(String key)
+ {
+ throw new UnsupportedOperationException(
+ "Cannot remove ServletRequest ParameterValues");
+ }
+
+ protected Enumeration getAttributeNames()
+ {
+ return _servletRequest.getParameterNames();
+ }
+}
\ No newline at end of file
Added: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/_SessionMap.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/_SessionMap.java?rev=959476&view=auto
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/_SessionMap.java (added)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/_SessionMap.java Thu Jul 1 00:15:53 2010
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.test.mock;
+
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+
+/**
+ * HttpSession attibutes as Map.
+ *
+ * @author Anton Koinov (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472618 $ $Date: 2006-11-08 15:06:54 -0500 (Mié, 08 Nov 2006) $
+ */
+class _SessionMap extends _AbstractAttributeMap
+{
+ private final HttpServletRequest _httpRequest;
+
+ _SessionMap(HttpServletRequest httpRequest)
+ {
+ _httpRequest = httpRequest;
+ }
+
+ protected Object getAttribute(String key)
+ {
+ HttpSession httpSession = getSession();
+ return (httpSession == null)
+ ? null : httpSession.getAttribute(key.toString());
+ }
+
+ protected void setAttribute(String key, Object value)
+ {
+ _httpRequest.getSession(true).setAttribute(key, value);
+ }
+
+ protected void removeAttribute(String key)
+ {
+ HttpSession httpSession = getSession();
+ if (httpSession != null)
+ {
+ httpSession.removeAttribute(key);
+ }
+ }
+
+ protected Enumeration getAttributeNames()
+ {
+ HttpSession httpSession = getSession();
+ return (httpSession == null)
+ ? _NullEnumeration.instance()
+ : httpSession.getAttributeNames();
+ }
+
+ private HttpSession getSession()
+ {
+ return _httpRequest.getSession(false);
+ }
+
+
+ public void putAll(Map t)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void clear()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
\ No newline at end of file