You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2018/04/15 19:10:54 UTC

[struts] 07/08: Fixes test after upgrading to the latest Spring 4 version

This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch struts-2-4
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 6a225ca9d3e382dc5e7a29174db7a7591ac621bd
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Sun Apr 1 19:32:29 2018 +0200

    Fixes test after upgrading to the latest Spring 4 version
---
 core/pom.xml                                              | 15 ++++++++++++++-
 .../struts2/interceptor/FileUploadInterceptorTest.java    | 10 +++++-----
 pom.xml                                                   |  1 -
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/core/pom.xml b/core/pom.xml
index 84cca53..68341f1 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -207,7 +207,11 @@
             <artifactId>spring-test</artifactId>
             <scope>test</scope>
         </dependency>
-
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+            <scope>test</scope>
+        </dependency>
         <!-- Test dependencies -->
         <dependency>
             <groupId>junit</groupId>
@@ -276,6 +280,15 @@
             <scope>test</scope>
         </dependency>
 
+        <!-- The Servlet API mocks in Spring Framework 4.x only supports Servlet 3.0 and higher.
+             This is only necessary in tests-->
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>3.1.0</version>
+            <scope>test</scope>
+        </dependency>
+
         <!-- These jars have to be in the compile scope in order to work with apt plugin
              (struts-annotations) and javadoc (the rest to process xwork sources). Marking 
              them optional to exclude them from transitive dependency resolution -->
diff --git a/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
index acf045e..47ec711 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
@@ -213,18 +213,18 @@ public class FileUploadInterceptorTest extends StrutsInternalTestCase {
         MockHttpServletRequest req = new MockHttpServletRequest();
 
         req.setCharacterEncoding("text/html");
-        req.setContentType("multipart/form-data; boundary=---1234");
+        req.setMethod("post");
+        req.addHeader("Content-type", "multipart/form-data");
         req.setContent(null); // there is no content
 
-        MyFileupAction action = new MyFileupAction();
+        MyFileupAction action = container.inject(MyFileupAction.class);
         MockActionInvocation mai = new MockActionInvocation();
         mai.setAction(action);
         mai.setResultCode("success");
         mai.setInvocationContext(ActionContext.getContext());
 
-        Map param = new HashMap();
-        ActionContext.getContext().setParameters(param);
-        ActionContext.getContext().put(ServletActionContext.HTTP_REQUEST, createMultipartRequest((HttpServletRequest) req, 2000));
+        ActionContext.getContext().setParameters(HttpParameters.create().build());
+        ActionContext.getContext().put(ServletActionContext.HTTP_REQUEST, createMultipartRequest(req, 2000));
 
         interceptor.intercept(mai);
 
diff --git a/pom.xml b/pom.xml
index 3da99f4..a4254bf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -877,7 +877,6 @@
                 <groupId>org.testng</groupId>
                 <artifactId>testng</artifactId>
                 <version>5.14.10</version>
-                <scope>compile</scope>
                 <optional>true</optional>
             </dependency>
 

-- 
To stop receiving notification emails like this one, please contact
lukaszlenart@apache.org.