struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1492077 - in /struts/struts2/trunk/plugins/junit/src/test: java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java resources/struts-convention-configuration.xml resources/view-success.ftl resources/view-success.jsp
Date Wed, 12 Jun 2013 06:48:54 GMT
Author: lukaszlenart
Date: Wed Jun 12 06:48:53 2013
New Revision: 1492077

URL: http://svn.apache.org/r1492077
Log:
Simplifies example a bit and uses FreeMarker template to check response

Added:
    struts/struts2/trunk/plugins/junit/src/test/resources/view-success.ftl
      - copied, changed from r1490143, struts/struts2/trunk/plugins/junit/src/test/resources/view-success.jsp
Removed:
    struts/struts2/trunk/plugins/junit/src/test/resources/view-success.jsp
Modified:
    struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java
    struts/struts2/trunk/plugins/junit/src/test/resources/struts-convention-configuration.xml

Modified: struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java?rev=1492077&r1=1492076&r2=1492077&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java
(original)
+++ struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java
Wed Jun 12 06:48:53 2013
@@ -22,25 +22,34 @@ package org.apache.struts2.convention;
 
 import actions.ViewAction;
 import org.apache.struts2.StrutsJUnit4TestCase;
-import org.junit.Assert;
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 /**
  * Uses the convention plugin to execute actions
  */
-public class StrutsJUnit4ConventionTestCaseTest extends StrutsJUnit4TestCase<ViewAction>{
+public class StrutsJUnit4ConventionTestCaseTest extends StrutsJUnit4TestCase<ViewAction>
{
+
     @Test
     public void testConventionUrl() throws Exception {
-        // TODO: Currently output is empty
+        // Output is filled out only for FreeMarker and Velocity templates
+        // If you wanna use JSP check response.getForwardedUrl()
         String output = executeAction("/view.action");
 
+        assertTrue(output.contains("This is the view Hello World"));
+
         ViewAction action = this.getAction();
-        Assert.assertEquals("Hello World", action.getMessage());
+        assertEquals("Hello World", action.getMessage());
     }
 
     @Override
     protected String getConfigPath() {
-        return "struts-convention-configuration.xml";
+        // struts-plugin.xml will load configuration from the Convention and Spring plugin
+        // struts-convention-configuration.xml overrides some settings from plugin to allow
work in limited environment
+        return "struts-plugin.xml,struts-convention-configuration.xml";
     }
+
 }
 

Modified: struts/struts2/trunk/plugins/junit/src/test/resources/struts-convention-configuration.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/test/resources/struts-convention-configuration.xml?rev=1492077&r1=1492076&r2=1492077&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/junit/src/test/resources/struts-convention-configuration.xml
(original)
+++ struts/struts2/trunk/plugins/junit/src/test/resources/struts-convention-configuration.xml
Wed Jun 12 06:48:53 2013
@@ -23,51 +23,18 @@
 -->
 
 <!DOCTYPE struts PUBLIC
-	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
-	"http://struts.apache.org/dtds/struts-2.3.dtd">
+        "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
+        "http://struts.apache.org/dtds/struts-2.3.dtd">
 
 <struts>
-  <bean type="com.opensymphony.xwork2.UnknownHandler" name="convention" class="org.apache.struts2.convention.ConventionUnknownHandler"/>
 
-  <bean type="org.apache.struts2.convention.ActionConfigBuilder" name="convention" class="org.apache.struts2.convention.PackageBasedActionConfigBuilder"/>
-  <bean type="org.apache.struts2.convention.ActionNameBuilder" name="convention" class="org.apache.struts2.convention.SEOActionNameBuilder"/>
-  <bean type="org.apache.struts2.convention.ResultMapBuilder" name="convention" class="org.apache.struts2.convention.DefaultResultMapBuilder"/>
-  <bean type="org.apache.struts2.convention.InterceptorMapBuilder" name="convention" class="org.apache.struts2.convention.DefaultInterceptorMapBuilder"/>
-  <bean type="org.apache.struts2.convention.ConventionsService" name="convention" class="org.apache.struts2.convention.ConventionsServiceImpl"/>
-
-  <bean type="com.opensymphony.xwork2.config.PackageProvider" name="convention.packageProvider"
class="org.apache.struts2.convention.ClasspathPackageProvider"/>
-  <bean type="com.opensymphony.xwork2.config.PackageProvider" name="convention.containerProvider"
class="org.apache.struts2.convention.ClasspathConfigurationProvider"/>
-
-  <constant name="struts.convention.actionConfigBuilder" value="convention"/>
-  <constant name="struts.convention.actionNameBuilder" value="convention"/>
-  <constant name="struts.convention.resultMapBuilder" value="convention"/>
-  <constant name="struts.convention.interceptorMapBuilder" value="convention"/>
-  <constant name="struts.convention.conventionsService" value="convention"/>
-
-  <constant name="struts.convention.result.path" value="/"/>
-  <constant name="struts.convention.result.flatLayout" value="true"/>
-  <constant name="struts.convention.action.suffix" value="Action"/>
-  <constant name="struts.convention.action.disableScanning" value="false"/>
-  <constant name="struts.convention.action.mapAllMatches" value="false"/>
-  <constant name="struts.convention.action.checkImplementsAction" value="true"/>
-  <constant name="struts.convention.default.parent.package" value="convention-default"/>
-  <constant name="struts.convention.action.name.lowercase" value="true"/>
-  <constant name="struts.convention.action.name.separator" value="-"/>
-  <constant name="struts.convention.package.locators" value="action,actions,struts,struts2"/>
-  <constant name="struts.convention.package.locators.disable" value="false"/>
-  <constant name="struts.convention.package.locators.basePackage" value=""/>
-  <constant name="struts.convention.exclude.packages" value="org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.*"/>
-  <constant name="struts.convention.relative.result.types" value="dispatcher,velocity,freemarker"/>
-  <constant name="struts.convention.redirect.to.slash" value="true"/>
-  <constant name="struts.convention.action.alwaysMapExecute" value="true"/>
-  <constant name="struts.mapper.alwaysSelectFullNamespace" value="true"/>
-  <!-- <constant name="struts.convention.action.includeJars"  /> -->
-  <constant name="struts.convention.action.fileProtocols" value="jar" />
+    <!-- result is defined in test/resources -->
+    <constant name="struts.convention.result.path" value="/"/>
 
-  <constant name="struts.convention.classes.reload" value="false" />
+    <!-- This is needed as there is struts2-spring-plugin on classpath -->
+    <constant name="struts.objectFactory" value="struts"/>
 
-  <constant name="struts.convention.exclude.parentClassLoader" value="true" />
+    <package name="convention-default" extends="struts-default">
+    </package>
 
-  <package name="convention-default" extends="struts-default">
-  </package>
 </struts>

Copied: struts/struts2/trunk/plugins/junit/src/test/resources/view-success.ftl (from r1490143,
struts/struts2/trunk/plugins/junit/src/test/resources/view-success.jsp)
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/test/resources/view-success.ftl?p2=struts/struts2/trunk/plugins/junit/src/test/resources/view-success.ftl&p1=struts/struts2/trunk/plugins/junit/src/test/resources/view-success.jsp&r1=1490143&r2=1492077&rev=1492077&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/junit/src/test/resources/view-success.jsp (original)
+++ struts/struts2/trunk/plugins/junit/src/test/resources/view-success.ftl Wed Jun 12 06:48:53
2013
@@ -20,6 +20,6 @@
   --%>
 <html>
 <body>
-This is the view
+This is the view ${message}
 </body>
 </html>
\ No newline at end of file



Mime
View raw message