struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grobme...@apache.org
Subject svn commit: r1457392 - /struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java
Date Sun, 17 Mar 2013 07:44:54 GMT
Author: grobmeier
Date: Sun Mar 17 07:44:54 2013
New Revision: 1457392

URL: http://svn.apache.org/r1457392
Log:
WW-4017: Support multiple Action executions and Session values

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

Modified: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java?rev=1457392&r1=1457391&r2=1457392&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java
(original)
+++ struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java
Sun Mar 17 07:44:54 2013
@@ -41,9 +41,11 @@ import org.springframework.mock.web.Mock
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
 import java.io.UnsupportedEncodingException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.logging.*;
@@ -199,6 +201,23 @@ public abstract class StrutsJUnit4TestCa
         pageContext = new MockPageContext(servletContext, request, response);
     }
 
+    public void finishExecution() {
+        HttpSession session = this.request.getSession();
+        Enumeration attributeNames = session.getAttributeNames();
+
+        MockHttpServletRequest nextRequest = new MockHttpServletRequest();
+
+        while (attributeNames.hasMoreElements()) {
+            String key = (String) attributeNames.nextElement();
+            Object attribute = session.getAttribute(key);
+            nextRequest.getSession().setAttribute(key, attribute);
+        }
+
+        this.response = new MockHttpServletResponse();
+        this.request = nextRequest;
+        this.pageContext = new MockPageContext(servletContext, request, response);
+    }
+
     /**
      * Sets up the configuration settings, XWork configuration, and
      * message resources



Mime
View raw message