Author: jjamrich
Date: 2011-09-05 04:52:27 -0400 (Mon, 05 Sep 2011)
New Revision: 22684
Removed:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusFacets.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/AbstracStatusTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestFacets.java
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/TestSimple.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java
Log:
RFPL-1439: update tests for a4j:status to use unified way to setting attributes
One small change in TestSimple. Removed dependency on AbstractComponentAttributes class
since this was IMHO quite missused. Now is used private method to set facets managing
status behavior
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/AbstracStatusTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/AbstracStatusTest.java 2011-09-05
08:51:54 UTC (rev 22683)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/AbstracStatusTest.java 2011-09-05
08:52:27 UTC (rev 22684)
@@ -40,8 +40,6 @@
JQueryLocator buttonError = pjq("input[id$=button3]");
JQueryLocator status = pjq("span[id$=status]");
- StatusAttributes attributes = new StatusAttributes();
-
TextRetriever retrieveStatus = retrieveText.locator(status);
XHRHalter haltHandler;
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusAttributes.java 2011-09-05
08:51:54 UTC (rev 22683)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusAttributes.java 2011-09-05
08:52:27 UTC (rev 22684)
@@ -21,31 +21,18 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.a4jStatus;
-import org.jboss.test.selenium.encapsulated.JavaScript;
-import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class StatusAttributes extends AbstractComponentAttributes {
- public void setOnError(JavaScript javaScript) {
- setProperty("onerror", javaScript.toString());
- }
+public enum StatusAttributes implements AttributeEnum {
- public void setOnStart(JavaScript javaScript) {
- setProperty("onstart", javaScript.toString());
- }
+ onerror,
+ onstart,
+ onstop,
+ onsuccess,
+ rendered
- public void setOnStop(JavaScript javaScript) {
- setProperty("onstop", javaScript.toString());
- }
-
- public void setOnSuccess(JavaScript javaScript) {
- setProperty("onsuccess", javaScript.toString());
- }
-
- public void setRendered(boolean rendered) {
- setProperty("rendered", Boolean.toString(rendered));
- }
}
Deleted:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusFacets.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusFacets.java 2011-09-05
08:51:54 UTC (rev 22683)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusFacets.java 2011-09-05
08:52:27 UTC (rev 22684)
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * JBoss, Home of Professional Open Source
- * Copyright 2010-2011, 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 org.jboss.test.selenium.locator.ElementLocator;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
-
-import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
-
-/**
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class StatusFacets extends AbstractComponentAttributes {
-
- JQueryLocator applyFacetsButton = pjq("input[id$=applyFacets]");
-
- @Override
- protected void applyText(ElementLocator<?> locator, String value) {
- selenium.type(locator, value);
- guardXhr(selenium).click(applyFacetsButton);
- }
-
- public void setStartText(String startText) {
- setProperty("facetStartText", startText);
- }
-
- public String getStartText() {
- return getProperty("facetStartText");
- }
-
- public void setStopText(String stopText) {
- setProperty("facetStopText", stopText);
- }
-
- public String getStopText() {
- return getProperty("facetStopText");
- }
-
- public void setErrorText(String errorText) {
- setProperty("facetErrorText", errorText);
- }
-
- public String getErrorText() {
- return getProperty("facetErrorText");
- }
-}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestFacets.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestFacets.java 2011-09-05
08:51:54 UTC (rev 22683)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestFacets.java 2011-09-05
08:52:27 UTC (rev 22684)
@@ -21,11 +21,13 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.a4jStatus;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import java.net.URL;
import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
import org.testng.annotations.Test;
/**
@@ -33,7 +35,8 @@
* @version $Revision$
*/
public class TestFacets extends AbstracStatusTest {
- StatusFacets facets = new StatusFacets();
+ JQueryLocator applyFacetsButton = pjq("input[id$=applyFacets]");
+ JQueryLocator inputFormat = pjq("input{id$={0}Input]");
@Override
public URL getTestUrl() {
@@ -52,20 +55,20 @@
void testChangingFacet(ElementLocator<?> button, IterateStatus iterateStatus)
{
switch (iterateStatus) {
case START:
- facets.setStartText(facets.getStartText() + "*");
+ setStartText(getStartText() + "*");
break;
case STOP:
- facets.setStopText(facets.getStopText() + "*");
+ setStopText(getStopText() + "*");
break;
case ERROR:
- facets.setErrorText(facets.getErrorText() + "*");
+ setErrorText(getErrorText() + "*");
break;
default:
throw new IllegalStateException();
}
- final String startText = facets.getStartText();
- final String stopText = (button.getAsString().equals(buttonError.getAsString()))
? facets.getErrorText() : facets.getStopText();
+ final String startText = getStartText();
+ final String stopText = (button.getAsString().equals(buttonError.getAsString()))
? getErrorText() : getStopText();
testRequestButton(button, startText, stopText);
}
@@ -73,4 +76,42 @@
private static enum IterateStatus {
START, STOP, ERROR
}
+
+ /**
+ * Routine to set value into input with specified locator
+ * @param locator
+ * @param value
+ */
+ private void setValueTo(ElementLocator<?> locator, String value) {
+ selenium.type(locator, value);
+ guardXhr(selenium).click(applyFacetsButton);
+ }
+
+ private String getValueFrom(ElementLocator<?> locator) {
+ return selenium.getValue(locator);
+ }
+
+ public void setStartText(String startText) {
+ setValueTo(inputFormat.format("facetStartText"), startText);
+ }
+
+ public String getStartText() {
+ return getValueFrom(inputFormat.format("facetStartText"));
+ }
+
+ public void setStopText(String stopText) {
+ setValueTo(inputFormat.format("facetStopText"), stopText);
+ }
+
+ public String getStopText() {
+ return getValueFrom(inputFormat.format("facetStopText"));
+ }
+
+ public void setErrorText(String errorText) {
+ setValueTo(inputFormat.format("facetErrorText"), errorText);
+ }
+
+ public String getErrorText() {
+ return getValueFrom(inputFormat.format("facetErrorText"));
+ }
}
\ No newline at end of file
Modified:
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 2011-09-05
08:51:54 UTC (rev 22683)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestInstantAttributes.java 2011-09-05
08:52:27 UTC (rev 22684)
@@ -24,6 +24,8 @@
import static org.jboss.test.selenium.encapsulated.JavaScript.js;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
+import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.statusAttributes;
+import static org.richfaces.tests.metamer.ftest.a4jStatus.StatusAttributes.*;
import java.net.URL;
@@ -40,8 +42,6 @@
*/
public class TestInstantAttributes extends AbstracStatusTest {
- StatusAttributes attributes = new StatusAttributes();
-
JavaScript alert = js("alert('{0}')");
@Override
@@ -51,19 +51,19 @@
@BeforeMethod
public void setupAttributes() {
- attributes.setRequestType(RequestType.XHR);
+ statusAttributes.setRequestType(RequestType.XHR);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RFPL-1516")
public void testOnStart() {
- attributes.setRequestType(null);
+ statusAttributes.setRequestType(null);
XHRHalter.enable();
for (int i = 0; i < 2; i++) {
final int ii = i;
retrieveRequestTime.initializeValue();
- attributes.setOnStart(js("window.metamer = " + ii));
+ statusAttributes.set(onstart, js("window.metamer = " + ii));
getCurrentXHRHalter().complete();
waitGui.waitForChange(retrieveRequestTime);
@@ -81,7 +81,7 @@
@IssueTracking({ "https://issues.jboss.org/browse/RF-9118",
"http://java.net/jira/browse/JAVASERVERFACES-1788" })
public void testOnError() {
for (int i = 0; i < 2; i++) {
- attributes.setOnError(alert.parametrize("error" + i));
+ statusAttributes.set(onerror, alert.parametrize("error" + i));
selenium.click(buttonError);
waitAjax.until(alertPresent);
@@ -92,7 +92,7 @@
@Test
public void testOnSuccess() {
for (int i = 0; i < 2; i++) {
- attributes.setOnSuccess(alert.parametrize("success" + 1));
+ statusAttributes.set(onsuccess, alert.parametrize("success" + 1));
selenium.click(button1);
waitAjax.until(alertPresent);
@@ -103,7 +103,7 @@
@Test
public void testOnStop() {
for (int i = 0; i < 2; i++) {
- attributes.setOnStop(alert.parametrize("stop" + i));
+ statusAttributes.set(onstop, alert.parametrize("stop" + i));
selenium.click(button1);
waitAjax.until(alertPresent);
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestSimple.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestSimple.java 2011-09-05
08:51:54 UTC (rev 22683)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/TestSimple.java 2011-09-05
08:52:27 UTC (rev 22684)
@@ -26,6 +26,8 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.statusAttributes;
+import static org.richfaces.tests.metamer.ftest.a4jStatus.StatusAttributes.rendered;
import java.net.URL;
@@ -40,8 +42,6 @@
*/
public class TestSimple extends AbstracStatusTest {
- StatusAttributes attributes = new StatusAttributes();
-
JQueryLocator defaultStatus = jq("span[id$=a4jStatusPanel]");
TextRetriever retrieveDefaultStatus = retrieveText.locator(defaultStatus);
@@ -78,7 +78,7 @@
public void testRendered() {
assertTrue(selenium.isElementPresent(status));
- attributes.setRendered(false);
+ statusAttributes.set(rendered, false);
assertFalse(selenium.isElementPresent(status));
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java 2011-09-05
08:51:54 UTC (rev 22683)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java 2011-09-05
08:52:27 UTC (rev 22684)
@@ -4,6 +4,7 @@
import org.richfaces.tests.metamer.ftest.a4jPoll.PollAttributes;
import org.richfaces.tests.metamer.ftest.a4jQueue.QueueAttributes;
import org.richfaces.tests.metamer.ftest.a4jRepeat.RepeatAttributes;
+import org.richfaces.tests.metamer.ftest.a4jStatus.StatusAttributes;
import org.richfaces.tests.metamer.ftest.richTooltip.TooltipAttributes;
import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
@@ -15,5 +16,6 @@
public static Attributes<QueueAttributes> queueAttributes = new
Attributes<QueueAttributes>(pjq("table.attributes[id$=queueAttributes]"));
public static Attributes<PollAttributes> pollAttributes = new
Attributes<PollAttributes>();
public static Attributes<RepeatAttributes> repeatAttributes = new
Attributes<RepeatAttributes>();
+ public static Attributes<StatusAttributes> statusAttributes = new
Attributes<StatusAttributes>();
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java 2011-09-05
08:51:54 UTC (rev 22683)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java 2011-09-05
08:52:27 UTC (rev 22684)
@@ -1,6 +1,7 @@
package org.richfaces.tests.metamer.ftest.attributes;
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guard;
+import static org.jboss.test.selenium.locator.Attribute.VALUE;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static
org.jboss.test.selenium.locator.reference.ReferencedLocator.referenceInferred;
import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
@@ -117,6 +118,14 @@
selenium.getInterceptionProxy().unregisterInterceptorType(RepeatForElementNotFound.class);
}
+ protected String getProperty(String propertyName) {
+ final ReferencedLocator<JQueryLocator> locator =
propertyLocator.format(propertyName, "");
+ if (selenium.getCount(locator) > 1) {
+ return selenium.getAttribute(propertyLocator.format(propertyName,
"[checked]").getAttribute(VALUE));
+ }
+ return selenium.getValue(locator);
+ }
+
protected void applyText(ElementLocator<?> locator, String value) {
guard(selenium, requestType).type(locator, value);
}