You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2007/01/24 01:21:23 UTC

svn commit: r499191 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/translator/ main/resources/org/apache/tapestry/ test/java/org/apache/tapestry/integration/ test/java/org/apache/tapestry/integration/app1/data/ test/jav...

Author: hlship
Date: Tue Jan 23 16:21:22 2007
New Revision: 499191

URL: http://svn.apache.org/viewvc?view=rev&rev=499191
Log:
Improve default L&F for fields containing errors.
Let the IntegerTranslator trim whitespace before parsing the input value.
Demonstrate that the default translator is selected based on the type of the property editted by the field.
Demonstrate that an unparseable/invalid value is retained and echoed back to the client (without changing the server-side value).

Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/IntegerTranslator.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/default.css
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/translator/IntegerTranslatorTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ValidForm.html

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/IntegerTranslator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/IntegerTranslator.java?view=diff&rev=499191&r1=499190&r2=499191
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/IntegerTranslator.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/IntegerTranslator.java Tue Jan 23 16:21:22 2007
@@ -37,9 +37,7 @@
 
         try
         {
-            // TODO: Should we trim the client value, or let that be handled upstream?
-
-            return Integer.parseInt(clientValue);
+            return Integer.parseInt(clientValue.trim());
         }
         catch (NumberFormatException ex)
         {

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/default.css
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/default.css?view=diff&rev=499191&r1=499190&r2=499191
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/default.css (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/default.css Tue Jan 23 16:21:22 2007
@@ -32,8 +32,9 @@
 
 INPUT.t-error, TEXTAREA.t-error
 {
-  background-color: red;
-  color: white;
+    border-color: red;
+    font-style: italic;
+    color: red;
 }
 
 DIV.t-exception-message

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=499191&r1=499190&r2=499191
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Tue Jan 23 16:21:22 2007
@@ -42,53 +42,63 @@
 { "integration" })
 public class IntegrationTests extends Assert
 {
+    /** 60 seconds */
+    public static final String PAGE_LOAD_TIMEOUT = "600000";
+
     private static final int JETTY_PORT = 9999;
 
     private static final String BASE_URL = format("http://localhost:%d/", JETTY_PORT);
 
-    /** 60 seconds */
-    public static final String PAGE_LOAD_TIMEOUT = "600000";
+    private JettyRunner _jettyRunner;
 
     private Selenium _selenium;
 
     private SeleniumServer _server;
 
-    private JettyRunner _jettyRunner;
-
-    @BeforeClass
-    public void startupBackground() throws Exception
+    @Test
+    public void any_component()
     {
-        _jettyRunner = new JettyRunner("/", JETTY_PORT, "src/test/app1");
-
-        _server = new SeleniumServer();
 
-        _server.start();
+        _selenium.open(BASE_URL);
 
-        _selenium = new DefaultSelenium("localhost", SeleniumServer.DEFAULT_PORT, "*firefox",
-                BASE_URL);
+        clickAndWait("link=AnyDemo");
 
-        _selenium.start();
+        assertSourcePresent(
+                "<span class=\"title\" id=\"title\">Page Title</span>",
+                "<div class=\"heading\" id=\"heading\">Heading</div>",
+                "<h2 class=\"section\" id=\"section\">Section</h2>",
+                "<li id=\"item\">Item (item)</li>",
+                "<li id=\"item_0\">Item (item_0)</li>",
+                "<li id=\"item_1\">Item (item_1)</li>");
     }
 
-    @AfterClass
-    public void shutdownBackground() throws Exception
+    @Test
+    public void assets() throws Exception
     {
-        // Thread.sleep(10000);
-        _selenium.stop();
+        _selenium.open(BASE_URL);
+        clickAndWait("link=AssetDemo");
 
-        _selenium = null;
+        assertText("//img[@id='img']/@src", "/images/tapestry_banner.gif");
 
-        _server.stop();
-        _server = null;
+        // This doesn't prove that the image shows up in the client browser (it does, but
+        // it could just as easily be a broken image). Haven't figured out how Selenium
+        // allows this to be verified. Note that the path below represents some aliasing
+        // of the raw classpath resource path.
 
-        _jettyRunner.stop();
-        _jettyRunner = null;
-    }
+        assertText("//img[@id='img_0']/@src", "/assets/app1/pages/tapestry-button.png");
 
-    private void clickAndWait(String link)
-    {
-        _selenium.click(link);
-        _selenium.waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+        // Read the byte stream for the asset and compare to the real copy.
+
+        URL url = new URL("http", "localhost", JETTY_PORT, "/assets/app1/pages/tapestry-button.png");
+
+        byte[] downloaded = readContent(url);
+
+        Resource classpathResource = new ClasspathResource(
+                "org/apache/tapestry/integration/app1/pages/tapestry-button.png");
+
+        byte[] actual = readContent(classpathResource.toURL());
+
+        assertEquals(downloaded, actual);
     }
 
     @Test
@@ -127,42 +137,36 @@
         assertTextPresent("Ho! Ho! Ho!");
     }
 
+    /**
+     * Tests the ability to inject a Block, and the ability to use the block to control rendering.
+     */
     @Test
-    public void injection() throws Exception
+    public void block_rendering() throws Exception
     {
         _selenium.open(BASE_URL);
+        clickAndWait("link=BlockDemo");
 
-        clickAndWait("link=Inject Demo");
+        assertTextPresent("[]");
 
-        // This is a test for a named @Inject:
-        assertTextPresent("<Proxy for tapestry.Request(org.apache.tapestry.services.Request)>");
+        _selenium.select("//select[@id='blockName']", "fred");
+        _selenium.waitForPageToLoad(PAGE_LOAD_TIMEOUT);
 
-        // This is a test for an annonymous @Inject and ComponentResourcesInjectionProvider
-        assertTextPresent("ComponentResources[org.apache.tapestry.integration.app1.pages.InjectDemo]");
+        assertTextPresent("[Block fred.]");
+
+        _selenium.select("//select[@id='blockName']", "barney");
+        _selenium.waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+
+        assertTextPresent("[Block barney.]");
 
-        // Another test, DefaultInjectionProvider
-        assertTextPresent("<Proxy for tapestry.BindingSource(org.apache.tapestry.services.BindingSource)>");
     }
 
     @Test
-    public void page_injection() throws Exception
+    public void component_parameter_default_from_method() throws Exception
     {
         _selenium.open(BASE_URL);
+        clickAndWait("link=ParameterDefault");
 
-        clickAndWait("link=Inject Demo");
-
-        clickAndWait("link=Fred");
-
-        assertTextPresent("You clicked Fred.");
-
-        clickAndWait("link=Back");
-        clickAndWait("link=Barney");
-
-        assertTextPresent("You clicked Barney.");
-
-        clickAndWait("link=Back");
-        clickAndWait("link=Wilma");
-        assertTextPresent("You clicked Wilma.");
+        assertTextPresent("Echo component default: [org.apache.tapestry.integration.app1.pages.ParameterDefault:echo]");
     }
 
     @Test
@@ -178,13 +182,9 @@
     }
 
     @Test
-    public void template_overridden()
+    public void encoded_loop_inside_a_form()
     {
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=Template Overriden by Class Page");
-
-        assertTextPresent("Output: ClassValue");
+        test_loop_inside_form("ToDo List");
     }
 
     @Test
@@ -198,55 +198,59 @@
     }
 
     @Test
-    public void expansion()
+    public void exception_report()
     {
         _selenium.open(BASE_URL);
 
-        clickAndWait("link=Expansion Page");
+        clickAndWait("link=BadTemplate Page");
 
-        assertTextPresent("[value provided by a template expansion]");
+        assertTextPresent("org.apache.tapestry.ioc.internal.util.TapestryException");
+        assertTextPresent("Failure parsing template classpath:org/apache/tapestry/integration/app1/pages/BadTemplate.html");
+        assertTextPresent("org.xml.sax.SAXParseException");
+        assertTextPresent("XML document structures must start and end within the same entity.");
     }
 
     @Test
-    public void subclass_inherits_parent_template()
+    public void expansion()
     {
         _selenium.open(BASE_URL);
 
-        clickAndWait("link=ExpansionSubclass");
+        clickAndWait("link=Expansion Page");
 
-        assertTextPresent("[value provided, in the subclass, via a template expansion]");
+        assertTextPresent("[value provided by a template expansion]");
     }
 
+    /**
+     * {@link InjectComponentWorker} is largely tested by the forms tests ({@link RenderDisabled}
+     * is built on it). This test is for the failure case, where a mixin class is used with the
+     * wrong type of component.
+     */
     @Test
-    public void exception_report()
+    public void inject_component_failure() throws Exception
     {
         _selenium.open(BASE_URL);
+        clickAndWait("link=InjectComponentMismatch");
 
-        clickAndWait("link=BadTemplate Page");
+        // And exception message:
 
-        assertTextPresent("org.apache.tapestry.ioc.internal.util.TapestryException");
-        assertTextPresent("Failure parsing template classpath:org/apache/tapestry/integration/app1/pages/BadTemplate.html");
-        assertTextPresent("org.xml.sax.SAXParseException");
-        assertTextPresent("XML document structures must start and end within the same entity.");
+        assertTextPresent("Component org.apache.tapestry.integration.app1.pages.InjectComponentMismatch is not assignable to field org.apache.tapestry.corelib.mixins.RenderDisabled._field (of type org.apache.tapestry.Field).");
     }
 
     @Test
-    public void simple_component_event()
+    public void injection() throws Exception
     {
-        final String YOU_CHOSE = "You chose: ";
-
         _selenium.open(BASE_URL);
 
-        clickAndWait("link=Action Page");
+        clickAndWait("link=Inject Demo");
 
-        assertFalse(_selenium.isTextPresent(YOU_CHOSE));
+        // This is a test for a named @Inject:
+        assertTextPresent("<Proxy for tapestry.Request(org.apache.tapestry.services.Request)>");
 
-        for (int i = 2; i < 5; i++)
-        {
-            clickAndWait("link=" + i);
+        // This is a test for an annonymous @Inject and ComponentResourcesInjectionProvider
+        assertTextPresent("ComponentResources[org.apache.tapestry.integration.app1.pages.InjectDemo]");
 
-            assertTextPresent(YOU_CHOSE + i);
-        }
+        // Another test, DefaultInjectionProvider
+        assertTextPresent("<Proxy for tapestry.BindingSource(org.apache.tapestry.services.BindingSource)>");
     }
 
     @Test
@@ -276,73 +280,48 @@
     }
 
     @Test
-    public void any_component()
-    {
-
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=AnyDemo");
-
-        assertSourcePresent(
-                "<span class=\"title\" id=\"title\">Page Title</span>",
-                "<div class=\"heading\" id=\"heading\">Heading</div>",
-                "<h2 class=\"section\" id=\"section\">Section</h2>",
-                "<li id=\"item\">Item (item)</li>",
-                "<li id=\"item_0\">Item (item_0)</li>",
-                "<li id=\"item_1\">Item (item_1)</li>");
-    }
-
-    @Test
-    public void render_phase_order()
+    public void localization()
     {
         _selenium.open(BASE_URL);
+        clickAndWait("link=Localization");
 
-        clickAndWait("link=RenderPhaseOrder");
-
-        assertTextPresent("[BEGIN-TRACER-MIXIN BEGIN-ABSTRACT-TRACER BEGIN-TRACER BODY AFTER-TRACER AFTER-ABSTRACT-TRACER AFTER-TRACER-MIXIN]");
+        assertTextPresent("Via injected Messages property: [Accessed via injected Messages]");
+        assertTextPresent("Via message: binding prefix: [Accessed via message: binding prefix]");
+        assertTextPresent("Page locale: [en]");
+        clickAndWait("link=French");
+        assertTextPresent("Page locale: [fr]");
+        clickAndWait("link=English");
+        assertTextPresent("Page locale: [en]");
     }
 
-    /**
-     * Tests for forms and form submissions and basic form control components. This also tests a few
-     * other things, such as computed default bindings and invisible instrumentation.
-     */
     @Test
-    public void simple_form()
+    public void page_injection() throws Exception
     {
         _selenium.open(BASE_URL);
 
-        clickAndWait("link=SimpleForm");
-
-        assertText("//label[1]", "Disabled");
-        assertText("//label[2]", "Email");
-        assertText("//label[3]", "Incident Message");
-        assertText("//label[4]", "Operating System");
-        assertText("//label[5]", "Urgent Processing Requested");
-
-        assertValue("email", "");
-        assertValue("message", "");
-        assertValue("operatingSystem", "osx");
-        assertValue("urgent", "on");
+        clickAndWait("link=Inject Demo");
 
-        _selenium.type("email", "foo@bar.baz");
-        _selenium.type("message", "Message for you, sir!");
-        _selenium.select("operatingSystem", "Windows NT");
-        _selenium.click("urgent");
+        clickAndWait("link=Fred");
 
-        clickAndWait("//input[@type='submit']");
+        assertTextPresent("You clicked Fred.");
 
-        assertValue("email", "foo@bar.baz");
-        assertValue("message", "Message for you, sir!");
-        assertValue("urgent", "off");
+        clickAndWait("link=Back");
+        clickAndWait("link=Barney");
 
-        // Tried to use "email:" and "exact:email:" but Selenium 0.8.1 doesn't seem to accept that.
+        assertTextPresent("You clicked Barney.");
 
-        assertTextPresent("[foo@bar.baz]");
-        assertTextPresent("[Message for you, sir!]");
-        assertTextPresent("[false]");
-        assertTextPresent("[winnt]");
+        clickAndWait("link=Back");
+        clickAndWait("link=Wilma");
+        assertTextPresent("You clicked Wilma.");
+    }
 
-        // Haven't figured out how to get selenium to check that fields are disabled.
+    @Test
+    public void passivate_activate() throws Exception
+    {
+        _selenium.open(BASE_URL);
+        clickAndWait("link=NumberSelect");
+        clickAndWait("link=5");
+        assertTextPresent("You chose 5.");
     }
 
     @Test
@@ -372,81 +351,36 @@
     }
 
     @Test
-    public void passivate_activate() throws Exception
+    public void render_phase_method_returns_a_component() throws Exception
     {
         _selenium.open(BASE_URL);
-        clickAndWait("link=NumberSelect");
-        clickAndWait("link=5");
-        assertTextPresent("You chose 5.");
-    }
+        clickAndWait("link=RenderComponentDemo");
 
-    @Test
-    public void localization()
-    {
-        _selenium.open(BASE_URL);
-        clickAndWait("link=Localization");
+        assertText("//span[@id='container']", "[]");
 
-        assertTextPresent("Via injected Messages property: [Accessed via injected Messages]");
-        assertTextPresent("Via message: binding prefix: [Accessed via message: binding prefix]");
-        assertTextPresent("Page locale: [en]");
-        clickAndWait("link=French");
-        assertTextPresent("Page locale: [fr]");
-        clickAndWait("link=English");
-        assertTextPresent("Page locale: [en]");
-    }
-
-    @Test
-    public void assets() throws Exception
-    {
-        _selenium.open(BASE_URL);
-        clickAndWait("link=AssetDemo");
-
-        assertText("//img[@id='img']/@src", "/images/tapestry_banner.gif");
-
-        // This doesn't prove that the image shows up in the client browser (it does, but
-        // it could just as easily be a broken image). Haven't figured out how Selenium
-        // allows this to be verified. Note that the path below represents some aliasing
-        // of the raw classpath resource path.
-
-        assertText("//img[@id='img_0']/@src", "/assets/app1/pages/tapestry-button.png");
-
-        // Read the byte stream for the asset and compare to the real copy.
-
-        URL url = new URL("http", "localhost", JETTY_PORT, "/assets/app1/pages/tapestry-button.png");
-
-        byte[] downloaded = readContent(url);
+        // Sneak in a little test for If and parameter else:
 
-        Resource classpathResource = new ClasspathResource(
-                "org/apache/tapestry/integration/app1/pages/tapestry-button.png");
+        assertTextPresent("Should be blank:");
 
-        byte[] actual = readContent(classpathResource.toURL());
+        clickAndWait("enabled");
 
-        assertEquals(downloaded, actual);
-    }
+        // After clicking the link (which submits the form), the page re-renders and shows us
+        // the optional component from inside the NeverRender, resurrected to render on the page
+        // after all.
 
-    @Test
-    public void component_parameter_default_from_method() throws Exception
-    {
-        _selenium.open(BASE_URL);
-        clickAndWait("link=ParameterDefault");
+        assertText("//span[@id='optional']", "Optional Text");
 
-        assertTextPresent("Echo component default: [org.apache.tapestry.integration.app1.pages.ParameterDefault:echo]");
+        assertTextPresent("Should now show up:");
     }
 
-    /**
-     * {@link InjectComponentWorker} is largely tested by the forms tests ({@link RenderDisabled}
-     * is built on it). This test is for the failure case, where a mixin class is used with the
-     * wrong type of component.
-     */
     @Test
-    public void inject_component_failure() throws Exception
+    public void render_phase_order()
     {
         _selenium.open(BASE_URL);
-        clickAndWait("link=InjectComponentMismatch");
 
-        // And exception message:
+        clickAndWait("link=RenderPhaseOrder");
 
-        assertTextPresent("Component org.apache.tapestry.integration.app1.pages.InjectComponentMismatch is not assignable to field org.apache.tapestry.corelib.mixins.RenderDisabled._field (of type org.apache.tapestry.Field).");
+        assertTextPresent("[BEGIN-TRACER-MIXIN BEGIN-ABSTRACT-TRACER BEGIN-TRACER BODY AFTER-TRACER AFTER-ABSTRACT-TRACER AFTER-TRACER-MIXIN]");
     }
 
     @Test
@@ -468,9 +402,19 @@
 
         _selenium.type("email", "foo@bar.baz");
         _selenium.type("message", "Show me the money!");
+        _selenium.type("hours", "foo");
 
         clickAndWait("//input[@type='submit']");
 
+        assertTextPresent("[false]");
+        assertTextPresent("The input value 'foo' is not parseable as an integer value.");
+
+        assertText("//input[@id='hours']/@value", "foo");
+
+        _selenium.type("hours", " 19 ");
+        _selenium.click("//input[@id='urgent']");
+        clickAndWait("//input[@type='submit']");
+
         // Make sure the decoration went away.
 
         // Sorry, not sure how to do that, since the attributes don't exist, we get xpath errors.
@@ -482,121 +426,141 @@
 
         assertTextPresent("[foo@bar.baz]");
         assertTextPresent("[Show me the money!]");
+        assertTextPresent("[true]");
+        assertTextPresent("[19]");
     }
 
-    @Test
-    public void render_phase_method_returns_a_component() throws Exception
+    @AfterClass
+    public void shutdownBackground() throws Exception
     {
-        _selenium.open(BASE_URL);
-        clickAndWait("link=RenderComponentDemo");
+        // Thread.sleep(10000);
+        _selenium.stop();
 
-        assertText("//span[@id='container']", "[]");
+        _selenium = null;
 
-        // Sneak in a little test for If and parameter else:
+        _server.stop();
+        _server = null;
 
-        assertTextPresent("Should be blank:");
+        _jettyRunner.stop();
+        _jettyRunner = null;
+    }
 
-        clickAndWait("enabled");
+    @Test
+    public void simple_component_event()
+    {
+        final String YOU_CHOSE = "You chose: ";
 
-        // After clicking the link (which submits the form), the page re-renders and shows us
-        // the optional component from inside the NeverRender, resurrected to render on the page
-        // after all.
+        _selenium.open(BASE_URL);
 
-        assertText("//span[@id='optional']", "Optional Text");
+        clickAndWait("link=Action Page");
 
-        assertTextPresent("Should now show up:");
-    }
+        assertFalse(_selenium.isTextPresent(YOU_CHOSE));
 
-    @Test
-    public void volatile_loop_inside_a_form()
-    {
-        test_loop_inside_form("ToDo List (Volatile)");
-    }
+        for (int i = 2; i < 5; i++)
+        {
+            clickAndWait("link=" + i);
 
-    @Test
-    public void encoded_loop_inside_a_form()
-    {
-        test_loop_inside_form("ToDo List");
+            assertTextPresent(YOU_CHOSE + i);
+        }
     }
 
-    private void test_loop_inside_form(String linkLabel)
+    /**
+     * Tests for forms and form submissions and basic form control components. This also tests a few
+     * other things, such as computed default bindings and invisible instrumentation.
+     */
+    @Test
+    public void simple_form()
     {
         _selenium.open(BASE_URL);
 
-        clickAndWait("link=" + linkLabel);
-        clickAndWait("reset");
+        clickAndWait("link=SimpleForm");
 
-        assertValue("title", "Ditch Struts");
-        assertValue("title_0", "Eliminate JSF");
-        assertValue("title_1", "Conquer Rife");
+        assertText("//label[1]", "Disabled");
+        assertText("//label[2]", "Email");
+        assertText("//label[3]", "Incident Message");
+        assertText("//label[4]", "Operating System");
+        assertText("//label[5]", "Urgent Processing Requested");
 
-        _selenium.type("title", "Ditch Struts - today");
-        _selenium.type("title_0", "Eliminate JSF - immediately");
-        _selenium.type("title_1", "Conquer Rife - post haste");
+        assertValue("email", "");
+        assertValue("message", "");
+        assertValue("operatingSystem", "osx");
+        assertValue("urgent", "on");
 
-        clickAndWait("//input[@value='Update ToDos']");
+        _selenium.type("email", "foo@bar.baz");
+        _selenium.type("message", "Message for you, sir!");
+        _selenium.select("operatingSystem", "Windows NT");
+        _selenium.click("urgent");
 
-        assertValue("title", "Ditch Struts - today");
-        assertValue("title_0", "Eliminate JSF - immediately");
-        assertValue("title_1", "Conquer Rife - post haste");
+        clickAndWait("//input[@type='submit']");
 
-        clickAndWait("addNew");
+        assertValue("email", "foo@bar.baz");
+        assertValue("message", "Message for you, sir!");
+        assertValue("urgent", "off");
 
-        _selenium.type("title_2", "Conquer World");
+        // Tried to use "email:" and "exact:email:" but Selenium 0.8.1 doesn't seem to accept that.
 
-        clickAndWait("//input[@value='Update ToDos']");
+        assertTextPresent("[foo@bar.baz]");
+        assertTextPresent("[Message for you, sir!]");
+        assertTextPresent("[false]");
+        assertTextPresent("[winnt]");
 
-        assertValue("title", "Ditch Struts - today");
-        assertValue("title_0", "Eliminate JSF - immediately");
-        assertValue("title_1", "Conquer Rife - post haste");
-        assertValue("title_2", "Conquer World");
+        // Haven't figured out how to get selenium to check that fields are disabled.
     }
 
-    /**
-     * Tests the ability to inject a Block, and the ability to use the block to control rendering.
-     */
-    @Test
-    public void block_rendering() throws Exception
+    @BeforeClass
+    public void startupBackground() throws Exception
     {
-        _selenium.open(BASE_URL);
-        clickAndWait("link=BlockDemo");
+        _jettyRunner = new JettyRunner("/", JETTY_PORT, "src/test/app1");
 
-        assertTextPresent("[]");
+        _server = new SeleniumServer();
 
-        _selenium.select("//select[@id='blockName']", "fred");
-        _selenium.waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+        _server.start();
 
-        assertTextPresent("[Block fred.]");
+        _selenium = new DefaultSelenium("localhost", SeleniumServer.DEFAULT_PORT, "*firefox",
+                BASE_URL);
 
-        _selenium.select("//select[@id='blockName']", "barney");
-        _selenium.waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+        _selenium.start();
+    }
 
-        assertTextPresent("[Block barney.]");
+    @Test
+    public void subclass_inherits_parent_template()
+    {
+        _selenium.open(BASE_URL);
 
+        clickAndWait("link=ExpansionSubclass");
+
+        assertTextPresent("[value provided, in the subclass, via a template expansion]");
     }
 
-    private byte[] readContent(URL url) throws Exception
+    @Test
+    public void template_overridden()
     {
-        InputStream is = new BufferedInputStream(url.openStream());
+        _selenium.open(BASE_URL);
 
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        clickAndWait("link=Template Overriden by Class Page");
 
-        byte[] buffer = new byte[10000];
+        assertTextPresent("Output: ClassValue");
+    }
 
-        while (true)
-        {
-            int length = is.read(buffer);
+    @Test
+    public void volatile_loop_inside_a_form()
+    {
+        test_loop_inside_form("ToDo List (Volatile)");
+    }
 
-            if (length < 0)
-                break;
+    private void assertSourcePresent(String... expected)
+    {
+        String source = _selenium.getHtmlSource();
 
-            os.write(buffer, 0, length);
-        }
+        for (String snippet : expected)
+        {
+            if (source.contains(snippet))
+                continue;
 
-        os.close();
-        is.close();
+            System.err.printf("Source content '%s' not found in:\n%s\n\n", snippet, source);
 
-        return os.toByteArray();
+            throw new AssertionError("Page did not contain source '" + snippet + "'.");
+        }
     }
 
     private void assertText(String locator, String expected)
@@ -631,11 +595,6 @@
         throw new AssertionError(String.format("%s was '%s' not '%s'", locator, actual, expected));
     }
 
-    private void assertValue(String locator, String expected)
-    {
-        assertEquals(_selenium.getValue(locator), expected);
-    }
-
     private void assertTextPresent(String text)
     {
         if (_selenium.isTextPresent(text))
@@ -647,18 +606,71 @@
         throw new AssertionError("Page did not contain '" + text + "'.");
     }
 
-    private void assertSourcePresent(String... expected)
+    private void assertValue(String locator, String expected)
     {
-        String source = _selenium.getHtmlSource();
+        assertEquals(_selenium.getValue(locator), expected);
+    }
 
-        for (String snippet : expected)
+    private void clickAndWait(String link)
+    {
+        _selenium.click(link);
+        _selenium.waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+    }
+
+    private byte[] readContent(URL url) throws Exception
+    {
+        InputStream is = new BufferedInputStream(url.openStream());
+
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+        byte[] buffer = new byte[10000];
+
+        while (true)
         {
-            if (source.contains(snippet))
-                continue;
+            int length = is.read(buffer);
 
-            System.err.printf("Source content '%s' not found in:\n%s\n\n", snippet, source);
+            if (length < 0)
+                break;
 
-            throw new AssertionError("Page did not contain source '" + snippet + "'.");
+            os.write(buffer, 0, length);
         }
+
+        os.close();
+        is.close();
+
+        return os.toByteArray();
+    }
+
+    private void test_loop_inside_form(String linkLabel)
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=" + linkLabel);
+        clickAndWait("reset");
+
+        assertValue("title", "Ditch Struts");
+        assertValue("title_0", "Eliminate JSF");
+        assertValue("title_1", "Conquer Rife");
+
+        _selenium.type("title", "Ditch Struts - today");
+        _selenium.type("title_0", "Eliminate JSF - immediately");
+        _selenium.type("title_1", "Conquer Rife - post haste");
+
+        clickAndWait("//input[@value='Update ToDos']");
+
+        assertValue("title", "Ditch Struts - today");
+        assertValue("title_0", "Eliminate JSF - immediately");
+        assertValue("title_1", "Conquer Rife - post haste");
+
+        clickAndWait("addNew");
+
+        _selenium.type("title_2", "Conquer World");
+
+        clickAndWait("//input[@value='Update ToDos']");
+
+        assertValue("title", "Ditch Struts - today");
+        assertValue("title_0", "Eliminate JSF - immediately");
+        assertValue("title_1", "Conquer Rife - post haste");
+        assertValue("title_2", "Conquer World");
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java?view=diff&rev=499191&r1=499190&r2=499191
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java Tue Jan 23 16:21:22 2007
@@ -28,6 +28,8 @@
 
     private String _operatingSystem;
 
+    private int _hours;
+
     public String getEmail()
     {
         return _email;
@@ -66,6 +68,16 @@
     public void setOperatingSystem(String os)
     {
         _operatingSystem = os;
+    }
+
+    public int getHours()
+    {
+        return _hours;
+    }
+
+    public void setHours(int hours)
+    {
+        _hours = hours;
     }
 
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/translator/IntegerTranslatorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/translator/IntegerTranslatorTest.java?view=diff&rev=499191&r1=499190&r2=499191
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/translator/IntegerTranslatorTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/translator/IntegerTranslatorTest.java Tue Jan 23 16:21:22 2007
@@ -79,4 +79,14 @@
 
         assertEquals(translator.parseClient("-23823", messages), new Integer(-23823));
     }
+
+    @Test
+    public void parse_ignores_trimmed_whitespace() throws Exception
+    {
+        Messages messages = validationMessages();
+
+        Translator<Integer> translator = new IntegerTranslator();
+
+        assertEquals(translator.parseClient(" -123 ", messages), new Integer(-123));
+    }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ValidForm.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ValidForm.html?view=diff&rev=499191&r1=499190&r2=499191
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ValidForm.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ValidForm.html Tue Jan 23 16:21:22 2007
@@ -16,6 +16,12 @@
         <input t:type="Checkbox" t:id="urgent" value="incident.urgent"/>
         <label t:type="Label" for="urgent"/>
         <br/>
+        
+        <label t:type="Label" for="hours"/>:
+        <input t:type="TextField" t:id="hours" value="incident.hours" size="10" t:validate="required"/>
+        
+        <br/>
+        
         <input type="submit"/>
     </t:comp>
     
@@ -28,6 +34,7 @@
         <li>email: [${incident.email}]</li>
         <li>message: [${incident.message}]</li>
         <li>urgent: [${incident.urgent}]</li>
+        <li>hours: [${incident.hours}]</li>
     </ul>