Improves tests to reuse the same ServletContext
Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/924531c5 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/924531c5 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/924531c5 Branch: refs/heads/develop Commit: 924531c54400882d1781ba3067d7af63825850c3 Parents: 43e86d7 Author: Lukasz Lenart <lukaszlen...@apache.org> Authored: Thu Mar 13 20:20:25 2014 +0100 Committer: Lukasz Lenart <lukaszlen...@apache.org> Committed: Thu Mar 13 20:20:25 2014 +0100 ---------------------------------------------------------------------- .../java/org/apache/struts2/StrutsInternalTestCase.java | 9 ++++----- .../java/org/apache/struts2/views/jsp/AbstractTagTest.java | 4 +--- 2 files changed, 5 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/924531c5/core/src/test/java/org/apache/struts2/StrutsInternalTestCase.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/struts2/StrutsInternalTestCase.java b/core/src/test/java/org/apache/struts2/StrutsInternalTestCase.java index 0b9d1c4..6816481 100644 --- a/core/src/test/java/org/apache/struts2/StrutsInternalTestCase.java +++ b/core/src/test/java/org/apache/struts2/StrutsInternalTestCase.java @@ -21,15 +21,12 @@ package org.apache.struts2; -import com.opensymphony.xwork2.ActionProxyFactory; import com.opensymphony.xwork2.XWorkTestCase; -import com.opensymphony.xwork2.config.ConfigurationProvider; -import com.opensymphony.xwork2.util.XWorkTestCaseHelper; import com.opensymphony.xwork2.util.logging.LoggerFactory; import com.opensymphony.xwork2.util.logging.jdk.JdkLoggerFactory; import org.apache.struts2.dispatcher.Dispatcher; import org.apache.struts2.util.StrutsTestCaseHelper; -import org.springframework.mock.web.MockServletContext; +import org.apache.struts2.views.jsp.StrutsMockServletContext; import java.text.SimpleDateFormat; import java.util.Date; @@ -75,6 +72,7 @@ public abstract class StrutsInternalTestCase extends XWorkTestCase { LoggerFactory.setLoggerFactory(new JdkLoggerFactory()); } + protected StrutsMockServletContext servletContext; protected Dispatcher dispatcher; /** @@ -87,7 +85,8 @@ public abstract class StrutsInternalTestCase extends XWorkTestCase { } protected Dispatcher initDispatcher(Map<String,String> params) { - dispatcher = StrutsTestCaseHelper.initDispatcher(new MockServletContext(), params); + servletContext = new StrutsMockServletContext(); + dispatcher = StrutsTestCaseHelper.initDispatcher(servletContext, params); configurationManager = dispatcher.getConfigurationManager(); configuration = configurationManager.getConfiguration(); container = configuration.getContainer(); http://git-wip-us.apache.org/repos/asf/struts/blob/924531c5/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java index 36b04fa..60eb170 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java @@ -61,7 +61,6 @@ public abstract class AbstractTagTest extends StrutsInternalTestCase { protected StrutsMockHttpServletRequest request; protected StrutsMockPageContext pageContext; protected HttpServletResponse response; - protected StrutsMockServletContext servletContext; protected Mock mockContainer; @@ -83,7 +82,7 @@ public abstract class AbstractTagTest extends StrutsInternalTestCase { createMocks(); } - protected void createMocks() { + protected void createMocks() throws Exception { action = this.getAction(); stack = ActionContext.getContext().getValueStack(); context = stack.getContext(); @@ -99,7 +98,6 @@ public abstract class AbstractTagTest extends StrutsInternalTestCase { JspWriter jspWriter = new StrutsMockJspWriter(writer); - servletContext = new StrutsMockServletContext(); servletContext.setRealPath(new File("nosuchfile.properties").getAbsolutePath()); servletContext.setServletInfo("Resin");