You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2006/11/16 19:27:23 UTC
svn commit: r475849 - in /tapestry/tapestry5/tapestry-core/trunk/src:
main/java/org/apache/tapestry/corelib/components/TextField.java
test/java/org/apache/tapestry/integration/IntegrationTests.java
test/resources/log4j.properties
Author: hlship
Date: Thu Nov 16 10:27:22 2006
New Revision: 475849
URL: http://svn.apache.org/viewvc?view=rev&rev=475849
Log:
Allow a TextField to edit an Object type, not necessarily a String.
Make better use of Selenium API for checking page results, and do a better job reporting errors.
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextField.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/log4j.properties
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=475849&r1=475848&r2=475849
==============================================================================
--- 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 Thu Nov 16 10:27:22 2006
@@ -23,7 +23,7 @@
public class TextField extends AbstractField
{
@Parameter(required = true)
- private String _value;
+ private Object _value;
@BeginRender
void begin(MarkupWriter writer)
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=475849&r1=475848&r2=475849
==============================================================================
--- 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 Thu Nov 16 10:27:22 2006
@@ -32,6 +32,7 @@
public class IntegrationTests extends Assert
{
private static final int JETTY_PORT = 9999;
+
private static final String BASE_URL = "http://localhost:9999/";
/** 60 seconds */
@@ -86,13 +87,11 @@
// Text from Start.html
- String body = _selenium.getBodyText();
-
- assertTrue(body.contains("First Tapestry 5 Page"));
+ assertTextPresent("First Tapestry 5 Page");
// This is text passed from Start.html to Output as a parameter
- assertTrue(body.contains("we have basic parameters working"));
+ assertTextPresent("we have basic parameters working");
}
private void clickAndWait(String link)
@@ -112,11 +111,7 @@
clickAndWait("link=Count Page");
- String body = _selenium.getBodyText();
-
- // Selenium is nice enough to remove the elements and excess whitespace.
-
- assertTrue(body.contains("Ho! Ho! Ho!"));
+ assertTextPresent("Ho! Ho! Ho!");
}
@Test
@@ -126,22 +121,14 @@
clickAndWait("link=Inject Page");
- String body = _selenium.getBodyText();
-
- // This is the output from the proxy for the WebRequest service, which is what's injected
- // into and output by, the component.
-
// This is a test for a named @Inject:
- assertTrue(body
- .contains("<Proxy for tapestry.WebRequest(org.apache.tapestry.services.WebRequest)>"));
+ assertTextPresent("<Proxy for tapestry.WebRequest(org.apache.tapestry.services.WebRequest)>");
// This is a test for an annonymous @Inject and ComponentResourcesInjectionProvider
- assertTrue(body
- .contains("ComponentResources[org.apache.tapestry.integration.app1.pages.InjectPage]"));
+ assertTextPresent("ComponentResources[org.apache.tapestry.integration.app1.pages.InjectPage]");
// Another test, DefaultInjectionProvider
- assertTrue(body
- .contains("<Proxy for tapestry.BindingSource(org.apache.tapestry.services.BindingSource)>"));
+ assertTextPresent("<Proxy for tapestry.BindingSource(org.apache.tapestry.services.BindingSource)>");
}
@Test
@@ -151,12 +138,9 @@
clickAndWait("link=Countdown Page");
- String body = _selenium.getBodyText();
+ assertTextPresent("regexp:\\s+5\\s+4\\s+3\\s+2\\s+1\\s+");
- assertTrue(body.contains("5 4 3 2 1"));
-
- assertTrue(body
- .contains("Brought to you by the org.apache.tapestry.integration.app1.components.Count"));
+ assertTextPresent("Brought to you by the org.apache.tapestry.integration.app1.components.Count");
}
@Test
@@ -166,9 +150,7 @@
clickAndWait("link=Template Overriden by Class Page");
- String body = _selenium.getBodyText();
-
- assertTrue(body.contains("Output: ClassValue"));
+ assertTextPresent("Output: ClassValue");
}
@Test
@@ -191,9 +173,7 @@
clickAndWait("link=Expansion Page");
- String body = _selenium.getBodyText();
-
- assertTrue(body.contains("[value provided by a template expansion]"));
+ assertTextPresent("[value provided by a template expansion]");
}
@Test
@@ -203,14 +183,10 @@
clickAndWait("link=BadTemplate Page");
- String body = _selenium.getBodyText();
-
- assertTrue(body.contains("org.apache.tapestry.internal.TapestryException"));
- assertTrue(body
- .contains("Failure parsing template classpath:org/apache/tapestry/integration/app1/pages/BadTemplate.html"));
- assertTrue(body.contains("org.xml.sax.SAXParseException"));
- assertTrue(body
- .contains("XML document structures must start and end within the same entity."));
+ 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
@@ -224,9 +200,7 @@
{
clickAndWait("link=" + i);
- String body = _selenium.getBodyText();
-
- assertTrue(body.contains("You chose: " + i));
+ assertTextPresent("You chose: " + i);
}
}
@@ -266,9 +240,32 @@
clickAndWait("link=RenderPhaseOrder");
- String body = _selenium.getBodyText().replaceAll("\\s+", " ");
+ 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", "foo@gmail.com");
+
+ clickAndWait("//input[@type='submit']");
+
+ assertTextPresent("You entered: foo@gmail.com");
+
+ }
+
+ 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());
- assertTrue(body
- .contains("[BEGIN-TRACER-MIXIN BEGIN-ABSTRACT-TRACER BEGIN-TRACER BODY AFTER-TRACER AFTER-ABSTRACT-TRACER AFTER-TRACER-MIXIN]"));
+ throw new AssertionError("Page did not contain '" + text + "'.");
}
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/log4j.properties?view=diff&rev=475849&r1=475848&r2=475849
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/log4j.properties (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/log4j.properties Thu Nov 16 10:27:22 2006
@@ -27,5 +27,5 @@
log4j.category.tapestry.ioc.ClassFactory=error
log4j.category.app=info
-log4j.category.org.apache.tapestry.integration.app1=debug
+log4j.category.org.apache.tapestry.integration.app1=error