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/tests/metamer/ftest/richColumn/AbstractColumnModelTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/AbstractColumnSortingTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/TestColumnComparator.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/TestColumnSorting.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/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
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/AbstractColumnModelTest.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/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 <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class AbstractColumnModelTest extends AbstractMetamerTest {
+
+ JQueryLocator table = pjq("table.rf-dt[id$=richDataTable]");
+ JQueryLocator header = table.getChild(jq("thead.rf-dt-thd"));
+
+ JQueryLocator headerRow = header.getChild(jq("tr.rf-dt-hdr"));
+ JQueryLocator headerCell = jq("th.rf-dt-hdr-c");
+
+ JQueryLocator bodyRow =
table.getChild(jq("tbody.rf-dt-b")).getChild(jq("tr.rf-dt-r"));
+ JQueryLocator bodyCell = jq("td.rf-dt-c");
+
+ ColumnAttributes attributes = new ColumnAttributes();
+
+ List<Capital> capitals;
+
+ @BeforeMethod
+ public void prepareModel() {
+ capitals = Model.unmarshallCapitals();
+ }
+
+ public Capital getCapital(int index) {
+ String state = selenium.getText(bodyCell(index + 1, 1));
+ String name = selenium.getText(bodyCell(index + 1, 2));
+ Capital result = new Capital();
+ result.setName(name);
+ result.setState(state);
+ return result;
+ }
+
+ public JQueryLocator bodyCell(int row, int column) {
+ return
bodyRow.getNthChildElement(row).getChild(bodyCell).getNthChildElement(column);
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/AbstractColumnSortingTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/AbstractColumnSortingTest.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/AbstractColumnSortingTest.java 2011-01-13
14:42: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 <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class AbstractColumnSortingTest extends AbstractColumnModelTest {
+
+ @Inject
+ @Use(enumeration = true)
+ SortOrder sortOrder;
+
+ @Test
+ public void testSortingWithSortOrder() {
+ attributes.setRequestType(RequestType.XHR);
+ attributes.setSortOrder(sortOrder);
+
+ switch (sortOrder) {
+ case ascending:
+ Collections.sort(capitals, RichColumnBean.STATE_NAME_LENGTH_COMPARATOR);
+ break;
+ case descending:
+ Collections.sort(capitals,
Collections.reverseOrder(RichColumnBean.STATE_NAME_LENGTH_COMPARATOR));
+ break;
+ }
+
+ for (int i = 0; i < capitals.size(); i++) {
+ Capital actualCapital = getCapital(i);
+ Capital expectedCapital = capitals.get(i);
+
+ assertEquals(actualCapital.getName(), expectedCapital.getName());
+ assertEquals(actualCapital.getState(), expectedCapital.getState());
+ }
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/TestColumnComparator.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/TestColumnComparator.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/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 <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+@Test
+public class TestColumnComparator extends AbstractColumnSortingTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richColumn/comparator.xhtml");
+ }
+}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/TestColumnSimple.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/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/tests/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 <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class TestColumnSimple extends AbstractMetamerTest {
+public class TestColumnSimple extends AbstractColumnModelTest {
- ColumnAttributes attributes = new ColumnAttributes();
-
- JQueryLocator table = pjq("table.rf-dt[id$=richDataTable]");
- JQueryLocator header = table.getChild(jq("thead.rf-dt-thd"));
-
- JQueryLocator headerRow = header.getChild(jq("tr.rf-dt-hdr"));
- JQueryLocator headerCell = jq("th.rf-dt-hdr-c");
-
- JQueryLocator bodyRow =
table.getChild(jq("tbody.rf-dt-b")).getChild(jq("tr.rf-dt-r"));
- JQueryLocator bodyCell = jq("td.rf-dt-c");
-
@Override
public URL getTestUrl() {
return buildUrl(contextPath,
"faces/components/richColumn/simple.xhtml");
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/TestColumnSorting.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/TestColumnSorting.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/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 <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+@Test
+public class TestColumnSorting extends AbstractColumnSortingTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richColumn/sorting.xhtml");
+ }
+}