diff --git a/core/pom.xml b/core/pom.xml
index 71b0ab67f..d562630fa 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -288,29 +288,20 @@
commons-fileupload
commons-fileupload
- 1.1.1
- true
+ 1.2.1
commons-io
commons-io
- 1.0
- true
+ 1.3.2
-
-
- commons-lang
- commons-lang
- 2.1
- true
-
-
+
org.springframework
spring-mock
2.0.8
- true
+ test
@@ -405,6 +396,7 @@
org.apache.struts
struts-annotations
1.0.3-20080216.121126-3
+ compile
true
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
index 54e82e3b7..a58b2cb0f 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
@@ -87,6 +87,7 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
try {
ServletFileUpload upload = new ServletFileUpload(fac);
upload.setSizeMax(maxSize);
+
List items = upload.parseRequest(createRequestContext(servletRequest));
for (Object item1 : items) {
@@ -298,6 +299,10 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
}
public InputStream getInputStream() throws IOException {
+ InputStream in = req.getInputStream();
+ if (in == null) {
+ throw new IOException("Missing content in the request");
+ }
return req.getInputStream();
}
};
diff --git a/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java b/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
index 4d62bea5e..ad86b6715 100644
--- a/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
+++ b/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
@@ -24,13 +24,14 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.struts2.dispatcher.Dispatcher;
-import org.springframework.mock.web.MockServletContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
+import javax.servlet.ServletContext;
+
/**
* Generic test setup methods to be used with any unit testing framework.
*/
@@ -44,11 +45,11 @@ public class StrutsTestCaseHelper {
LocalizedTextUtil.clearDefaultResourceBundles();
}
- public static Dispatcher initDispatcher(Map params) {
+ public static Dispatcher initDispatcher(ServletContext ctx, Map params) {
if (params == null) {
params = new HashMap();
}
- Dispatcher du = new Dispatcher(new MockServletContext(), params);
+ Dispatcher du = new Dispatcher(ctx, params);
du.init();
Dispatcher.setInstance(du);
diff --git a/core/src/test/java/org/apache/struts2/StrutsTestCase.java b/core/src/test/java/org/apache/struts2/StrutsTestCase.java
index c3583aa91..bb39d7534 100644
--- a/core/src/test/java/org/apache/struts2/StrutsTestCase.java
+++ b/core/src/test/java/org/apache/struts2/StrutsTestCase.java
@@ -32,6 +32,7 @@ import java.util.logging.SimpleFormatter;
import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.util.StrutsTestCaseHelper;
+import org.springframework.mock.web.MockServletContext;
import com.opensymphony.xwork2.XWorkTestCase;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
@@ -81,7 +82,7 @@ public abstract class StrutsTestCase extends XWorkTestCase {
}
protected Dispatcher initDispatcher(Map params) {
- Dispatcher du = StrutsTestCaseHelper.initDispatcher(params);
+ Dispatcher du = StrutsTestCaseHelper.initDispatcher(new MockServletContext(), params);
configurationManager = du.getConfigurationManager();
configuration = configurationManager.getConfiguration();
container = configuration.getContainer();
diff --git a/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java b/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
index 6a208edf4..1a2b806e1 100644
--- a/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
+++ b/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
@@ -32,6 +32,7 @@ import java.util.logging.SimpleFormatter;
import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.util.StrutsTestCaseHelper;
+import org.springframework.mock.web.MockServletContext;
import com.opensymphony.xwork2.XWorkTestCase;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
@@ -81,7 +82,7 @@ public abstract class StrutsTestCase extends XWorkTestCase {
}
protected Dispatcher initDispatcher(Map params) {
- Dispatcher du = StrutsTestCaseHelper.initDispatcher(params);
+ Dispatcher du = StrutsTestCaseHelper.initDispatcher(new MockServletContext(), params);
configurationManager = du.getConfigurationManager();
configuration = configurationManager.getConfiguration();
container = configuration.getContainer();
diff --git a/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java b/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java
index d75610bee..fdff514ba 100644
--- a/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java
+++ b/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java
@@ -26,6 +26,7 @@ import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.util.StrutsTestCaseHelper;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
+import org.springframework.mock.web.MockServletContext;
import com.opensymphony.xwork2.TestNGXWorkTestCase;
@@ -42,7 +43,7 @@ public class StrutsTestCase extends TestNGXWorkTestCase {
}
protected Dispatcher initDispatcher(Map params) {
- Dispatcher du = StrutsTestCaseHelper.initDispatcher(params);
+ Dispatcher du = StrutsTestCaseHelper.initDispatcher(new MockServletContext(), params);
configurationManager = du.getConfigurationManager();
configuration = configurationManager.getConfiguration();
container = configuration.getContainer();