Author: greddin Date: Thu Mar 8 08:25:17 2007 New Revision: 516091 URL: http://svn.apache.org/viewvc?view=rev&rev=516091 Log: SHALE-421. Applied patch submitted by Antonio Petrelli. Adds Portlet support to shale-test.
Added: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletContext.java (with props) shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletRequest.java (with props) shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletResponse.java (with props) shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletSession.java (with props) Modified: shale/framework/trunk/shale-test/pom.xml Modified: shale/framework/trunk/shale-test/pom.xml URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/pom.xml?view=diff&rev=516091&r1=516090&r2=516091 ============================================================================== --- shale/framework/trunk/shale-test/pom.xml (original) +++ shale/framework/trunk/shale-test/pom.xml Thu Mar 8 08:25:17 2007 @@ -85,6 +85,13 @@ <optional>true</optional> </dependency> + <dependency> + <groupId>javax.portlet</groupId> + <artifactId>portlet-api</artifactId> + <version>1.0</version> + <scope>provided</scope> + </dependency> + </dependencies> <!-- Allow building with JDK 1.4 as well as JDK 1.5, Added: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletContext.java URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletContext.java?view=auto&rev=516091 ============================================================================== --- shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletContext.java (added) +++ shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletContext.java Thu Mar 8 08:25:17 2007 @@ -0,0 +1,326 @@ +/* + * 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.shale.test.mock; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Set; + +import javax.portlet.PortletContext; +import javax.portlet.PortletRequestDispatcher; + +/** + * <p>Mock implementation of <code>PortletContext</code>.</p> + * + * $Id$ + */ +public class MockPortletContext implements PortletContext { + + // ----------------------------------------------------- Mock Object Methods + + /** + * <p>Add a context initialization parameter to the set of parameters + * recognized by this instance.</p> + * + * @param name Parameter name + * @param value Parameter value + */ + public void addInitParameter(String name, String value) { + + parameters.put(name, value); + + } + + + /** + * <p>Add a new MIME type mapping to the set of mappings recognized by this + * instance.</p> + * + * @param extension Extension to check for (without the period) + * @param contentType Corresponding content type + */ + public void addMimeType(String extension, String contentType) { + + mimeTypes.put(extension, contentType); + + } + + + /** + * <p>Set the document root for <code>getRealPath()</code> resolution. + * This parameter <strong>MUST</strong> represent a directory.</p> + * + * @param documentRoot The new base directory + */ + public void setDocumentRoot(File documentRoot) { + + this.documentRoot = documentRoot; + + } + + // ------------------------------------------------------ Instance Variables + + private Hashtable attributes = new Hashtable(); + private File documentRoot = null; + private Hashtable mimeTypes = new Hashtable(); + private Hashtable parameters = new Hashtable(); + + + // -------------------------------------------------- PortletContext Methods + + + /** [EMAIL PROTECTED] */ + public Object getAttribute(String name) { + + return attributes.get(name); + + } + + + /** [EMAIL PROTECTED] */ + public Enumeration getAttributeNames() { + + return attributes.keys(); + + } + + + /** [EMAIL PROTECTED] */ + public String getInitParameter(String name) { + + return (String) parameters.get(name); + + } + + + /** [EMAIL PROTECTED] */ + public Enumeration getInitParameterNames() { + + return parameters.keys(); + + } + + + /** [EMAIL PROTECTED] */ + public int getMajorVersion() { + + return 1; + + } + + + /** [EMAIL PROTECTED] */ + public String getMimeType(String path) { + + int period = path.lastIndexOf('.'); + if (period < 0) { + return null; + } + String extension = path.substring(period + 1); + return (String) mimeTypes.get(extension); + + } + + + public int getMinorVersion() { + + // TODO Auto-generated method stub + return 0; + } + + + public PortletRequestDispatcher getNamedDispatcher(String arg0) { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public String getPortletContextName() { + + return "MockPortletContext"; + + } + + + /** [EMAIL PROTECTED] */ + public String getRealPath(String path) { + + if (documentRoot != null) { + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The specified path ('" + + path + "') does not start with a '/' character"); + } + File resolved = new File(documentRoot, path.substring(1)); + try { + return resolved.getCanonicalPath(); + } catch (IOException e) { + return resolved.getAbsolutePath(); + } + } else { + return null; + } + + } + + + /** [EMAIL PROTECTED] */ + public PortletRequestDispatcher getRequestDispatcher(String arg0) { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public URL getResource(String path) throws MalformedURLException { + + if (documentRoot != null) { + if (!path.startsWith("/")) { + throw new MalformedURLException("The specified path ('" + path + + "') does not start with a '/' character"); + } + File resolved = new File(documentRoot, path.substring(1)); + if (resolved.exists()) { + return resolved.toURL(); + } else { + return null; + } + } else { + return null; + } + + } + + + /** [EMAIL PROTECTED] */ + public InputStream getResourceAsStream(String path) { + + try { + URL url = getResource(path); + if (url != null) { + return url.openStream(); + } + } catch (Exception e) { + ; + } + return null; + + } + + + /** [EMAIL PROTECTED] */ + public Set getResourcePaths(String path) { + + if (documentRoot == null) { + return null; + } + + // Enforce the leading slash restriction + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The specified path ('" + path + + "') does not start with a '/' character"); + } + + // Locate the File node for this path's directory (if it exists) + File node = new File(documentRoot, path.substring(1)); + if (!node.exists()) { + return null; + } + if (!node.isDirectory()) { + return null; + } + + // Construct a Set containing the paths to the contents of this + // directory + Set set = new HashSet(); + String[] files = node.list(); + if (files == null) { + return null; + } + for (int i = 0; i < files.length; i++) { + String subfile = path + files[i]; + File subnode = new File(node, files[i]); + if (subnode.isDirectory()) { + subfile += "/"; + } + set.add(subfile); + } + + // Return the completed set + return set; + + } + + + /** [EMAIL PROTECTED] */ + public String getServerInfo() { + + return "MockPortletContext"; + } + + + /** [EMAIL PROTECTED] */ + public void log(String message) { + + System.out.println(message); + + } + + + /** [EMAIL PROTECTED] */ + public void log(String message, Throwable exception) { + + System.out.println(message); + exception.printStackTrace(); + + } + + + /** [EMAIL PROTECTED] */ + public void removeAttribute(String name) { + + if (attributes.containsKey(name)) { + attributes.remove(name); + } + + } + + + /** [EMAIL PROTECTED] */ + public void setAttribute(String name, Object value) { + + if (name == null) { + throw new IllegalArgumentException("Attribute name cannot be null"); + } + if (value == null) { + removeAttribute(name); + return; + } + attributes.put(name, value); + + } + +} Propchange: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletContext.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletContext.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Added: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletRequest.java URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletRequest.java?view=auto&rev=516091 ============================================================================== --- shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletRequest.java (added) +++ shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletRequest.java Thu Mar 8 08:25:17 2007 @@ -0,0 +1,421 @@ +/* + * 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.shale.test.mock; + +import java.security.Principal; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import javax.portlet.PortalContext; +import javax.portlet.PortletMode; +import javax.portlet.PortletPreferences; +import javax.portlet.PortletRequest; +import javax.portlet.PortletSession; +import javax.portlet.WindowState; + +/** + * <p> Mock implementation of <code>PortletRequest</code>. </p> + * + * $Id$ + */ + +public class MockPortletRequest implements PortletRequest { + + // ------------------------------------------------------------ Constructors + + public MockPortletRequest() { + + super(); + + } + + + public MockPortletRequest(PortletSession session) { + + super(); + this.session = session; + + } + + + // ----------------------------------------------------- Mock Object Methods + + /** + * <p> Add a request parameter for this request. </p> + * + * @param name Parameter name + * @param value Parameter value + */ + public void addParameter(String name, String value) { + + String[] values = (String[]) parameters.get(name); + if (values == null) { + String[] results = new String[] { value }; + parameters.put(name, results); + return; + } + String[] results = new String[values.length + 1]; + System.arraycopy(values, 0, results, 0, values.length); + results[values.length] = value; + parameters.put(name, results); + + } + + + /** + * <p> Set the <code>PortletSession</code> associated with this request. + * </p> + * + * @param session The new session + */ + public void setPortletSession(PortletSession session) { + + this.session = session; + } + + + /** + * <p> Set the <code>Locale</code> associated with this request. </p> + * + * @param locale The new locale + */ + public void setLocale(Locale locale) { + + this.locale = locale; + + } + + + /** + * <p> Set the <code>Principal</code> associated with this request. </p> + * + * @param principal The new Principal + */ + public void setUserPrincipal(Principal principal) { + + this.principal = principal; + + } + + // ------------------------------------------------------ Instance Variables + + private Map attributes = new HashMap(); + private String contextPath = null; + private Locale locale = null; + private Map parameters = new HashMap(); + private Principal principal = null; + private PortletSession session = null; + + + // -------------------------------------------------- PortletRequest Methods + + + /** [EMAIL PROTECTED] */ + public String getAuthType() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public String getContextPath() { + + return contextPath; + + } + + + /** [EMAIL PROTECTED] */ + public Object getAttribute(String name) { + + return attributes.get(name); + + } + + + /** [EMAIL PROTECTED] */ + public Enumeration getAttributeNames() { + + return new MockEnumeration(attributes.keySet().iterator()); + + } + + + /** [EMAIL PROTECTED] */ + public Locale getLocale() { + + return locale; + } + + + /** [EMAIL PROTECTED] */ + public Enumeration getLocales() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public String getParameter(String name) { + + String[] values = (String[]) parameters.get(name); + if (values != null) { + return values[0]; + } else { + return null; + } + + } + + + /** [EMAIL PROTECTED] */ + public Map getParameterMap() { + + return parameters; + + } + + + /** [EMAIL PROTECTED] */ + public Enumeration getParameterNames() { + + return new MockEnumeration(parameters.keySet().iterator()); + + } + + + /** [EMAIL PROTECTED] */ + public String[] getParameterValues(String name) { + + return (String[]) parameters.get(name); + + } + + + /** [EMAIL PROTECTED] */ + public PortalContext getPortalContext() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public PortletMode getPortletMode() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public PortletSession getPortletSession() { + + return getPortletSession(true); + + } + + + /** [EMAIL PROTECTED] */ + public PortletSession getPortletSession(boolean create) { + + if (create && (session == null)) { + throw new UnsupportedOperationException(); + } + return session; + + } + + + /** [EMAIL PROTECTED] */ + public PortletPreferences getPreferences() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public Enumeration getProperties(String arg0) { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public String getProperty(String arg0) { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public Enumeration getPropertyNames() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public String getRemoteUser() { + + if (principal != null) { + return principal.getName(); + } else { + return null; + } + + } + + + /** [EMAIL PROTECTED] */ + public String getRequestedSessionId() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public String getResponseContentType() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public Enumeration getResponseContentTypes() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public String getScheme() { + + return ("http"); + + } + + + /** [EMAIL PROTECTED] */ + public String getServerName() { + + return ("localhost"); + + } + + + /** [EMAIL PROTECTED] */ + public int getServerPort() { + + return (8080); + + } + + + /** [EMAIL PROTECTED] */ + public Principal getUserPrincipal() { + + return principal; + + } + + + /** [EMAIL PROTECTED] */ + public WindowState getWindowState() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public boolean isPortletModeAllowed(PortletMode arg0) { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public boolean isRequestedSessionIdValid() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public boolean isSecure() { + + return false; + + } + + + /** [EMAIL PROTECTED] */ + public boolean isUserInRole(String arg0) { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public boolean isWindowStateAllowed(WindowState arg0) { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public void removeAttribute(String name) { + + if (attributes.containsKey(name)) { + attributes.remove(name); + } + + } + + + /** [EMAIL PROTECTED] */ + public void setAttribute(String name, Object value) { + + if (name == null) { + throw new IllegalArgumentException("Attribute name cannot be null"); + } + if (value == null) { + removeAttribute(name); + return; + } + attributes.put(name, value); + + } + +} Propchange: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletRequest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletRequest.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Added: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletResponse.java URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletResponse.java?view=auto&rev=516091 ============================================================================== --- shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletResponse.java (added) +++ shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletResponse.java Thu Mar 8 08:25:17 2007 @@ -0,0 +1,62 @@ +/* + * 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.shale.test.mock; + +import javax.portlet.PortletResponse; + +/** + * <p>Mock implementation of <code>PortletResponse</code>.</p> + * + * $Id$ + */ + +public class MockPortletResponse implements PortletResponse { + + /** + * <p>Return a default instance.</p> + */ + public MockPortletResponse() { + + } + + + // -------------------------------------------------- PortletContext Methods + + /** [EMAIL PROTECTED] */ + public void addProperty(String name, String value) { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public String encodeURL(String url) { + + return url; + } + + + /** [EMAIL PROTECTED] */ + public void setProperty(String name, String value) { + + throw new UnsupportedOperationException(); + + } + +} Propchange: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletResponse.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletResponse.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Added: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletSession.java URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletSession.java?view=auto&rev=516091 ============================================================================== --- shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletSession.java (added) +++ shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletSession.java Thu Mar 8 08:25:17 2007 @@ -0,0 +1,268 @@ +/* + * 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.shale.test.mock; + +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.portlet.PortletContext; +import javax.portlet.PortletSession; + +/** + * <p> Mock implementation of <code>PortletSession</code>. </p> + * + * $Id$ + */ +public class MockPortletSession implements PortletSession { + + // ------------------------------------------------------------ Constructors + + /** + * <p> Configure a default instance. </p> + */ + public MockPortletSession() { + + super(); + + } + + + /** + * <p> Configure a session instance associated with the specified servlet + * context. </p> + * + * @param servletContext The associated servlet context + */ + public MockPortletSession(PortletContext portletContext) { + + super(); + this.portletContext = portletContext; + + } + + + // ----------------------------------------------------- Mock Object Methods + + /** + * <p> Set the <code>PortletContext</code> associated with this session. + * </p> + * + * @param servletContext The associated servlet context + */ + public void setPortletContext(PortletContext portletContext) { + + this.portletContext = portletContext; + + } + + // ------------------------------------------------------ Instance Variables + + private Map portletAttributes = new HashMap(); + private Map applicationAttributes = new HashMap(); + private String id = "123"; + private PortletContext portletContext = null; + + + // ---------------------------------------------------------- Public Methods + + /** + * <p> Set the session identifier of this session. </p> + * + * @param id The new session identifier + */ + public void setId(String id) { + + this.id = id; + + } + + + // -------------------------------------------------- PortletSession Methods + + + /** [EMAIL PROTECTED] */ + public Object getAttribute(String name) { + + return getAttribute(name, PORTLET_SCOPE); + + } + + + /** [EMAIL PROTECTED] */ + public Object getAttribute(String name, int scope) { + + if (scope == PORTLET_SCOPE) { + return portletAttributes.get(name); + } else if (scope == APPLICATION_SCOPE) { + return applicationAttributes.get(name); + } + + throw new IllegalArgumentException("Scope constant " + scope + + " not recognized"); + + } + + + /** [EMAIL PROTECTED] */ + public Enumeration getAttributeNames() { + + return getAttributeNames(PORTLET_SCOPE); + + } + + + /** [EMAIL PROTECTED] */ + public Enumeration getAttributeNames(int scope) { + + if (scope == PORTLET_SCOPE) { + return new MockEnumeration(portletAttributes.keySet().iterator()); + } else if (scope == APPLICATION_SCOPE) { + return new MockEnumeration(applicationAttributes.keySet() + .iterator()); + } + + throw new IllegalArgumentException("Scope constant " + scope + + " not recognized"); + + } + + + /** [EMAIL PROTECTED] */ + public long getCreationTime() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public String getId() { + + return this.id; + + } + + + /** [EMAIL PROTECTED] */ + public long getLastAccessedTime() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public int getMaxInactiveInterval() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public PortletContext getPortletContext() { + + return portletContext; + } + + + /** [EMAIL PROTECTED] */ + public void invalidate() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public boolean isNew() { + + throw new UnsupportedOperationException(); + + } + + + /** [EMAIL PROTECTED] */ + public void removeAttribute(String name) { + + removeAttribute(name, PORTLET_SCOPE); + + } + + + /** [EMAIL PROTECTED] */ + public void removeAttribute(String name, int scope) { + + Map attributes; + if (scope == PORTLET_SCOPE) { + attributes = portletAttributes; + } else if (scope == APPLICATION_SCOPE) { + attributes = applicationAttributes; + } else { + throw new IllegalArgumentException("Scope constant " + scope + + " not recognized"); + } + if (attributes.containsKey(name)) { + attributes.remove(name); + } + + } + + + /** [EMAIL PROTECTED] */ + public void setAttribute(String name, Object value) { + + setAttribute(name, value, PORTLET_SCOPE); + + } + + + /** [EMAIL PROTECTED] */ + public void setAttribute(String name, Object value, int scope) { + + if (name == null) { + throw new IllegalArgumentException("Attribute name cannot be null"); + } + if (value == null) { + removeAttribute(name, scope); + return; + } + + Map attributes; + if (scope == PORTLET_SCOPE) { + attributes = portletAttributes; + } else if (scope == APPLICATION_SCOPE) { + attributes = applicationAttributes; + } else { + throw new IllegalArgumentException("Scope constant " + scope + + " not recognized"); + } + attributes.put(name, value); + + } + + + /** [EMAIL PROTECTED] */ + public void setMaxInactiveInterval(int arg0) { + + throw new UnsupportedOperationException(); + + } + +} Propchange: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletSession.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockPortletSession.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL