[richfaces-svn-commits] JBoss Rich Faces SVN: r18834 - in modules/tests/metamer/trunk: ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Aug 19 20:01:58 EDT 2010


Author: lfryc at redhat.com
Date: 2010-08-19 20:01:57 -0400 (Thu, 19 Aug 2010)
New Revision: 18834

Added:
   modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestInstantAttributes.java
Modified:
   modules/tests/metamer/trunk/application/src/main/webapp/components/a4jStatus/instantAttributes.xhtml
Log:
a4j:status - added tests for instant attributes (RFPL-735)

Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/a4jStatus/instantAttributes.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/a4jStatus/instantAttributes.xhtml	2010-08-19 23:24:46 UTC (rev 18833)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/a4jStatus/instantAttributes.xhtml	2010-08-20 00:01:57 UTC (rev 18834)
@@ -83,7 +83,7 @@
 	<ui:define name="outOfTemplateAfter">
 		<h:form id="attributesForm">
 			<metamer:attributes value="#{a4jStatusBean.attributes}"
-				id="attributes" type="ajax" render="status" />
+				id="attributes" type="ajax" render="commonGrid" />
 		</h:form>
 	</ui:define>
 

Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestInstantAttributes.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestInstantAttributes.java	                        (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestInstantAttributes.java	2010-08-20 00:01:57 UTC (rev 18834)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.a4jStatus;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.jboss.test.selenium.encapsulated.JavaScript.js;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc at redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestInstantAttributes extends AbstracStatusTest {
+
+    StatusAttributes attributes = new StatusAttributes() {
+        protected void applyText(ElementLocator<?> locator, String value) {
+            guardXhr(selenium).type(locator, value);
+
+        };
+    };
+
+    JavaScript alert = js("alert('{0}')");
+
+    @Override
+    public URL getTestUrl() {
+        return buildUrl(contextPath, "faces/components/a4jStatus/instantAttributes.xhtml");
+    }
+
+    @BeforeMethod
+    public void installStatusExtensions() {
+        super.installStatusExtensions();
+    }
+
+    @Test
+    public void testOnStart() {
+        for (int i = 0; i < 2; i++) {
+            attributes.setOnStart(alert.parametrize("start" + 1));
+
+            enableHalt();
+            selenium.click(button1);
+            selenium.waitForCondition(js("selenium.isAlertPresent()"));
+            assertEquals(selenium.getAlert(), "start" + 1);
+            waitForHalt();
+            unhalt();
+            disableHalt();
+        }
+    }
+
+    @Test
+    public void testOnError() {
+        for (int i = 0; i < 2; i++) {
+            attributes.setOnError(alert.parametrize("error" + i));
+
+            guardXhr(selenium).click(buttonError);
+            assertEquals(selenium.getAlert(), "error" + i);
+        }
+    }
+
+    @Test
+    public void testOnSuccess() {
+        for (int i = 0; i < 2; i++) {
+            attributes.setOnSuccess(alert.parametrize("success" + 1));
+
+            guardXhr(selenium).click(button1);
+            assertEquals(selenium.getAlert(), "success" + 1);
+        }
+    }
+
+    @Test
+    public void testOnStop() {
+        for (int i = 0; i < 2; i++) {
+            attributes.setOnStop(alert.parametrize("stop" + i));
+
+            guardXhr(selenium).click(button1);
+            assertEquals(selenium.getAlert(), "stop" + i);
+
+            guardXhr(selenium).click(buttonError);
+            assertEquals(selenium.getAlert(), "stop" + i);
+        }
+    }
+
+}
\ No newline at end of file



More information about the richfaces-svn-commits mailing list