diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/portlet/SetPortletModeAction.java b/spring-webflow/src/main/java/org/springframework/webflow/action/portlet/SetPortletModeAction.java deleted file mode 100644 index 04b379e4..00000000 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/portlet/SetPortletModeAction.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed 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.springframework.webflow.action.portlet; - -import javax.portlet.ActionResponse; -import javax.portlet.PortletMode; - -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; -import org.springframework.webflow.action.AbstractAction; -import org.springframework.webflow.context.portlet.PortletExternalContext; -import org.springframework.webflow.execution.Event; -import org.springframework.webflow.execution.RequestContext; - -/** - * Action implementation that changes a PortletResponse mode. The action only generates the - * {@link org.springframework.webflow.action.AbstractAction#success()} event. All error cases result in an exception - * being thrown. - *
- * This class is usefull when you want to change the current PortletMode before entering a specific state, e.g. it can - * be the first state in a subflow. - *
- * Note: if you can, change the PortletMode using Portlet URLs (PortletURL class or portlet TAG). - * - * @author J.Enrique Ruiz - * @author Cesar Ordinana - * @author Erwin Vervaet - */ -public class SetPortletModeAction extends AbstractAction { - - /** - * The portlet mode to set can be specified in an action state action attribute with this name ("portletMode"). - */ - public static final String PORTLET_MODE_ATTRIBUTE = "portletMode"; - - /** - * The default portlet mode. Default is "view". - */ - private PortletMode portletMode = PortletMode.VIEW; - - /** - * Returns the mode that will be set in the response. - */ - public PortletMode getPortletMode() { - return portletMode; - } - - /** - * Sets the mode that will be set in the response. - */ - public void setPortletMode(PortletMode portletMode) { - Assert.notNull(portletMode, "The portlet mode is required and cannot be null"); - this.portletMode = portletMode; - } - - /** - * Sets the PortletMode. - * @param context the action execution context, for accessing and setting data in "flow scope" or "request scope" - * @return the action result event - * @throws Exception an unrecoverable exception occured, either checked or unchecked - */ - protected Event doExecute(RequestContext context) throws Exception { - Assert.isInstanceOf(PortletExternalContext.class, context.getExternalContext(), "'" - + ClassUtils.getShortName(this.getClass()) + "' can only work with 'PortletExternalContext': "); - PortletExternalContext portletContext = (PortletExternalContext) context.getExternalContext(); - if (portletContext.getResponse() instanceof ActionResponse) { - PortletMode mode = (PortletMode) context.getAttributes().get(PORTLET_MODE_ATTRIBUTE, PortletMode.class, - getPortletMode()); - ((ActionResponse) portletContext.getResponse()).setPortletMode(mode); - return success(); - } else { - // portlet mode and the window state can be changed through - // ActionResponse only, if this is not the case, it means that this - // action has been invoked directly in a RenderRequest - throw new IllegalStateException("SetPortletModeAction can only be invoked within a Action request -- " - + "make sure you are not invoking it in a RenderRequest"); - } - } -} \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/portlet/package.html b/spring-webflow/src/main/java/org/springframework/webflow/action/portlet/package.html deleted file mode 100644 index c55506e5..00000000 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/portlet/package.html +++ /dev/null @@ -1,7 +0,0 @@ - -
--Action implementations that define logic specific to flows executing in a JSR-168 Portlet environment. -
- - diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletContextMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletContextMap.java deleted file mode 100644 index 07ec43ab..00000000 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletContextMap.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed 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.springframework.webflow.context.portlet; - -import java.util.Iterator; - -import javax.portlet.PortletContext; - -import org.springframework.binding.collection.SharedMap; -import org.springframework.binding.collection.StringKeyedMapAdapter; -import org.springframework.webflow.core.collection.CollectionUtils; - -/** - * A shared map backed by the Portlet context for accessing application scoped attributes. - * - * @author Keith Donald - */ -public class PortletContextMap extends StringKeyedMapAdapter implements SharedMap { - - /** - * The wrapped portlet context. - */ - private PortletContext context; - - /** - * Create a new map wrapping given portlet context. - */ - public PortletContextMap(PortletContext context) { - this.context = context; - } - - protected Object getAttribute(String key) { - return context.getAttribute(key); - } - - protected void setAttribute(String key, Object value) { - context.setAttribute(key, value); - } - - protected void removeAttribute(String key) { - context.removeAttribute(key); - } - - protected Iterator getAttributeNames() { - return CollectionUtils.toIterator(context.getAttributeNames()); - } - - public Object getMutex() { - return context; - } -} \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java deleted file mode 100644 index efe73a9d..00000000 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed 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.springframework.webflow.context.portlet; - -import java.io.PrintWriter; -import java.util.Map; - -import javax.portlet.PortletContext; -import javax.portlet.PortletRequest; -import javax.portlet.PortletResponse; -import javax.portlet.PortletSession; - -import org.springframework.core.style.ToStringCreator; -import org.springframework.webflow.context.ExternalContext; -import org.springframework.webflow.context.FlowDefinitionRequestInfo; -import org.springframework.webflow.context.FlowExecutionRequestInfo; -import org.springframework.webflow.context.RequestPath; -import org.springframework.webflow.core.FlowException; -import org.springframework.webflow.core.collection.LocalAttributeMap; -import org.springframework.webflow.core.collection.LocalParameterMap; -import org.springframework.webflow.core.collection.LocalSharedAttributeMap; -import org.springframework.webflow.core.collection.MutableAttributeMap; -import org.springframework.webflow.core.collection.ParameterMap; -import org.springframework.webflow.core.collection.SharedAttributeMap; - -/** - * Provides contextual information about a JSR-168 Portlet environment that has called into Spring Web Flow. - * - * @author Keith Donald - */ -public class PortletExternalContext implements ExternalContext { - - /** - * The context. - */ - private PortletContext context; - - /** - * The request. - */ - private PortletRequest request; - - /** - * The response. - */ - private PortletResponse response; - - /** - * An accessor for the portlet request parameter map. - */ - private ParameterMap requestParameterMap; - - /** - * An accessor for the portlet request attribute map. - */ - private MutableAttributeMap requestMap; - - /** - * An accessor for the local portlet session map. - */ - private SharedAttributeMap sessionMap; - - /** - * An accessor for the global portlet session map. - */ - private SharedAttributeMap globalSessionMap; - - /** - * An accessor for the portlet context application map. - */ - private SharedAttributeMap applicationMap; - - /** - * An accessor for the portlet user info map. - */ - private MutableAttributeMap userInfoMap; - - /** - * Create an external context wrapping given Portlet context, request and response. - * @param context the Portlet context - * @param request the Portlet request - * @param response the Portlet response - */ - public PortletExternalContext(PortletContext context, PortletRequest request, PortletResponse response) { - this.context = context; - this.request = request; - this.response = response; - this.requestParameterMap = new LocalParameterMap(new PortletRequestParameterMap(request)); - this.requestMap = new LocalAttributeMap(new PortletRequestMap(request)); - this.sessionMap = new LocalSharedAttributeMap(new PortletSessionMap(request, PortletSession.PORTLET_SCOPE)); - this.globalSessionMap = new LocalSharedAttributeMap(new PortletSessionMap(request, - PortletSession.APPLICATION_SCOPE)); - this.applicationMap = new LocalSharedAttributeMap(new PortletContextMap(context)); - Map userInfo = (Map) request.getAttribute(PortletRequest.USER_INFO); - this.userInfoMap = userInfo != null ? new LocalAttributeMap(userInfo) : null; - } - - public ParameterMap getRequestParameterMap() { - return requestParameterMap; - } - - public MutableAttributeMap getRequestMap() { - return requestMap; - } - - public SharedAttributeMap getSessionMap() { - return sessionMap; - } - - public SharedAttributeMap getGlobalSessionMap() { - return globalSessionMap; - } - - public SharedAttributeMap getApplicationMap() { - return applicationMap; - } - - /** - * Returns the {@link PortletRequest#USER_INFO} map as a mutable attribute map. - * @return the Portlet user info - */ - public MutableAttributeMap getUserInfoMap() { - return userInfoMap; - } - - /** - * Returns the wrapped Portlet context. - */ - public Object getContext() { - return context; - } - - /** - * Returns the wrapped Portlet request. - */ - public Object getRequest() { - return request; - } - - /** - * Returns the wrapped Portlet response. - */ - public Object getResponse() { - return response; - } - - public String getFlowId() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public String getFlowExecutionKey() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public RequestPath getRequestPath() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public String getRequestMethod() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public PrintWriter getResponseWriter() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public String buildFlowDefinitionUrl(FlowDefinitionRequestInfo urlInfo) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public String buildFlowExecutionUrl(FlowExecutionRequestInfo urlInfo, boolean contextRelative) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public String encode(String string) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public void sendFlowDefinitionRedirect(FlowDefinitionRequestInfo urlInfo) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public void sendFlowExecutionRedirect(FlowExecutionRequestInfo urlInfo) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public void sendExternalRedirect(String resourceUrl) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public void setPausedResult(String flowExecutionKey) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public void setEndedResult(String flowExecutionKey) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public void setExceptionResult(FlowException e) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public boolean isResponseCommitted() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public String toString() { - return new ToStringCreator(this).append("requestParameterMap", getRequestParameterMap()).toString(); - } - -} \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestMap.java deleted file mode 100644 index 2ed04d57..00000000 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestMap.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed 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.springframework.webflow.context.portlet; - -import java.util.Iterator; - -import javax.portlet.PortletRequest; - -import org.springframework.binding.collection.StringKeyedMapAdapter; -import org.springframework.webflow.core.collection.CollectionUtils; - -/** - * Map backed by the Portlet request for accessing request scoped attributes. - * - * @author Keith Donald - */ -public class PortletRequestMap extends StringKeyedMapAdapter { - - /** - * The wrapped portlet request. - */ - private PortletRequest request; - - /** - * Create a new map wrapping the attributes of given portlet request. - */ - public PortletRequestMap(PortletRequest request) { - this.request = request; - } - - protected Object getAttribute(String key) { - return request.getAttribute(key); - } - - protected void setAttribute(String key, Object value) { - request.setAttribute(key, value); - } - - protected void removeAttribute(String key) { - request.removeAttribute(key); - } - - protected Iterator getAttributeNames() { - return CollectionUtils.toIterator(request.getAttributeNames()); - } -} \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestParameterMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestParameterMap.java deleted file mode 100644 index f93a7e15..00000000 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestParameterMap.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed 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.springframework.webflow.context.portlet; - -import java.util.Iterator; - -import javax.portlet.PortletRequest; - -import org.springframework.binding.collection.CompositeIterator; -import org.springframework.binding.collection.StringKeyedMapAdapter; -import org.springframework.web.portlet.multipart.MultipartActionRequest; -import org.springframework.webflow.core.collection.CollectionUtils; - -/** - * Map backed by the Portlet request parameter map for accessing request local portlet parameters. - * - * @author Keith Donald - */ -public class PortletRequestParameterMap extends StringKeyedMapAdapter { - - /** - * The wrapped portlet request. - */ - private PortletRequest request; - - /** - * Create a new map wrapping the parameters of given portlet request. - */ - public PortletRequestParameterMap(PortletRequest request) { - this.request = request; - } - - protected Object getAttribute(String key) { - if (request instanceof MultipartActionRequest) { - MultipartActionRequest multipartRequest = (MultipartActionRequest) request; - Object data = multipartRequest.getFileMap().get(key); - if (data != null) { - return data; - } - } - String[] parameters = request.getParameterValues(key); - if (parameters == null) { - return null; - } else if (parameters.length == 1) { - return parameters[0]; - } else { - return parameters; - } - } - - protected void setAttribute(String key, Object value) { - throw new UnsupportedOperationException("PortletRequest parameter maps are immutable"); - } - - protected void removeAttribute(String key) { - throw new UnsupportedOperationException("PortletRequest parameter maps are immutable"); - } - - protected Iterator getAttributeNames() { - if (request instanceof MultipartActionRequest) { - MultipartActionRequest multipartRequest = (MultipartActionRequest) request; - CompositeIterator iterator = new CompositeIterator(); - iterator.add(multipartRequest.getFileMap().keySet().iterator()); - iterator.add(CollectionUtils.toIterator(request.getParameterNames())); - return iterator; - } else { - return CollectionUtils.toIterator(request.getParameterNames()); - } - } -} \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletSessionMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletSessionMap.java deleted file mode 100644 index 83b2a953..00000000 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletSessionMap.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed 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.springframework.webflow.context.portlet; - -import java.util.Iterator; - -import javax.portlet.PortletRequest; -import javax.portlet.PortletSession; - -import org.springframework.binding.collection.SharedMap; -import org.springframework.binding.collection.StringKeyedMapAdapter; -import org.springframework.web.util.WebUtils; -import org.springframework.webflow.context.servlet.HttpSessionMapBindingListener; -import org.springframework.webflow.core.collection.AttributeMapBindingListener; -import org.springframework.webflow.core.collection.CollectionUtils; - -/** - * Shared map backed by the Portlet session for accessing session scoped attributes in a Portlet environment. - * - * @author Keith Donald - */ -public class PortletSessionMap extends StringKeyedMapAdapter implements SharedMap { - - /** - * The wrapped portlet request, providing access to the session. - */ - private PortletRequest request; - - /** - * The scope to access in the session, either APPLICATION (global) or PORTLET. - */ - private int scope; - - /** - * Create a new map wrapping the session associated with given request. - * @param request the current portlet request - * @param scope the scope to access in the session, either {@link PortletSession#APPLICATION_SCOPE} (global) or - * {@link PortletSession#PORTLET_SCOPE} - */ - public PortletSessionMap(PortletRequest request, int scope) { - this.request = request; - this.scope = scope; - } - - /** - * Return the portlet session associated with the wrapped request, or null if no such session exits. - */ - private PortletSession getSession() { - return request.getPortletSession(false); - } - - protected Object getAttribute(String key) { - PortletSession session = getSession(); - if (session == null) { - return null; - } - Object value = session.getAttribute(key, scope); - if (value instanceof HttpSessionMapBindingListener) { - // unwrap - return ((HttpSessionMapBindingListener) value).getListener(); - } else { - return value; - } - } - - protected void setAttribute(String key, Object value) { - PortletSession session = request.getPortletSession(true); - if (value instanceof AttributeMapBindingListener) { - // wrap - session.setAttribute(key, new HttpSessionMapBindingListener((AttributeMapBindingListener) value, this), - scope); - } else { - session.setAttribute(key, value, scope); - } - } - - protected void removeAttribute(String key) { - PortletSession session = getSession(); - if (session != null) { - session.removeAttribute(key, scope); - } - } - - protected Iterator getAttributeNames() { - PortletSession session = getSession(); - return session == null ? CollectionUtils.EMPTY_ITERATOR : CollectionUtils.toIterator(session - .getAttributeNames(scope)); - } - - public Object getMutex() { - PortletSession session = request.getPortletSession(true); - Object mutex = session.getAttribute(WebUtils.SESSION_MUTEX_ATTRIBUTE, scope); - return mutex != null ? mutex : session; - } -} \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/package.html b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/package.html deleted file mode 100644 index be157edb..00000000 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -The representation of a client request into Spring Web Flow from a JSR-168 Portlet environment. --Portlets are specified in the Java Portlet Standard. - - diff --git a/spring-webflow/src/test/java/org/springframework/webflow/action/portlet/SetPortletModeActionTests.java b/spring-webflow/src/test/java/org/springframework/webflow/action/portlet/SetPortletModeActionTests.java deleted file mode 100644 index 7c4950dd..00000000 --- a/spring-webflow/src/test/java/org/springframework/webflow/action/portlet/SetPortletModeActionTests.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed 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.springframework.webflow.action.portlet; - -import javax.portlet.PortletMode; - -import junit.framework.TestCase; - -import org.springframework.mock.web.portlet.MockActionRequest; -import org.springframework.mock.web.portlet.MockActionResponse; -import org.springframework.mock.web.portlet.MockPortletContext; -import org.springframework.mock.web.portlet.MockRenderRequest; -import org.springframework.mock.web.portlet.MockRenderResponse; -import org.springframework.webflow.context.portlet.PortletExternalContext; -import org.springframework.webflow.execution.Event; -import org.springframework.webflow.test.MockRequestContext; - -/** - * Unit test for the {@link SetPortletModeAction} class. - * - * @author Ulrik Sandberg - */ -public class SetPortletModeActionTests extends TestCase { - - private SetPortletModeAction tested; - - protected void setUp() throws Exception { - super.setUp(); - tested = new SetPortletModeAction(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - tested = null; - } - - public void testDoExecute() throws Exception { - MockActionResponse mockActionResponse = new MockActionResponse(); - PortletExternalContext externalContext = new PortletExternalContext(new MockPortletContext(), - new MockActionRequest(), mockActionResponse); - MockRequestContext mockRequestContext = new MockRequestContext(); - mockRequestContext.setExternalContext(externalContext); - - // perform test - Event result = tested.doExecute(mockRequestContext); - - assertEquals(tested.getEventFactorySupport().getSuccessEventId(), result.getId()); - assertEquals(tested.getPortletMode(), mockActionResponse.getPortletMode()); - } - - public void testDoExecuteWithPortletModeAsAttribute() throws Exception { - MockActionResponse mockActionResponse = new MockActionResponse(); - PortletExternalContext externalContext = new PortletExternalContext(new MockPortletContext(), - new MockActionRequest(), mockActionResponse); - MockRequestContext mockRequestContext = new MockRequestContext(); - mockRequestContext.setExternalContext(externalContext); - mockRequestContext.setAttribute(SetPortletModeAction.PORTLET_MODE_ATTRIBUTE, PortletMode.HELP); - - // perform test - Event result = tested.doExecute(mockRequestContext); - - assertEquals(tested.getEventFactorySupport().getSuccessEventId(), result.getId()); - assertEquals(PortletMode.HELP, mockActionResponse.getPortletMode()); - } - - public void testDoExecuteWithWrongResponseClass() throws Exception { - MockRenderResponse mockRenderResponse = new MockRenderResponse(); - PortletExternalContext externalContext = new PortletExternalContext(new MockPortletContext(), - new MockRenderRequest(), mockRenderResponse); - MockRequestContext mockRequestContext = new MockRequestContext(); - mockRequestContext.setExternalContext(externalContext); - mockRequestContext.setAttribute(SetPortletModeAction.PORTLET_MODE_ATTRIBUTE, PortletMode.HELP); - - // perform test - try { - tested.doExecute(mockRequestContext); - fail("ActionExecutionException expected"); - } catch (IllegalStateException e) { - // expected - } - } -} diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletContextMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletContextMapTests.java deleted file mode 100644 index fb0dde40..00000000 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletContextMapTests.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed 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.springframework.webflow.context.portlet; - -import java.util.Iterator; - -import junit.framework.TestCase; - -import org.springframework.mock.web.portlet.MockPortletContext; - -/** - * Unit test for the {@link PortletContextMap} class. - * - * @author Ulrik Sandberg - */ -public class PortletContextMapTests extends TestCase { - - private PortletContextMap tested; - - private MockPortletContext context; - - protected void setUp() throws Exception { - super.setUp(); - context = new MockPortletContext(); - tested = new PortletContextMap(context); - } - - protected void tearDown() throws Exception { - super.tearDown(); - context = null; - tested = null; - } - - public void testGetAttribute() { - context.setAttribute("Some key", "Some value"); - // perform test - Object result = tested.getAttribute("Some key"); - assertEquals("Some value", result); - } - - public void testSetAttribute() { - // perform test - tested.setAttribute("Some key", "Some value"); - assertEquals("Some value", context.getAttribute("Some key")); - } - - public void testRemoveAttribute() { - context.setAttribute("Some key", "Some value"); - // perform test - tested.removeAttribute("Some key"); - assertNull(context.getAttribute("Some key")); - } - - public void testGetAttributeNames() { - context.setAttribute("Some key", "Some value"); - context.removeAttribute("javax.servlet.context.tempdir"); - // perform test - Iterator names = tested.getAttributeNames(); - assertNotNull("Null result unexpected", names); - assertTrue("More elements", names.hasNext()); - String name = (String) names.next(); - assertEquals("Some key", name); - } -} \ No newline at end of file diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestMapTests.java deleted file mode 100644 index 12d122f7..00000000 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestMapTests.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed 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.springframework.webflow.context.portlet; - -import java.util.Iterator; - -import junit.framework.TestCase; - -import org.springframework.mock.web.portlet.MockPortletRequest; - -/** - * Unit test for the {@link PortletRequestMap} class. - * - * @author Ulrik Sandberg - */ -public class PortletRequestMapTests extends TestCase { - - private PortletRequestMap tested; - - private MockPortletRequest request; - - protected void setUp() throws Exception { - super.setUp(); - request = new MockPortletRequest(); - tested = new PortletRequestMap(request); - } - - protected void tearDown() throws Exception { - super.tearDown(); - request = null; - tested = null; - } - - public void testGetAttribute() { - request.setAttribute("Some key", "Some value"); - // perform test - Object result = tested.getAttribute("Some key"); - assertEquals("Some value", result); - } - - public void testSetAttribute() { - // perform test - tested.setAttribute("Some key", "Some value"); - assertEquals("Some value", request.getAttribute("Some key")); - } - - public void testRemoveAttribute() { - request.setAttribute("Some key", "Some value"); - // perform test - tested.removeAttribute("Some key"); - assertNull(request.getAttribute("Some key")); - } - - public void testGetAttributeNames() { - request.setAttribute("Some key", "Some value"); - request.removeAttribute("javax.servlet.context.tempdir"); - // perform test - Iterator names = tested.getAttributeNames(); - assertNotNull("Null result unexpected", names); - assertTrue("More elements", names.hasNext()); - String name = (String) names.next(); - assertEquals("Some key", name); - } -} \ No newline at end of file diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestParameterMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestParameterMapTests.java deleted file mode 100644 index 00100092..00000000 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestParameterMapTests.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed 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.springframework.webflow.context.portlet; - -import java.util.Iterator; - -import junit.framework.TestCase; - -import org.springframework.mock.web.portlet.MockPortletRequest; - -/** - * Unit test for the {@link PortletRequestParameterMap} class. - * - * @author Ulrik Sandberg - */ -public class PortletRequestParameterMapTests extends TestCase { - - private PortletRequestParameterMap tested; - - private MockPortletRequest request; - - protected void setUp() throws Exception { - super.setUp(); - request = new MockPortletRequest(); - tested = new PortletRequestParameterMap(request); - } - - protected void tearDown() throws Exception { - super.tearDown(); - request = null; - tested = null; - } - - public void testGetAttribute() { - request.setParameter("Some param", "Some value"); - // perform test - Object result = tested.getAttribute("Some param"); - assertEquals("Some value", result); - } - - public void testSetAttribute() { - // perform test - try { - tested.setAttribute("Some key", "Some value"); - fail("UnsupportedOperationException expected"); - } catch (UnsupportedOperationException expected) { - // expected - } - } - - public void testRemoveAttribute() { - request.setParameter("Some param", "Some value"); - // perform test - try { - tested.removeAttribute("Some param"); - fail("UnsupportedOperationException expected"); - } catch (UnsupportedOperationException expected) { - // expected - } - } - - public void testGetAttributeNames() { - request.setParameter("Some param", "Some value"); - // perform test - Iterator names = tested.getAttributeNames(); - assertNotNull("Null result unexpected", names); - assertTrue("More elements", names.hasNext()); - String name = (String) names.next(); - assertEquals("Some param", name); - } -} \ No newline at end of file diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletSessionMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletSessionMapTests.java deleted file mode 100644 index 24027925..00000000 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletSessionMapTests.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed 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.springframework.webflow.context.portlet; - -import java.util.Iterator; - -import javax.portlet.PortletSession; - -import junit.framework.TestCase; - -import org.springframework.mock.web.portlet.MockPortletRequest; -import org.springframework.web.util.WebUtils; - -/** - * Unit test for the {@link PortletSessionMap} class. - * - * @author Ulrik Sandberg - */ -public class PortletSessionMapTests extends TestCase { - - private PortletSessionMap tested; - - private MockPortletRequest request; - - protected void setUp() throws Exception { - super.setUp(); - request = new MockPortletRequest(); - tested = new PortletSessionMap(request, PortletSession.PORTLET_SCOPE); - } - - protected void tearDown() throws Exception { - super.tearDown(); - request = null; - tested = null; - } - - public void testGetAttribute() { - request.getPortletSession().setAttribute("Some key", "Some value"); - // perform test - Object result = tested.getAttribute("Some key"); - assertEquals("Some value", result); - } - - public void testGetAttributeNullSession() { - request.setSession(null); - // perform test - Object result = tested.getAttribute("Some key"); - assertNull("No value expected", result); - } - - public void testSetAttribute() { - // perform test - tested.setAttribute("Some key", "Some value"); - assertEquals("Some value", request.getPortletSession().getAttribute("Some key")); - } - - public void testRemoveAttribute() { - request.getPortletSession().setAttribute("Some key", "Some value"); - // perform test - tested.removeAttribute("Some key"); - assertNull(request.getPortletSession().getAttribute("Some key")); - } - - public void testRemoveAttributeNullSession() { - request.setSession(null); - // perform test - tested.removeAttribute("Some key"); - assertNull(request.getPortletSession().getAttribute("Some key")); - } - - public void testGetAttributeNames() { - request.getPortletSession().setAttribute("Some key", "Some value"); - // perform test - Iterator names = tested.getAttributeNames(); - assertNotNull("Null result unexpected", names); - assertTrue("More elements", names.hasNext()); - String name = (String) names.next(); - assertEquals("Some key", name); - } - - public void testGetAttributeNamesNullSession() { - request.setSession(null); - // perform test - Iterator names = tested.getAttributeNames(); - assertNotNull("Null result unexpected", names); - assertFalse("No elements expected", names.hasNext()); - } - - public void testGetSessionAsMutex() { - Object mutex = tested.getMutex(); - assertSame(mutex, request.getPortletSession()); - } - - public void testGetSessionMutex() { - Object object = new Object(); - request.getPortletSession().setAttribute(WebUtils.SESSION_MUTEX_ATTRIBUTE, object); - Object mutex = tested.getMutex(); - assertSame(mutex, object); - } -} \ No newline at end of file