struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [46/50] [abbrv] struts git commit: Merge remote-tracking branch 'upstream/master' into http-parameters
Date Fri, 15 Jul 2016 13:19:13 GMT
Merge remote-tracking branch 'upstream/master' into http-parameters

Conflicts:
	core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
	core/src/test/java/com/opensymphony/xwork2/interceptor/I18nInterceptorTest.java
	core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
	core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java
	core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
	core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/bb21dbe4
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/bb21dbe4
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/bb21dbe4

Branch: refs/heads/master
Commit: bb21dbe4929cf88a4c2565fdbd359d0e0b067e1f
Parents: abd8c6b fc2179c
Author: Lukasz Lenart <lukasz.lenart@gmail.com>
Authored: Sat Mar 12 16:03:42 2016 +0100
Committer: Lukasz Lenart <lukasz.lenart@gmail.com>
Committed: Sat Mar 12 16:03:42 2016 +0100

----------------------------------------------------------------------
 .gitignore                                      |   1 -
 apps/portlet/pom.xml                            |   2 +-
 .../struts2/portlet/test/BasePortletTest.java   |   6 +-
 .../portlet/test/Struts2PortletTest.java        |   2 +
 .../org/demo/rest/example/IndexController.java  |  16 ++
 apps/rest-showcase/src/main/webapp/index.jsp    |   2 -
 .../showcase/tiles/TilesAnnotationsAction.java  |  40 +++
 apps/showcase/src/main/webapp/WEB-INF/tiles.xml |  10 +-
 .../src/main/webapp/WEB-INF/tiles/body.jsp      |   3 +
 .../webapp/WEB-INF/tiles/layout-annotations.jsp |  14 ++
 .../WEB-INF/validation/ajaxFormSubmit.jsp       |   7 +-
 assembly/pom.xml                                |   5 -
 assembly/src/main/assembly/all.xml              |   4 -
 assembly/src/main/assembly/docs.xml             |   4 -
 bom/pom.xml                                     |   5 -
 .../xwork2/DefaultActionInvocation.java         |   7 +-
 .../com/opensymphony/xwork2/XWorkConstants.java |   1 +
 ...ervletContextAwareConfigurationProvider.java |  32 +++
 .../xwork2/config/entities/ActionConfig.java    |   1 +
 .../xwork2/config/entities/AllowedMethods.java  |  30 +++
 .../xwork2/config/entities/PackageConfig.java   |   2 +-
 .../xwork2/config/impl/ActionConfigMatcher.java |   1 +
 .../providers/XmlConfigurationProvider.java     |  32 +--
 .../interceptor/DefaultWorkflowInterceptor.java |   4 +-
 .../xwork2/interceptor/I18nInterceptor.java     |   5 +
 .../interceptor/ParametersInterceptor.java      |  29 +--
 .../com/opensymphony/xwork2/ognl/OgnlUtil.java  |  15 +-
 .../xwork2/ognl/OgnlValueStack.java             |   1 +
 .../xwork2/ognl/SecurityMemberAccess.java       |  16 +-
 .../xwork2/util/LocalizedTextUtil.java          |  31 ++-
 .../validator/DelegatingValidatorContext.java   |   7 +-
 .../org/apache/struts2/StrutsConstants.java     |   1 +
 .../apache/struts2/components/Component.java    |   6 +-
 .../org/apache/struts2/components/UIBean.java   |   4 +-
 .../template/VelocityTemplateEngine.java        |   2 +-
 .../config/DefaultBeanSelectionProvider.java    |   1 +
 .../apache/struts2/dispatcher/Dispatcher.java   |   3 +
 .../struts2/dispatcher/PrepareOperations.java   |   2 +
 .../multipart/JakartaMultiPartRequest.java      |  12 +-
 .../struts2/interceptor/CookieInterceptor.java  |  12 +-
 .../interceptor/MessageStoreInterceptor.java    |  58 +----
 .../MessageStorePreResultListener.java          |  95 +++++++
 .../org/apache/struts2/util/ComponentUtils.java |   9 +-
 .../struts2/views/jsp/ui/AbstractUITag.java     |   2 +-
 core/src/main/resources/struts-default.xml      |  20 +-
 .../resources/template/simple/checkboxlist.ftl  |   7 +-
 .../main/resources/template/simple/radiomap.ftl |   5 +-
 .../xwork2/DefaultActionInvocationTest.java     |   3 +
 .../config/entities/ActionConfigTest.java       |   4 +-
 .../config/entities/AllowedMethodsTest.java     |  15 ++
 .../config/impl/ActionConfigMatcherTest.java    |  16 +-
 ...ConfigurationProviderAllowedMethodsTest.java |  38 ++-
 .../XmlConfigurationProviderResultsTest.java    |  54 ++++
 .../xwork2/config/providers/XmlHelperTest.java  | 234 ++++++-----------
 .../xwork2/interceptor/I18nInterceptorTest.java |  16 +-
 .../ParameterRemoverInterceptorTest.java        |  23 +-
 .../PrefixMethodInvocationUtilTest.java         | 135 ++++------
 .../interceptor/PrepareInterceptorTest.java     |  83 +++---
 .../xwork2/ognl/SecurityMemberAccessTest.java   |  20 +-
 .../validator/VisitorFieldValidatorTest.java    |   2 +-
 .../org/apache/struts2/RequestUtilsTest.java    |  66 +++--
 .../interceptor/CookieInterceptorTest.java      | 124 ++++-----
 .../interceptor/I18nInterceptorTest.java        |  16 +-
 .../MessageStoreInterceptorTest.java            | 183 +++-----------
 .../MessageStorePreResultListenerTest.java      | 252 +++++++++++++++++++
 .../ServletConfigInterceptorTest.java           |  70 +++---
 .../struts2/result/VelocityResultTest.java      |   4 +-
 .../apache/struts2/util/ComponentUtilsTest.java |  44 ++++
 .../apache/struts2/views/jsp/ActionTagTest.java |   3 +-
 .../struts2/views/jsp/IncludeTagTest.java       |  50 ++--
 .../struts2/views/util/ResourceUtilTest.java    |  24 +-
 .../com/opensymphony/xwork2/TestBean.properties |   2 +-
 .../providers/xwork-test-allowed-methods.xml    |   6 +-
 .../providers/xwork-test-result-names.xml       |  48 ++++
 plugins/convention/pom.xml                      |   5 -
 .../convention/DefaultResultMapBuilder.java     |  20 +-
 .../PackageBasedActionConfigBuilder.java        |   6 +-
 .../convention/annotation/AllowedMethods.java   |   2 +-
 .../struts2/convention/annotation/Result.java   |   2 +-
 .../ConventionUnknownHandlerTest.java           |   6 +-
 .../convention/DefaultResultMapBuilderTest.java |  58 +++++
 .../PackageBasedActionConfigBuilderTest.java    |   4 +-
 .../actions/allowedmethods/package-info.java    |   2 +-
 .../result/ActionLevelResultsNamesAction.java   |  47 ++++
 plugins/javatemplates/pom.xml                   |   6 +-
 .../views/java/simple/TextFieldHandler.java     |   4 +-
 .../struts2/views/java/simple/AbstractTest.java |  36 +--
 .../rest/DefaultContentTypeHandlerManager.java  |  69 ++++-
 .../apache/struts2/rest/RestActionMapper.java   |   7 +-
 .../DefaultContentTypeHandlerManagerTest.java   |  42 ++++
 .../struts2/rest/RestActionMapperTest.java      |  41 ++-
 .../sitemesh/VelocityDecoratorServlet.java      |  53 ++--
 .../tiles/StrutsTilesAnnotationProcessor.java   | 177 +++++++++++++
 .../tiles/annotation/TilesAddAttribute.java     |  30 +++
 .../tiles/annotation/TilesAddListAttribute.java |  28 +++
 .../tiles/annotation/TilesDefinition.java       |  66 +++++
 .../tiles/annotation/TilesDefinitions.java      |  36 +++
 .../tiles/annotation/TilesPutAttribute.java     |  32 +++
 .../tiles/annotation/TilesPutListAttribute.java |  32 +++
 .../apache/struts2/views/tiles/TilesResult.java |  69 ++++-
 .../StrutsTilesAnnotationProcessorTest.java     | 147 +++++++++++
 .../TilesTestActionMultipleAnnotations.java     |  12 +
 .../tiles/TilesTestActionSingleAnnotation.java  |  49 ++++
 ...TilesTestActionSingleAnnotationAllEmpty.java |  28 +++
 pom.xml                                         |  23 +-
 .../VisitorValidatorTestAction.properties       |   1 +
 106 files changed, 2308 insertions(+), 941 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/bb21dbe4/core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java
----------------------------------------------------------------------
diff --cc core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java
index 3d1e6f2,cf4995e..acc0d7b
--- a/core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java
+++ b/core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java
@@@ -20,9 -20,8 +20,10 @@@ import com.opensymphony.xwork2.ActionIn
  import com.opensymphony.xwork2.util.LocalizedTextUtil;
  import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.Logger;
 +import org.apache.struts2.dispatcher.Parameter;
 +import org.apache.struts2.dispatcher.HttpParameters;
  
+ import java.util.Arrays;
  import java.util.Locale;
  import java.util.Map;
  

http://git-wip-us.apache.org/repos/asf/struts/blob/bb21dbe4/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
----------------------------------------------------------------------
diff --cc core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
index 67288ff,f90e8c3..80aa363
--- a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
+++ b/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
@@@ -168,10 -169,11 +168,10 @@@ public class ParametersInterceptor exte
              acceptableParameters = new TreeMap<>();
          }
  
 -        for (Map.Entry<String, Object> entry : params.entrySet()) {
 -            String name = entry.getKey();
 -            Object value = entry.getValue();
 +        for (String name : params.getNames()) {
 +            Parameter parameter = params.get(name);
-             if (isAcceptableParameter(name, action) && isAcceptableValue(parameter.getValue()))
{
+             if (isAcceptableParameter(name, action)) {
 -                acceptableParameters.put(name, entry.getValue());
 +                acceptableParameters.put(name, parameter);
              }
          }
  

http://git-wip-us.apache.org/repos/asf/struts/blob/bb21dbe4/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/struts/blob/bb21dbe4/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
index 341615d,4b7220e..f3e8cb5
--- a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
@@@ -27,9 -27,7 +27,8 @@@ import com.opensymphony.xwork2.intercep
  import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
  import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.Logger;
 +import org.apache.struts2.dispatcher.HttpParameters;
  
- import org.apache.struts2.ServletActionContext;
  import org.apache.struts2.result.ServletRedirectResult;
  
  import java.util.ArrayList;

http://git-wip-us.apache.org/repos/asf/struts/blob/bb21dbe4/core/src/test/java/com/opensymphony/xwork2/interceptor/I18nInterceptorTest.java
----------------------------------------------------------------------
diff --cc core/src/test/java/com/opensymphony/xwork2/interceptor/I18nInterceptorTest.java
index 2a4d98c,17c27aa..f4dfa93
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/I18nInterceptorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/I18nInterceptorTest.java
@@@ -83,12 -82,12 +83,12 @@@ public class I18nInterceptorTest extend
      }
  
      public void testCountryOnlyLocale() throws Exception {
-         prepare(I18nInterceptor.DEFAULT_PARAMETER, "DK");
 -        params.put(I18nInterceptor.DEFAULT_PARAMETER, "NL");
++        prepare(I18nInterceptor.DEFAULT_PARAMETER, "NL");
          interceptor.intercept(mai);
  
 -        assertNull(params.get(I18nInterceptor.DEFAULT_PARAMETER)); // should have been removed
 +        assertFalse(mai.getInvocationContext().getParameters().get(I18nInterceptor.DEFAULT_PARAMETER).isDefined());
// should have been removed
  
-         Locale denmark = new Locale("DK");
+         Locale denmark = new Locale("NL");
          assertNotNull(session.get(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE)); // should
be stored here
          assertEquals(denmark, session.get(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE)); //
should create a locale object
      }
@@@ -105,12 -104,12 +105,12 @@@
      }
  
      public void testWithVariant() throws Exception {
-         prepare(I18nInterceptor.DEFAULT_PARAMETER, "fr_CA_xx");
 -        params.put(I18nInterceptor.DEFAULT_PARAMETER, "ja_JP_JP");
++        prepare(I18nInterceptor.DEFAULT_PARAMETER, "ja_JP_JP");
          interceptor.intercept(mai);
  
 -        assertNull(params.get(I18nInterceptor.DEFAULT_PARAMETER)); // should have been removed
 +        assertFalse(mai.getInvocationContext().getParameters().get(I18nInterceptor.DEFAULT_PARAMETER).isDefined());
// should have been removed
  
-         Locale variant = new Locale("fr", "CA", "xx");
+         Locale variant = new Locale("ja", "JP", "JP");
          Locale locale = (Locale) session.get(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE);
          assertNotNull(locale); // should be stored here
          assertEquals(variant, locale);
@@@ -118,13 -117,13 +118,13 @@@
      }
  
      public void testWithVariantRequestOnly() throws Exception {
-         prepare(I18nInterceptor.DEFAULT_REQUESTONLY_PARAMETER, "fr_CA_xx");
 -        params.put(I18nInterceptor.DEFAULT_REQUESTONLY_PARAMETER, "ja_JP_JP");
++        prepare(I18nInterceptor.DEFAULT_REQUESTONLY_PARAMETER, "ja_JP_JP");
          interceptor.intercept(mai);
  
 -        assertNull(params.get(I18nInterceptor.DEFAULT_PARAMETER)); // should have been removed
 +        assertFalse(mai.getInvocationContext().getParameters().get(I18nInterceptor.DEFAULT_PARAMETER).isDefined());
// should have been removed
          assertNull(session.get(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE));
  
-         Locale variant = new Locale("fr", "CA", "xx");
+         Locale variant = new Locale("ja", "JP", "JP");
          Locale locale = mai.getInvocationContext().getLocale();
          assertNotNull(locale); // should be stored here
          assertEquals(variant, locale);

http://git-wip-us.apache.org/repos/asf/struts/blob/bb21dbe4/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
----------------------------------------------------------------------
diff --cc core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
index eeaec7c,720ef93..5412fb8
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
@@@ -4,8 -4,7 +4,9 @@@ import com.opensymphony.xwork2.ActionCo
  import com.opensymphony.xwork2.ActionInvocation;
  import com.opensymphony.xwork2.ActionSupport;
  import junit.framework.TestCase;
 +import org.apache.struts2.dispatcher.HttpParameters;
 +import org.easymock.MockControl;
+ import static org.easymock.EasyMock.*;
  
  import java.util.LinkedHashMap;
  import java.util.Map;
@@@ -34,30 -31,31 +33,30 @@@ public class ParameterRemoverIntercepto
  	}
  	
  	public void testInterception1() throws Exception {
 -		contextMap.put(ActionContext.PARAMETERS, new LinkedHashMap<String, Object>() {
 -			private static final long serialVersionUID = 0L;
 +		contextMap.put(ActionContext.PARAMETERS, HttpParameters.create(new LinkedHashMap<String,
Object>() {
  			{
 -				put("param1", new String[] { "paramValue1" });
 -				put("param2", new String[] { "paramValue2" });
 -				put("param3", new String[] { "paramValue3" });
 -				put("param", new String[] { "paramValue" });
 +				put("param1", new String[]{"paramValue1"});
 +				put("param2", new String[]{"paramValue2"});
 +				put("param3", new String[]{"paramValue3"});
 +				put("param", new String[]{"paramValue"});
  			}
 -		});
 +		}).build());
  		
- 		actionInvocationControl.replay();
+ 		replay(actionInvocation);
  		
  		ParameterRemoverInterceptor interceptor = new ParameterRemoverInterceptor();
  		interceptor.setParamNames("param1,param2");
  		interceptor.setParamValues("paramValue1,paramValue2");
  		interceptor.intercept(actionInvocation);
  		
 -		Map params = (Map) contextMap.get(ActionContext.PARAMETERS);
 -		assertEquals(params.size(), 2);
 -		assertTrue(params.containsKey("param3"));
 -		assertTrue(params.containsKey("param"));
 -		assertEquals(((String[])params.get("param3"))[0], "paramValue3");
 -		assertEquals(((String[])params.get("param"))[0], "paramValue");
 +		HttpParameters params = (HttpParameters) contextMap.get(ActionContext.PARAMETERS);
 +		assertEquals(params.getNames().size(), 2);
 +		assertTrue(params.contains("param3"));
 +		assertTrue(params.contains("param"));
 +		assertEquals(params.get("param3").getValue(), "paramValue3");
 +		assertEquals(params.get("param").getValue(), "paramValue");
  		
- 		actionInvocationControl.verify();
+ 		verify(actionInvocation);
  	}
  	
  	
@@@ -67,19 -66,19 +66,19 @@@
  				put("param1", new String[] { "paramValue2" });
  				put("param2", new String[] { "paramValue1" });
  			}
 -		});
 +		}).build());
  		
- 		actionInvocationControl.replay();
+ 		replay(actionInvocation);
  		
  		ParameterRemoverInterceptor interceptor = new ParameterRemoverInterceptor();
  		interceptor.setParamNames("param1,param2");
  		interceptor.setParamValues("paramValue1,paramValue2");
  		interceptor.intercept(actionInvocation);
  		
 -		Map params = (Map) contextMap.get(ActionContext.PARAMETERS);
 -		assertEquals(params.size(), 0);
 +		HttpParameters params = (HttpParameters) contextMap.get(ActionContext.PARAMETERS);
 +		assertEquals(params.getNames().size(), 0);
  		
- 		actionInvocationControl.verify();
+ 		verify(actionInvocation);
  	}
  	
  	
@@@ -89,23 -89,23 +88,23 @@@
  				put("param1", new String[] { "paramValueOne" });
  				put("param2", new String[] { "paramValueTwo" });
  			}
 -		});
 +		}).build());
  		
- 		actionInvocationControl.replay();
+ 		replay(actionInvocation);
  		
  		ParameterRemoverInterceptor interceptor = new ParameterRemoverInterceptor();
  		interceptor.setParamNames("param1,param2");
  		interceptor.setParamValues("paramValue1,paramValue2");
  		interceptor.intercept(actionInvocation);
  		
 -		Map params = (Map) contextMap.get(ActionContext.PARAMETERS);
 -		assertEquals(params.size(), 2);
 -		assertTrue(params.containsKey("param1"));
 -		assertTrue(params.containsKey("param2"));
 -		assertEquals(((String[])params.get("param1"))[0], "paramValueOne");
 -		assertEquals(((String[])params.get("param2"))[0], "paramValueTwo");
 +		HttpParameters params = (HttpParameters) contextMap.get(ActionContext.PARAMETERS);
 +		assertEquals(params.getNames().size(), 2);
 +		assertTrue(params.contains("param1"));
 +		assertTrue(params.contains("param2"));
 +		assertEquals(params.get("param1").getValue(), "paramValueOne");
 +		assertEquals(params.get("param2").getValue(), "paramValueTwo");
  		
- 		actionInvocationControl.verify();
+ 		verify(actionInvocation);
  	}
  	
  	class SampleAction extends ActionSupport {

http://git-wip-us.apache.org/repos/asf/struts/blob/bb21dbe4/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java
----------------------------------------------------------------------
diff --cc core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java
index a3784d3,9fc8396..1e73955
--- a/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java
@@@ -27,9 -27,10 +27,11 @@@ import java.util.LinkedHashMap
  import java.util.List;
  import java.util.Map;
  
+ import com.opensymphony.xwork2.ActionProxy;
+ import com.opensymphony.xwork2.interceptor.PreResultListener;
  import org.apache.struts2.ServletActionContext;
  import org.apache.struts2.StrutsInternalTestCase;
 +import org.apache.struts2.dispatcher.HttpParameters;
  import org.apache.struts2.result.ServletActionRedirectResult;
  import org.easymock.EasyMock;
  
@@@ -65,81 -69,24 +70,22 @@@ public class MessageStoreInterceptorTes
          interceptor.setAllowRequestParameterSwitch(true);
          interceptor.setOperationMode(MessageStoreInterceptor.STORE_MODE);
  
- 
-         Map sessionMap = new LinkedHashMap();
 -        Map paramMap = new LinkedHashMap();
--
          ActionSupport action = new ActionSupport();
          action.addActionError("some action error 1");
-         action.addActionError("some action error 2");
          action.addActionMessage("some action message 1");
-         action.addActionMessage("some action message 2");
-         action.addFieldError("field1", "some field error 1");
          action.addFieldError("field2", "some field error 2");
  
          ActionContext actionContext = new ActionContext(new HashMap());
 -        actionContext.put(ActionContext.PARAMETERS, paramMap);
 +        actionContext.setParameters(HttpParameters.createEmpty().build());
-         actionContext.setSession(sessionMap);
- 
-         // Mock (ActionInvocation)
-         ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
-         mockActionInvocation.getInvocationContext();
-         EasyMock.expectLastCall().andReturn(actionContext);
-         EasyMock.expectLastCall().anyTimes();
- 
-         mockActionInvocation.invoke();
-         EasyMock.expectLastCall().andReturn(Action.SUCCESS);
- 
-         mockActionInvocation.getAction();
-         EasyMock.expectLastCall().andReturn(action);
-         
-         mockActionInvocation.getResult();
-         EasyMock.expectLastCall().andReturn(new ServletActionRedirectResult());
- 
-         EasyMock.replay(mockActionInvocation);
  
-         interceptor.init();
-         interceptor.intercept(mockActionInvocation);
-         interceptor.destroy();
- 
-         assertEquals(sessionMap.size(), 3);
-         assertTrue(sessionMap.containsKey(MessageStoreInterceptor.actionErrorsSessionKey));
-         assertTrue(sessionMap.containsKey(MessageStoreInterceptor.actionMessagesSessionKey));
-         assertTrue(sessionMap.containsKey(MessageStoreInterceptor.fieldErrorsSessionKey));
- 
-         List actionErrors = (List) sessionMap.get(MessageStoreInterceptor.actionErrorsSessionKey);
-         List actionMessages = (List) sessionMap.get(MessageStoreInterceptor.actionMessagesSessionKey);
-         Map fieldErrors = (Map) sessionMap.get(MessageStoreInterceptor.fieldErrorsSessionKey);
- 
-         assertEquals(actionErrors.size(), 2);
-         assertEquals(actionMessages.size(), 2);
-         assertEquals(fieldErrors.size(), 2);
- 
-         assertTrue(actionErrors.contains("some action error 1"));
-         assertTrue(actionErrors.contains("some action error 2"));
-         assertTrue(actionMessages.contains("some action message 1"));
-         assertTrue(actionMessages.contains("some action message 2"));
-         assertTrue(fieldErrors.containsKey("field1"));
-         assertTrue(fieldErrors.containsKey("field2"));
-         assertEquals(((List)fieldErrors.get("field1")).size(), 1);
-         assertEquals(((List)fieldErrors.get("field2")).size(), 1);
-         assertEquals(((List)fieldErrors.get("field1")).get(0), "some field error 1");
-         assertEquals(((List)fieldErrors.get("field2")).get(0), "some field error 2");
- 
-         EasyMock.verify(mockActionInvocation);
-     }
- 
-     public void testIgnoreMessageWithoutSession() throws Exception {
-         MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
-         interceptor.setAllowRequestParameterSwitch(true);
-         interceptor.setOperationMode(MessageStoreInterceptor.STORE_MODE);
+         HttpSession mockedSession = EasyMock.createControl().createMock(HttpSession.class);
+         HttpServletRequest mockedRequest = EasyMock.createControl().createMock(HttpServletRequest.class);
+         mockedRequest.getSession(false);
+         EasyMock.expectLastCall().andReturn(mockedSession);
+         EasyMock.expectLastCall().once();
+         ServletActionContext.setRequest(mockedRequest);
  
-         ActionSupport action = new ActionSupport();
-         action.addActionError("some action error 1");
-         action.addActionMessage("some action message 1");
-         action.addFieldError("field2", "some field error 2");
- 
-         ActionContext actionContext = new ActionContext(new HashMap());
-         actionContext.setParameters(HttpParameters.createEmpty().build());
+         EasyMock.replay(mockedRequest);
  
          // Mock (ActionInvocation)
          ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
@@@ -198,9 -143,17 +141,17 @@@
          sessionMap.put(MessageStoreInterceptor.actionMessagesSessionKey, actionMessages);
          sessionMap.put(MessageStoreInterceptor.fieldErrorsSessionKey, fieldErrors);
  
+         HttpSession mockedSession = EasyMock.createControl().createMock(HttpSession.class);
+         HttpServletRequest mockedRequest = EasyMock.createControl().createMock(HttpServletRequest.class);
+         mockedRequest.getSession(false);
+         EasyMock.expectLastCall().andReturn(mockedSession);
+         EasyMock.expectLastCall().once();
+         ServletActionContext.setRequest(mockedRequest);
+ 
+         EasyMock.replay(mockedRequest);
  
          ActionContext actionContext = new ActionContext(new HashMap());
 -        actionContext.put(ActionContext.PARAMETERS, paramsMap);
 +        actionContext.setParameters(HttpParameters.createEmpty().build());
          actionContext.put(ActionContext.SESSION, sessionMap);
  
          mockActionInvocation.getInvocationContext();
@@@ -252,9 -206,18 +203,18 @@@
          action.addFieldError("field2", "some field error 2");
  
          ActionContext actionContext = new ActionContext(new HashMap());
 -        actionContext.put(ActionContext.PARAMETERS, paramMap);
 +        actionContext.setParameters(HttpParameters.createEmpty().build());
          actionContext.put(ActionContext.SESSION, sessionMap);
  
+         HttpSession mockedSession = EasyMock.createControl().createMock(HttpSession.class);
+         HttpServletRequest mockedRequest = EasyMock.createControl().createMock(HttpServletRequest.class);
+         mockedRequest.getSession(false);
+         EasyMock.expectLastCall().andReturn(mockedSession);
+         EasyMock.expectLastCall().once();
+         ServletActionContext.setRequest(mockedRequest);
+ 
+         EasyMock.replay(mockedRequest);
+ 
          // Mock (ActionInvocation)
          ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
          mockActionInvocation.getInvocationContext();

http://git-wip-us.apache.org/repos/asf/struts/blob/bb21dbe4/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
----------------------------------------------------------------------
diff --cc core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
index 982d7b1,a3b8a7b..244d5f3
--- a/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
@@@ -30,9 -30,10 +30,11 @@@ import javax.servlet.http.HttpServletRe
  
  import org.apache.struts2.StrutsInternalTestCase;
  import org.apache.struts2.StrutsStatics;
+ import org.apache.struts2.interceptor.servlet.ServletPrincipalProxy;
 +import org.apache.struts2.dispatcher.HttpParameters;
  import org.apache.struts2.util.ServletContextAware;
- import org.easymock.MockControl;
+ 
+ import static org.easymock.EasyMock.*;
  import org.springframework.mock.web.MockHttpServletRequest;
  import org.springframework.mock.web.MockHttpServletResponse;
  import org.springframework.mock.web.MockServletContext;
@@@ -89,15 -87,15 +88,15 @@@ public class ServletConfigInterceptorTe
  
          MockActionInvocation mai = createActionInvocation(mock);
  
 -        Map<String, Object> param = new HashMap<String, Object>();
 +        HttpParameters param = HttpParameters.createEmpty().build();
          mai.getInvocationContext().setParameters(param);
  
 -        mock.setParameters((Map)param);
 +        mock.setParameters(param);
-         control.setVoidCallable();
+         expectLastCall().times(1);
  
-         control.replay();
+         replay(mock);
          interceptor.intercept(mai);
-         control.verify();
+         verify(mock);
      }
  
      public void testSessionAware() throws Exception {
@@@ -125,13 -121,13 +122,13 @@@
  
          Map<String, Object> app = new HashMap<String, Object>();
          mai.getInvocationContext().setApplication(app);
 -        
 +
          mock.setApplication(app);
-         control.setVoidCallable();
+         expectLastCall().times(1);
  
-         control.replay();
+         replay(mock);
          interceptor.intercept(mai);
-         control.verify();
+         verify(mock);
      }
  
      public void testPrincipalAware() throws Exception {
@@@ -148,12 -142,12 +143,12 @@@
          MockServletContext ctx = new MockServletContext();
          mai.getInvocationContext().put(StrutsStatics.SERVLET_CONTEXT, ctx);
  
-         mock.setPrincipalProxy(null); // we can do this because of ALWAYS_MATCHER
-         control.setVoidCallable();
+         mock.setPrincipalProxy(anyObject(ServletPrincipalProxy.class)); // less strick match
is needed for this unit test to be conducted using mocks
+         expectLastCall().times(1);
 -        
 +
-         control.replay();
+         replay(mock);
          interceptor.intercept(mai);
-         control.verify();
+         verify(mock);
      }
  
      public void testPrincipalProxy() throws Exception {
@@@ -186,13 -179,13 +180,13 @@@
  
          MockServletContext ctx = new MockServletContext();
          mai.getInvocationContext().put(StrutsStatics.SERVLET_CONTEXT, ctx);
 -        
 +
          mock.setServletContext((ServletContext) ctx);
-         control.setVoidCallable();
+         expectLastCall().times(1);
 -        
 +
-         control.replay();
+         replay(mock);
          interceptor.intercept(mai);
-         control.verify();
+         verify(mock);
      }
  
      private MockActionInvocation createActionInvocation(Object mock) {

http://git-wip-us.apache.org/repos/asf/struts/blob/bb21dbe4/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
----------------------------------------------------------------------
diff --cc core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
index 4d2f878,2b1cd82..024ded8
--- a/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
@@@ -180,8 -178,9 +180,9 @@@ public class ActionTagTest extends Abst
          TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
  
          assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
 -        assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
 +        assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof
PageContext);
-         assertNull(result); // result is never executed, hence never set into invocation
+         assertNotNull(result);
+         assertFalse(result.isExecuted());
      }
  
       public void testExecuteButResetReturnSameInvocation() throws Exception {


Mime
View raw message