Updated Branches: refs/heads/5.4-js-rewrite 3cc722f01 -> 04e0d898f
Convert test code from MultiZoneUpdate to AjaxResponseRenderer and fix broken tests Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/04e0d898 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/04e0d898 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/04e0d898 Branch: refs/heads/5.4-js-rewrite Commit: 04e0d898f53349d5a533c9de6e8b6df8731ca717 Parents: 3cc722f Author: Howard M. Lewis Ship <[email protected]> Authored: Tue Nov 27 18:39:03 2012 +0000 Committer: Howard M. Lewis Ship <[email protected]> Committed: Tue Nov 27 18:39:03 2012 +0000 ---------------------------------------------------------------------- .../tapestry5/integration/app1/ZoneTests.java | 21 ++++--- .../app1/pages/MultiZoneStringBodyDemo.java | 43 +++++---------- .../app1/pages/MultiZoneStringBodyDemo.tml | 11 ++--- 3 files changed, 31 insertions(+), 44 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/04e0d898/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java index c4b490e..d1bad25 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java @@ -1,4 +1,4 @@ -// Copyright 2009, 2010, 2011 The Apache Software Foundation +// Copyright 2009, 2010, 2011, 2012 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. @@ -32,6 +32,8 @@ public class ZoneTests extends TapestryCoreTestCase { openLinks("Select Zone Demo"); + sleep(SETUP_TIME); + select("carMaker", "Bmw"); waitForElementToAppear("carModelContainer"); @@ -260,21 +262,21 @@ public class ZoneTests extends TapestryCoreTestCase assertText("row-" + i, numbers[i]); } - click("click_7"); + click("link=click 7"); waitForElementToAppear("row-7"); - // 7- are unchanged - for (int i = 0; i <= 7; i++) + // 0-6 are unchanged + for (int i = 0; i < 7; i++) { assertText("row-" + i, numbers[i]); } - // 8+ are modified - for (int i = 8; i <= 10; i++) + // 7+ are modified + for (int i = 7; i <= 10; i++) { assertText("row-" + i, i + " is the integer value"); } - click("reset"); + click("link=Reset Zones"); waitForElementToAppear("wholeLoopZone"); // all elements reset via AJAX @@ -300,9 +302,11 @@ public class ZoneTests extends TapestryCoreTestCase { openLinks("Zone Demo"); + sleep(SETUP_TIME); + click("link=Select \"CSS Injection\""); - sleep(100); + sleep(SETUP_TIME); // First check that the update arrived @@ -311,7 +315,6 @@ public class ZoneTests extends TapestryCoreTestCase // Next see if we can verify that the presentation matches the exceptations; greend and underlined. Underlined from // zonedemo-viaajax.css; green from zonedmeo-overrides.css (not blue as defined in zonedemo-viaajax.css). - assertCSS("demo-aip", "color", "rgb(0, 128, 0)"); assertCSS("demo-aip", "text-decoration", "underline"); } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/04e0d898/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.java index 71abc3d..0542042 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.java @@ -1,12 +1,14 @@ package org.apache.tapestry5.integration.app1.pages; import org.apache.tapestry5.Block; -import org.apache.tapestry5.ajax.MultiZoneUpdate; import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.corelib.components.Zone; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.apache.tapestry5.services.ajax.AjaxResponseRenderer; -public class MultiZoneStringBodyDemo { +public class MultiZoneStringBodyDemo +{ @Property private String[] list = { @@ -22,41 +24,26 @@ public class MultiZoneStringBodyDemo { @InjectComponent private Zone wholeLoopZone; - @InjectComponent - private Zone dummyZone; + @Inject + private AjaxResponseRenderer ajaxResponseRenderer; - public String getRowId() { + public String getRowId() + { return "row-" + index; } - public String getClickId() { - return "click_" + getItemId(); - } - - public int getItemId() { - return index; - } - - public MultiZoneUpdate onClick(int i) { - - MultiZoneUpdate mzu = new MultiZoneUpdate("dummyZone", dummyZone); - - while (i < list.length) { - - String clientId = "row-" + (i); - - String value = Integer.toString(i) + " is the integer value"; - - mzu = mzu.add(clientId, value); + void onClick(int i) + { + while (i < list.length) + { + ajaxResponseRenderer.addRender("row-" + (i), Integer.toString(i) + " is the integer value"); ++i; } - - return mzu; - } - public Block onReset() { + public Block onReset() + { return wholeLoopZone.getBody(); } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/04e0d898/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.tml b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.tml index be2f133..61ee15e 100644 --- a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.tml +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.tml @@ -1,4 +1,4 @@ -<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xml:space="default"> +<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xml:space="default"> <h1>Zone/Ajax Loop/MultiZoneUpdate</h1> @@ -7,17 +7,14 @@ A multi-zone update that is determined dynamically and uses a string that is coe <t:zone t:id="wholeLoopZone" id="wholeLoopZone"> <ul t:type="loop" t:source="list" t:value="item" index="index"> - <li> - <t:eventlink t:id="click" t:event="click" t:zone="wholeLoopZone" t:context="itemId">click</t:eventlink> - + <li xml:space="preserve"> + <t:eventlink t:id="click" t:event="click" t:zone="wholeLoopZone" t:context="index">click ${index}</t:eventlink> <span t:type="zone" t:id="numberZone" id="${rowId}">${item}</span> </li> </ul> </t:zone> -<t:eventlink t:id="reset" t:event="reset" t:zone="wholeLoopZone">reset</t:eventlink> - -<t:zone t:id="dummyZone" id="dummyZone"/> +<t:eventlink class="btn btn-warning" t:id="reset" t:event="reset" t:zone="wholeLoopZone">Reset Zones</t:eventlink> </html>
