Merge branch '3.2.x'

* 3.2.x: (28 commits)
  Hide 'doc' changes from jdiff reports
  Document @Bean 'lite' mode vs @Configuration
  Final preparations for 3.2.2
  Remove Tiles 3 configuration method
  Polishing
  Extracted buildRequestAttributes template method from FrameworkServlet
  Added "beforeExistingAdvisors" flag to AbstractAdvisingBeanPostProcessor
  Minor refinements along the way of researching static CGLIB callbacks
  Compare Kind references before checking log levels
  Polish Javadoc in RequestAttributes
  Fix copy-n-paste errors in NativeWebRequest
  Fix issue with restoring included attributes
  Add additional test for daylight savings glitch
  Document context hierarchy support in the TCF
  Fix test for daylight savings glitch
  Make the methodParameter field of HandlerMethod final
  Disable AsyncTests in spring-test-mvc
  Reformat the testing chapter
  Document context hierarchy support in the TCF
  Document context hierarchy support in the TCF
  ...
This commit is contained in:
Phillip Webb
2013-03-13 14:01:46 -07:00
267 changed files with 8384 additions and 6246 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2013 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.
@@ -16,9 +16,6 @@
package org.springframework.web.portlet.context;
import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
import java.io.Serializable;
import javax.portlet.PortletRequest;
@@ -28,6 +25,9 @@ import org.springframework.mock.web.portlet.MockPortletRequest;
import org.springframework.mock.web.portlet.MockPortletSession;
import org.springframework.web.context.request.RequestAttributes;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;
/**
* @author Rick Evans
* @author Juergen Hoeller
@@ -136,15 +136,13 @@ public class PortletRequestAttributesTests {
@Test
public void testGetSessionScopedAttributeDoesNotForceCreationOfSession() throws Exception {
PortletRequest request = createMock(PortletRequest.class);
expect(request.getPortletSession(false)).andReturn(null);
replay(request);
PortletRequest request = mock(PortletRequest.class);
PortletRequestAttributes attrs = new PortletRequestAttributes(request);
Object value = attrs.getAttribute(KEY, RequestAttributes.SCOPE_SESSION);
assertNull(value);
verify(request);
verify(request).getPortletSession(false);
}
@Test
@@ -161,14 +159,12 @@ public class PortletRequestAttributesTests {
@Test
public void testRemoveSessionScopedAttributeDoesNotForceCreationOfSession() throws Exception {
PortletRequest request = createMock(PortletRequest.class);
expect(request.getPortletSession(false)).andReturn(null);
replay(request);
PortletRequest request = mock(PortletRequest.class);
PortletRequestAttributes attrs = new PortletRequestAttributes(request);
attrs.removeAttribute(KEY, RequestAttributes.SCOPE_SESSION);
verify(request);
verify(request).getPortletSession(false);
}
}

View File

@@ -21,23 +21,23 @@ import java.io.FileNotFoundException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.portlet.PortletContext;
import javax.portlet.PortletRequest;
import javax.portlet.PortletSession;
import org.junit.Test;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
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.MockPortletRequest;
import org.springframework.mock.web.portlet.MockPortletSession;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.web.util.WebUtils;
import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;
/**
* @author Rick Evans
@@ -60,9 +60,8 @@ public final class PortletUtilsTests {
public void testGetRealPathInterpretsLocationAsRelativeToWebAppRootIfPathDoesNotBeginWithALeadingSlash() throws Exception {
final String originalPath = "web/foo";
final String expectedRealPath = "/" + originalPath;
PortletContext ctx = createMock(PortletContext.class);
expect(ctx.getRealPath(expectedRealPath)).andReturn(expectedRealPath);
replay(ctx);
PortletContext ctx = mock(PortletContext.class);
given(ctx.getRealPath(expectedRealPath)).willReturn(expectedRealPath);
String actualRealPath = PortletUtils.getRealPath(ctx, originalPath);
assertEquals(expectedRealPath, actualRealPath);
@@ -402,13 +401,11 @@ public final class PortletUtilsTests {
@Test
public void testGetSessionAttributeDoes_Not_CreateANewSession() throws Exception {
PortletRequest request = createMock(PortletRequest.class);
expect(request.getPortletSession(false)).andReturn(null);
replay(request);
PortletRequest request = mock(PortletRequest.class);
Object sessionAttribute = PortletUtils.getSessionAttribute(request, "foo");
assertNull("Must return null if session attribute does not exist (or if Session does not exist)", sessionAttribute);
verify(request);
verify(request).getPortletSession(false);
}
@Test
@@ -416,15 +413,12 @@ public final class PortletUtilsTests {
MockPortletSession session = new MockPortletSession();
session.setAttribute("foo", "foo");
PortletRequest request = createMock(PortletRequest.class);
expect(request.getPortletSession(false)).andReturn(session);
replay(request);
PortletRequest request = mock(PortletRequest.class);
given(request.getPortletSession(false)).willReturn(session);
Object sessionAttribute = PortletUtils.getSessionAttribute(request, "foo");
assertNotNull("Must not return null if session attribute exists (and Session exists)", sessionAttribute);
assertEquals("foo", sessionAttribute);
verify(request);
}
@Test
@@ -432,102 +426,72 @@ public final class PortletUtilsTests {
MockPortletSession session = new MockPortletSession();
session.setAttribute("foo", "foo");
PortletRequest request = createMock(PortletRequest.class);
expect(request.getPortletSession(false)).andReturn(session);
replay(request);
PortletRequest request = mock(PortletRequest.class);
given(request.getPortletSession(false)).willReturn(session);
Object sessionAttribute = PortletUtils.getRequiredSessionAttribute(request, "foo");
assertNotNull("Must not return null if session attribute exists (and Session exists)", sessionAttribute);
assertEquals("foo", sessionAttribute);
verify(request);
}
@Test
public void testGetRequiredSessionAttributeWithExistingSessionAndNoAttribute() throws Exception {
MockPortletSession session = new MockPortletSession();
final PortletRequest request = createMock(PortletRequest.class);
expect(request.getPortletSession(false)).andReturn(session);
replay(request);
final PortletRequest request = mock(PortletRequest.class);
given(request.getPortletSession(false)).willReturn(session);
try {
PortletUtils.getRequiredSessionAttribute(request, "foo");
fail("expected IllegalStateException");
} catch (IllegalStateException ex) { /* expected */ }
verify(request);
}
@Test
public void testSetSessionAttributeWithExistingSessionAndNullValue() throws Exception {
PortletSession session = createMock(PortletSession.class);
PortletRequest request = createMock(PortletRequest.class);
expect(request.getPortletSession(false)).andReturn(session); // must not create Session for null value...
session.removeAttribute("foo", PortletSession.APPLICATION_SCOPE);
replay(request, session);
PortletSession session = mock(PortletSession.class);
PortletRequest request = mock(PortletRequest.class);
given(request.getPortletSession(false)).willReturn(session); // must not create Session for null value...
PortletUtils.setSessionAttribute(request, "foo", null, PortletSession.APPLICATION_SCOPE);
verify(request, session);
verify(session).removeAttribute("foo", PortletSession.APPLICATION_SCOPE);
}
@Test
public void testSetSessionAttributeWithNoExistingSessionAndNullValue() throws Exception {
PortletRequest request = createMock(PortletRequest.class);
expect(request.getPortletSession(false)).andReturn(null); // must not create Session for null value...
replay(request);
PortletRequest request = mock(PortletRequest.class);
PortletUtils.setSessionAttribute(request, "foo", null, PortletSession.APPLICATION_SCOPE);
verify(request);
verify(request).getPortletSession(false); // must not create Session for null value...
}
@Test
public void testSetSessionAttributeWithExistingSessionAndSpecificScope() throws Exception {
PortletSession session = createMock(PortletSession.class);
PortletRequest request = createMock(PortletRequest.class);
expect(request.getPortletSession()).andReturn(session); // must not create Session ...
session.setAttribute("foo", "foo", PortletSession.APPLICATION_SCOPE);
replay(request, session);
PortletSession session = mock(PortletSession.class);
PortletRequest request = mock(PortletRequest.class);
given(request.getPortletSession()).willReturn(session); // must not create Session ...
PortletUtils.setSessionAttribute(request, "foo", "foo", PortletSession.APPLICATION_SCOPE);
verify(request, session);
verify(session).setAttribute("foo", "foo", PortletSession.APPLICATION_SCOPE);
}
@Test
public void testGetSessionAttributeWithExistingSessionAndSpecificScope() throws Exception {
PortletSession session = createMock(PortletSession.class);
PortletRequest request = createMock(PortletRequest.class);
expect(request.getPortletSession(false)).andReturn(session);
expect(session.getAttribute("foo", PortletSession.APPLICATION_SCOPE)).andReturn("foo");
replay(request, session);
PortletSession session = mock(PortletSession.class);
PortletRequest request = mock(PortletRequest.class);
given(request.getPortletSession(false)).willReturn(session);
given(session.getAttribute("foo", PortletSession.APPLICATION_SCOPE)).willReturn("foo");
Object sessionAttribute = PortletUtils.getSessionAttribute(request, "foo", PortletSession.APPLICATION_SCOPE);
assertNotNull("Must not return null if session attribute exists (and Session exists)", sessionAttribute);
assertEquals("foo", sessionAttribute);
verify(request, session);
}
@Test
public void testGetSessionAttributeWithExistingSessionDefaultsToPortletScope() throws Exception {
PortletSession session = createMock(PortletSession.class);
PortletRequest request = createMock(PortletRequest.class);
expect(request.getPortletSession(false)).andReturn(session);
expect(session.getAttribute("foo", PortletSession.PORTLET_SCOPE)).andReturn("foo");
replay(request, session);
PortletSession session = mock(PortletSession.class);
PortletRequest request = mock(PortletRequest.class);
given(request.getPortletSession(false)).willReturn(session);
given(session.getAttribute("foo", PortletSession.PORTLET_SCOPE)).willReturn("foo");
Object sessionAttribute = PortletUtils.getSessionAttribute(request, "foo");
assertNotNull("Must not return null if session attribute exists (and Session exists)", sessionAttribute);
assertEquals("foo", sessionAttribute);
verify(request, session);
}