From richfaces-svn-commits at lists.jboss.org Tue Nov 1 13:29:16 2011 Content-Type: multipart/mixed; boundary="===============4034524294806475043==" MIME-Version: 1.0 From: richfaces-svn-commits at lists.jboss.org To: richfaces-svn-commits at lists.jboss.org Subject: [richfaces-svn-commits] JBoss Rich Faces SVN: r22859 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator. Date: Tue, 01 Nov 2011 13:29:15 -0400 Message-ID: <201111011729.pA1HTFvk012042@svn01.web.mwc.hst.phx2.redhat.com> --===============4034524294806475043== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/tes= ts/metamer/ftest/richValidator/AbstractValidatorsTest.java modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richValidator/TestWrappingValidatorSingle.java Log: tests for rich:validator fixed Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfa= ces/tests/metamer/ftest/richValidator/AbstractValidatorsTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richValidator/AbstractValidatorsTest.java 2011-11-01 17:2= 1:30 UTC (rev 22858) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richValidator/AbstractValidatorsTest.java 2011-11-01 17:2= 9:15 UTC (rev 22859) @@ -33,48 +33,57 @@ = /** * Abstract class with selenium test for validators - * + * = * @author Jan Jamrich * @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 messages =3D new HashMap(); - = private Map wrongValue =3D new HashMap(); - = private JQueryLocator inputFormat =3D pjq("input[id$=3D:{0}]"); - = private JQueryLocator setWrongBtn =3D pjq("input[id$=3DsetWrongValuesB= utton]"); private JQueryLocator setCorrectBtn =3D pjq("input[id$=3DsetCorrectVal= uesButton]"); - = private JQueryLocator hCommandBtn =3D pjq("input[id$=3DhButton]"); private JQueryLocator a4jCommandBtn =3D pjq("input[id$=3Da4jButton]"); - = private JQueryLocator selectionItem =3D pjq("table[id$=3D:size] tr > t= d > input[value=3D{0}]"); - = private JQueryLocator msgFormat =3D pjq("span[id$=3D{0}Msg] span.rf-ms= g-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 =3D new SimpleDateFormat("dd MMM yyyy"); long offset =3D 24 * 60 * 60 * 1000; // more than 24 hours to get = correct past date wrongValue.put(ID.past, sdf.format(new Date(System.currentTimeMill= is() + offset))); wrongValue.put(ID.future, sdf.format(new Date(System.currentTimeMi= llis() - 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)).tex= t(messages.get(ID.notNull))); waitGui.until(textEquals.locator(msgFormat.format(ID.pattern)).tex= t(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 manyC= heckbox validation // waitGui.until(textEquals.locator(msgFormat.format(ID.size)).tex= t(messages.get(ID.size))); } - = + @IssueTracking(value =3D "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(m= essages.get(ID.size))); } - = + /** * Boolean input, verify true */ public void verifyBooleanTrue() { - = + selenium.click(setCorrectBtn); - = + // checkBoolean to true selenium.check(inputFormat.format(ID.assertTrue), (Boolean) wrongV= alue.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) wrong= Value.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.dig= its).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).t= oString()); selenium.click(a4jCommandBtn); - = + waitGui.until(textEquals.locator(msgFormat.format(ID.max)).text(me= ssages.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).t= oString()); selenium.click(a4jCommandBtn); - = + waitGui.until(textEquals.locator(msgFormat.format(ID.min)).text(me= ssages.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.min= Max).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.n= otEmpty).toString()); selenium.click(a4jCommandBtn); - = + waitGui.until(textEquals.locator(msgFormat.format(ID.notEmpty)).te= xt(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)).tex= t(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.pa= ttern).toString()); selenium.click(a4jCommandBtn); - = + waitGui.until(textEquals.locator(msgFormat.format(ID.pattern)).tex= t(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.cus= tom).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.reg= exp).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(m= essages.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.fut= ure).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 =3D "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.si= ze).toString()); selenium.check(selectionItem.format(wrongValue.get(ID.size)), true= ); - = + selenium.click(a4jCommandBtn); - = waitGui.until(textEquals.locator(msgFormat.format(ID.size)).text(m= essages.get(ID.size))); } - = + } Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfa= ces/tests/metamer/ftest/richValidator/TestWrappingValidatorSingle.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/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/te= sts/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 thi= s 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 Jan Jamrich * @version $Revision$ */ public class TestWrappingValidatorSingle extends AbstractValidatorsTest { - = + private JQueryLocator input =3D pjq("input[id$=3D:min]"); private JQueryLocator setCorrectValBtn =3D pjq("input[id$=3DsetCorrect= ValuesButton]"); private JQueryLocator a4jSubmitBtn =3D pjq("input[id$=3Da4jButton]"); @@ -54,34 +53,34 @@ public URL getTestUrl() { return URLUtils.buildUrl(contextPath, "faces/components/richValida= tor/single.xhtml"); } - = - @Test + + @Test(groups =3D { "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 o= r 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")); } - = + } --===============4034524294806475043==--