Return-Path: Delivered-To: apmail-tapestry-commits-archive@locus.apache.org Received: (qmail 48210 invoked from network); 8 Jun 2007 01:54:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Jun 2007 01:54:27 -0000 Received: (qmail 44035 invoked by uid 500); 8 Jun 2007 01:54:30 -0000 Delivered-To: apmail-tapestry-commits-archive@tapestry.apache.org Received: (qmail 44008 invoked by uid 500); 8 Jun 2007 01:54:30 -0000 Mailing-List: contact commits-help@tapestry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tapestry.apache.org Delivered-To: mailing list commits@tapestry.apache.org Received: (qmail 43991 invoked by uid 99); 8 Jun 2007 01:54:30 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2007 18:54:30 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2007 18:54:25 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 49B681A981A; Thu, 7 Jun 2007 18:54:05 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Fri, 08 Jun 2007 01:54:05 -0000 To: commits@tapestry.apache.org From: gredler@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070608015405.49B681A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ + + +

Return Type Tests

+ +

+ Test null return values. +

+ +

+ Test string return values. +

+ +

+ Test class return values. +

+ +

+ Test page return values. +

+ +

+ Test link return values. +

+ +

+ Test stream return values. +

+ +

+ Test bad return values. +

+ + 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 @@ -

Tapestry 5 Integration Application 1

+

Tapestry 5 Integration Application 1

@@ -93,9 +93,6 @@ Grid Enum Demo -- handling of enum types in the Grid
  • - Text Stream Response -- component - event that directly returns a stream of character (rather than a redirect)
  • -
  • Protected Page -- Demonstrate result of non-void return from a page's activate method.
  • @@ -110,14 +107,8 @@
  • Client Validation Demo --BeanEditor with validation enabled
  • -
  • Recursive Demo -- check for handling of recursive components
  • - -
  • - BadReturnType Demo -- Error report due - to event handler method returning unacceptible return value (an Integer)
  • -
  • Renderable Demo -- Shows that render phase methods can return a Renderable object
  • @@ -135,6 +126,10 @@ expansions inside attributes of ordinary elements
  • Palette Demo -- multiple selection component +
  • +
  • + Return Types -- Tests various event handler + return types
  • 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 = "Success!"; + 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 = "Success!"; - - 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. }