struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1311951 - /struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
Date Tue, 10 Apr 2012 19:33:51 GMT
Author: lukaszlenart
Date: Tue Apr 10 19:33:51 2012
New Revision: 1311951

URL: http://svn.apache.org/viewvc?rev=1311951&view=rev
Log:
WW-3442 adds Session initialisation method to solve problem with missing session and allow
to initialise session on its own in test cases

Modified:
    struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java

Modified: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java?rev=1311951&r1=1311950&r2=1311951&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
(original)
+++ struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
Tue Apr 10 19:33:51 2012
@@ -149,17 +149,23 @@ public abstract class StrutsTestCase ext
         return proxy;
     }
 
-    private void initActionContext(ActionContext actionContext) {
-        actionContext.setParameters(new HashMap(request.getParameterMap()));
-
-        initMockPortletContext(actionContext);
+    protected void initActionContext(ActionContext actionContext) {
+        actionContext.setParameters(new HashMap<String, Object>(request.getParameterMap()));
+        initSession(actionContext);
+        initPortletContext(actionContext);
         applyAdditionalParams(actionContext);
-
         // set the action context to the one used by the proxy
         ActionContext.setContext(actionContext);
     }
 
-    private void initMockPortletContext(ActionContext actionContext) {
+    protected void initSession(ActionContext actionContext) {
+        Map<String, Object> session = actionContext.getSession();
+        if (session == null) {
+            actionContext.setSession(new HashMap<String, Object>());
+        }
+    }
+
+    protected void initPortletContext(ActionContext actionContext) {
         try {
             ClassLoaderUtil.loadClass("javax.portlet.PortletContext", getClass());
             Class mockClazz = ClassLoaderUtil.loadClass("org.springframework.mock.web.portlet.MockPortletContext",
getClass());



Mime
View raw message