From richfaces-svn-commits at lists.jboss.org Tue May 24 08:48:36 2011 Content-Type: multipart/mixed; boundary="===============2244848094046271109==" 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: r22508 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: richInplaceInput and 1 other directory. Date: Tue, 24 May 2011 08:48:36 -0400 Message-ID: <201105241248.p4OCmaSA007333@svn01.web.mwc.hst.phx2.redhat.com> --===============2244848094046271109== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jjamrich Date: 2011-05-24 08:48:35 -0400 (Tue, 24 May 2011) New Revision: 22508 Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richAutocomplete/TestAutocompleteWithJSR303.java modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richAutocomplete/TestComponentWithJSR303.java modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richInplaceInput/TestInplaceInputWithJSR303.java Log: RFPL-1421: add selenium tests for autocomplete a inplaceInput Cover JSR-303 validations for autocomplete and inplaceInput components by selenium tests Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces= /tests/metamer/ftest/richAutocomplete/TestAutocompleteWithJSR303.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/richAutocomplete/TestAutocompleteWithJSR303.java = (rev 0) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richAutocomplete/TestAutocompleteWithJSR303.java 2011-05-= 24 12:48:35 UTC (rev 22508) @@ -0,0 +1,72 @@ +/*************************************************************************= ****** + * 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.richAutocomplete; + +import java.net.URL; + +import org.jboss.test.selenium.utils.URLUtils; +import org.testng.annotations.Test; + +/** + * Test for page faces/components/richAutocomplete/jsr303.xhtml + * + * @author Jan Jamrich + * @version $Revision$ + */ +public class TestAutocompleteWithJSR303 extends TestComponentWithJSR303 { + + @Override + public URL getTestUrl() { + return URLUtils.buildUrl(contextPath, "faces/components/richAutoco= mplete/jsr303.xhtml"); + } + = + @Test + public void testNotEmpty() { + verifyNotEmpty(); + } + = + @Test + public void testRegExpPattern() { + verifyRegExpPattern(); + } + = + @Test + public void testStringSize() { + verifyStringSize(); + } + = + @Test + public void testCustomString() { + verifyCustomString(); + } + = + @Test = + public void testAllInputsWrong() { + verifyAllInputsWrong(); + } + = + @Test + public void testAllInputsCorrect() { + verifyAllInputsCorrect(); + } + = +} Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces= /tests/metamer/ftest/richAutocomplete/TestComponentWithJSR303.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/richAutocomplete/TestComponentWithJSR303.java = (rev 0) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richAutocomplete/TestComponentWithJSR303.java 2011-05-24 = 12:48:35 UTC (rev 22508) @@ -0,0 +1,205 @@ +/*************************************************************************= ****** + * 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.richAutocomplete; + +import static org.jboss.test.selenium.locator.LocatorFactory.jq; + +import org.jboss.test.selenium.dom.Event; +import org.jboss.test.selenium.locator.JQueryLocator; +import org.richfaces.tests.metamer.ftest.AbstractMetamerTest; + +/** + * Test for component with JSF-303 validators + * = + * @author Jan Jamrich + * @version $Revision$ + */ +public abstract class TestComponentWithJSR303 extends AbstractMetamerTest { + = + private static final String NOT_EMPTY_VALIDATION_MSG =3D "may not be e= mpty"; + private static final String CORRECT_NOT_EMPTY =3D "xyz"; + = + private static final String WRONG_REG_EXP =3D "1a^"; + private static final String CORRECT_REG_EXP =3D "a2^E"; + private static final String REGEXP_VALIDATION_MSG =3D "must match \"[a= -z].*\""; + = + = + private static final String WRONG_STRING_SIZE =3D "x"; + private static final String CORRECT_STRING_SIZE =3D "abc3"; + private static final String STRING_SIZE_VALIDATION_MSG =3D "size must = be between 3 and 6"; + = + private static final String WRONG_CUSTOM_STRING =3D "rich faces"; + private static final String CORRECT_CUSTOM_STRING =3D "RichFaces"; + private static final String CUSTOM_STRING_VALIDATION_MSG =3D "string i= s not \"RichFaces\""; + = + private JQueryLocator notEmptyInput =3D pjq("input[id$=3D:input1Input]= "); + private JQueryLocator regExpPatternInput =3D pjq("input[id$=3D:input2I= nput]"); + private JQueryLocator stringSizeInput =3D pjq("input[id$=3D:input3Inpu= t]"); + private JQueryLocator customStringInput =3D pjq("input[id$=3D:input4In= put]"); + = + private JQueryLocator hCommandButton =3D pjq("input[id$=3D:hButton]"); + private JQueryLocator a4jCommandButton =3D pjq("input[id$=3D:a4jButton= ]"); + = + private JQueryLocator output1 =3D pjq("span[id$=3D:output1]"); + private JQueryLocator output2 =3D pjq("span[id$=3D:output2]"); + private JQueryLocator output3 =3D pjq("span[id$=3D:output3]"); + private JQueryLocator output4 =3D pjq("span[id$=3D:output4]"); + = + private JQueryLocator input1Msg =3D pjq("span.rf-msg-err[id$=3D:input1= ]"); + private JQueryLocator input2Msg =3D pjq("span.rf-msg-err[id$=3D:input2= ]"); + private JQueryLocator input3Msg =3D pjq("span.rf-msg-err[id$=3D:input3= ]"); + private JQueryLocator input4Msg =3D pjq("span.rf-msg-err[id$=3D:input4= ]"); + + protected void verifyNotEmpty() { + setAllCorrect(false); + selenium.type(notEmptyInput, ""); = + selenium.click(a4jCommandButton); = + = + waitGui.until(textEquals.locator(input1Msg.getChild(jq("span.rf-ms= g-det"))).text(NOT_EMPTY_VALIDATION_MSG)); + = + setAllCorrect(false); + selenium.type(notEmptyInput, ""); + selenium.click(hCommandButton); + selenium.waitForPageToLoad(); + = + waitGui.until(textEquals.locator(input1Msg.getChild(jq("span.rf-ms= g-det"))).text(NOT_EMPTY_VALIDATION_MSG)); + } + = + protected void verifyRegExpPattern() { + = + setAllCorrect(false); + selenium.type(regExpPatternInput, WRONG_REG_EXP); = + selenium.click(a4jCommandButton); = + = + waitGui.until(textEquals.locator(input2Msg.getChild(jq("span.rf-ms= g-det"))).text(REGEXP_VALIDATION_MSG)); + = + setAllCorrect(false); + selenium.type(regExpPatternInput, WRONG_REG_EXP); + selenium.click(hCommandButton); + selenium.waitForPageToLoad(); + = + waitGui.until(textEquals.locator(input2Msg.getChild(jq("span.rf-ms= g-det"))).text(REGEXP_VALIDATION_MSG)); + } + = + protected void verifyStringSize() { + setAllCorrect(false); + selenium.type(stringSizeInput, WRONG_STRING_SIZE); = + selenium.click(a4jCommandButton); = + = + waitGui.until(textEquals.locator(input3Msg.getChild(jq("span.rf-ms= g-det"))).text(STRING_SIZE_VALIDATION_MSG)); + = + setAllCorrect(false); + selenium.type(stringSizeInput, WRONG_STRING_SIZE); + selenium.click(hCommandButton); + selenium.waitForPageToLoad(); + = + waitGui.until(textEquals.locator(input3Msg.getChild(jq("span.rf-ms= g-det"))).text(STRING_SIZE_VALIDATION_MSG)); + } + = + protected void verifyCustomString() { + setAllCorrect(false); + selenium.type(customStringInput, WRONG_CUSTOM_STRING); = + selenium.click(a4jCommandButton); = + = + waitGui.until(textEquals.locator(input4Msg.getChild(jq("span.rf-ms= g-det"))).text(CUSTOM_STRING_VALIDATION_MSG)); + = + setAllCorrect(false); + selenium.type(customStringInput, WRONG_CUSTOM_STRING); + selenium.click(hCommandButton); + selenium.waitForPageToLoad(); + = + waitGui.until(textEquals.locator(input4Msg.getChild(jq("span.rf-ms= g-det"))).text(CUSTOM_STRING_VALIDATION_MSG)); + } + = + protected void verifyAllInputsWrong() { + setAllWrong(false); + selenium.click(a4jCommandButton); + = + waitGui.until(textEquals.locator(input1Msg.getChild(jq("span.rf-ms= g-det"))).text(NOT_EMPTY_VALIDATION_MSG)); + waitGui.until(textEquals.locator(input2Msg.getChild(jq("span.rf-ms= g-det"))).text(REGEXP_VALIDATION_MSG)); + waitGui.until(textEquals.locator(input3Msg.getChild(jq("span.rf-ms= g-det"))).text(STRING_SIZE_VALIDATION_MSG)); + waitGui.until(textEquals.locator(input4Msg.getChild(jq("span.rf-ms= g-det"))).text(CUSTOM_STRING_VALIDATION_MSG)); + = + setAllCorrect(false); + setAllWrong(false); + selenium.click(hCommandButton); + selenium.waitForPageToLoad(); + = + waitGui.until(textEquals.locator(input1Msg.getChild(jq("span.rf-ms= g-det"))).text(NOT_EMPTY_VALIDATION_MSG)); + waitGui.until(textEquals.locator(input2Msg.getChild(jq("span.rf-ms= g-det"))).text(REGEXP_VALIDATION_MSG)); + waitGui.until(textEquals.locator(input3Msg.getChild(jq("span.rf-ms= g-det"))).text(STRING_SIZE_VALIDATION_MSG)); + waitGui.until(textEquals.locator(input4Msg.getChild(jq("span.rf-ms= g-det"))).text(CUSTOM_STRING_VALIDATION_MSG)); + = + } + = + protected void verifyAllInputsCorrect() { + = + // with full form submit + setAllWrong(true); + setAllCorrect(false); + selenium.click(hCommandButton); + selenium.waitForPageToLoad(); + = + waitGui.until(textEquals.locator(output1).text(CORRECT_NOT_EMPTY)); + waitGui.until(textEquals.locator(output2).text(CORRECT_REG_EXP)); + waitGui.until(textEquals.locator(output3).text(CORRECT_STRING_SIZE= )); + waitGui.until(textEquals.locator(output4).text(CORRECT_CUSTOM_STRI= NG)); + = + // with ajax (no need click a4j:commandButton) = + setAllWrong(true); + setAllCorrect(true); + = + waitGui.until(textEquals.locator(output1).text(CORRECT_NOT_EMPTY)); + waitGui.until(textEquals.locator(output2).text(CORRECT_REG_EXP)); + waitGui.until(textEquals.locator(output3).text(CORRECT_STRING_SIZE= )); + waitGui.until(textEquals.locator(output4).text(CORRECT_CUSTOM_STRI= NG)); + } + = + private void setAllWrong(boolean withBlur) { + selenium.type(notEmptyInput, ""); + if (withBlur) { selenium.fireEvent(notEmptyInput, Event.BLUR); } + = + selenium.type(regExpPatternInput, WRONG_REG_EXP); + if (withBlur) { selenium.fireEvent(regExpPatternInput, Event.BLUR)= ; } + = + selenium.type(stringSizeInput, WRONG_STRING_SIZE); + if (withBlur) { selenium.fireEvent(stringSizeInput, Event.BLUR); } + = + selenium.type(customStringInput, WRONG_CUSTOM_STRING); + if (withBlur) { selenium.fireEvent(customStringInput, Event.BLUR);= } + } + = + private void setAllCorrect(boolean withBlur) { + selenium.type(notEmptyInput, CORRECT_NOT_EMPTY); + if (withBlur) { selenium.fireEvent(notEmptyInput, Event.BLUR); } + = + selenium.type(regExpPatternInput, CORRECT_REG_EXP); + if (withBlur) { selenium.fireEvent(regExpPatternInput, Event.BLUR)= ; } + = + selenium.type(stringSizeInput, CORRECT_STRING_SIZE); + if (withBlur) { selenium.fireEvent(stringSizeInput, Event.BLUR); } + = + selenium.type(customStringInput, CORRECT_CUSTOM_STRING); + if (withBlur) { selenium.fireEvent(customStringInput, Event.BLUR);= } + } + +} Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces= /tests/metamer/ftest/richInplaceInput/TestInplaceInputWithJSR303.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/richInplaceInput/TestInplaceInputWithJSR303.java = (rev 0) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richInplaceInput/TestInplaceInputWithJSR303.java 2011-05-= 24 12:48:35 UTC (rev 22508) @@ -0,0 +1,72 @@ +/*************************************************************************= ****** + * 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.richInplaceInput; + +import java.net.URL; +import org.richfaces.tests.metamer.ftest.richAutocomplete.TestComponentWit= hJSR303; +import org.jboss.test.selenium.utils.URLUtils; +import org.testng.annotations.Test; + +/** + * Test for page faces/components/richInplaceInput/jsr303.xhtml + * + * @author Jan Jamrich + * @version $Revision$ + */ +public class TestInplaceInputWithJSR303 extends TestComponentWithJSR303 { + + @Override + public URL getTestUrl() { + return URLUtils.buildUrl(contextPath, "faces/components/richInplac= eInput/jsr303.xhtml"); + } + = + @Test + public void testNotEmpty() { + verifyNotEmpty(); + } + = + @Test + public void testRegExpPattern() { + verifyRegExpPattern(); + } + = + @Test + public void testStringSize() { + verifyStringSize(); + } + = + @Test + public void testCustomString() { + verifyCustomString(); + } + = + @Test = + public void testAllInputsWrong() { + verifyAllInputsWrong(); + } + = + @Test + public void testAllInputsCorrect() { + verifyAllInputsCorrect(); + } + +} --===============2244848094046271109==--