struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r577775 - in /struts/struts2/trunk/plugins: portlet/src/test/java/org/apache/struts2/portlet/dispatcher/ portlet/src/test/java/org/apache/struts2/portlet/interceptor/ portlet/src/test/java/org/apache/struts2/views/jsp/ struts1/ struts1/src/...
Date Thu, 20 Sep 2007 14:43:39 GMT
Author: mrdon
Date: Thu Sep 20 07:43:38 2007
New Revision: 577775

URL: http://svn.apache.org/viewvc?rev=577775&view=rev
Log:
Fixing tests
WW-1715

Modified:
    struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
    struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java
    struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
    struts/struts2/trunk/plugins/struts1/pom.xml
    struts/struts2/trunk/plugins/struts1/src/test/java/org/apache/struts2/s1/Struts1FactoryTest.java

Modified: struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java?rev=577775&r1=577774&r2=577775&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
(original)
+++ struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
Thu Sep 20 07:43:38 2007
@@ -44,6 +44,7 @@
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.dispatcher.mapper.ActionMapper;
 import org.apache.struts2.portlet.PortletActionConstants;
+import org.easymock.EasyMock;
 import org.jmock.Mock;
 import org.jmock.cglib.MockObjectTestCase;
 import org.jmock.core.Constraint;
@@ -133,7 +134,7 @@
 
         initPortletConfig(initParams, new HashMap());
         initRequest(requestParams, new HashMap(), sessionMap, new HashMap(), PortletMode.VIEW,
WindowState.NORMAL, false, null);
-        setupActionFactory("/view", "testAction", "success", ValueStackFactory.getFactory().createValueStack());
+        setupActionFactory("/view", "testAction", "success", EasyMock.createNiceMock(ValueStack.class));
 
         mockInvocation.expects(once()).method("getStack").will(
                 returnValue(null));
@@ -165,7 +166,7 @@
         initParams.put(StrutsConstants.STRUTS_ALWAYS_SELECT_FULL_NAMESPACE, "true");
         initPortletConfig(initParams, new HashMap());
         initRequest(requestParams, new HashMap(), new HashMap(), new HashMap(), PortletMode.VIEW,
WindowState.NORMAL, true, null);
-        setupActionFactory("/view", "testAction", "success", ValueStackFactory.getFactory().createValueStack());
+        setupActionFactory("/view", "testAction", "success", EasyMock.createNiceMock(ValueStack.class));
         //mockSession.expects(once()).method("setAttribute").with(new Constraint[]{eq(PortletActionConstants.LAST_MODE),
eq(PortletMode.VIEW)});
         try {
             dispatcher
@@ -266,7 +267,7 @@
 
         initPortletConfig(initParams, new HashMap());
         initRequest(requestParams, new HashMap(), sessionMap, new HashMap(), mode, WindowState.NORMAL,
false, null);
-        setupActionFactory("/edit", "default", "success", ValueStackFactory.getFactory().createValueStack());
+        setupActionFactory("/edit", "default", "success", EasyMock.createNiceMock(ValueStack.class));
 
         mockInvocation.expects(once()).method("getStack").will(
                 returnValue(null));

Modified: struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java?rev=577775&r1=577774&r2=577775&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java
(original)
+++ struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java
Thu Sep 20 07:43:38 2007
@@ -28,6 +28,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.struts2.StrutsTestCase;
 import org.apache.struts2.dispatcher.DefaultActionSupport;
 import org.apache.struts2.portlet.PortletActionConstants;
 import org.apache.struts2.portlet.dispatcher.DirectRenderFromEventAction;
@@ -38,11 +39,12 @@
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
 
-public class PortletStateInterceptorTest extends TestCase implements PortletActionConstants
{
+public class PortletStateInterceptorTest extends StrutsTestCase implements PortletActionConstants
{
 
 	private PortletStateInterceptor interceptor;
 	
 	public void setUp() throws Exception {
+	    super.setUp();
 		interceptor = new PortletStateInterceptor();
 	}
 	
@@ -60,7 +62,7 @@
 		EasyMock.expect(invocation.getInvocationContext()).andStubReturn(ctx);
 		actionResponse.setRenderParameter(EVENT_ACTION, "true");
 		
-		ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+		ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
 		EasyMock.expect(invocation.getStack()).andStubReturn(stack);
 		
 		EasyMock.replay(actionResponse);
@@ -79,10 +81,11 @@
 		RenderRequest renderRequest = EasyMock.createNiceMock(RenderRequest.class);
 		ActionInvocation invocation = EasyMock.createNiceMock(ActionInvocation.class);
 		
-		ValueStack eventPhaseStack = ValueStackFactory.getFactory().createValueStack();
+		
+		ValueStack eventPhaseStack = container.getInstance(ValueStackFactory.class).createValueStack();
 		eventPhaseStack.set("testKey", "testValue");
 		
-		ValueStack currentStack = ValueStackFactory.getFactory().createValueStack();
+		ValueStack currentStack = container.getInstance(ValueStackFactory.class).createValueStack();
 		currentStack.set("anotherTestKey", "anotherTestValue");
 		
 		Map<String, Object> ctxMap = new HashMap<String, Object>();
@@ -118,10 +121,10 @@
 		RenderRequest renderRequest = EasyMock.createNiceMock(RenderRequest.class);
 		ActionInvocation invocation = EasyMock.createNiceMock(ActionInvocation.class);
 		
-		ValueStack eventPhaseStack = ValueStackFactory.getFactory().createValueStack();
+		ValueStack eventPhaseStack = container.getInstance(ValueStackFactory.class).createValueStack();
 		eventPhaseStack.set("testKey", "testValue");
 		
-		ValueStack currentStack = ValueStackFactory.getFactory().createValueStack();
+		ValueStack currentStack = container.getInstance(ValueStackFactory.class).createValueStack();
 		currentStack.set("anotherTestKey", "anotherTestValue");
 		
 		EasyMock.expect(invocation.getStack()).andStubReturn(currentStack);

Modified: struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java?rev=577775&r1=577774&r2=577775&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
(original)
+++ struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
Thu Sep 20 07:43:38 2007
@@ -86,7 +86,10 @@
 
         mockPortletApiAvailable();
 
-        stack = ValueStackFactory.getFactory().createValueStack();
+        stack = du.getContainer().getInstance(ValueStackFactory.class).createValueStack();
+        stack.getContext().put(ActionContext.CONTAINER, du.getContainer());
+        ActionContext.setContext(new ActionContext(stack.getContext()));
+        
 
 
         mockHttpReq = mock(HttpServletRequest.class);

Modified: struts/struts2/trunk/plugins/struts1/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/struts1/pom.xml?rev=577775&r1=577774&r2=577775&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/struts1/pom.xml (original)
+++ struts/struts2/trunk/plugins/struts1/pom.xml Thu Sep 20 07:43:38 2007
@@ -53,5 +53,28 @@
             <version>0.09</version>
             <scope>test</scope>
         </dependency>
+
+        <!-- Mocks for unit testing (by Spring) -->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-mock</artifactId>
+            <version>1.2.8</version>
+            <optional>true</optional>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+            <version>1.2.8</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>jsp-api</artifactId>
+            <version>2.0</version>
+            <scope>provided</scope>
+        </dependency>
+
     </dependencies>
 </project>

Modified: struts/struts2/trunk/plugins/struts1/src/test/java/org/apache/struts2/s1/Struts1FactoryTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/struts1/src/test/java/org/apache/struts2/s1/Struts1FactoryTest.java?rev=577775&r1=577774&r2=577775&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/struts1/src/test/java/org/apache/struts2/s1/Struts1FactoryTest.java
(original)
+++ struts/struts2/trunk/plugins/struts1/src/test/java/org/apache/struts2/s1/Struts1FactoryTest.java
Thu Sep 20 07:43:38 2007
@@ -32,6 +32,7 @@
 import org.apache.struts.config.ExceptionConfig;
 import org.apache.struts.config.ForwardConfig;
 import org.apache.struts.config.ModuleConfig;
+import org.apache.struts2.StrutsTestCase;
 import org.apache.struts2.config.StrutsXmlConfigurationProvider;
 
 import com.opensymphony.xwork2.ActionSupport;
@@ -46,31 +47,21 @@
 /**
  * Test of Struts1Factory, which creates Struts 1.x wrappers around XWork config objects.
  */
-public class Struts1FactoryTest extends TestCase {
+public class Struts1FactoryTest extends StrutsTestCase {
 
     private static final String PACKAGE_NAME = "org/apache/struts2/s1";
     
     protected Struts1Factory factory = null;
-    protected Configuration config;
-
-    public Struts1FactoryTest(String name) throws Exception {
-        super(name);
-    }
-
-
-    public static void main(String args[]) {
-        junit.textui.TestRunner.run(Struts1FactoryTest.class);
-    }
 
     /**
      * Set up instance variables required by this test case.
+     * @throws Exception 
      */
-    public void setUp() {
-        ConfigurationManager manager = new ConfigurationManager();
-        StrutsXmlConfigurationProvider provider = new StrutsXmlConfigurationProvider(PACKAGE_NAME
+ "/test-struts-factory.xml", true, null);
-        manager.addConfigurationProvider(provider);
-        config = manager.getConfiguration();
-        factory = new Struts1Factory(config);
+    public void setUp() throws Exception {
+        super.setUp();
+        loadConfigurationProviders(new StrutsXmlConfigurationProvider(PACKAGE_NAME + "/test-struts-factory.xml",
true, null));
+        factory = new Struts1Factory(configuration);
+        
     }
 
     /**
@@ -121,7 +112,7 @@
      * The ActionConfig is loaded from test-struts-factory.xml.
      */
     public void testCreateActionMapping() {
-        PackageConfig packageConfig = config.getPackageConfig(PACKAGE_NAME);
+        PackageConfig packageConfig = configuration.getPackageConfig(PACKAGE_NAME);
         com.opensymphony.xwork2.config.entities.ActionConfig actionConfig =
                 (com.opensymphony.xwork2.config.entities.ActionConfig) packageConfig.getActionConfigs().get("action1");
         ActionMapping mapping = factory.createActionMapping(actionConfig);
@@ -179,7 +170,7 @@
      * The ResultConfig is loaded from test-struts-factory.xml.
      */
     public void testCreateActionForward() {
-        PackageConfig packageConfig = config.getPackageConfig(PACKAGE_NAME);
+        PackageConfig packageConfig = configuration.getPackageConfig(PACKAGE_NAME);
         ResultConfig resultConfig = (ResultConfig) packageConfig.getGlobalResultConfigs().get("globalResult");
         ActionForward fwd = factory.createActionForward(resultConfig);
         assertNotNull(fwd);
@@ -196,7 +187,7 @@
      * The ExceptionConfig is loaded from test-struts-factory.xml.
      */
     public void testCreateExceptionConfig() {
-        PackageConfig packageConfig = config.getPackageConfig(PACKAGE_NAME);
+        PackageConfig packageConfig = configuration.getPackageConfig(PACKAGE_NAME);
         ExceptionMappingConfig cfg = (ExceptionMappingConfig) packageConfig.getGlobalExceptionMappingConfigs().get(0);
         ExceptionConfig exceptionConfig = factory.createExceptionConfig(cfg);
         assertNotNull(exceptionConfig);



Mime
View raw message