This is an automated email from the ASF dual-hosted git repository. kusal pushed a commit to branch WW-5334-move-convention-test in repository https://gitbox.apache.org/repos/asf/struts.git
commit dc43c891da38f219835ed7b77b3eb0d19a1f5c78 Author: Kusal Kithul-Godage <g...@kusal.io> AuthorDate: Sun Aug 20 22:19:28 2023 +1000 WW-5334 Extract ConventionJUnit4Test into correct module --- plugins/convention/pom.xml | 15 +++++++++++++++ .../src/test/java/actions/MessageAction.java} | 5 +++-- .../apache/struts2/convention/ConventionJUnit4Test.java} | 11 +++++------ .../src/test/resources/message-success.ftl} | 0 .../test/resources/struts-convention-configuration.xml | 9 +-------- plugins/junit/pom.xml | 14 -------------- pom.xml | 5 +++++ 7 files changed, 29 insertions(+), 30 deletions(-) diff --git a/plugins/convention/pom.xml b/plugins/convention/pom.xml index 8c366cb64..35f4a63a5 100644 --- a/plugins/convention/pom.xml +++ b/plugins/convention/pom.xml @@ -59,11 +59,26 @@ </dependency> <!-- testing --> + <dependency> + <groupId>org.apache.struts</groupId> + <artifactId>struts2-junit-plugin</artifactId> + <scope>test</scope> + </dependency> <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-compress</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <scope>test</scope> + </dependency> </dependencies> <properties> diff --git a/plugins/junit/src/test/java/actions/ViewAction.java b/plugins/convention/src/test/java/actions/MessageAction.java similarity index 85% rename from plugins/junit/src/test/java/actions/ViewAction.java rename to plugins/convention/src/test/java/actions/MessageAction.java index 30635a184..2482fdbc8 100644 --- a/plugins/junit/src/test/java/actions/ViewAction.java +++ b/plugins/convention/src/test/java/actions/MessageAction.java @@ -21,9 +21,10 @@ package actions; import com.opensymphony.xwork2.ActionSupport; /** - * Example action, which is called by the convention plugin test case + * Example action, called by {@link org.apache.struts2.convention.ConventionJUnit4Test}. + * Result defined by message-success.ftl. */ -public class ViewAction extends ActionSupport { +public class MessageAction extends ActionSupport { private String message; public String getMessage() { diff --git a/plugins/junit/src/test/java/org/apache/struts2/junit/convention/StrutsJUnit4ConventionTestCaseTest.java b/plugins/convention/src/test/java/org/apache/struts2/convention/ConventionJUnit4Test.java similarity index 86% rename from plugins/junit/src/test/java/org/apache/struts2/junit/convention/StrutsJUnit4ConventionTestCaseTest.java rename to plugins/convention/src/test/java/org/apache/struts2/convention/ConventionJUnit4Test.java index 6a6351ef7..5c97c9312 100644 --- a/plugins/junit/src/test/java/org/apache/struts2/junit/convention/StrutsJUnit4ConventionTestCaseTest.java +++ b/plugins/convention/src/test/java/org/apache/struts2/convention/ConventionJUnit4Test.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.struts2.junit.convention; +package org.apache.struts2.convention; -import actions.ViewAction; +import actions.MessageAction; import org.apache.struts2.junit.StrutsJUnit4TestCase; import org.junit.Test; @@ -28,17 +28,17 @@ import static org.junit.Assert.assertTrue; /** * Uses the convention plugin to execute actions */ -public class StrutsJUnit4ConventionTestCaseTest extends StrutsJUnit4TestCase<ViewAction> { +public class ConventionJUnit4Test extends StrutsJUnit4TestCase<MessageAction> { @Test public void testConventionUrl() throws Exception { // Output is filled out only for FreeMarker and Velocity templates // If you wanna use JSP check response.getForwardedUrl() - String output = executeAction("/view.action"); + String output = executeAction("/message.action"); assertTrue(output.contains("This is the view Hello World")); - ViewAction action = this.getAction(); + MessageAction action = this.getAction(); assertEquals("Hello World", action.getMessage()); } @@ -48,6 +48,5 @@ public class StrutsJUnit4ConventionTestCaseTest extends StrutsJUnit4TestCase<Vie // struts-convention-configuration.xml overrides some settings from plugin to allow work in limited environment return "struts-plugin.xml,struts-convention-configuration.xml"; } - } diff --git a/plugins/junit/src/test/resources/view-success.ftl b/plugins/convention/src/test/resources/message-success.ftl similarity index 100% rename from plugins/junit/src/test/resources/view-success.ftl rename to plugins/convention/src/test/resources/message-success.ftl diff --git a/plugins/junit/src/test/resources/struts-convention-configuration.xml b/plugins/convention/src/test/resources/struts-convention-configuration.xml similarity index 80% rename from plugins/junit/src/test/resources/struts-convention-configuration.xml rename to plugins/convention/src/test/resources/struts-convention-configuration.xml index 1c3768b63..2c760ace2 100644 --- a/plugins/junit/src/test/resources/struts-convention-configuration.xml +++ b/plugins/convention/src/test/resources/struts-convention-configuration.xml @@ -25,14 +25,7 @@ "https://struts.apache.org/dtds/struts-6.0.dtd"> <struts> - - <!-- result is defined in test/resources --> <constant name="struts.convention.result.path" value="/"/> - <!-- This is needed as there is struts2-spring-plugin on classpath --> - <constant name="struts.objectFactory" value="struts"/> - - <package name="convention-default" extends="struts-default"> - </package> - + <package name="convention-default" extends="struts-default"/> </struts> diff --git a/plugins/junit/pom.xml b/plugins/junit/pom.xml index 8b4c99436..0fae24db4 100644 --- a/plugins/junit/pom.xml +++ b/plugins/junit/pom.xml @@ -53,20 +53,6 @@ <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> - - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-compress</artifactId> - <version>1.23.0</version> - <scope>test</scope> - </dependency> </dependencies> <properties> diff --git a/pom.xml b/pom.xml index e650eb27f..59f57395f 100644 --- a/pom.xml +++ b/pom.xml @@ -1041,6 +1041,11 @@ <artifactId>log4j-slf4j-impl</artifactId> <version>${log4j2.version}</version> </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-compress</artifactId> + <version>1.23.0</version> + </dependency> <dependency> <groupId>org.testng</groupId>