From richfaces-svn-commits at lists.jboss.org Thu Jan 13 09:42:01 2011 Content-Type: multipart/mixed; boundary="===============3569676072359096718==" 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: r20988 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn. Date: Thu, 13 Jan 2011 09:42:00 -0500 Message-ID: <201101131442.p0DEg0G3005983@svn01.web.mwc.hst.phx2.redhat.com> --===============3569676072359096718== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: lfryc(a)redhat.com Date: 2011-01-13 09:42:00 -0500 (Thu, 13 Jan 2011) New Revision: 20988 Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richColumn/AbstractColumnModelTest.java modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richColumn/AbstractColumnSortingTest.java modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richColumn/TestColumnComparator.java modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richColumn/TestColumnSorting.java Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richColumn/TestColumnSimple.java Log: rich:column - Sorting and Comparator samples automated (RFPL-729) Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces= /tests/metamer/ftest/richColumn/AbstractColumnModelTest.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/richColumn/AbstractColumnModelTest.java = (rev 0) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richColumn/AbstractColumnModelTest.java 2011-01-13 14:42:= 00 UTC (rev 20988) @@ -0,0 +1,70 @@ +/*************************************************************************= ****** + * 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.richColumn; + +import static org.jboss.test.selenium.locator.LocatorFactory.jq; + +import java.util.List; + +import org.jboss.test.selenium.locator.JQueryLocator; +import org.richfaces.tests.metamer.bean.Model; +import org.richfaces.tests.metamer.ftest.AbstractMetamerTest; +import org.richfaces.tests.metamer.model.Capital; +import org.testng.annotations.BeforeMethod; + +/** + * @author Lukas Fryc + * @version $Revision$ + */ +public abstract class AbstractColumnModelTest extends AbstractMetamerTest { + + JQueryLocator table =3D pjq("table.rf-dt[id$=3DrichDataTable]"); + JQueryLocator header =3D table.getChild(jq("thead.rf-dt-thd")); + + JQueryLocator headerRow =3D header.getChild(jq("tr.rf-dt-hdr")); + JQueryLocator headerCell =3D jq("th.rf-dt-hdr-c"); + + JQueryLocator bodyRow =3D table.getChild(jq("tbody.rf-dt-b")).getChild= (jq("tr.rf-dt-r")); + JQueryLocator bodyCell =3D jq("td.rf-dt-c"); + + ColumnAttributes attributes =3D new ColumnAttributes(); + + List capitals; + + @BeforeMethod + public void prepareModel() { + capitals =3D Model.unmarshallCapitals(); + } + + public Capital getCapital(int index) { + String state =3D selenium.getText(bodyCell(index + 1, 1)); + String name =3D selenium.getText(bodyCell(index + 1, 2)); + Capital result =3D new Capital(); + result.setName(name); + result.setState(state); + return result; + } + + public JQueryLocator bodyCell(int row, int column) { + return bodyRow.getNthChildElement(row).getChild(bodyCell).getNthCh= ildElement(column); + } +} Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces= /tests/metamer/ftest/richColumn/AbstractColumnSortingTest.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/richColumn/AbstractColumnSortingTest.java = (rev 0) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richColumn/AbstractColumnSortingTest.java 2011-01-13 14:4= 2:00 UTC (rev 20988) @@ -0,0 +1,68 @@ +/*************************************************************************= ****** + * 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.richColumn; + +import static org.testng.Assert.assertEquals; + +import java.util.Collections; + +import org.jboss.test.selenium.request.RequestType; +import org.richfaces.component.SortOrder; +import org.richfaces.tests.metamer.bean.RichColumnBean; +import org.richfaces.tests.metamer.ftest.annotations.Inject; +import org.richfaces.tests.metamer.ftest.annotations.Use; +import org.richfaces.tests.metamer.model.Capital; +import org.testng.annotations.Test; + +/** + * @author Lukas Fryc + * @version $Revision$ + */ +public abstract class AbstractColumnSortingTest extends AbstractColumnMode= lTest { + + @Inject + @Use(enumeration =3D true) + SortOrder sortOrder; + + @Test + public void testSortingWithSortOrder() { + attributes.setRequestType(RequestType.XHR); + attributes.setSortOrder(sortOrder); + + switch (sortOrder) { + case ascending: + Collections.sort(capitals, RichColumnBean.STATE_NAME_LENGT= H_COMPARATOR); + break; + case descending: + Collections.sort(capitals, Collections.reverseOrder(RichCo= lumnBean.STATE_NAME_LENGTH_COMPARATOR)); + break; + } + + for (int i =3D 0; i < capitals.size(); i++) { + Capital actualCapital =3D getCapital(i); + Capital expectedCapital =3D capitals.get(i); + + assertEquals(actualCapital.getName(), expectedCapital.getName(= )); + assertEquals(actualCapital.getState(), expectedCapital.getStat= e()); + } + } +} Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces= /tests/metamer/ftest/richColumn/TestColumnComparator.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/richColumn/TestColumnComparator.java = (rev 0) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richColumn/TestColumnComparator.java 2011-01-13 14:42:00 = UTC (rev 20988) @@ -0,0 +1,41 @@ +/*************************************************************************= ****** + * 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.richColumn; + +import static org.jboss.test.selenium.utils.URLUtils.buildUrl; + +import java.net.URL; + +import org.testng.annotations.Test; + +/** + * @author Lukas Fryc + * @version $Revision$ + */ +(a)Test +public class TestColumnComparator extends AbstractColumnSortingTest { + + @Override + public URL getTestUrl() { + return buildUrl(contextPath, "faces/components/richColumn/comparat= or.xhtml"); + } +} Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfa= ces/tests/metamer/ftest/richColumn/TestColumnSimple.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/richColumn/TestColumnSimple.java 2011-01-13 14:40:51 UTC = (rev 20987) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richColumn/TestColumnSimple.java 2011-01-13 14:42:00 UTC = (rev 20988) @@ -23,14 +23,12 @@ = import static org.jboss.test.selenium.locator.Attribute.COLSPAN; import static org.jboss.test.selenium.locator.Attribute.ROWSPAN; -import static org.jboss.test.selenium.locator.LocatorFactory.jq; import static org.jboss.test.selenium.utils.URLUtils.buildUrl; import static org.testng.Assert.assertEquals; = import java.net.URL; = import org.jboss.test.selenium.locator.JQueryLocator; -import org.richfaces.tests.metamer.ftest.AbstractMetamerTest; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = @@ -38,19 +36,8 @@ * @author Lukas Fryc * @version $Revision$ */ -public class TestColumnSimple extends AbstractMetamerTest { +public class TestColumnSimple extends AbstractColumnModelTest { = - ColumnAttributes attributes =3D new ColumnAttributes(); - - JQueryLocator table =3D pjq("table.rf-dt[id$=3DrichDataTable]"); - JQueryLocator header =3D table.getChild(jq("thead.rf-dt-thd")); - - JQueryLocator headerRow =3D header.getChild(jq("tr.rf-dt-hdr")); - JQueryLocator headerCell =3D jq("th.rf-dt-hdr-c"); - - JQueryLocator bodyRow =3D table.getChild(jq("tbody.rf-dt-b")).getChild= (jq("tr.rf-dt-r")); - JQueryLocator bodyCell =3D jq("td.rf-dt-c"); - @Override public URL getTestUrl() { return buildUrl(contextPath, "faces/components/richColumn/simple.x= html"); Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces= /tests/metamer/ftest/richColumn/TestColumnSorting.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/richColumn/TestColumnSorting.java = (rev 0) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richColumn/TestColumnSorting.java 2011-01-13 14:42:00 UTC= (rev 20988) @@ -0,0 +1,41 @@ +/*************************************************************************= ****** + * 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.richColumn; + +import static org.jboss.test.selenium.utils.URLUtils.buildUrl; + +import java.net.URL; + +import org.testng.annotations.Test; + +/** + * @author Lukas Fryc + * @version $Revision$ + */ +(a)Test +public class TestColumnSorting extends AbstractColumnSortingTest { + + @Override + public URL getTestUrl() { + return buildUrl(contextPath, "faces/components/richColumn/sorting.= xhtml"); + } +} --===============3569676072359096718==--