jvanzyl 02/01/18 07:53:43
Modified: src/java/org/apache/turbine/pipeline DefaultActionValve.java
DefaultTargetValve.java DirectTargetValve.java
src/rttest/org/apache/turbine TurbineServletTest.java
src/rttest/testapp/templates/app/layouts Default.vm
src/rttest/testapp/templates/app/navigations
DefaultBottom.vm
src/rttest/testapp/templates/app/screens Error.vm Index.vm
Log:
- committing patches submitted by Jeff Brekke for the testbed so that
it actually looks at the results :-)
- fixes to the pipeline submitted by James Taylor
Revision Changes Path
1.4 +3 -3
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultActionValve.java
Index: DefaultActionValve.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultActionValve.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultActionValve.java 18 Jan 2002 03:33:58 -0000 1.3
+++ DefaultActionValve.java 18 Jan 2002 15:53:42 -0000 1.4
@@ -82,7 +82,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
- * @version $Id: DefaultActionValve.java,v 1.3 2002/01/18 03:33:58 jvanzyl Exp $
+ * @version $Id: DefaultActionValve.java,v 1.4 2002/01/18 15:53:42 jvanzyl Exp $
*/
public class DefaultActionValve
implements Valve, TurbineConstants
@@ -208,7 +208,7 @@
}
Action action =
- (Action) Turbine.getResolver().getModule( ACTION, data.getAction()
);
+ (Action) Turbine.getResolver().getModule( ACTIONS, data.getAction()
);
action.execute(data);
data.setAction(null);
}
@@ -259,7 +259,7 @@
if (data.hasAction())
{
Turbine.getResolver()
- .getModule( ACTION, data.getAction() ).execute( data );
+ .getModule( ACTIONS, data.getAction() ).execute( data );
}
}
1.6 +4 -2
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultTargetValve.java
Index: DefaultTargetValve.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultTargetValve.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultTargetValve.java 18 Jan 2002 03:33:58 -0000 1.5
+++ DefaultTargetValve.java 18 Jan 2002 15:53:42 -0000 1.6
@@ -81,7 +81,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
* @author <a href="mailto:[EMAIL PROTECTED]">James Taylor</a>
- * @version $Id: DefaultTargetValve.java,v 1.5 2002/01/18 03:33:58 jvanzyl Exp $
+ * @version $Id: DefaultTargetValve.java,v 1.6 2002/01/18 15:53:42 jvanzyl Exp $
*/
public class DefaultTargetValve
implements Valve
@@ -151,6 +151,8 @@
TemplateContext context = Module.getTemplateContext( data );
+ context.put( "template", target );
+
// Resolve the layout template for this target
String layout = Turbine.getResolver().getTemplate("layouts", target);
@@ -173,7 +175,6 @@
// FIXME: Can we remove some hardcoding here?
context.put("renderer", r);
- context.put("template", target);
// Render the target
@@ -212,3 +213,4 @@
}
}
}
+
1.3 +2 -2
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DirectTargetValve.java
Index: DirectTargetValve.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DirectTargetValve.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DirectTargetValve.java 18 Jan 2002 03:33:58 -0000 1.2
+++ DirectTargetValve.java 18 Jan 2002 15:53:42 -0000 1.3
@@ -70,7 +70,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">John McNally</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @author <a href="mailto:[EMAIL PROTECTED]">James Taylor</a>
- * @version $Id: DirectTargetValve.java,v 1.2 2002/01/18 03:33:58 jvanzyl Exp $
+ * @version $Id: DirectTargetValve.java,v 1.3 2002/01/18 15:53:42 jvanzyl Exp $
* @see org.apache.turbine.pipeline.ClassicPipeline
*/
public class DirectTargetValve
@@ -98,10 +98,10 @@
// FIXME: Can we remove some hardcoding here?
context.put("renderer", r);
- context.put("template", target);
// Render the target directly to the response
r.render( data, target );
}
}
+
1.3 +134 -30
jakarta-turbine-3/src/rttest/org/apache/turbine/TurbineServletTest.java
Index: TurbineServletTest.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/rttest/org/apache/turbine/TurbineServletTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TurbineServletTest.java 17 Jan 2002 20:38:28 -0000 1.2
+++ TurbineServletTest.java 18 Jan 2002 15:53:42 -0000 1.3
@@ -1,10 +1,63 @@
package org.apache.turbine;
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache Turbine", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import com.meterware.httpunit.WebForm;
import com.meterware.httpunit.WebTable;
import com.meterware.httpunit.WebResponse;
@@ -18,9 +71,9 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jeff Brekke</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: TurbineServletTest.java,v 1.2 2002/01/17 20:38:28 jvanzyl Exp $
+ * @version $Id: TurbineServletTest.java,v 1.3 2002/01/18 15:53:42 jvanzyl Exp $
*/
-public class TurbineServletTest
+public class TurbineServletTest
extends ServletTestCase
{
/**
@@ -29,66 +82,117 @@
Turbine turbine;
/**
- * Port to use for testing.
- */
- String testPort;
-
- /**
* Default Constructor.
*/
public TurbineServletTest(String name)
{
super(name);
}
-
- public static Test suite()
+
+ /**
+ * Default test suite for this test case.
+ */
+ public static Test suite()
{
- // All methods starting with "test" will be executed in the test suite.
return new TestSuite(TurbineServletTest.class);
}
- protected void setUp()
+ /**
+ * This setup will be running server side. We startup Turbine and
+ * get our test port from the properties. This gets run before
+ * each testXXX test.
+ */
+ protected void setUp()
throws Exception
{
super.setUp();
config.setInitParameter("properties",
"/WEB-INF/conf/TurbineResources.properties");
- testPort = System.getProperty("test.port");
turbine = new Turbine();
turbine.init(config);
}
- protected void tearDown()
+ /**
+ * After each testXXX test runs, shut down the Turbine servlet.
+ */
+ protected void tearDown()
throws Exception
{
turbine.destroy();
super.tearDown();
}
- public void beginGet(WebRequest theRequest)
+ /**
+ * This begin runs client side before the testHompage test runs.
+ * We'll set up our simualated url here.
+ */
+ public void beginHomepage(WebRequest theRequest)
{
- theRequest.setURL("localhost:"+testPort, "/test", "/servlet/test",null,
null);
+ theRequest.setURL(null, "/test", "/servlet/test", null, null);
}
-
- public void testGet()
+
+ /**
+ * Run our actual test. Here we just call the doGet on the
+ * servlet.
+ */
+ public void testHomepage()
throws Exception
{
turbine.doGet(request, response);
}
- public void endGet(WebResponse theResponse)
+ /**
+ * Check the response from our test using HttpUnit.
+ */
+ public void endHomepage(WebResponse theResponse)
throws Exception
{
- System.out.println("Checking the response!");
- /*
- WebTable table = theResponse.getTables()[0];
+ // Verify the Title
+ assertEquals(theResponse.getTitle(), "Test Application");
+
+ // Verify the layout
+ WebTable table = theResponse.getTableWithID("layout");
assertEquals("rows", 3, table.getRowCount());
- assertEquals("columns", 2, table.getColumnCount());
- assertEquals(theResponse.getTitle(), "Please Login");
- WebForm form = theResponse.getForms()[0];
- String[] paramNames = form.getParameterNames();
- assertEquals("parameters", 2, paramNames.length);
- assertEquals("username", paramNames[0]);
- assertEquals("password", paramNames[1]);
- */
+ assertEquals("columns", 1, table.getColumnCount());
+
+ assertEquals("Turbine Test App",
table.getTableCellWithID("topNav").asText().trim());
+ assertEquals("Powered By Turbine!",
table.getTableCellWithID("bottomNav").asText().trim());
+ assertEquals("Please stand by, This is only a test.",
table.getTableCellWithID("screen").asText().trim());
+ }
+
+ /**
+ * Setup our request url to attempt to load a bogus action
+ * which will cause Turbine to render the Error.vm.
+ */
+ public void beginErrorTemplate(WebRequest theRequest)
+ {
+ theRequest.setURL(null, "/test", "/servlet/test", "/action/NoSuchAction",
null);
+ }
+
+ /**
+ * Call the doGet on the servlet
+ */
+ public void testErrorTemplate()
+ throws Exception
+ {
+ turbine.doGet(request, response);
+ }
+
+ /**
+ * Check our response with HttpUnit. This will be the Error.vm
+ * template with our exception.
+ */
+ public void endErrorTemplate(WebResponse theResponse)
+ throws Exception
+ {
+ // Verify the Title
+ assertEquals(theResponse.getTitle(), "Test Application");
+
+ // Verify the layout
+ WebTable table = theResponse.getTableWithID("error");
+ assertEquals("rows", 2, table.getRowCount());
+ assertEquals("columns", 1, table.getColumnCount());
+
+ assertEquals("Error", table.getCellAsText(0, 0).trim());
+ assertTrue("No exception or stack trace?", table.getCellAsText(1,
0).trim().length() > 0);
}
}
1.2 +5 -5
jakarta-turbine-3/src/rttest/testapp/templates/app/layouts/Default.vm
Index: Default.vm
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/rttest/testapp/templates/app/layouts/Default.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Default.vm 17 Jan 2002 16:47:23 -0000 1.1
+++ Default.vm 18 Jan 2002 15:53:42 -0000 1.2
@@ -3,23 +3,23 @@
<html>
<head>
- <title>$page.Title</title>
+ <title>Test Application</title>
</head>
<body bgcolor="#ffffff">
-<table width="100%">
+<table id=layout width="100%">
<tr>
- <td colspan="2">
+ <td id=topNav>
$renderer.render("navigations", $data, "/DefaultTop.vm")
</td>
</tr>
<tr>
- <td align="left" valign="top">
+ <td align="left" valign="top" id=screen>
$renderer.render("screens", $data, $template)
</td>
</tr>
<tr>
- <td colspan="2">
+ <td id=bottomNav>
$renderer.render("navigations", $data, "/DefaultBottom.vm")
</td>
</tr>
1.2 +1 -2
jakarta-turbine-3/src/rttest/testapp/templates/app/navigations/DefaultBottom.vm
Index: DefaultBottom.vm
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/rttest/testapp/templates/app/navigations/DefaultBottom.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultBottom.vm 17 Jan 2002 16:47:24 -0000 1.1
+++ DefaultBottom.vm 18 Jan 2002 15:53:42 -0000 1.2
@@ -1,5 +1,4 @@
<font face="verdana,geneva,helvetica">
-
<hr>
-
+Powered By Turbine!
</font>
1.2 +12 -16
jakarta-turbine-3/src/rttest/testapp/templates/app/screens/Error.vm
Index: Error.vm
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/rttest/testapp/templates/app/screens/Error.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Error.vm 17 Jan 2002 16:47:24 -0000 1.1
+++ Error.vm 18 Jan 2002 15:53:43 -0000 1.2
@@ -1,18 +1,14 @@
-$page.setTitle("Error")
-
-$page.setBgColor("#ffffff")
-
<font face="verdana,geneva,helvetica">
-
-<h2>Error</h2>
-
-$processingException
-
-<hr>
-
-$stackTrace
-
+<table id=error>
+ <tr>
+ <td><h2>Error</h2></td>
+ </tr>
+ <tr>
+ <td>
+ $processingException
+ <hr>
+ $stackTrace
+ </td>
+ </tr>
+</table>
</font>
-
-<br>
-
1.2 +1 -7
jakarta-turbine-3/src/rttest/testapp/templates/app/screens/Index.vm
Index: Index.vm
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/rttest/testapp/templates/app/screens/Index.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Index.vm 17 Jan 2002 16:47:24 -0000 1.1
+++ Index.vm 18 Jan 2002 15:53:43 -0000 1.2
@@ -1,7 +1 @@
-$page.setTitle("Index")
-$page.setBgColor("#ffffff")
-
-1
-2
-3
-4
+Please stand by, This is only a test.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>