Author: ppitonak(a)redhat.com
Date: 2011-11-01 13:29:15 -0400 (Tue, 01 Nov 2011)
New Revision: 22859
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/AbstractValidatorsTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestWrappingValidatorSingle.java
Log:
tests for rich:validator fixed
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/AbstractValidatorsTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/AbstractValidatorsTest.java 2011-11-01
17:21:30 UTC (rev 22858)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/AbstractValidatorsTest.java 2011-11-01
17:29:15 UTC (rev 22859)
@@ -33,48 +33,57 @@
/**
* Abstract class with selenium test for validators
- *
+ *
* @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
* @version $Revision$
*/
public abstract class AbstractValidatorsTest extends AbstractMetamerTest {
-
-
+
private enum ID {
- /** Boolean, true */ assertTrue,
- /** Boolean false */ assertFalse,
- /** Decimal from 2.5 to 9.688 */ decimalMinMax,
- /** Decimal 3 digits and 4 fract */ digits ,
- /** Integer max 10 */ max,
- /** Integer min 2 */ min,
- /** Integer from 2 to 10 */ minMax,
- /** Text, not empty */ notEmpty,
- /** Text, not null */ notNull,
- /** Text, pattern '[a-z].*' */ pattern,
- /** custom validator */ custom,
- /** custom regExp validator */ regexp,
- /** date past */ past,
- /** date future */ future,
- /** String size from 2 to 4 */ stringSize,
- /** Selection size */ size
+ /** Boolean, true */
+ assertTrue,
+ /** Boolean false */
+ assertFalse,
+ /** Decimal from 2.5 to 9.688 */
+ decimalMinMax,
+ /** Decimal 3 digits and 4 fract */
+ digits,
+ /** Integer max 10 */
+ max,
+ /** Integer min 2 */
+ min,
+ /** Integer from 2 to 10 */
+ minMax,
+ /** Text, not empty */
+ notEmpty,
+ /** Text, not null */
+ notNull,
+ /** Text, pattern '[a-z].*' */
+ pattern,
+ /** custom validator */
+ custom,
+ /** custom regExp validator */
+ regexp,
+ /** date past */
+ past,
+ /** date future */
+ future,
+ /** String size from 2 to 4 */
+ stringSize,
+ /** Selection size */
+ size
}
-
+
private Map<ID, String> messages = new HashMap<AbstractValidatorsTest.ID,
String>();
-
private Map<ID, Object> wrongValue = new HashMap<AbstractValidatorsTest.ID,
Object>();
-
private JQueryLocator inputFormat = pjq("input[id$=:{0}]");
-
private JQueryLocator setWrongBtn =
pjq("input[id$=setWrongValuesButton]");
private JQueryLocator setCorrectBtn =
pjq("input[id$=setCorrectValuesButton]");
-
private JQueryLocator hCommandBtn = pjq("input[id$=hButton]");
private JQueryLocator a4jCommandBtn = pjq("input[id$=a4jButton]");
-
private JQueryLocator selectionItem = pjq("table[id$=:size] tr > td >
input[value={0}]");
-
private JQueryLocator msgFormat = pjq("span[id$={0}Msg] span.rf-msg-det");
-
+
@BeforeClass
public void init() {
messages.put(ID.assertTrue, "must be true");
@@ -92,8 +101,8 @@
messages.put(ID.past, "must be in the past");
messages.put(ID.future, "must be in the future");
messages.put(ID.stringSize, "size must be between 2 and 4");
- messages.put(ID.size, "???????"); // RF-11035
-
+ messages.put(ID.size, "size must be between 2 and 4"); // RF-11035
+
wrongValue.put(ID.assertTrue, Boolean.FALSE);
wrongValue.put(ID.assertFalse, Boolean.TRUE);
wrongValue.put(ID.decimalMinMax, "10.688");
@@ -106,21 +115,21 @@
wrongValue.put(ID.pattern, "@@@");
wrongValue.put(ID.custom, "@@@");
wrongValue.put(ID.regexp, "@@@");
-
+
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy");
long offset = 24 * 60 * 60 * 1000; // more than 24 hours to get correct past
date
wrongValue.put(ID.past, sdf.format(new Date(System.currentTimeMillis() +
offset)));
wrongValue.put(ID.future, sdf.format(new Date(System.currentTimeMillis() -
offset)));
-
+
wrongValue.put(ID.stringSize, "JSF 2");
wrongValue.put(ID.size, "F"); // RF-11035
}
public void verifyAllWrongWithAjaxSubmit() {
selenium.click(setWrongBtn);
-
+
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
waitGui.until(textEquals.locator(msgFormat.format(ID.assertFalse)).text(messages.get(ID.assertFalse)));
waitGui.until(textEquals.locator(msgFormat.format(ID.decimalMinMax)).text(messages.get(ID.decimalMinMax)));
@@ -132,7 +141,7 @@
waitGui.until(textEquals.locator(msgFormat.format(ID.notNull)).text(messages.get(ID.notNull)));
waitGui.until(textEquals.locator(msgFormat.format(ID.pattern)).text(messages.get(ID.pattern)));
waitGui.until(textEquals.locator(msgFormat.format(ID.custom)).text(messages.get(ID.custom)));
-
+
if (selenium.isElementPresent(inputFormat.format(ID.regexp))) {
// regExp validator isn't present in JSR303 validation
waitGui.until(textEquals.locator(msgFormat.format(ID.regexp)).text(messages.get(ID.regexp)));
@@ -143,13 +152,13 @@
// TODO JJa 2011-06-06: remove comment when fixed issue with manyCheckbox
validation
//
waitGui.until(textEquals.locator(msgFormat.format(ID.size)).text(messages.get(ID.size)));
}
-
+
@IssueTracking(value = "https://issues.jboss.org/browse/RF-11035")
public void verifyAllWrongWithJSFSubmit() {
- selenium.click(setCorrectBtn);
-
+ selenium.click(setWrongBtn);
+
selenium.click(hCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
waitGui.until(textEquals.locator(msgFormat.format(ID.assertFalse)).text(messages.get(ID.assertFalse)));
waitGui.until(textEquals.locator(msgFormat.format(ID.decimalMinMax)).text(messages.get(ID.decimalMinMax)));
@@ -171,235 +180,234 @@
waitGui.until(textEquals.locator(msgFormat.format(ID.stringSize)).text(messages.get(ID.stringSize)));
waitGui.until(textEquals.locator(msgFormat.format(ID.size)).text(messages.get(ID.size)));
}
-
+
/**
* Boolean input, verify true
*/
public void verifyBooleanTrue() {
-
+
selenium.click(setCorrectBtn);
-
+
// checkBoolean to true
selenium.check(inputFormat.format(ID.assertTrue), (Boolean)
wrongValue.get(ID.assertTrue));
-
+
// guardNoRequest(selenium).click(a4jCommandBtn);
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
}
-
+
/**
* Boolean input, verify false
*/
public void verifyBooleanFalse() {
-
+
selenium.click(setCorrectBtn);
-
+
// checkBoolean to false
selenium.check(inputFormat.format(ID.assertFalse), (Boolean)
wrongValue.get(ID.assertFalse));
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.assertFalse)).text(messages.get(ID.assertFalse)));
}
-
+
/**
* Decimal input, verify from 2.5 to 9.688
*/
protected void verifyDecimalMinMax() {
-
+
selenium.click(setCorrectBtn);
-
+
// Decimal input
selenium.type(inputFormat.format(ID.decimalMinMax),
wrongValue.get(ID.decimalMinMax).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.decimalMinMax)).text(messages.get(ID.decimalMinMax)));
}
-
+
/**
* Decimal input, verify digits
*/
protected void verifyDecimalDigits() {
-
+
selenium.click(setCorrectBtn);
-
+
// decimal input digits
selenium.type(inputFormat.format(ID.digits),
wrongValue.get(ID.digits).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.decimalMinMax)).text(messages.get(ID.decimalMinMax)));
}
-
+
/**
* Integer input, verify max
*/
protected void verifyMax() {
-
+
selenium.click(setCorrectBtn);
-
+
// integer input max
selenium.type(inputFormat.format(ID.max), wrongValue.get(ID.max).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.max)).text(messages.get(ID.max)));
}
-
+
/**
* Integer input, verify min
*/
protected void verifyMin() {
-
+
selenium.click(setCorrectBtn);
-
+
// integer input min
selenium.type(inputFormat.format(ID.min), wrongValue.get(ID.min).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.min)).text(messages.get(ID.min)));
}
-
+
/**
* Integer input, verify min max
*/
protected void verifyMinMax() {
-
+
selenium.click(setCorrectBtn);
-
+
// integer input min and max
selenium.type(inputFormat.format(ID.minMax),
wrongValue.get(ID.minMax).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.minMax)).text(messages.get(ID.minMax)));
}
-
+
/**
* Integer input, verify not empty
*/
protected void verifyNotEmpty() {
-
+
selenium.click(setCorrectBtn);
-
+
// string input not empty
selenium.type(inputFormat.format(ID.notEmpty),
wrongValue.get(ID.notEmpty).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.notEmpty)).text(messages.get(ID.notEmpty)));
}
-
+
/**
* Integer input, verify not null
*/
protected void verifyNotNull() {
-
+
selenium.click(setCorrectBtn);
-
+
// string input not null
selenium.type(inputFormat.format(ID.notNull), "");
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.notNull)).text(messages.get(ID.notNull)));
}
-
+
/**
* Integer input, verify string pattern
*/
protected void verifyPattern() {
-
+
selenium.click(setCorrectBtn);
-
+
// string input custom pattern
selenium.type(inputFormat.format(ID.pattern),
wrongValue.get(ID.pattern).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.pattern)).text(messages.get(ID.pattern)));
}
-
+
/**
* Integer input, verify custom string
*/
protected void verifyCustom() {
-
+
selenium.click(setCorrectBtn);
-
+
// string input custom string
selenium.type(inputFormat.format(ID.custom),
wrongValue.get(ID.custom).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.custom)).text(messages.get(ID.custom)));
}
-
+
/**
* Integer input, verify regExp
*/
protected void verifyRegExp() {
-
+
selenium.click(setCorrectBtn);
-
+
// string input regExp pattern
selenium.type(inputFormat.format(ID.regexp),
wrongValue.get(ID.regexp).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.regexp)).text(messages.get(ID.regexp)));
}
-
+
/**
* Integer input, verify date in past
*/
protected void verifyDatePast() {
-
+
selenium.click(setCorrectBtn);
-
+
// date input past
selenium.type(inputFormat.format(ID.past), wrongValue.get(ID.past).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.past)).text(messages.get(ID.past)));
}
-
+
/**
* Integer input, verify date in future
*/
protected void verifyDateFuture() {
-
+
selenium.click(setCorrectBtn);
-
+
// date input future
selenium.type(inputFormat.format(ID.future),
wrongValue.get(ID.future).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.future)).text(messages.get(ID.future)));
}
-
+
/**
* Integer input, verify string size
*/
protected void verifyStringSize() {
-
+
selenium.click(setCorrectBtn);
-
+
// string input string size
selenium.type(inputFormat.format(ID.stringSize),
wrongValue.get(ID.stringSize).toString());
selenium.click(a4jCommandBtn);
-
+
waitGui.until(textEquals.locator(msgFormat.format(ID.stringSize)).text(messages.get(ID.stringSize)));
}
-
+
/**
* Integer input, verify selection size
*/
@IssueTracking(value = "https://issues.jboss.org/browse/RF-11035")
protected void verifySelectionSize() {
-
+
selenium.click(setCorrectBtn);
selenium.click(setWrongBtn);
-
+
// many checkBox input selection size
// selenium.type(inputFormat.format(ID.size),
wrongValue.get(ID.size).toString());
selenium.check(selectionItem.format(wrongValue.get(ID.size)), true);
-
+
selenium.click(a4jCommandBtn);
-
waitGui.until(textEquals.locator(msgFormat.format(ID.size)).text(messages.get(ID.size)));
}
-
+
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestWrappingValidatorSingle.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestWrappingValidatorSingle.java 2011-11-01
17:21:30 UTC (rev 22858)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestWrappingValidatorSingle.java 2011-11-01
17:29:15 UTC (rev 22859)
@@ -35,15 +35,14 @@
/**
* Selenium tests for page faces/components/richValidator/single.xhtml
*
- * Test no-request handling client side validation.
- * Validation for min is done by javax.validation.constraints.Min, and this should
completely
- * handle validation on client side.
- *
+ * Test no-request handling client side validation. Validation for min is done by
javax.validation.constraints.Min, and
+ * this should completely handle validation on client side.
+ *
* @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
* @version $Revision$
*/
public class TestWrappingValidatorSingle extends AbstractValidatorsTest {
-
+
private JQueryLocator input = pjq("input[id$=:min]");
private JQueryLocator setCorrectValBtn =
pjq("input[id$=setCorrectValuesButton]");
private JQueryLocator a4jSubmitBtn = pjq("input[id$=a4jButton]");
@@ -54,34 +53,34 @@
public URL getTestUrl() {
return URLUtils.buildUrl(contextPath,
"faces/components/richValidator/single.xhtml");
}
-
- @Test
+
+ @Test(groups = { "4.Future" })
@IssueTracking("https://issues.jboss.org/browse/RF-11576")
public void testIntegerMin() {
selenium.click(setCorrectValBtn);
-
+
// integer input min
selenium.type(input, "1");
guardNoRequest(selenium).click(a4jSubmitBtn);
-
+
waitGui.until(textEquals.locator(msg).text("must be greater than or equal to
2"));
}
-
+
/**
* Check validation on input after blur event fired and no XHR request as well
- *
+ *
*/
@Test
public void testValidateOnBlur() {
selenium.click(setCorrectValBtn);
-
+
// integer input min
- selenium.type(input , "1");
-
+ selenium.type(input, "1");
+
// no request (HTTP neither XHR) should be sent if validation fails
guardNoRequest(selenium).fireEvent(input, Event.BLUR);
-
+
waitModel.until(textEquals.locator(msg).text("must be greater than or equal
to 2"));
}
-
+
}