You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by gr...@apache.org on 2007/06/08 03:54:05 UTC
svn commit: r545367 - in /tapestry/tapestry5/trunk/tapestry-core/src/test:
app1/WEB-INF/ java/org/apache/tapestry/integration/
java/org/apache/tapestry/integration/app1/pages/
Author: gredler
Date: Thu Jun 7 18:54:04 2007
New Revision: 545367
URL: http://svn.apache.org/viewvc?view=rev&rev=545367
Log:
add integration tests for the various event handler return types
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/ReturnTypes.html
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/Start.html
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/ReturnTypes.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/ReturnTypes.html?view=auto&rev=545367
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/ReturnTypes.html (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/ReturnTypes.html Thu Jun 7 18:54:04 2007
@@ -0,0 +1,33 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <h1>Return Type Tests</h1>
+
+ <p>
+ Test <a t:type="ActionLink" t:id="NullReturnValue">null</a> return values.
+ </p>
+
+ <p>
+ Test <a t:type="ActionLink" t:id="StringReturnValue">string</a> return values.
+ </p>
+
+ <p>
+ Test <a t:type="ActionLink" t:id="ClassReturnValue">class</a> return values.
+ </p>
+
+ <p>
+ Test <a t:type="ActionLink" t:id="PageReturnValue">page</a> return values.
+ </p>
+
+ <p>
+ Test <a t:type="ActionLink" t:id="LinkReturnValue">link</a> return values.
+ </p>
+
+ <p>
+ Test <a t:type="ActionLink" t:id="StreamReturnValue">stream</a> return values.
+ </p>
+
+ <p>
+ Test <a t:type="ActionLink" t:id="BadReturnValue">bad</a> return values.
+ </p>
+
+</html>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/Start.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/Start.html?view=diff&rev=545367&r1=545366&r2=545367
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/Start.html (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/Start.html Thu Jun 7 18:54:04 2007
@@ -1,6 +1,6 @@
<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
- <h1> Tapestry 5 Integration Application 1</h1>
+ <h1>Tapestry 5 Integration Application 1</h1>
<table>
<tr>
@@ -93,9 +93,6 @@
<a t:type="PageLink" page="gridenumdemo">Grid Enum Demo</a> -- handling of enum types in
the Grid </li>
<li>
- <a t:type="ActionLink" t:id="textStreamResponse">Text Stream Response</a> -- component
- event that directly returns a stream of character (rather than a redirect) </li>
- <li>
<a t:type="PageLink" page="protected">Protected Page</a> -- Demonstrate result of
non-void return from a page's activate method. </li>
<li>
@@ -110,14 +107,8 @@
<li>
<a t:type="pagelink" page="ValidBeanEditorDemo">Client Validation Demo</a> --BeanEditor
with validation enabled </li>
-
<li>
<a href="recursivedemo">Recursive Demo</a> -- check for handling of recursive components </li>
-
- <li>
- <t:actionlink t:id="badreturntype">BadReturnType Demo</t:actionlink> -- Error report due
- to event handler method returning unacceptible return value (an Integer) </li>
-
<li>
<t:pagelink page="renderabledemo">Renderable Demo</t:pagelink> -- Shows that render
phase methods can return a Renderable object </li>
@@ -135,6 +126,10 @@
expansions inside attributes of ordinary elements </li>
<li>
<t:pagelink page="PaletteDemo">Palette Demo</t:pagelink> -- multiple selection component
+ </li>
+ <li>
+ <t:pagelink page="ReturnTypes">Return Types</t:pagelink> -- Tests various event handler
+ return types
</li>
</ul>
</td>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=545367&r1=545366&r2=545367
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Thu Jun 7 18:54:04 2007
@@ -711,16 +711,6 @@
}
@Test
- public void stream_response() throws Exception
- {
- open(BASE_URL);
-
- clickAndWait("link=Text Stream Response");
-
- assertText("//body", "Success!");
- }
-
- @Test
public void null_grid() throws Exception
{
open(BASE_URL);
@@ -840,18 +830,6 @@
}
@Test
- public void check_handling_of_unexpected_type_from_component_event_handler_method()
- {
- open(BASE_URL);
- clickAndWait("link=BadReturnType Demo");
-
- assertTextPresent(
- "An unexpected application exception has occurred.",
- "An event handler for component org.apache.tapestry.integration.app1.pages.Start returned the value 20 (from method org.apache.tapestry.integration.app1.pages.Start.onActionFromBadReturnType() (at Start.java:34)). Return type java.lang.Integer can not be handled.");
-
- }
-
- @Test
public void render_phase_method_may_return_renderable()
{
open(BASE_URL);
@@ -979,4 +957,44 @@
assertTextPresent("[ERLANG, RUBY, HASKELL, JAVA, LISP, ML, PYTHON, PERL]");
}
+
+ @Test
+ public void event_handler_return_types() {
+
+ open(BASE_URL);
+ assertTextPresent("Tapestry 5 Integration Application 1");
+
+ clickAndWait("link=Return Types");
+ assertTextPresent("Return Type Tests");
+
+ clickAndWait("link=null");
+ assertTextPresent("Return Type Tests");
+
+ clickAndWait("link=string");
+ assertTextPresent("Tapestry 5 Integration Application 1");
+ goBack();
+
+ clickAndWait("link=class");
+ assertTextPresent("Tapestry 5 Integration Application 1");
+ goBack();
+
+ clickAndWait("link=page");
+ assertTextPresent("Tapestry 5 Integration Application 1");
+ goBack();
+
+ clickAndWait("link=link");
+ assertTextPresent("Tapestry 5 Integration Application 1");
+ goBack();
+
+ clickAndWait("link=stream");
+ assertTextPresent("Success!");
+ goBack();
+
+ clickAndWait("link=bad");
+ assertTextPresent(
+ "An unexpected application exception has occurred.",
+ "An event handler for component org.apache.tapestry.integration.app1.pages.Start returned the value 20 (from method org.apache.tapestry.integration.app1.pages.Start.onActionFromBadReturnType() (at Start.java:34)). Return type java.lang.Integer can not be handled.");
+
+ }
+
}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java?view=auto&rev=545367
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java Thu Jun 7 18:54:04 2007
@@ -0,0 +1,72 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed 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.tapestry.integration.app1.pages;
+
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.annotations.Inject;
+import org.apache.tapestry.annotations.InjectPage;
+import org.apache.tapestry.services.ComponentEventResultProcessor;
+import org.apache.tapestry.util.TextStreamResponse;
+
+/**
+ * Tests the various event handler method return types.
+ *
+ * @see ComponentEventResultProcessor
+ */
+public class ReturnTypes
+{
+ @InjectPage
+ private Start _start;
+
+ @Inject
+ private ComponentResources _resources;
+
+ Object onActionFromNullReturnValue()
+ {
+ return null;
+ }
+
+ Object onActionFromStringReturnValue()
+ {
+ return "start";
+ }
+
+ Object onActionFromClassReturnValue()
+ {
+ return Start.class;
+ }
+
+ Object onActionFromPageReturnValue()
+ {
+ return _start;
+ }
+
+ Object onActionFromLinkReturnValue()
+ {
+ return _resources.createPageLink("start");
+ }
+
+ Object onActionFromStreamReturnValue()
+ {
+ String text = "<html><body>Success!</body></html>";
+ return new TextStreamResponse("text/html", text);
+ }
+
+ Object onActionFromBadReturnValue()
+ {
+ // What is Tapestry supposed to do with this? Let's see that Exception Report page.
+ return 20;
+ }
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java?view=diff&rev=545367&r1=545366&r2=545367
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java Thu Jun 7 18:54:04 2007
@@ -14,23 +14,10 @@
package org.apache.tapestry.integration.app1.pages;
-import org.apache.tapestry.util.TextStreamResponse;
-
/**
* Have to start somewhere!
*/
public class Start
{
- Object onActionFromTextStreamResponse()
- {
- String text = "<html><body>Success!</body></html>";
-
- return new TextStreamResponse("text/html", text);
- }
-
- Object onActionFromBadReturnType()
- {
- // What is Tapestry supposed to do with this? Let's see than Exception Report page.
- return 20;
- }
+ // Empty.
}