From 58f3b578e7e42a38630fe080f77e9de748c8b084 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 12 Jun 2013 06:48:53 +0000 Subject: [PATCH] Simplifies example a bit and uses FreeMarker template to check response git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1492077 13f79535-47bb-0310-9956-ffa450edef68 --- .../StrutsJUnit4ConventionTestCaseTest.java | 19 +++++-- .../struts-convention-configuration.xml | 49 +++---------------- .../{view-success.jsp => view-success.ftl} | 2 +- 3 files changed, 23 insertions(+), 47 deletions(-) rename plugins/junit/src/test/resources/{view-success.jsp => view-success.ftl} (96%) diff --git a/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java b/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java index f2c96ea21..a81d79768 100644 --- a/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java +++ b/plugins/junit/src/test/java/org/apache/struts2/convention/StrutsJUnit4ConventionTestCaseTest.java @@ -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{ +public class StrutsJUnit4ConventionTestCaseTest extends StrutsJUnit4TestCase { + @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"; } + } diff --git a/plugins/junit/src/test/resources/struts-convention-configuration.xml b/plugins/junit/src/test/resources/struts-convention-configuration.xml index 3495c184a..77525f084 100644 --- a/plugins/junit/src/test/resources/struts-convention-configuration.xml +++ b/plugins/junit/src/test/resources/struts-convention-configuration.xml @@ -23,51 +23,18 @@ --> + "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" + "http://struts.apache.org/dtds/struts-2.3.dtd"> - - - - - - + + - - + + - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/junit/src/test/resources/view-success.jsp b/plugins/junit/src/test/resources/view-success.ftl similarity index 96% rename from plugins/junit/src/test/resources/view-success.jsp rename to plugins/junit/src/test/resources/view-success.ftl index b2cd0da7f..22c9ce66e 100644 --- a/plugins/junit/src/test/resources/view-success.jsp +++ b/plugins/junit/src/test/resources/view-success.ftl @@ -20,6 +20,6 @@ --%> -This is the view +This is the view ${message} \ No newline at end of file