mirror of
https://github.com/apache/struts.git
synced 2026-08-06 07:06:58 +00:00
* Upgrading commons-fileupload to 1.2.1, now required
* Cleaning up testing so spring's mocks are not in the compile scope WW-2590 WW-2588 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@647434 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+5
-13
@@ -288,29 +288,20 @@
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<optional>true</optional>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.1</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Mocks for unit testing (by Spring) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-mock</artifactId>
|
||||
<version>2.0.8</version>
|
||||
<optional>true</optional>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -405,6 +396,7 @@
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts-annotations</artifactId>
|
||||
<version>1.0.3-20080216.121126-3</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
+5
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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<String,String> params) {
|
||||
public static Dispatcher initDispatcher(ServletContext ctx, Map<String,String> params) {
|
||||
if (params == null) {
|
||||
params = new HashMap<String,String>();
|
||||
}
|
||||
Dispatcher du = new Dispatcher(new MockServletContext(), params);
|
||||
Dispatcher du = new Dispatcher(ctx, params);
|
||||
du.init();
|
||||
Dispatcher.setInstance(du);
|
||||
|
||||
|
||||
@@ -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<String,String> params) {
|
||||
Dispatcher du = StrutsTestCaseHelper.initDispatcher(params);
|
||||
Dispatcher du = StrutsTestCaseHelper.initDispatcher(new MockServletContext(), params);
|
||||
configurationManager = du.getConfigurationManager();
|
||||
configuration = configurationManager.getConfiguration();
|
||||
container = configuration.getContainer();
|
||||
|
||||
@@ -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<String,String> params) {
|
||||
Dispatcher du = StrutsTestCaseHelper.initDispatcher(params);
|
||||
Dispatcher du = StrutsTestCaseHelper.initDispatcher(new MockServletContext(), params);
|
||||
configurationManager = du.getConfigurationManager();
|
||||
configuration = configurationManager.getConfiguration();
|
||||
container = configuration.getContainer();
|
||||
|
||||
@@ -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<String,String> params) {
|
||||
Dispatcher du = StrutsTestCaseHelper.initDispatcher(params);
|
||||
Dispatcher du = StrutsTestCaseHelper.initDispatcher(new MockServletContext(), params);
|
||||
configurationManager = du.getConfigurationManager();
|
||||
configuration = configurationManager.getConfiguration();
|
||||
container = configuration.getContainer();
|
||||
|
||||
Reference in New Issue
Block a user