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 2009/12/15 18:47:14 UTC
svn commit: r890908 - in
/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration:
IntegrationTests.java TapestryCoreTestCase.java core/CoreBehaviorsTest.java
Author: hlship
Date: Tue Dec 15 17:47:14 2009
New Revision: 890908
URL: http://svn.apache.org/viewvc?rev=890908&view=rev
Log:
Continue work of converting to new style Selenium tests
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/core/CoreBehaviorsTest.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=890908&r1=890907&r2=890908&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java Tue Dec 15 17:47:14 2009
@@ -86,7 +86,6 @@
assertEquals(downloaded, actual);
}
-
@Test
public void component_parameter_default_from_method() throws Exception
{
@@ -95,29 +94,12 @@
assertTextPresent("Echo component default: [ParameterDefault:echo]");
}
-
-
@Test
public void encoded_loop_inside_a_form()
{
test_loop_inside_form("ToDo List");
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@Test
public void password_field()
{
@@ -143,9 +125,6 @@
assertTextPresent("You have provided the correct user name and password.");
}
-
-
-
@Test
public void server_side_validation_for_textfield_and_textarea() throws Exception
{
@@ -194,23 +173,6 @@
assertTextPresent("[19]");
}
- @Test
- public void simple_component_event()
- {
- final String YOU_CHOSE = "You chose: ";
-
- start("Action Page");
-
- assertFalse(isTextPresent(YOU_CHOSE));
-
- for (int i = 2; i < 5; i++)
- {
- clickAndWait("link=" + i);
-
- assertTextPresent(YOU_CHOSE + i);
- }
- }
-
/**
* Tests for forms and form submissions and basic form control components.
* also tests a few other things, such as
@@ -264,22 +226,6 @@
}
@Test
- public void subclass_inherits_parent_template()
- {
- start("ExpansionSubclass");
-
- assertTextPresent("[value provided, in the subclass, via a template expansion]");
- }
-
- @Test
- public void template_overridden()
- {
- start("Template Overridden by Class Page");
-
- assertTextPresent("Output: ClassValue");
- }
-
- @Test
public void volatile_loop_inside_a_form()
{
test_loop_inside_form("ToDo List (Volatile)");
@@ -423,14 +369,6 @@
assertTextPresent("Howard", "Lewis Ship", "0", "100% He-Man", "U.S. Citizen");
}
- @Test
- public void pageloaded_lifecycle_method_invoked()
- {
- start("PageLoaded Demo");
-
- assertTextPresent("[pageLoaded() was invoked.]");
- }
-
/**
* Basic Grid rendering, with a column render override. Also tests sorting.
*/
@@ -562,89 +500,6 @@
}
@Test
- public void navigation_response_from_page_activate() throws Exception
- {
- start("Protected Page");
-
- assertText("pagetitle", "Security Alert");
-
- // The message is set by Protected, but is rendered by SecurityAlert.
-
- assertTextPresent("Access to Protected page is denied");
- }
-
- @Test
- public void mixed_page_activation_context_and_component_context()
- {
- start("Kicker");
-
- clickAndWait("link=kick target");
-
- assertTextSeries("//li[%d]", 1, "betty", "wilma", "betty/wilma", "\u82B1\u5B50");
- assertTextPresent("No component context.");
-
- clickAndWait("link=go");
-
- assertTextSeries("//li[%d]", 1, "betty", "wilma", "betty/wilma", "\u82B1\u5B50");
- assertTextSeries("//ul[2]/li[%d]", 1, "fred", "barney", "clark kent", "fred/barney",
- "\u592A\u90CE");
- }
-
- @Test
- public void page_link_with_explicit_empty_context()
- {
- start("Kicker");
-
- clickAndWait("link=kick target");
-
- assertTextSeries("//li[%d]", 1, "betty", "wilma", "betty/wilma", "\u82B1\u5B50");
-
- clickAndWait("link=Target base, no context");
-
- assertTextPresent("No activation context.");
- }
-
- @Test
- public void page_link_with_explicit_activation_context()
- {
- start("PageLink Context Demo", "no context");
-
- assertTextPresent("No activation context.");
-
- clickAndWait("link=PageLink Context Demo");
-
- clickAndWait("link=literal context");
-
- assertText("//li[1]", "literal context");
-
- clickAndWait("link=PageLink Context Demo");
-
- clickAndWait("link=computed context");
-
- assertTextSeries("//li[%d]", 1, "fred", "7", "true");
-
- clickAndWait("link=PageLink Context Demo");
-
- clickAndWait("link=unsafe characters");
-
- assertText("//li[1]", "unsafe characters: !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~");
-
- clickAndWait("link=PageLink Context Demo");
-
- clickAndWait("link=japanese kanji");
-
- assertText("//li[1]", "japanese kanji: \u65E5\u672C\u8A9E");
-
- // TAPESTRY-2221
-
- clickAndWait("link=PageLink Context Demo");
-
- clickAndWait("link=Null in context");
-
- assertText("//li[1]", "NULL");
- }
-
- @Test
public void page_context_in_form()
{
start("Page Context in Form");
@@ -700,103 +555,6 @@
}
@Test
- public void recursive_components_are_identified_as_errors()
- {
- start("Recursive Demo");
-
- assertTextPresent(
- "An unexpected application exception has occurred.",
- "The template for component org.apache.tapestry5.integration.app1.components.Recursive is recursive (contains another direct or indirect reference to component org.apache.tapestry5.integration.app1.components.Recursive). This is not supported (components may not contain themselves).",
- "component is <t:recursive>recursive</t:recursive>, so we\'ll see a failure.");
- }
-
- @Test
- public void render_phase_method_may_return_renderable()
- {
- start("Renderable Demo");
-
- assertTextPresent("Renderable Demo", "[This proves it works.]");
- }
-
- @Test
- public void verify_event_handler_invocation_order_and_circumstance()
- {
- String clear = "link=clear";
-
- start("EventHandler Demo");
-
- clickAndWait(clear);
-
- clickAndWait("link=No Context");
- assertText("methodNames",
- "[parent.eventHandlerZero(), parent.onAction(), child.eventHandlerZeroChild()]");
-
- clickAndWait(clear);
- clickAndWait("link=Single context value");
-
- assertText(
- "methodNames",
- "[parent.eventHandlerOne(String), parent.eventHandlerZero(), parent.onAction(String), parent.onAction(), child.eventHandlerOneChild(), child.eventHandlerZeroChild()]");
-
- clickAndWait(clear);
- clickAndWait("link=Two value context");
-
- assertText(
- "methodNames",
- "[parent.eventHandlerOne(String), parent.eventHandlerZero(), parent.onAction(String), parent.onAction(), child.eventHandlerOneChild(), child.eventHandlerZeroChild()]");
-
- clickAndWait(clear);
- clickAndWait("link=Two value context (from fred)");
-
- assertText(
- "methodNames",
- "[parent.eventHandlerOne(String), parent.eventHandlerZero(), parent.onAction(String), parent.onAction(), child.eventHandlerForFred(), child.eventHandlerOneChild(), child.eventHandlerZeroChild(), child.onActionFromFred(String), child.onActionFromFred()]");
- }
-
- @Test
- public void inherited_bindings()
- {
- start("Inherited Bindings Demo");
-
- assertTextPresent("Bound: [ value: the-bound-value, bound: true ]",
- "Unbound: [ value: null, bound: false ]");
- }
-
- @Test
- public void client_persistence()
- {
- start("Client Persistence Demo");
- // can't assume session won't exist because other tests use form
- // components w/ defaults, which means
- // session creation to store the ValidationTracker. So we explicitly
- // clear the session here.
- clickAndWait("link=nix session");
-
- assertTextPresent("Persisted value: []", "Session: [false]");
-
- clickAndWait("link=store string");
-
- assertTextPresent("Persisted value: [A String]", "Session: [false]");
- }
-
- @Test
- public void attribute_expansions()
- {
- start("Attribute Expansions Demo");
-
- assertAttribute("//div[@id='mixed-expansion']/@style", "color: blue;");
- assertAttribute("//div[@id='single']/@class", "red");
- assertAttribute("//div[@id='consecutive']/@class", "goober-red");
- assertAttribute("//div[@id='trailer']/@class", "goober-green");
- assertText("//div[@id='formal']",
- "ALERT-expansions work inside formal component parameters as well");
-
- // An unrelated test, but fills in a bunch of minor gaps.
-
- assertSourcePresent("<!-- A comment! -->");
- }
-
- @Test
public void palette_component()
{
start("Palette Demo", "reset");
@@ -883,58 +641,7 @@
assertBubbleMessage("languages", "You must provide a value for Languages.");
}
- @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();
- waitForPageToLoad();
-
- clickAndWait("link=class");
- assertTextPresent("Tapestry 5 Integration Application 1");
- goBack();
- waitForPageToLoad();
-
- clickAndWait("link=page");
- assertTextPresent("Tapestry 5 Integration Application 1");
- goBack();
- waitForPageToLoad();
-
- clickAndWait("link=link");
- assertTextPresent("Tapestry 5 Integration Application 1");
- goBack();
- waitForPageToLoad();
-
- clickAndWait("link=stream");
- assertTextPresent("Success!");
- goBack();
- waitForPageToLoad();
-
- /*
- * clickAndWait("link=URL");
- * assertTextPresent("Google>");
- * goBack();
- * waitForPageToLoad();
- */
-
- clickAndWait("link=bad");
- assertTextPresent(
- "An unexpected application exception has occurred.",
- "A component event handler method returned the value 20. Return type java.lang.Integer can not be handled.",
- "context:ReturnTypes.tml, line 50");
- }
+
@Test
public void access_to_page_name()
@@ -1090,13 +797,6 @@
assertFieldValue("urgency_0", "LOW");
}
- @Test
- public void missing_template_for_page()
- {
- start("Missing Template Demo");
-
- assertTextPresent("Page MissingTemplate did not generate any markup when rendered. This could be because its template file could not be located, or because a render phase method in the page prevented rendering.");
- }
/**
* This can test some output and parsing capability of the DateField
@@ -1153,16 +853,6 @@
assertTextPresent("Howard Lewis Ship", "Dec 24, 1966");
}
- /**
- * This basically checks that the services status page does not error.
- */
- @Test
- public void services_status()
- {
- open(BASE_URL + "servicestatus");
-
- assertTextPresent("Tapestry IoC Services Status");
- }
@Test
public void event_based_translate() throws Exception
@@ -1237,16 +927,6 @@
click("link=Direct JSON response");
}
- /**
- * Tests TAPESTRY-1934.
- */
- @Test
- public void base_class_must_be_in_controlled_package() throws Exception
- {
- open(BASE_URL + "invalidsuperclass");
-
- assertTextPresent("Base class org.apache.tapestry5.integration.app1.WrongPackageForBaseClass (super class of org.apache.tapestry5.integration.app1.pages.InvalidSuperClass) is not in a controlled package and is therefore not valid. You should try moving the class to package org.apache.tapestry5.integration.app1.base.");
- }
@Test
public void xml_content() throws Exception
@@ -1258,33 +938,8 @@
// assertSourcePresent("<![CDATA[< & >]]>");
}
- /**
- * Tests TAPESTRY-2005.
- */
- @Test
- public void components_passed_as_parameters() throws Exception
- {
- start("ComponentParameter Demo");
-
- // This component is inside a block, and is only rendered because it is
- // passed as a parameter, of type ActionLink,
- // to an ActionLinkIndirect component.
-
- clickAndWait("link=click me");
-
- assertTextPresent("Link was clicked.");
- }
- /**
- * Tests TAPESTRY-1546
- */
- @Test
- public void inherit_informals() throws Exception
- {
- start("Inherit Informal Parameters Demo");
-
- assertAttribute("//span[@id='target']/@class", "inherit");
- }
+
@Test
public void disabled_fields() throws Exception
@@ -1337,16 +992,7 @@
assertTextPresent("[FirstName Property Editor Override]");
}
- /**
- * TAPESTRY-1830
- */
- @Test
- public void var_binding()
- {
- start("Var Binding Demo");
- assertTextSeries("//li[%d]", 1, "1", "2", "3");
- }
/**
* TAPESTRY-2021
@@ -1499,31 +1145,7 @@
"[Before field Required Value]", "[After field Required Value (required)]");
}
- /**
- * TAPESTRY-1724
- */
- @Test
- public void component_event_errors()
- {
- start("Exception Event Demo", "enable", "force invalid activation context");
-
- assertTextPresent("Exception: Exception in method org.apache.tapestry5.integration.app1.pages.ExceptionEventDemo.onActivate(float)");
- clickAndWait("link=force invalid event context");
-
- assertTextPresent("Exception: Exception in method org.apache.tapestry5.integration.app1.pages.ExceptionEventDemo.onActionFromFail(float)");
-
- // Revert to normal handling: return null from the onException() event
- // handler method.
-
- clickAndWait("link=disable");
-
- clickAndWait("link=force invalid event context");
-
- assertTextPresent("An unexpected application exception has occurred.",
- "org.apache.tapestry5.runtime.ComponentEventException",
- "java.lang.NumberFormatException");
- }
/**
* TAPESTRY-1416
@@ -1540,69 +1162,11 @@
assertTextSeries("//tr[1]/td[%d]", 1, "7", "view", "1", "");
}
- /**
- * TAPESTRY-1518
- */
- @Test
- public void generic_page_type()
- {
- start("Generic Page Class Demo");
-
- assertTextPresent("Editor for org.apache.tapestry5.integration.app1.data.Track");
-
- assertText("//label[@id='title-label']", "Title");
- assertAttribute("//label[@id='title-label']/@for", "title");
- }
-
- /**
- * TAPESTRY-2088
- */
- @Test
- public void primitive_array_as_parameter_type()
- {
- start("Primitive Array Parameter Demo");
-
- assertSourcePresent("<ul><li>1</li><li>3</li><li>5</li><li>7</li><li>9</li></ul>");
- }
-
- /**
- * TAPESTRY-2097
- */
- @Test
- public void render_queue_exception()
- {
- start("Render Error Demo");
-
- assertTextPresent("An unexpected application exception has occurred");
- // Just sample a smattering of the vast amount of data in the exception
- // report.
- assertTextPresent("RenderErrorDemo", "class " + RenderErrorDemo.class.getName(),
- "RenderErrorDemo:border", "RenderErrorDemo:echo");
- }
- /**
- * TAPESTRY-1594
- */
- @Test
- public void ignored_paths_filter()
- {
- start("Unreachable Page");
- assertTextPresent("HTTP ERROR: 404");
- }
-
- /**
- * TAPESTRY-2085
- */
- @Test
- public void render_phase_methods_may_throw_checked_exceptions()
- {
- start("Render Phase Method Exception Demo");
- assertTextPresent("Render queue error in BeginRender[RenderPhaseMethodExceptionDemo]: java.sql.SQLException: Simulated JDBC exception while rendering.");
- }
/**
* TAPESTRY-2085
@@ -1650,22 +1214,6 @@
assertTextPresent("ToDo #" + i);
}
- /**
- * TAPESTRY-2114
- */
- @Test
- public void boolean_properties_can_use_get_or_is_as_method_name_prefix()
- {
- start("Boolean Property Demo", "clear");
-
- assertText("usingGet", "false");
- assertText("usingIs", "false");
-
- clickAndWait("link=set");
-
- assertText("usingGet", "true");
- assertText("usingIs", "true");
- }
@Test
public void form_fragment()
@@ -1726,8 +1274,8 @@
* certificates.
* <p/>
* <p/>
- * Verified: Selenium can't handle this, even with a user manually OK-ing
- * the certificate warning dialogs.
+ * Verified: Selenium can't handle this, even with a user manually OK-ing the certificate
+ * warning dialogs.
*/
@Test(enabled = false)
public void secure_page_access()
@@ -1767,64 +1315,10 @@
assertText("message", "from getActionURL()");
}
- /**
- * TAPESTRY-1475
- */
- @Test
- public void discard_persistent_field_changes()
- {
- start("Persistent Demo");
-
- assertText("message", "");
-
- clickAndWait("link=Update the message field");
-
- assertText("message", "updated");
-
- clickAndWait("link=Refresh page");
-
- assertText("message", "updated");
-
- clickAndWait("link=Discard persistent field changes");
-
- assertText("message", "");
- }
-
- /**
- * TAPESTRY-2150. Also demonstrates how to add a ValueEncoder for an entity
- * object, to allow seamless encoding of
- * the entity's id into the URL.
- */
- @Test
- public void nested_page_names()
- {
- start("Music Page", "2");
-
- assertText("activePageName", "Music");
-
- clickAndWait("link=The Gift");
-
- assertText("activePageName", "music/Details");
- }
-
- /**
- * TAPESTRY-2235
- */
- @Test
- public void generated_activation_context_handlers()
- {
- start("Music Page", "69");
-
- assertText("activePageName", "Music");
- clickAndWait("link=Wake Me Up (Copy)");
- assertText("activePageName", "music/Details2");
- assertText("//dd[@class='title']", "Wake Me Up");
-
- assertText("//dd[@class='artist']", "Norah Jones");
- }
+
/**
* TAPESTRY-1869
@@ -1847,16 +1341,6 @@
assertText("//dd[@class='value']", "237");
}
- /**
- * TAPESTRY-1999
- */
- @Test
- public void list_as_event_context()
- {
- start("List Event Context Demo");
-
- assertTextSeries("//ul[@id='eventcontext']/li[%d]", 1, "1", "2", "3");
- }
@Test
public void form_injector()
@@ -1896,29 +1380,9 @@
assertTextPresent("Result: 10.14159");
}
- /**
- * TAPESTRY-2196
- */
- @Test
- public void protected_field_in_page_class()
- {
- start("Protected Fields Demo", "Trigger the Exception");
- assertTextPresent(
- "An unexpected application exception has occurred.",
- "Class org.apache.tapestry5.integration.app1.pages.ProtectedFields contains field(s) (_field) that are not private. You should change these fields to private, and add accessor methods if needed.");
- }
- /**
- * TAPESTRY-2078
- */
- @Test
- public void noclassdeffound_exception_is_linked_to_underlying_cause()
- {
- start("Class Transformation Exception Demo");
-
- assertTextPresent("Class org.apache.tapestry5.integration.app1.pages.Datum contains field(s) (_value) that are not private. You should change these fields to private, and add accessor methods if needed.");
- }
+
/**
* TAPESTRY-2244
@@ -1980,35 +1444,7 @@
}
}
- /**
- * TAPESTRY-2338
- */
- @Test
- public void cached_properties_cleared_at_end_of_request()
- {
- start("Clean Cache Demo");
- String time1_1 = getText("time1");
- String time1_2 = getText("time1");
-
- // Don't know what they are but they should be the same.
-
- assertEquals(time1_2, time1_1);
-
- click("link=update");
-
- sleep(250);
-
- String time2_1 = getText("time1");
- String time2_2 = getText("time1");
-
- // Check that @Cache is still working
-
- assertEquals(time2_2, time2_1);
-
- assertFalse(time2_1.equals(time1_1),
- "After update the nanoseconds time did not change, meaning @Cache was broken.");
- }
@Test
public void inplace_grid()
@@ -2026,29 +1462,7 @@
"Timestamp should not have changed because updates are in-place.");
}
- @Test
- public void method_advice()
- {
- start("Method Advice Demo");
-
- // @ReverseStrings intercepted and reversed the result:
- assertText("message", "!olleH");
-
- // @ReverseStrings doesn't do anything for non-Strings
- assertText("version", "5");
-
- // @ReverseStrings filtered the checked exception to a string result
- assertText(
- "cranky",
- "Invocation of method getCranky() failed with org.apache.tapestry5.integration.app1.services.DearGodWhyMeException.");
-
- // Now to check advice on a setter that manipulates parameters
-
- type("text", "Tapestry");
- clickAndWait(SUBMIT);
-
- assertText("output-text", "yrtsepaT");
- }
+
// TAPESTRY-2460
@@ -2072,24 +1486,9 @@
// we made it past the form submit without error.
}
- /**
- * TAPESTRY-2476
- */
- @Test
- public void null_parameter_when_not_allowed()
- {
- start("Null Parameter Demo");
-
- assertTextPresent("Parameter 'object' of component NullParameterDemo:beandisplay is bound to null.");
- }
+
- @Test
- public void component_classes_may_not_be_directly_instantiated()
- {
- start("Instantiate Page");
- assertTextPresent("Component class org.apache.tapestry5.integration.app1.pages.Music may not be instantiated directly.");
- }
/**
* TAPESTRY-2502
@@ -2133,15 +1532,6 @@
assertTextPresent("Forms require that the request method be POST and that the t:formdata query parameter have values.");
}
- /**
- * TAPESTRY-2567
- */
- public void field_annotation_conflict()
- {
- start("Field Annotation Conflict");
-
- assertTextPresent("Field flashDemo of class org.apache.tapestry5.integration.app1.pages.FieldAnnotationConflict is already claimed by @org.apache.tapestry5.annotations.InjectPage and can not be claimed by @org.apache.tapestry5.annotations.Parameter.");
- }
/**
* TAPESTRY-2592
@@ -2190,45 +1580,8 @@
waitForCondition(condition, PAGE_LOAD_TIMEOUT);
}
- /**
- * TAPESTRY-2610
- */
- public void access_to_informal_parameters()
- {
- start("Informal Parameters Demo");
- assertTextSeries("//dl[@id='informals']/dt[%d]", 1, "barney", "fred", "pageName");
- assertTextSeries("//dl[@id='informals']/dd[%d]", 1, "rubble", "flintstone",
- "InformalParametersDemo");
- }
-
- /**
- * TAPESTRY-2517
- */
- public void cached_exception_for_loading_failed_page()
- {
- start("Failed Field Injection Demo");
- assertTextPresent("Error obtaining injected value for field org.apache.tapestry5.integration.app1.pages.FailedInjectDemo.buffer: No service implements the interface java.lang.StringBuffer.");
-
- refresh();
- waitForPageToLoad(PAGE_LOAD_TIMEOUT);
-
- // Before this bug was fixed, this message would not appear; instead on
- // complaining about _$resources would appear which was very confusing.
-
- assertTextPresent("Error obtaining injected value for field org.apache.tapestry5.integration.app1.pages.FailedInjectDemo.buffer: No service implements the interface java.lang.StringBuffer.");
- }
-
- /**
- * TAPESTRTY-2644
- */
- public void create_page_link_via_page_class()
- {
- start("PageLink via Class Demo");
-
- assertTextPresent("Demonstrates the use of the @Inject annotation.");
- }
/**
* TAPESTRY-2438
@@ -2955,13 +2308,14 @@
/**
* asserts that the "echo value" mixins are properly functioning (ie
+ *
* @BindParameter, and mixin ordering).
- * each integer value specifies the echo mixin number (echovalue => 1,
- * echovalue2 => 2, echovalue3 => 3; 0 is the original value)
- * from which the specified echo mixin is expected to "receive" its value.
- * So if echo1From is 2, then the "original value"
- * printed by echo1 is expected to be the value set by echo2. If a given
- * "from" is < 0, checking the corresponding mixin values is disabled.
+ * each integer value specifies the echo mixin number (echovalue => 1,
+ * echovalue2 => 2, echovalue3 => 3; 0 is the original value)
+ * from which the specified echo mixin is expected to "receive" its value.
+ * So if echo1From is 2, then the "original value"
+ * printed by echo1 is expected to be the value set by echo2. If a given
+ * "from" is < 0, checking the corresponding mixin values is disabled.
*/
private void assertEchoMixins(String fieldName, String originalValue, int echo1From,
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java?rev=890908&r1=890907&r2=890908&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java Tue Dec 15 17:47:14 2009
@@ -23,6 +23,8 @@
*/
public static final String PAGE_LOAD_TIMEOUT = "15000";
+ public static final String SUBMIT = "//input[@type='submit']";
+
/**
* Click a link identified by a locator, then wait for the resulting page to load.
* This is not useful for Ajax updates, just normal full-page refreshes.
@@ -34,6 +36,15 @@
{
click(locator);
+ waitForPageToLoad();
+ }
+
+ /**
+ * Waits for the page to load (up to 15 seconds). This is invoked after clicking on an element
+ * that forces a full page refresh.
+ */
+ protected final void waitForPageToLoad()
+ {
waitForPageToLoad(PAGE_LOAD_TIMEOUT);
}
@@ -48,7 +59,62 @@
for (String text : linkText)
{
click("link=" + text);
- waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+ waitForPageToLoad();
+ }
+ }
+
+ protected final void assertTextSeries(String idFormat, int startIndex, String... values)
+ {
+ for (int i = 0; i < values.length; i++)
+ {
+ String id = String.format(idFormat, startIndex + i);
+
+ assertText(id, values[i]);
+ }
+ }
+
+ /**
+ * Used when the locator identifies an attribute, not an element.
+ *
+ * @param locator
+ * identifies the attribute whose value is to be asserted
+ * @param expected
+ * expected value for the attribute
+ */
+ protected final void assertAttribute(String locator, String expected)
+ {
+ String actual = null;
+
+ try
+ {
+ actual = getAttribute(locator);
+ }
+ catch (RuntimeException ex)
+ {
+ System.err.printf("Error accessing %s: %s, in:\n\n%s\n\n", locator, ex.getMessage(),
+ getHtmlSource());
+
+ throw ex;
+ }
+
+ if (actual.equals(expected))
+ return;
+
+ System.err.printf("Text for attribute %s should be '%s' but is '%s', in:\n\n%s\n\n",
+ locator, expected, actual, getHtmlSource());
+
+ throw new AssertionError(String.format("%s was '%s' not '%s'", locator, actual, expected));
+ }
+
+ protected final void sleep(long millis)
+ {
+ try
+ {
+ Thread.sleep(millis);
+ }
+ catch (InterruptedException ex)
+ {
+ // Ignore.
}
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/core/CoreBehaviorsTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/core/CoreBehaviorsTest.java?rev=890908&r1=890907&r2=890908&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/core/CoreBehaviorsTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/core/CoreBehaviorsTest.java Tue Dec 15 17:47:14 2009
@@ -16,6 +16,7 @@
import org.apache.tapestry5.corelib.mixins.RenderDisabled;
import org.apache.tapestry5.integration.TapestryCoreTestCase;
+import org.apache.tapestry5.integration.app1.pages.RenderErrorDemo;
import org.testng.annotations.Test;
public class CoreBehaviorsTest extends TapestryCoreTestCase
@@ -236,4 +237,660 @@
assertTextPresent("[BEGIN-TRACER-MIXIN BEGIN-ABSTRACT-TRACER BEGIN-TRACER BODY AFTER-TRACER AFTER-ABSTRACT-TRACER AFTER-TRACER-MIXIN]");
}
+
+ @Test
+ public void simple_component_event()
+ {
+ final String YOU_CHOSE = "You chose: ";
+
+ clickThru("Action Page");
+
+ assertFalse(isTextPresent(YOU_CHOSE));
+
+ for (int i = 2; i < 5; i++)
+ {
+ clickAndWait("link=" + i);
+
+ assertTextPresent(YOU_CHOSE + i);
+ }
+ }
+
+ @Test
+ public void subclass_inherits_parent_template()
+ {
+ clickThru("ExpansionSubclass");
+
+ assertTextPresent("[value provided, in the subclass, via a template expansion]");
+ }
+
+ @Test
+ public void template_overridden()
+ {
+ clickThru("Template Overridden by Class Page");
+
+ assertTextPresent("Output: ClassValue");
+ }
+
+ @Test
+ public void pageloaded_lifecycle_method_invoked()
+ {
+ clickThru("PageLoaded Demo");
+
+ assertTextPresent("[pageLoaded() was invoked.]");
+ }
+
+ @Test
+ public void navigation_response_from_page_activate() throws Exception
+ {
+ clickThru("Protected Page");
+
+ assertText("pagetitle", "Security Alert");
+
+ // The message is set by Protected, but is rendered by SecurityAlert.
+
+ assertTextPresent("Access to Protected page is denied");
+ }
+
+ @Test
+ public void mixed_page_activation_context_and_component_context()
+ {
+ clickThru("Kicker");
+
+ clickAndWait("link=kick target");
+
+ assertTextSeries("//li[%d]", 1, "betty", "wilma", "betty/wilma", "\u82B1\u5B50");
+ assertTextPresent("No component context.");
+
+ clickAndWait("link=go");
+
+ assertTextSeries("//li[%d]", 1, "betty", "wilma", "betty/wilma", "\u82B1\u5B50");
+ assertTextSeries("//ul[2]/li[%d]", 1, "fred", "barney", "clark kent", "fred/barney",
+ "\u592A\u90CE");
+ }
+
+ @Test
+ public void page_link_with_explicit_empty_context()
+ {
+ clickThru("Kicker");
+
+ clickAndWait("link=kick target");
+
+ assertTextSeries("//li[%d]", 1, "betty", "wilma", "betty/wilma", "\u82B1\u5B50");
+
+ clickAndWait("link=Target base, no context");
+
+ assertTextPresent("No activation context.");
+ }
+
+ @Test
+ public void page_link_with_explicit_activation_context()
+ {
+ clickThru("PageLink Context Demo", "no context");
+
+ assertTextPresent("No activation context.");
+
+ clickAndWait("link=PageLink Context Demo");
+
+ clickAndWait("link=literal context");
+
+ assertText("//li[1]", "literal context");
+
+ clickAndWait("link=PageLink Context Demo");
+
+ clickAndWait("link=computed context");
+
+ assertTextSeries("//li[%d]", 1, "fred", "7", "true");
+
+ clickAndWait("link=PageLink Context Demo");
+
+ clickAndWait("link=unsafe characters");
+
+ assertText("//li[1]", "unsafe characters: !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~");
+
+ clickAndWait("link=PageLink Context Demo");
+
+ clickAndWait("link=japanese kanji");
+
+ assertText("//li[1]", "japanese kanji: \u65E5\u672C\u8A9E");
+
+ // TAPESTRY-2221
+
+ clickAndWait("link=PageLink Context Demo");
+
+ clickAndWait("link=Null in context");
+
+ assertText("//li[1]", "NULL");
+ }
+
+ @Test
+ public void recursive_components_are_identified_as_errors()
+ {
+ clickThru("Recursive Demo");
+
+ assertTextPresent(
+ "An unexpected application exception has occurred.",
+ "The template for component org.apache.tapestry5.integration.app1.components.Recursive is recursive (contains another direct or indirect reference to component org.apache.tapestry5.integration.app1.components.Recursive). This is not supported (components may not contain themselves).",
+ "component is <t:recursive>recursive</t:recursive>, so we\'ll see a failure.");
+ }
+
+ @Test
+ public void render_phase_method_may_return_renderable()
+ {
+ clickThru("Renderable Demo");
+
+ assertTextPresent("Renderable Demo", "[This proves it works.]");
+ }
+
+ @Test
+ public void verify_event_handler_invocation_order_and_circumstance()
+ {
+ String clear = "link=clear";
+
+ clickThru("EventHandler Demo");
+
+ clickAndWait(clear);
+
+ clickAndWait("link=No Context");
+ assertText("methodNames",
+ "[parent.eventHandlerZero(), parent.onAction(), child.eventHandlerZeroChild()]");
+
+ clickAndWait(clear);
+ clickAndWait("link=Single context value");
+
+ assertText(
+ "methodNames",
+ "[parent.eventHandlerOne(String), parent.eventHandlerZero(), parent.onAction(String), parent.onAction(), child.eventHandlerOneChild(), child.eventHandlerZeroChild()]");
+
+ clickAndWait(clear);
+ clickAndWait("link=Two value context");
+
+ assertText(
+ "methodNames",
+ "[parent.eventHandlerOne(String), parent.eventHandlerZero(), parent.onAction(String), parent.onAction(), child.eventHandlerOneChild(), child.eventHandlerZeroChild()]");
+
+ clickAndWait(clear);
+ clickAndWait("link=Two value context (from fred)");
+
+ assertText(
+ "methodNames",
+ "[parent.eventHandlerOne(String), parent.eventHandlerZero(), parent.onAction(String), parent.onAction(), child.eventHandlerForFred(), child.eventHandlerOneChild(), child.eventHandlerZeroChild(), child.onActionFromFred(String), child.onActionFromFred()]");
+ }
+
+ @Test
+ public void inherited_bindings()
+ {
+ clickThru("Inherited Bindings Demo");
+
+ assertTextPresent("Bound: [ value: the-bound-value, bound: true ]",
+ "Unbound: [ value: null, bound: false ]");
+ }
+
+ @Test
+ public void client_persistence()
+ {
+ clickThru("Client Persistence Demo");
+ // can't assume session won't exist because other tests use form
+ // components w/ defaults, which means
+ // session creation to store the ValidationTracker. So we explicitly
+ // clear the session here.
+ clickAndWait("link=nix session");
+
+ assertTextPresent("Persisted value: []", "Session: [false]");
+
+ clickAndWait("link=store string");
+
+ assertTextPresent("Persisted value: [A String]", "Session: [false]");
+ }
+
+ @Test
+ public void attribute_expansions()
+ {
+ clickThru("Attribute Expansions Demo");
+
+ assertAttribute("//div[@id='mixed-expansion']/@style", "color: blue;");
+ assertAttribute("//div[@id='single']/@class", "red");
+ assertAttribute("//div[@id='consecutive']/@class", "goober-red");
+ assertAttribute("//div[@id='trailer']/@class", "goober-green");
+ assertText("//div[@id='formal']",
+ "ALERT-expansions work inside formal component parameters as well");
+
+ // An unrelated test, but fills in a bunch of minor gaps.
+
+ assertSourcePresent("<!-- A comment! -->");
+ }
+
+ @Test
+ public void event_handler_return_types()
+ {
+ openBaseURL();
+
+ 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();
+ waitForPageToLoad();
+
+ clickAndWait("link=class");
+ assertTextPresent("Tapestry 5 Integration Application 1");
+ goBack();
+ waitForPageToLoad();
+
+ clickAndWait("link=page");
+ assertTextPresent("Tapestry 5 Integration Application 1");
+ goBack();
+ waitForPageToLoad();
+
+ clickAndWait("link=link");
+ assertTextPresent("Tapestry 5 Integration Application 1");
+ goBack();
+ waitForPageToLoad();
+
+ clickAndWait("link=stream");
+ assertTextPresent("Success!");
+ goBack();
+ waitForPageToLoad();
+
+ /*
+ * clickAndWait("link=URL");
+ * assertTextPresent("Google>");
+ * goBack();
+ * waitForPageToLoad();
+ */
+
+ clickAndWait("link=bad");
+ assertTextPresent(
+ "An unexpected application exception has occurred.",
+ "A component event handler method returned the value 20. Return type java.lang.Integer can not be handled.",
+ "context:ReturnTypes.tml, line 50");
+ }
+
+ @Test
+ public void missing_template_for_page()
+ {
+ clickThru("Missing Template Demo");
+
+ assertTextPresent("Page MissingTemplate did not generate any markup when rendered. This could be because its template file could not be located, or because a render phase method in the page prevented rendering.");
+ }
+
+ /**
+ * This basically checks that the services status page does not error.
+ */
+ @Test
+ public void services_status()
+ {
+ open(getBaseURL() + "servicestatus");
+
+ assertTextPresent("Tapestry IoC Services Status");
+ }
+
+ /**
+ * Tests TAPESTRY-1934.
+ */
+ @Test
+ public void base_class_must_be_in_controlled_package() throws Exception
+ {
+ open(getBaseURL() + "invalidsuperclass");
+
+ assertTextPresent("Base class org.apache.tapestry5.integration.app1.WrongPackageForBaseClass (super class of org.apache.tapestry5.integration.app1.pages.InvalidSuperClass) is not in a controlled package and is therefore not valid. You should try moving the class to package org.apache.tapestry5.integration.app1.base.");
+ }
+
+ /**
+ * Tests TAPESTRY-2005.
+ */
+ @Test
+ public void components_passed_as_parameters() throws Exception
+ {
+ clickThru("ComponentParameter Demo");
+
+ // This component is inside a block, and is only rendered because it is
+ // passed as a parameter, of type ActionLink,
+ // to an ActionLinkIndirect component.
+
+ clickAndWait("link=click me");
+
+ assertTextPresent("Link was clicked.");
+ }
+
+ /**
+ * Tests TAPESTRY-1546
+ */
+ @Test
+ public void inherit_informals() throws Exception
+ {
+ clickThru("Inherit Informal Parameters Demo");
+
+ assertAttribute("//span[@id='target']/@class", "inherit");
+ }
+
+ /**
+ * TAPESTRY-1830
+ */
+ @Test
+ public void var_binding()
+ {
+ clickThru("Var Binding Demo");
+
+ assertTextSeries("//li[%d]", 1, "1", "2", "3");
+ }
+
+ /**
+ * TAPESTRY-1724
+ */
+ @Test
+ public void component_event_errors()
+ {
+ clickThru("Exception Event Demo", "enable", "force invalid activation context");
+
+ assertTextPresent("Exception: Exception in method org.apache.tapestry5.integration.app1.pages.ExceptionEventDemo.onActivate(float)");
+
+ clickAndWait("link=force invalid event context");
+
+ assertTextPresent("Exception: Exception in method org.apache.tapestry5.integration.app1.pages.ExceptionEventDemo.onActionFromFail(float)");
+
+ // Revert to normal handling: return null from the onException() event
+ // handler method.
+
+ clickAndWait("link=disable");
+
+ clickAndWait("link=force invalid event context");
+
+ assertTextPresent("An unexpected application exception has occurred.",
+ "org.apache.tapestry5.runtime.ComponentEventException",
+ "java.lang.NumberFormatException");
+ }
+
+ /**
+ * TAPESTRY-1518
+ */
+ @Test
+ public void generic_page_type()
+ {
+ clickThru("Generic Page Class Demo");
+
+ assertTextPresent("Editor for org.apache.tapestry5.integration.app1.data.Track");
+
+ assertText("//label[@id='title-label']", "Title");
+ assertAttribute("//label[@id='title-label']/@for", "title");
+ }
+
+ /**
+ * TAPESTRY-2097
+ */
+ @Test
+ public void render_queue_exception()
+ {
+ clickThru("Render Error Demo");
+
+ assertTextPresent("An unexpected application exception has occurred");
+
+ // Just sample a smattering of the vast amount of data in the exception
+ // report.
+
+ assertTextPresent("RenderErrorDemo", "class " + RenderErrorDemo.class.getName(),
+ "RenderErrorDemo:border", "RenderErrorDemo:echo");
+ }
+
+ /**
+ * TAPESTRY-2088
+ */
+ @Test
+ public void primitive_array_as_parameter_type()
+ {
+ clickThru("Primitive Array Parameter Demo");
+
+ assertSourcePresent("<ul><li>1</li><li>3</li><li>5</li><li>7</li><li>9</li></ul>");
+ }
+
+ /**
+ * TAPESTRY-1594
+ */
+ @Test
+ public void ignored_paths_filter()
+ {
+ clickThru("Unreachable Page");
+
+ // This message changes from one release of Jetty to the next sometimes
+ assertText("//title", "Error 404 Not Found");
+ }
+
+ /**
+ * TAPESTRY-2085
+ */
+ @Test
+ public void render_phase_methods_may_throw_checked_exceptions()
+ {
+ clickThru("Render Phase Method Exception Demo");
+
+ assertTextPresent("Render queue error in BeginRender[RenderPhaseMethodExceptionDemo]: java.sql.SQLException: Simulated JDBC exception while rendering.");
+ }
+
+ /**
+ * TAPESTRY-2114
+ */
+ @Test
+ public void boolean_properties_can_use_get_or_is_as_method_name_prefix()
+ {
+ clickThru("Boolean Property Demo", "clear");
+
+ assertText("usingGet", "false");
+ assertText("usingIs", "false");
+
+ clickAndWait("link=set");
+
+ assertText("usingGet", "true");
+ assertText("usingIs", "true");
+ }
+
+ /**
+ * TAPESTRY-1475
+ */
+ @Test
+ public void discard_persistent_field_changes()
+ {
+ clickThru("Persistent Demo");
+
+ assertText("message", "");
+
+ clickAndWait("link=Update the message field");
+
+ assertText("message", "updated");
+
+ clickAndWait("link=Refresh page");
+
+ assertText("message", "updated");
+
+ clickAndWait("link=Discard persistent field changes");
+
+ assertText("message", "");
+ }
+
+ /**
+ * TAPESTRY-2150. Also demonstrates how to add a ValueEncoder for an entity
+ * object, to allow seamless encoding of
+ * the entity's id into the URL.
+ */
+ @Test
+ public void nested_page_names()
+ {
+ clickThru("Music Page", "2");
+
+ assertText("activePageName", "Music");
+
+ clickAndWait("link=The Gift");
+
+ assertText("activePageName", "music/Details");
+ }
+
+ /**
+ * TAPESTRY-2235
+ */
+ @Test
+ public void generated_activation_context_handlers()
+ {
+ clickThru("Music Page", "69");
+
+ assertText("activePageName", "Music");
+
+ clickAndWait("link=Wake Me Up (Copy)");
+
+ assertText("activePageName", "music/Details2");
+
+ assertText("//dd[@class='title']", "Wake Me Up");
+
+ assertText("//dd[@class='artist']", "Norah Jones");
+ }
+
+ /**
+ * TAPESTRY-1999
+ */
+ @Test
+ public void list_as_event_context()
+ {
+ clickThru("List Event Context Demo");
+
+ assertTextSeries("//ul[@id='eventcontext']/li[%d]", 1, "1", "2", "3");
+ }
+
+ /**
+ * TAPESTRY-2196
+ */
+ @Test
+ public void protected_field_in_page_class()
+ {
+ clickThru("Protected Fields Demo", "Trigger the Exception");
+
+ assertTextPresent(
+ "An unexpected application exception has occurred.",
+ "Class org.apache.tapestry5.integration.app1.pages.ProtectedFields contains field(s) (_field) that are not private. You should change these fields to private, and add accessor methods if needed.");
+ }
+
+ /**
+ * TAPESTRY-2078
+ */
+ @Test
+ public void noclassdeffound_exception_is_linked_to_underlying_cause()
+ {
+ clickThru("Class Transformation Exception Demo");
+
+ assertTextPresent("Class org.apache.tapestry5.integration.app1.pages.Datum contains field(s) (_value) that are not private. You should change these fields to private, and add accessor methods if needed.");
+ }
+
+ /**
+ * TAPESTRY-2338
+ */
+ @Test
+ public void cached_properties_cleared_at_end_of_request()
+ {
+ clickThru("Clean Cache Demo");
+
+ String time1_1 = getText("time1");
+ String time1_2 = getText("time1");
+
+ // Don't know what they are but they should be the same.
+
+ assertEquals(time1_2, time1_1);
+
+ click("link=update");
+
+ sleep(250);
+
+ String time2_1 = getText("time1");
+ String time2_2 = getText("time1");
+
+ // Check that @Cache is still working
+
+ assertEquals(time2_2, time2_1);
+
+ assertFalse(time2_1.equals(time1_1),
+ "After update the nanoseconds time did not change, meaning @Cache was broken.");
+ }
+
+ @Test
+ public void method_advice()
+ {
+ clickThru("Method Advice Demo");
+
+ // @ReverseStrings intercepted and reversed the result:
+ assertText("message", "!olleH");
+
+ // @ReverseStrings doesn't do anything for non-Strings
+ assertText("version", "5");
+
+ // @ReverseStrings filtered the checked exception to a string result
+ assertText(
+ "cranky",
+ "Invocation of method getCranky() failed with org.apache.tapestry5.integration.app1.services.DearGodWhyMeException.");
+
+ // Now to check advice on a setter that manipulates parameters
+
+ type("text", "Tapestry");
+ clickAndWait(SUBMIT);
+
+ assertText("output-text", "yrtsepaT");
+ }
+
+ @Test
+ public void component_classes_may_not_be_directly_instantiated()
+ {
+ clickThru("Instantiate Page");
+
+ assertTextPresent("Component class org.apache.tapestry5.integration.app1.pages.Music may not be instantiated directly.");
+ }
+
+ /**
+ * TAPESTRY-2567
+ */
+ public void field_annotation_conflict()
+ {
+ clickThru("Field Annotation Conflict");
+
+ assertTextPresent("Field flashDemo of class org.apache.tapestry5.integration.app1.pages.FieldAnnotationConflict is already claimed by @org.apache.tapestry5.annotations.InjectPage and can not be claimed by @org.apache.tapestry5.annotations.Parameter.");
+ }
+
+ /**
+ * TAPESTRY-2610
+ */
+ public void access_to_informal_parameters()
+ {
+ clickThru("Informal Parameters Demo");
+
+ assertTextSeries("//dl[@id='informals']/dt[%d]", 1, "barney", "fred", "pageName");
+ assertTextSeries("//dl[@id='informals']/dd[%d]", 1, "rubble", "flintstone",
+ "InformalParametersDemo");
+ }
+
+ /**
+ * TAPESTRY-2517
+ */
+ public void cached_exception_for_loading_failed_page()
+ {
+ clickThru("Failed Field Injection Demo");
+
+ assertTextPresent("Error obtaining injected value for field org.apache.tapestry5.integration.app1.pages.FailedInjectDemo.buffer: No service implements the interface java.lang.StringBuffer.");
+
+ refresh();
+ waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+
+ // Before this bug was fixed, this message would not appear; instead on
+ // complaining about _$resources would appear which was very confusing.
+
+ assertTextPresent("Error obtaining injected value for field org.apache.tapestry5.integration.app1.pages.FailedInjectDemo.buffer: No service implements the interface java.lang.StringBuffer.");
+ }
+
+ /**
+ * TAPESTRTY-2644
+ */
+ public void create_page_link_via_page_class()
+ {
+ clickThru("PageLink via Class Demo");
+
+ assertTextPresent("Demonstrates the use of the @Inject annotation.");
+ }
}