Author: hlship
Date: Fri Nov 17 10:20:58 2006
New Revision: 476235

URL: http://svn.apache.org/viewvc?view=rev&rev=476235
Log:
Add a Checkbox component.
Change default binding prefix for parameters specified via <t:comp> element to 
be "prop:".

Added:
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
Modified:
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextField.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderImpl.java
    
tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/component-classes.apt
    tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/event.apt
    tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/parameters.apt
    tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt
    
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/resources/org/apache/tapestry/integration/app1/pages/ActionPage.html
    
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/InstanceMixin.html
    
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/MerryChristmas.html
    
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ParameterConflict.html
    
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.html
    
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/Start.html

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java?view=auto&rev=476235
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
 Fri Nov 17 10:20:58 2006
@@ -0,0 +1,59 @@
+// Copyright 2006 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.corelib.components;
+
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.annotations.AfterRender;
+import org.apache.tapestry.annotations.BeginRender;
+import org.apache.tapestry.annotations.Parameter;
+import org.apache.tapestry.services.WebRequest;
+
+/** A Checkbox coponent is simply a &lt;input type="checkbox"&gt;. */
+public class Checkbox extends AbstractField
+{
+
+    @Parameter(required = true)
+    private boolean _value;
+
+    @BeginRender
+    void begin(MarkupWriter writer)
+    {
+        writer.element(
+                "input",
+                "type",
+                "checkbox",
+                "name",
+                getElementName(),
+                "id",
+                getClientId(),
+                "checked",
+                _value ? "checked" : null);
+    }
+
+    @AfterRender
+    void after(MarkupWriter writer)
+    {
+        writer.end(); // input
+    }
+
+    @Override
+    protected void processSubmission(WebRequest request)
+    {
+        String postedValue = request.getParameter(getElementName());
+
+        _value = postedValue != null;
+    }
+
+}

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java
 Fri Nov 17 10:20:58 2006
@@ -16,10 +16,15 @@
 
 import org.apache.tapestry.MarkupWriter;
 import org.apache.tapestry.annotations.AfterRender;
+import org.apache.tapestry.annotations.BeforeRenderBody;
 import org.apache.tapestry.annotations.BeginRender;
 import org.apache.tapestry.annotations.Parameter;
 import org.apache.tapestry.services.WebRequest;
 
+/**
+ * TextArea component corresponds to a &lt;textarea&gt;. The value parameter 
is almost always bound
+ * to a string, but this is not an absolute requirement.
+ */
 public class TextArea extends AbstractField
 {
 
@@ -29,13 +34,20 @@
     @BeginRender
     void begin(MarkupWriter writer)
     {
-        writer.element("textarea", "name", getElementName(), "id", 
getClientId(), "value", _value);
+        writer.element("textarea", "name", getElementName(), "id", 
getClientId());
+    }
+
+    /** This will prevent the body of the component from rendering. */
+    @BeforeRenderBody
+    boolean rejectBody()
+    {
+        return false;
     }
 
     @AfterRender
     void after(MarkupWriter writer)
     {
-        // TextArea will not have a template. Should we forbid a body?
+        // TextArea will not have a template.
 
         if (_value != null)
             writer.write(_value.toString());

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextField.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextField.java?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextField.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextField.java
 Fri Nov 17 10:20:58 2006
@@ -12,35 +12,49 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.corelib.components;
-
-import org.apache.tapestry.MarkupWriter;
-import org.apache.tapestry.annotations.AfterRender;
-import org.apache.tapestry.annotations.BeginRender;
-import org.apache.tapestry.annotations.Parameter;
-import org.apache.tapestry.services.WebRequest;
-
-public class TextField extends AbstractField
-{
-    @Parameter(required = true)
-    private Object _value;
-
-    @BeginRender
-    void begin(MarkupWriter writer)
-    {
-        writer.element("input", "type", "text", "name", getElementName(), 
"id", getClientId(), "value", _value);
-    }
-
-    @AfterRender
-    void after(MarkupWriter writer)
-    {
-        writer.end(); // input
-    }
-
-    @Override
-    protected void processSubmission(WebRequest request)
-    {
-        _value = request.getParameter(getElementName());
-    }
-
-}
+package org.apache.tapestry.corelib.components;
+
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.annotations.AfterRender;
+import org.apache.tapestry.annotations.BeginRender;
+import org.apache.tapestry.annotations.Parameter;
+import org.apache.tapestry.services.WebRequest;
+
+/**
+ * TextField component corresponds to &lt;input type="text"&gt;. The value 
parameter will be
+ * editted. TextField is generally used with string values, but other values 
are acceptible, as long
+ * as they can be freely converted back and forth to strings.
+ */
+public class TextField extends AbstractField
+{
+    @Parameter(required = true)
+    private Object _value;
+
+    @BeginRender
+    void begin(MarkupWriter writer)
+    {
+        writer.element(
+                "input",
+                "type",
+                "text",
+                "name",
+                getElementName(),
+                "id",
+                getClientId(),
+                "value",
+                _value);
+    }
+
+    @AfterRender
+    void after(MarkupWriter writer)
+    {
+        writer.end(); // input
+    }
+
+    @Override
+    protected void processSubmission(WebRequest request)
+    {
+        _value = request.getParameter(getElementName());
+    }
+
+}

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderImpl.java?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderImpl.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderImpl.java
 Fri Nov 17 10:20:58 2006
@@ -421,14 +421,14 @@
         if (resources.isBound(name))
             return;
 
-        // Default binding prefix inside templates is literal.
-        // This may be subject to change; possibly inside <t:comp> the default 
should be "prop:",
-        // and once we add "invisible instrumentation", then we can let those 
properties default to
-        // "literal:"?
-        // What makes sense, and what's least surprising to the end developer?
+   
+        // When using the <t:comp> element (all that's supported right now), 
parameter
+        // are assumed to be prop expressions unless specifically other.  When 
we add invisible
+        // instrumentation back in, LITERAL_BINDING_PREFIX will be the default 
for those 
+        // attributes.
 
         Binding binding = _bindingSource.newBinding("parameter " + name, 
loadingElement
-                .getComponentResources(), 
InternalConstants.LITERAL_BINDING_PREFIX, token
+                .getComponentResources(), 
InternalConstants.PROP_BINDING_PREFIX, token
                 .getValue(), token.getLocation());
 
         component.addParameter(name, binding);

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/component-classes.apt
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/component-classes.apt?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/component-classes.apt 
(original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/component-classes.apt 
Fri Nov 17 10:20:58 2006
@@ -178,8 +178,8 @@
   The start and end parameters of the Count component are bound to literal 
values, and the value
   parameter of the Count component is bound to the countValue property of the 
Countdown component.
   
-  Note that inside the component class, the default binding prefix is "prop:", 
whereas inside a component template,
-  the default binding prefix is "literal:".  In the example we could write 
<<<"value=prop:countValue">>> if we desired to be
+  Note that inside the component class, the default binding prefix is always 
"prop:". 
+  In the example we could write <<<"value=prop:countValue">>> if we desired to 
be
   fully explicit.
   
   However, certain literal values, such as the numeric literals in the example,

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/event.apt
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/event.apt?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/event.apt 
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/event.apt Fri Nov 
17 10:20:58 2006
@@ -26,8 +26,8 @@
 <p> Choose a number from 1 to 10: </p>
 
 <p>
-    <t:comp type="Count" end="10" value="prop:index">
-        <t:comp id="choose" type="ActionLink" 
context="prop:index">${index}</t:comp>
+    <t:comp type="Count" end="10" value="index">
+        <t:comp id="choose" type="ActionLink" context="index">${index}</t:comp>
     </t:comp>
 </p>
 +---+

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/parameters.apt
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/parameters.apt?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/parameters.apt 
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/parameters.apt 
Fri Nov 17 10:20:58 2006
@@ -110,9 +110,7 @@
 Binding Expressions
 
   The value inside the template, "3" in the previous example, is a <binding 
expression>.
-  
-  This binding expression is the simplest form, a literal string.
-  
+    
   By placing a prefix in front of the value, you can change how Tapestry 
interprets the remainder
   of the expression (the part after the colon):
   
@@ -124,7 +122,7 @@
 | prop:      | The name of a property of the containing component to read or 
update.            |
 
*------------+----------------------------------------------------------------------------------+
 
-  Inside component classes, the default binding prefix is "prop:".
+  The default binding prefix is "prop:".
 
   <<Note: More prefixes are forthcoming.>>
     
@@ -135,23 +133,22 @@
   Property bindings are normally either simple names of properties 
("prop:userName")
   or paths to properties ("prop:user.address.city").
     
-  In addition, a few special cases are also supported. These are especially 
useful inside
-  Java annotations, since prop: is the default binding prefix outside the 
component template.
+  In addition, a few special cases are also supported. 
   In most cases, these special values save you the trouble of adding a 
"literal:" prefix to
   the value.
   
   * "true" and "false" will be converted to booleans. 
   
-  * "null" will be the null value. 
+  * "null" will be the  value null. 
     
   * "this" will be the component itself.
   
   * Simple numeric values are also accepted. These will be parsed into Long or 
Double objects.
     Ex: "prop:3.14".
     
-  * A range of integers separated by two periods. Ex: "prop:1..10".  
+  * A range of integers separated by two periods. Ex: "1..10".  
   
-  * Literal strings, inside single quotes.  Ex: "prop:'Hello World'"
+  * Literal strings, inside single quotes.  Ex: "'Hello World'"
   
   []
   
@@ -170,7 +167,7 @@
 +---+
 <t:comp type="Border" 
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
     <p> Countdown:
-        <t:comp type="Count" start="5" end="1" value="prop:index"> 
+        <t:comp type="Count" start="5" end="1" value="index"> 
           ${index} ...  
         </t:comp>
     </p>

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt 
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt Fri 
Nov 17 10:20:58 2006
@@ -79,7 +79,8 @@
   
   Additional attributes are used to {{{parameters.html}bind parameters of the 
component}}.  
   When parameters are bound
-  in this way, the values are interpreted as literal string values unless a 
specific prefix is given.
+  in this way, the values are interpreted as property expressions (that is, 
the "prop:" prefix is assumed unless
+  another value is specifically provided).
   
   The \<comp\> element defines where, within the containing component's 
template, the embedded component is active.
   

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=476235&r1=476234&r2=476235
==============================================================================
--- 
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
 Fri Nov 17 10:20:58 2006
@@ -12,264 +12,279 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.integration;
-
-import org.openqa.selenium.server.SeleniumServer;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.thoughtworks.selenium.DefaultSelenium;
-import com.thoughtworks.selenium.Selenium;
-
-/**
- * Note: If these tests fail with BindException when starting Jetty, it could 
be Skype. At least on
- * my system, Skype is listening on localhost:80.
- */
[EMAIL PROTECTED](timeOut = 50000, sequential = true, groups =
-{ "integration" })
-public class IntegrationTests extends Assert
-{
-    private static final int JETTY_PORT = 9999;
-
-    private static final String BASE_URL = "http://localhost:9999/";;
-
-    /** 60 seconds */
-    public static final String PAGE_LOAD_TIMEOUT = "600000";
-
-    private Selenium _selenium;
-
-    private SeleniumServer _server;
-
-    private JettyRunner _jettyRunner;
-
-    @BeforeClass
-    public void startupBackground() throws Exception
-    {
-        _jettyRunner = new JettyRunner("/", JETTY_PORT, "src/test/app1");
-
-        _server = new SeleniumServer();
-
-        _server.start();
-
-        _selenium = new DefaultSelenium("localhost", 
SeleniumServer.DEFAULT_PORT, "*firefox",
-                BASE_URL);
-
-        _selenium.start();
-    }
-
-    @AfterClass
-    public void shutdownBackground() throws Exception
-    {
-        // Thread.sleep(10000);
-
-        _selenium.stop();
-        _selenium = null;
-
-        _server.stop();
-        _server = null;
-
-        _jettyRunner.stop();
-        _jettyRunner = null;
-    }
-
-    @Test
-    public void app1_basic_output() throws Exception
-    {
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=Start Page");
-
-        // This comes from the Border cmponent's template
-
-        assertTrue(_selenium.getTitle().contains("Tapestry"));
-
-        // Text from Start.html
-
-        assertTextPresent("First Tapestry 5 Page");
-
-        // This is text passed from Start.html to Output as a parameter
-
-        assertTextPresent("we have basic parameters working");
-    }
-
-    private void clickAndWait(String link)
-    {
-        _selenium.click(link);
-        _selenium.waitForPageToLoad(PAGE_LOAD_TIMEOUT);
-    }
-
-    @Test
-    public void app1_basic_parameters() throws Exception
-    {
-
-        // OK ... this could be a separate test, but for efficiency, we'll mix 
it in here.
-        // It takes a while to start up Selenium RC (and a Firefox browser).
-
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=Count Page");
-
-        assertTextPresent("Ho! Ho! Ho!");
-    }
-
-    @Test
-    public void app1_injection() throws Exception
-    {
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=Inject Page");
-
-        // This is a test for a named @Inject:
-        assertTextPresent("<Proxy for 
tapestry.WebRequest(org.apache.tapestry.services.WebRequest)>");
-
-        // This is a test for an annonymous @Inject and 
ComponentResourcesInjectionProvider
-        
assertTextPresent("ComponentResources[org.apache.tapestry.integration.app1.pages.InjectPage]");
-
-        // Another test, DefaultInjectionProvider
-        assertTextPresent("<Proxy for 
tapestry.BindingSource(org.apache.tapestry.services.BindingSource)>");
-    }
-
-    @Test
-    public void app1_embedded_components()
-    {
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=Countdown Page");
-
-        assertTextPresent("regexp:\\s+5\\s+4\\s+3\\s+2\\s+1\\s+");
-
-        assertTextPresent("Brought to you by the 
org.apache.tapestry.integration.app1.components.Count");
-    }
-
-    @Test
-    public void app1_template_overridden()
-    {
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=Template Overriden by Class Page");
-
-        assertTextPresent("Output: ClassValue");
-    }
-
-    @Test
-    public void app1_environmental()
-    {
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=Environmental Annotation Useage");
-
-        String source = _selenium.getHtmlSource();
-
-        assertTrue(source
-                .contains("[<strong>A message provided by the 
RenderableProvider component.</strong>]"));
-    }
-
-    @Test
-    public void app1_expansion()
-    {
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=Expansion Page");
-
-        assertTextPresent("[value provided by a template expansion]");
-    }
-
-    @Test
-    public void app1_exception_report()
-    {
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=BadTemplate Page");
-
-        assertTextPresent("org.apache.tapestry.internal.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 app1_simple_component_event()
-    {
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=Action Page");
-
-        for (int i = 2; i < 5; i++)
-        {
-            clickAndWait("link=" + i);
-
-            assertTextPresent("You chose: " + i);
-        }
-    }
-
-    @Test
-    public void app1_instance_mixin()
-    {
-        _selenium.open(BASE_URL);
-
-        final String[] dates =
-        { "Jun 13, 1999", "Jul 15, 2001", "Dec 4, 2005" };
-
-        clickAndWait("link=InstanceMixin");
-
-        String body = _selenium.getHtmlSource();
-
-        for (String date : dates)
-        {
-            String snippet = String.format("[%s]", date);
-            assertTrue(body.contains(snippet), snippet);
-        }
-
-        clickAndWait("link=Toggle emphasis");
-
-        body = _selenium.getHtmlSource();
-
-        for (String date : dates)
-        {
-            String snippet = String.format("[<em>%s</em>]", date);
-            assertTrue(body.contains(snippet), snippet);
-        }
-    }
-
-    @Test
-    public void app1_render_phase_order()
-    {
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=RenderPhaseOrder");
-
-        assertTextPresent("[BEGIN-TRACER-MIXIN BEGIN-ABSTRACT-TRACER 
BEGIN-TRACER BODY AFTER-TRACER AFTER-ABSTRACT-TRACER AFTER-TRACER-MIXIN]");
-    }
-
-    @Test
-    public void app1_simple_form()
-    {
-        _selenium.open(BASE_URL);
-
-        clickAndWait("link=SimpleForm");
-
-        _selenium.type("email", "[EMAIL PROTECTED]");
-        _selenium.type("message", "Message for you, sir!");
-
-        clickAndWait("//[EMAIL PROTECTED]'submit']");
-
-        // Tried to use "email:" and "exact:email:" but Selenium 0.8.1 doesn't 
seem to accept that.
-        
-        assertTextPresent("[EMAIL PROTECTED]");
-        assertTextPresent("[Message for you, sir!]");
-
-    }
-
-    private void assertTextPresent(String text)
-    {
-        if (_selenium.isTextPresent(text))
-            return;
-
-        System.err.printf("Text pattern '%s' not found in:\n%s\n\n", text, 
_selenium
-                .getHtmlSource());
-
-        throw new AssertionError("Page did not contain '" + text + "'.");
-    }
-}
+package org.apache.tapestry.integration;
+
+import org.openqa.selenium.server.SeleniumServer;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.Selenium;
+
+/**
+ * Note: If these tests fail with BindException when starting Jetty, it could 
be Skype. At least on
+ * my system, Skype is listening on localhost:80.
+ */
[EMAIL PROTECTED](timeOut = 50000, sequential = true, groups =
+{ "integration" })
+public class IntegrationTests extends Assert
+{
+    private static final int JETTY_PORT = 9999;
+
+    private static final String BASE_URL = "http://localhost:9999/";;
+
+    /** 60 seconds */
+    public static final String PAGE_LOAD_TIMEOUT = "600000";
+
+    private Selenium _selenium;
+
+    private SeleniumServer _server;
+
+    private JettyRunner _jettyRunner;
+
+    @BeforeClass
+    public void startupBackground() throws Exception
+    {
+        _jettyRunner = new JettyRunner("/", JETTY_PORT, "src/test/app1");
+
+        _server = new SeleniumServer();
+
+        _server.start();
+
+        _selenium = new DefaultSelenium("localhost", 
SeleniumServer.DEFAULT_PORT, "*firefox",
+                BASE_URL);
+
+        _selenium.start();
+    }
+
+    @AfterClass
+    public void shutdownBackground() throws Exception
+    {
+        // Thread.sleep(10000);
+
+        _selenium.stop();
+        _selenium = null;
+
+        _server.stop();
+        _server = null;
+
+        _jettyRunner.stop();
+        _jettyRunner = null;
+    }
+
+    @Test
+    public void app1_basic_output() throws Exception
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=Start Page");
+
+        // This comes from the Border cmponent's template
+
+        assertTrue(_selenium.getTitle().contains("Tapestry"));
+
+        // Text from Start.html
+
+        assertTextPresent("First Tapestry 5 Page");
+
+        // This is text passed from Start.html to Output as a parameter
+
+        assertTextPresent("we have basic parameters working");
+    }
+
+    private void clickAndWait(String link)
+    {
+        _selenium.click(link);
+        _selenium.waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+    }
+
+    @Test
+    public void app1_basic_parameters() throws Exception
+    {
+
+        // OK ... this could be a separate test, but for efficiency, we'll mix 
it in here.
+        // It takes a while to start up Selenium RC (and a Firefox browser).
+
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=Count Page");
+
+        assertTextPresent("Ho! Ho! Ho!");
+    }
+
+    @Test
+    public void app1_injection() throws Exception
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=Inject Page");
+
+        // This is a test for a named @Inject:
+        assertTextPresent("<Proxy for 
tapestry.WebRequest(org.apache.tapestry.services.WebRequest)>");
+
+        // This is a test for an annonymous @Inject and 
ComponentResourcesInjectionProvider
+        
assertTextPresent("ComponentResources[org.apache.tapestry.integration.app1.pages.InjectPage]");
+
+        // Another test, DefaultInjectionProvider
+        assertTextPresent("<Proxy for 
tapestry.BindingSource(org.apache.tapestry.services.BindingSource)>");
+    }
+
+    @Test
+    public void app1_embedded_components()
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=Countdown Page");
+
+        assertTextPresent("regexp:\\s+5\\s+4\\s+3\\s+2\\s+1\\s+");
+
+        assertTextPresent("Brought to you by the 
org.apache.tapestry.integration.app1.components.Count");
+    }
+
+    @Test
+    public void app1_template_overridden()
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=Template Overriden by Class Page");
+
+        assertTextPresent("Output: ClassValue");
+    }
+
+    @Test
+    public void app1_environmental()
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=Environmental Annotation Useage");
+
+        String source = _selenium.getHtmlSource();
+
+        assertTrue(source
+                .contains("[<strong>A message provided by the 
RenderableProvider component.</strong>]"));
+    }
+
+    @Test
+    public void app1_expansion()
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=Expansion Page");
+
+        assertTextPresent("[value provided by a template expansion]");
+    }
+
+    @Test
+    public void app1_exception_report()
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=BadTemplate Page");
+
+        assertTextPresent("org.apache.tapestry.internal.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 app1_simple_component_event()
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=Action Page");
+
+        for (int i = 2; i < 5; i++)
+        {
+            clickAndWait("link=" + i);
+
+            assertTextPresent("You chose: " + i);
+        }
+    }
+
+    @Test
+    public void app1_instance_mixin()
+    {
+        _selenium.open(BASE_URL);
+
+        final String[] dates =
+        { "Jun 13, 1999", "Jul 15, 2001", "Dec 4, 2005" };
+
+        clickAndWait("link=InstanceMixin");
+
+        String body = _selenium.getHtmlSource();
+
+        for (String date : dates)
+        {
+            String snippet = String.format("[%s]", date);
+            assertTrue(body.contains(snippet), snippet);
+        }
+
+        clickAndWait("link=Toggle emphasis");
+
+        body = _selenium.getHtmlSource();
+
+        for (String date : dates)
+        {
+            String snippet = String.format("[<em>%s</em>]", date);
+            assertTrue(body.contains(snippet), snippet);
+        }
+    }
+
+    @Test
+    public void app1_render_phase_order()
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=RenderPhaseOrder");
+
+        assertTextPresent("[BEGIN-TRACER-MIXIN BEGIN-ABSTRACT-TRACER 
BEGIN-TRACER BODY AFTER-TRACER AFTER-ABSTRACT-TRACER AFTER-TRACER-MIXIN]");
+    }
+
+    /** Tests for forms and form submissions and basic form control 
components. */
+    @Test
+    public void app1_simple_form()
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=SimpleForm");
+
+        assertValue("email", "");
+        assertValue("message", "");
+        assertValue("urgent", "off");
+
+        _selenium.type("email", "[EMAIL PROTECTED]");
+        _selenium.type("message", "Message for you, sir!");
+        _selenium.click("urgent");
+
+        clickAndWait("//[EMAIL PROTECTED]'submit']");
+
+        assertValue("email", "[EMAIL PROTECTED]");
+        assertValue("message", "Message for you, sir!");
+        assertValue("urgent", "on");
+
+        // Tried to use "email:" and "exact:email:" but Selenium 0.8.1 doesn't 
seem to accept that.
+
+        assertTextPresent("[EMAIL PROTECTED]");
+        assertTextPresent("[Message for you, sir!]");
+        assertTextPresent("[true]");
+    }
+
+    private void assertValue(String locator, String expected)
+    {
+        assertEquals(_selenium.getValue(locator), expected);
+    }
+
+    private void assertTextPresent(String text)
+    {
+        if (_selenium.isTextPresent(text))
+            return;
+
+        System.err.printf("Text pattern '%s' not found in:\n%s\n\n", text, 
_selenium
+                .getHtmlSource());
+
+        throw new AssertionError("Page did not contain '" + text + "'.");
+    }
+}

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=476235&r1=476234&r2=476235
==============================================================================
--- 
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
 Fri Nov 17 10:20:58 2006
@@ -24,6 +24,8 @@
 
     private String _message;
 
+    private boolean _urgent;
+
     public String getEmail()
     {
         return _email;
@@ -42,6 +44,16 @@
     public void setMessage(String message)
     {
         _message = message;
+    }
+
+    public boolean isUrgent()
+    {
+        return _urgent;
+    }
+
+    public void setUrgent(boolean urgent)
+    {
+        _urgent = urgent;
     }
 
 }

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ActionPage.html
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ActionPage.html?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ActionPage.html
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ActionPage.html
 Fri Nov 17 10:20:58 2006
@@ -3,12 +3,12 @@
     <p> Choose a number from 1 to 10: </p>
 
     <p>
-        <t:comp type="Count" end="10" value="prop:index">
-            <t:comp id="choose" type="ActionLink" context="prop:index" 
class="prop:linkClass">${index}</t:comp>
+        <t:comp type="Count" end="10" value="index">
+            <t:comp id="choose" type="ActionLink" context="index" 
class="linkClass">${index}</t:comp>
         </t:comp>
     </p>
 
-    <t:comp type="If" test="prop:index">
+    <t:comp type="If" test="index">
         <p> <strong>You chose: ${value}</strong>.</p>
     </t:comp>
 

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/InstanceMixin.html
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/InstanceMixin.html?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/InstanceMixin.html
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/InstanceMixin.html
 Fri Nov 17 10:20:58 2006
@@ -2,9 +2,9 @@
 
     <p> Date #1: [<t:comp type="Output" 
         mixins="Emphasis" 
-        value="prop:date1" 
-        test="prop:showEmphasis"
-        format="prop:format"/>]
+        value="date1" 
+        test="showEmphasis"
+        format="format"/>]
     </p>
     
     <p>

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/MerryChristmas.html
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/MerryChristmas.html?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/MerryChristmas.html
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/MerryChristmas.html
 Fri Nov 17 10:20:58 2006
@@ -1,4 +1,4 @@
 <t:comp type="Border" 
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
-    <p> Merry Christmas: <t:comp type="Loop" source="prop:1..3"> Ho! </t:comp>
+    <p> Merry Christmas: <t:comp type="Loop" source="1..3"> Ho! </t:comp>
     </p>
 </t:comp>

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ParameterConflict.html
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ParameterConflict.html?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ParameterConflict.html
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ParameterConflict.html
 Fri Nov 17 10:20:58 2006
@@ -3,5 +3,5 @@
     <p> This component demonstrates that template values are overriden by
         bindings inside the @Component annotation, in the component class.</p>
         
-        Output: <t:comp id="echo" value="TemplateValue"/>
+        Output: <t:comp id="echo" value="literal:TemplateValue"/>
 </t:comp>

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.html
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.html?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.html
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.html
 Fri Nov 17 10:20:58 2006
@@ -5,11 +5,18 @@
 
     <t:comp type="Form">
 
-        Email: <t:comp type="TextField" id="email" value="prop:incident.email" 
size="50"/>
+        Email: <t:comp type="TextField" id="email" value="incident.email" 
size="50"/>
 
 <br/>
 
-Message: <t:comp type="TextArea" id="message" value="prop:incident.message" 
cols="50" rows="10"/>
+Message: <t:comp type="TextArea" id="message" value="incident.message" 
cols="50" rows="10">
+    You can put text here, but it isn't used.
+    </t:comp>
+
+
+<br/>
+
+Urgent?: <t:comp type="Checkbox" id="urgent" value="incident.urgent"/>
 
         <br/>
         
@@ -26,7 +33,8 @@
     
     <ul>
         <li>email: [${incident.email}]</li>
-        <li>message: [${incident.message}]</li>
+        <li>message: [${incident.message}]</li>
+        <li>urgent: [${incident.urgent}]</li>
     </ul>
 
     

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/Start.html
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/Start.html?view=diff&rev=476235&r1=476234&r2=476235
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/Start.html
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/Start.html
 Fri Nov 17 10:20:58 2006
@@ -7,6 +7,6 @@
     </p>
     <p>
         Here's some output from the Echo component:
-        <t:comp type="Echo" value="Yep, we have basic parameters working."/>
+        <t:comp type="Echo" value="literal:Yep, we have basic parameters 
working."/>
     </p>
 </t:comp>


Reply via email to