Author: amarkhel
Date: 2008-07-07 07:56:34 -0400 (Mon, 07 Jul 2008)
New Revision: 9421
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxHTMLCommandLinkTest.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxLoadBundleTest.java
Log:
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxHTMLCommandLinkTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxHTMLCommandLinkTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxHTMLCommandLinkTest.java 2008-07-07
11:56:34 UTC (rev 9421)
@@ -0,0 +1,130 @@
+package org.richfaces.testng;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.RichSeleniumTest;
+import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+
+public class AjaxHTMLCommandLinkTest extends SeleniumTestBase implements RichSeleniumTest
{
+
+ public AjaxHTMLCommandLinkTest() {
+ super("http", "localhost", serverPort);
+ }
+
+ /**
+ * This method are invoking before selenium tests started
+ */
+ @BeforeMethod
+ @Parameters({"browser", "filterPrefix"})
+ public void startSelenium(String browser, String filterPrefix) {
+ super.startSelenium(browser, filterPrefix);
+ }
+
+
+ @BeforeMethod
+ @Parameters({"loadStyleStrategy", "loadScriptStrategy"})
+ protected void loadConfiguration(String loadStyleStrategy, String loadScriptStrategy)
throws Exception {
+ super.loadConfiguration(loadStyleStrategy, loadScriptStrategy);
+ }
+
+ /**
+ * This method are invoking after selenium tests completed
+ */
+ @AfterMethod(alwaysRun=true)
+ public void stopSelenium() {
+ super.stopSelenium();
+ }
+
+ @Test
+ public void testAjaxCommandLinkComponent() throws Exception {
+ _testAjaxCommandLinkComponent(Template.SIMPLE);
+ _testAjaxCommandLinkComponent(Template.DATA_TABLE);
+ _testAjaxCommandLinkComponent(Template.MODAL_PANEL);
+ }
+
+ private void _testAjaxCommandLinkComponent(Template template) {
+ renderPage(template);
+
+ String parentId = getParentId() + "_form:";
+
+ String linkId = parentId + "l1";
+ boolean immediate = false;
+ writeStatus("Click link 1");
+ setValidation(true);
+ clickById(linkId);
+ waitForAjaxCompletion();
+ waitForOnCompleteHndler();
+ checkButton(linkId, true, immediate, true, true, true);
+
+ linkId = parentId + "l2";
+ immediate = false;
+ writeStatus("Click link 2");
+ setValidation(false);
+ clickById(linkId);
+ waitForAjaxCompletion();
+ waitForOnCompleteHndler();
+ checkButton(linkId, false, immediate, false, false, false);
+
+ linkId = parentId + "l3";
+ immediate = true;
+ writeStatus("Click link 3");
+ setValidation(true);
+ clickById(linkId);
+ waitForAjaxCompletion();
+ waitForOnCompleteHndler();
+ checkButton(linkId, true, immediate, true, true, false);
+
+ linkId = parentId + "l4";
+ immediate = true;
+ writeStatus("Click link 4");
+ setValidation(false);
+ clickById(linkId);
+ waitForAjaxCompletion();
+ waitForOnCompleteHndler();
+ checkButton(linkId, true, immediate, true, true, false);
+
+
+ }
+
+ private void setValidation(boolean success) {
+ StringBuffer buffer = new StringBuffer("setValidation(");
+ buffer.append(success);
+ buffer.append(");");
+ runScript(buffer.toString());
+ }
+
+ private void waitForOnCompleteHndler () {
+ waiteForCondition("_onCompleteHandler == true;", 3000);
+ runScript("_onCompleteHandler = false;");
+ }
+
+ private void checkButton(String id, boolean testData, boolean immediate, boolean
testAction, boolean testFListener, boolean testInput) {
+ writeStatus("Checking link...");
+ StringBuffer buffer = new StringBuffer("checkLink('");
+ buffer.append(id);
+ buffer.append("',");
+ buffer.append(testData);
+ buffer.append(",");
+ buffer.append(testAction);
+ buffer.append(",");
+ buffer.append(testFListener);
+ buffer.append(",");
+ buffer.append(testInput);
+ buffer.append(");");
+ String result = runScript(buffer.toString());
+ if (result != null && result.length() > 0) {
+ Assert.fail("<a4j:htmlCommandLink> [immediate="+immediate+"]
test failure caused by " + result);
+ }
+
+ }
+
+ public String getTestUrl() {
+ return "pages/ajaxHTMLCommandLink/ajaxHTMLLinkTest.xhtml";
+ }
+
+}
Property changes on:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxHTMLCommandLinkTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxLoadBundleTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxLoadBundleTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxLoadBundleTest.java 2008-07-07
11:56:34 UTC (rev 9421)
@@ -0,0 +1,44 @@
+package org.richfaces.testng;
+
+import junit.framework.Assert;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.SeleniumTestBase;
+import org.testng.annotations.Test;
+
+public class AjaxLoadBundleTest extends SeleniumTestBase {
+ private static final String URL = "pages/loadBundle/loadBundle.xhtml";
+ private static final String BUTTON_ID = "b1";
+ private static final String SAMPLE_MESSAGE = "Error was occured.";
+ private final static String FORM_ID = "form:";
+ private final static String FIRST_LINK_ID = FORM_ID + "error";
+ private final static String SECOND_LINK_ID = FORM_ID + "_link";
+
+ /**
+ * @see org.richfaces.SeleniumTestBase#getTestUrl()
+ */
+ @Override
+ public String getTestUrl() {
+ return URL;
+ }
+
+ @Test(dataProvider = "templates")
+ public void testAjaxMediaOutput(Template template) throws Exception {
+ renderPage(template);
+ writeStatus("Testing loadBundle component");
+ String textId = getParentId() + FIRST_LINK_ID;
+ AssertPresent(textId);
+ AssertNotPresent(getParentId() + SECOND_LINK_ID);
+ Assert.assertEquals(getTextById(textId), SAMPLE_MESSAGE);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testAjaxReRender(Template template) throws Exception {
+ renderPage(template);
+ writeStatus("Testing loadBundle component after ajax rerender");
+ String buttonId = getParentId() + FORM_ID + BUTTON_ID;
+ clickById(buttonId);
+ waitForAjaxCompletion();
+ AssertPresent(getParentId() + SECOND_LINK_ID);
+ }
+}
Property changes on:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxLoadBundleTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native