Author: abelevich
Date: 2009-03-17 12:17:55 -0400 (Tue, 17 Mar 2009)
New Revision: 12988
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxPushTest.java
Log:
fix test according to new layout and listener impl
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxPushTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxPushTest.java 2009-03-17
16:16:56 UTC (rev 12987)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxPushTest.java 2009-03-17
16:17:55 UTC (rev 12988)
@@ -31,10 +31,8 @@
public class AjaxPushTest extends SeleniumTestBase {
- private final static String RESTART_RESET = "#{ajaxPushBean.restart}";
-
private final static String STOP_RESET = "#{ajaxPushBean.stop}";
-
+
private static Map<String, String> params = new HashMap<String,
String>();
static {
@@ -52,34 +50,15 @@
String startBtnID = parentId + "startButton";
String stopBtnID = parentId + "stopButton";
- String startPanelID = parentId + "startPanel";
- String progressPanelID = parentId + "progressPanel";
-
- writeStatus("Check layout before start pushing");
-
- AssertRendered(startBtnID);
- AssertRendered(startPanelID);
-
- AssertNotRendered(stopBtnID);
- AssertNotRendered(progressPanelID);
-
writeStatus("Start push component. Test bean has to start sending events to
registered PushEventListener");
clickAjaxCommandAndWait(startBtnID);
- writeStatus("Check layout after pushing started");
-
- AssertNotRendered(startBtnID);
- AssertNotRendered(startPanelID);
-
- AssertRendered(stopBtnID);
- AssertRendered(progressPanelID);
-
writeStatus("check whether push events are being fired");
int eventBefore = getEventsCount();
- delay(3000);
+ delay(1500);
int eventAfter = getEventsCount();
@@ -88,31 +67,43 @@
}
writeStatus("stop pushing");
-
clickAjaxCommandAndWait(stopBtnID);
-
- writeStatus("Check layout after pushing stopped");
-
- AssertRendered(startBtnID);
- AssertRendered(startPanelID);
-
- AssertNotRendered(stopBtnID);
- AssertNotRendered(progressPanelID);
-
}
@Test
public void testNestedParams(Template template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, RESTART_RESET);
+ tester.renderPage(template, STOP_RESET);
writeStatus("Test component encodes nested f:param tags and their values are
present as request parameters");
- tester.testRequestParameters(params);
+
+ tester.reset();
+ tester.clickLoad();
+
+ String parentId = getParentId() + "autoTestForm:";
+ String startBtn = parentId + "startButton";
+ String stopBtn = parentId + "stopButton";
+
+ clickAjaxCommandAndWait(startBtn);
+
+ delay(1500);
+
+ for (String name : params.keySet()) {
+ String value = runScript("requestParamsMap" + "." +
name);
+ if (value == null) {
+ Assert.fail("Parameter [" + name + "] is not present in
ajax request");
+ } else if (!value.equals(params.get(name))) {
+ Assert.fail("Parameter [" + name + "] value is invalid.
Expected [" + params.get(name) + "]. But was ["
+ + value + "]");
+ }
+ }
+ clickAjaxCommandAndWait(stopBtn);
+
}
@Test
public void testRenderedAttribute(Template template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, null);
+ tester.renderPage(template, STOP_RESET);
writeStatus("Test component with rendered = false is not present on the
page");
tester.testRendered();
}
@@ -120,7 +111,7 @@
@Test
public void testAjaxSingle(Template template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, RESTART_RESET);
+ tester.renderPage(template, STOP_RESET);
writeStatus("Test ajaxSingle attribute");
tester.testAjaxSingle();
}
@@ -128,15 +119,15 @@
@Test
public void testAjaxSingleWithInternalValidationFailed(Template template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, RESTART_RESET);
+ tester.renderPage(template, STOP_RESET);
writeStatus("Test ajaxSingle attribute in case of invalid children
state");
tester.testAjaxSingleWithInternalValidationFailed();
}
-
+
@Test
public void testImmediate(Template template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, RESTART_RESET);
+ tester.renderPage(template, STOP_RESET);
writeStatus("Test immediate attribute");
tester.testImmediate();
}
@@ -144,7 +135,7 @@
@Test
public void testImmediateWithExternalValidationFailed(Template template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, RESTART_RESET);
+ tester.renderPage(template, STOP_RESET);
writeStatus("Test immediate attribute with external validation
failed");
tester.testImmediateWithExternalValidationFailed();
}
@@ -152,14 +143,19 @@
@Test
public void testListenersAreNotInvokedInCaseOfExternalValidationFailure(Template
template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, RESTART_RESET);
+ tester.renderPage(template, STOP_RESET);
writeStatus("Test listeners aren't invoked in case of external
validation failure");
tester.testExtrenalValidationFailure();
}
@Override
public void sendAjax() {
- delay(1500);
+ String parentId = getParentId() + "autoTestForm:";
+ String startBtn = parentId + "startButton";
+ String stopBtn = parentId + "stopButton";
+ clickAjaxCommandAndWait(startBtn);
+ delay(5000);
+ clickAjaxCommandAndWait(stopBtn);
}
@Override