diff options
author | Emmanuel Bourg <ebourg@apache.org> | 2016-08-03 19:55:01 +0200 |
---|---|---|
committer | Emmanuel Bourg <ebourg@apache.org> | 2016-08-03 19:55:01 +0200 |
commit | 75a721d1019da2a2fa86e24ff439df4a224e5b19 (patch) | |
tree | 2c44c00ce2c8641cccad177177e5682e187a17ea /spring-webmvc-portlet/src/test | |
parent | 9eaca6a06af3cbceb3754de19d477be770614265 (diff) |
Imported Upstream version 4.3.2
Diffstat (limited to 'spring-webmvc-portlet/src/test')
5 files changed, 26 insertions, 25 deletions
diff --git a/spring-webmvc-portlet/src/test/java/org/springframework/mock/web/portlet/ServletWrappingPortletContext.java b/spring-webmvc-portlet/src/test/java/org/springframework/mock/web/portlet/ServletWrappingPortletContext.java index 545f159e..716f71b0 100644 --- a/spring-webmvc-portlet/src/test/java/org/springframework/mock/web/portlet/ServletWrappingPortletContext.java +++ b/spring-webmvc-portlet/src/test/java/org/springframework/mock/web/portlet/ServletWrappingPortletContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 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. @@ -21,7 +21,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Collections; import java.util.Enumeration; -import java.util.HashSet; import java.util.Set; import javax.portlet.PortletContext; import javax.portlet.PortletRequestDispatcher; @@ -35,7 +34,7 @@ import org.springframework.util.Assert; * * @author Juergen Hoeller * @since 3.0 - * @see org.springframework.mock.web.portlet.MockPortletContext + * @see MockPortletContext */ public class ServletWrappingPortletContext implements PortletContext { @@ -156,7 +155,7 @@ public class ServletWrappingPortletContext implements PortletContext { @Override public Enumeration<String> getContainerRuntimeOptions() { - return Collections.enumeration(new HashSet<String>()); + return Collections.enumeration(Collections.<String>emptySet()); } } diff --git a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/PortletRequestAttributesTests.java b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/PortletRequestAttributesTests.java index 4875a2d6..40237e81 100644 --- a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/PortletRequestAttributesTests.java +++ b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/PortletRequestAttributesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 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. @@ -18,6 +18,7 @@ package org.springframework.web.portlet.context; import java.io.Serializable; import javax.portlet.PortletRequest; +import javax.portlet.PortletSession; import org.junit.Test; @@ -37,12 +38,12 @@ public class PortletRequestAttributesTests { private static final String KEY = "ThatThingThatThing"; - @SuppressWarnings("serial") - private static final Serializable VALUE = new Serializable() { }; + private static final Serializable VALUE = new Serializable() { + }; - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void testCtorRejectsNullArg() throws Exception { new PortletRequestAttributes(null); } @@ -85,53 +86,51 @@ public class PortletRequestAttributesTests { @Test public void testSetSessionScopedAttribute() throws Exception { MockPortletSession session = new MockPortletSession(); - session.setAttribute(KEY, VALUE); + session.setAttribute(KEY, VALUE, PortletSession.PORTLET_SCOPE); MockPortletRequest request = new MockPortletRequest(); request.setSession(session); PortletRequestAttributes attrs = new PortletRequestAttributes(request); attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_SESSION); - Object value = session.getAttribute(KEY); - assertSame(VALUE, value); + assertSame(VALUE, session.getAttribute(KEY, PortletSession.PORTLET_SCOPE)); } @Test public void testSetSessionScopedAttributeAfterCompletion() throws Exception { MockPortletSession session = new MockPortletSession(); - session.setAttribute(KEY, VALUE); + session.setAttribute(KEY, VALUE, PortletSession.PORTLET_SCOPE); MockPortletRequest request = new MockPortletRequest(); request.setSession(session); PortletRequestAttributes attrs = new PortletRequestAttributes(request); + assertSame(VALUE, attrs.getAttribute(KEY, RequestAttributes.SCOPE_SESSION)); attrs.requestCompleted(); request.close(); attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_SESSION); - Object value = session.getAttribute(KEY); - assertSame(VALUE, value); + assertSame(VALUE, session.getAttribute(KEY, PortletSession.PORTLET_SCOPE)); } @Test public void testSetGlobalSessionScopedAttribute() throws Exception { MockPortletSession session = new MockPortletSession(); - session.setAttribute(KEY, VALUE); + session.setAttribute(KEY, VALUE, PortletSession.APPLICATION_SCOPE); MockPortletRequest request = new MockPortletRequest(); request.setSession(session); PortletRequestAttributes attrs = new PortletRequestAttributes(request); attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_GLOBAL_SESSION); - Object value = session.getAttribute(KEY); - assertSame(VALUE, value); + assertSame(VALUE, session.getAttribute(KEY, PortletSession.APPLICATION_SCOPE)); } @Test public void testSetGlobalSessionScopedAttributeAfterCompletion() throws Exception { MockPortletSession session = new MockPortletSession(); - session.setAttribute(KEY, VALUE); + session.setAttribute(KEY, VALUE, PortletSession.APPLICATION_SCOPE); MockPortletRequest request = new MockPortletRequest(); request.setSession(session); PortletRequestAttributes attrs = new PortletRequestAttributes(request); + assertSame(VALUE, attrs.getAttribute(KEY, RequestAttributes.SCOPE_GLOBAL_SESSION)); attrs.requestCompleted(); request.close(); attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_GLOBAL_SESSION); - Object value = session.getAttribute(KEY); - assertSame(VALUE, value); + assertSame(VALUE, session.getAttribute(KEY, PortletSession.APPLICATION_SCOPE)); } @Test diff --git a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/XmlPortletApplicationContextTests.java b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/XmlPortletApplicationContextTests.java index 67a4530e..b4f3e8e9 100644 --- a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/XmlPortletApplicationContextTests.java +++ b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/XmlPortletApplicationContextTests.java @@ -58,7 +58,7 @@ public class XmlPortletApplicationContextTests extends AbstractXmlWebApplication beanFactory.addBeanPostProcessor(new BeanPostProcessor() { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - if(bean instanceof TestBean) { + if (bean instanceof TestBean) { ((TestBean) bean).getFriends().add("myFriend"); } return bean; diff --git a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/mvc/PortletWrappingControllerTests.java b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/mvc/PortletWrappingControllerTests.java index 3a5df549..62532a76 100644 --- a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/mvc/PortletWrappingControllerTests.java +++ b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/mvc/PortletWrappingControllerTests.java @@ -162,9 +162,11 @@ public final class PortletWrappingControllerTests { public void processAction(ActionRequest request, ActionResponse response) throws PortletException { if (request.getParameter("test") != null) { response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, "myPortlet-action"); - } else if (request.getParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME) != null) { + } + else if (request.getParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME) != null) { response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, getPortletConfig().getPortletName()); - } else { + } + else { throw new IllegalArgumentException("no request parameters"); } } diff --git a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/util/PortletUtilsTests.java b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/util/PortletUtilsTests.java index 52c80665..7ab898b2 100644 --- a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/util/PortletUtilsTests.java +++ b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/util/PortletUtilsTests.java @@ -435,12 +435,13 @@ public final class PortletUtilsTests { public void testGetRequiredSessionAttributeWithExistingSessionAndNoAttribute() throws Exception { MockPortletSession session = new MockPortletSession(); - final PortletRequest request = mock(PortletRequest.class); + PortletRequest request = mock(PortletRequest.class); given(request.getPortletSession(false)).willReturn(session); try { PortletUtils.getRequiredSessionAttribute(request, "foo"); fail("expected IllegalStateException"); - } catch (IllegalStateException ex) { /* expected */ } + } + catch (IllegalStateException ex) { /* expected */ } } |