Author: grobmeier
Date: Wed Mar 20 08:17:33 2013
New Revision: 1458681

URL: http://svn.apache.org/r1458681
Log:
added example on how to use the convention plugin in conjunction with the junit 
plugin

Added:
    struts/struts2/trunk/plugins/junit/src/test/java/actions/
    struts/struts2/trunk/plugins/junit/src/test/java/actions/ViewAction.java   
(with props)
    
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/convention/
    
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java
   (with props)
    
struts/struts2/trunk/plugins/junit/src/test/resources/struts-convention-configuration.xml
   (with props)
    struts/struts2/trunk/plugins/junit/src/test/resources/view-success.jsp   
(with props)
Modified:
    struts/struts2/trunk/plugins/junit/pom.xml

Modified: struts/struts2/trunk/plugins/junit/pom.xml
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/pom.xml?rev=1458681&r1=1458680&r2=1458681&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/junit/pom.xml (original)
+++ struts/struts2/trunk/plugins/junit/pom.xml Wed Mar 20 08:17:33 2013
@@ -66,6 +66,14 @@
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
+
+        <!-- Convention Plugin tests -->
+        <dependency>
+            <groupId>org.apache.struts</groupId>
+            <artifactId>struts2-convention-plugin</artifactId>
+            <scope>test</scope>
+        </dependency>
+
         <!-- Portlet -->
         <dependency>
             <groupId>javax.portlet</groupId>

Added: struts/struts2/trunk/plugins/junit/src/test/java/actions/ViewAction.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/test/java/actions/ViewAction.java?rev=1458681&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/junit/src/test/java/actions/ViewAction.java 
(added)
+++ struts/struts2/trunk/plugins/junit/src/test/java/actions/ViewAction.java 
Wed Mar 20 08:17:33 2013
@@ -0,0 +1,42 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package actions;
+
+import com.opensymphony.xwork2.ActionSupport;
+import org.apache.struts2.convention.annotation.Action;
+import org.apache.struts2.convention.annotation.Result;
+
+/**
+ * Example action, which is called by the convention plugin test case
+ */
+public class ViewAction extends ActionSupport {
+    private String message;
+
+    public String getMessage() {
+        return message;
+    }
+
+
+    public String execute() {
+        message = "Hello World";
+        return SUCCESS;
+    }
+}

Propchange: 
struts/struts2/trunk/plugins/junit/src/test/java/actions/ViewAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
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=1458681&view=auto
==============================================================================
--- 
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java
 (added)
+++ 
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java
 Wed Mar 20 08:17:33 2013
@@ -0,0 +1,46 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.convention;
+
+import actions.ViewAction;
+import org.apache.struts2.StrutsJUnit4TestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Uses the convention plugin to execute actions
+ */
+public class StrutsJUnit4ConventionTestCaseTest extends 
StrutsJUnit4TestCase<ViewAction>{
+    @Test
+    public void testConventionUrl() throws Exception {
+        // TODO: Currently output is empty
+        String output = executeAction("/view.action");
+
+        ViewAction action = this.getAction();
+        Assert.assertEquals("Hello World", action.getMessage());
+    }
+
+    @Override
+    protected String getConfigPath() {
+        return "struts-convention-configuration.xml";
+    }
+}
+

Propchange: 
struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
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=1458681&view=auto
==============================================================================
--- 
struts/struts2/trunk/plugins/junit/src/test/resources/struts-convention-configuration.xml
 (added)
+++ 
struts/struts2/trunk/plugins/junit/src/test/resources/struts-convention-configuration.xml
 Wed Mar 20 08:17:33 2013
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+-->
+
+<!DOCTYPE struts PUBLIC
+       "-//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" />
+
+  <constant name="struts.convention.classes.reload" value="false" />
+
+  <constant name="struts.convention.exclude.parentClassLoader" value="true" />
+
+  <package name="convention-default" extends="struts-default">
+  </package>
+</struts>

Propchange: 
struts/struts2/trunk/plugins/junit/src/test/resources/struts-convention-configuration.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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.jsp?rev=1458681&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/junit/src/test/resources/view-success.jsp 
(added)
+++ struts/struts2/trunk/plugins/junit/src/test/resources/view-success.jsp Wed 
Mar 20 08:17:33 2013
@@ -0,0 +1,25 @@
+<%--
+  ~ $Id$
+  ~
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~  http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  --%>
+<html>
+<body>
+This is the view
+</body>
+</html>
\ No newline at end of file

Propchange: 
struts/struts2/trunk/plugins/junit/src/test/resources/view-success.jsp
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to