[richfaces-svn-commits] JBoss Rich Faces SVN: r18571 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed Aug 11 17:14:26 EDT 2010


Author: lfryc at redhat.com
Date: 2010-08-11 17:14:25 -0400 (Wed, 11 Aug 2010)
New Revision: 18571

Added:
   modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/AbstractDataGridTest.java
   modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestPagination.java
Modified:
   modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestSimple.java
Log:
derived AbstractDataGridTest, created stub for TestPagination (RFPL-672)

Copied: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/AbstractDataGridTest.java (from rev 18570, modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestSimple.java)
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/AbstractDataGridTest.java	                        (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/AbstractDataGridTest.java	2010-08-11 21:14:25 UTC (rev 18571)
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * 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.richDataGrid;
+
+import static java.lang.Math.ceil;
+import static java.lang.Math.max;
+import static java.lang.Math.min;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.JAXBException;
+
+import org.jboss.test.selenium.locator.ElementLocator;
+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.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.model.DataGrid;
+import org.richfaces.tests.metamer.model.Capital;
+import org.testng.annotations.BeforeMethod;
+
+/**
+ * @author <a href="mailto:lfryc at redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class AbstractDataGridTest extends AbstractMetamerTest {
+
+    protected static final int ELEMENTS_TOTAL = 50;
+
+    List<Capital> capitals;
+
+    JQueryLocator attributeColumns = pjq("input[id$=columnsInput]");
+    JQueryLocator attributeElements = pjq("input[id$=elementsInput]");
+    JQueryLocator attributeFirst = pjq("input[id$=firstInput]");
+
+    DataGrid dataGrid = new DataGrid(jq("table.rf-dg[id$=richDataGrid]"));
+
+    @Inject
+    @Use(ints = { 3 })
+    Integer columns;
+
+    @Inject
+    @Use(empty = true)
+    Integer elements;
+
+    @Inject
+    @Use(empty = true)
+    Integer first;
+
+    @SuppressWarnings("restriction")
+    public AbstractDataGridTest() throws JAXBException {
+        capitals = Model.unmarshallCapitals();
+    }
+
+    @BeforeMethod
+    public void prepareAttributes() {
+        prepareAttribute(attributeColumns, columns);
+        prepareAttribute(attributeElements, elements);
+        prepareAttribute(attributeFirst, first);
+    }
+
+    private void prepareAttribute(ElementLocator<?> inputLocator, Object value) {
+        String v = value == null ? "" : value.toString();
+        guardHttp(selenium).type(inputLocator, v);
+    }
+
+    protected void verifyCounts() {
+        int nFirst = first == null ? 0 : min(ELEMENTS_TOTAL, max(0, first));
+        int nElements = (elements == null ? ELEMENTS_TOTAL : min(elements, ELEMENTS_TOTAL)) - nFirst;
+        int nColumns = columns;
+        double nRows = ceil((float) nElements / columns);
+
+        assertEquals(dataGrid.getElementCount(), (int) nElements);
+        assertEquals(dataGrid.getColumnCount(), (int) nColumns);
+        assertEquals(dataGrid.getRowCount(), (int) nRows);
+    }
+
+    protected void verifyElements() {
+        int nFirst = first == null ? 0 : min(ELEMENTS_TOTAL, max(0, first));
+        int nElements = (elements == null ? ELEMENTS_TOTAL : min(elements, ELEMENTS_TOTAL)) - nFirst;
+
+        Iterator<Capital> capitalIterator = capitals.subList(nFirst, nFirst + nElements).iterator();
+        Iterator<JQueryLocator> elementIterator = dataGrid.iterateElements();
+
+        while (capitalIterator.hasNext()) {
+            final Capital capital = capitalIterator.next();
+            if (!elementIterator.hasNext()) {
+                fail("there should be next element for state name: " + capital.getState());
+            }
+            final JQueryLocator element = elementIterator.next().getChild(jq("span"));
+            assertEquals(selenium.getText(element), capital.getState());
+        }
+    }
+}

Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestPagination.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestPagination.java	                        (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestPagination.java	2010-08-11 21:14:25 UTC (rev 18571)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.richDataGrid;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import javax.xml.bind.JAXBException;
+
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc at redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+ at Use(field = "elements", ints = { 7 })
+public class TestPagination extends AbstractDataGridTest {
+
+    public TestPagination() throws JAXBException {
+        super();
+    }
+
+    @Override
+    public URL getTestUrl() {
+        return buildUrl(contextPath, "faces/components/richDataGrid/scroller.xhtml");
+    }
+
+    @Test
+    public void testPagination() {
+        
+    }
+}
\ No newline at end of file

Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestSimple.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestSimple.java	2010-08-11 21:13:47 UTC (rev 18570)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestSimple.java	2010-08-11 21:14:25 UTC (rev 18571)
@@ -21,63 +21,23 @@
  *******************************************************************************/
 package org.richfaces.tests.metamer.ftest.richDataGrid;
 
-import static java.lang.Math.ceil;
-import static java.lang.Math.max;
-import static java.lang.Math.min;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
-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 static org.testng.Assert.fail;
 
 import java.net.URL;
-import java.util.Iterator;
-import java.util.List;
 
 import javax.xml.bind.JAXBException;
 
-import org.jboss.test.selenium.locator.ElementLocator;
-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.ftest.annotations.Inject;
 import org.richfaces.tests.metamer.ftest.annotations.Use;
-import org.richfaces.tests.metamer.ftest.model.DataGrid;
-import org.richfaces.tests.metamer.model.Capital;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 /**
  * @author <a href="mailto:lfryc at redhat.com">Lukas Fryc</a>
  * @version $Revision$
  */
-public class TestSimple extends AbstractMetamerTest {
+public class TestSimple extends AbstractDataGridTest {
 
-    private static final int ELEMENTS_TOTAL = 50;
-
-    List<Capital> capitals;
-
-    JQueryLocator attributeColumns = pjq("input[id$=columnsInput]");
-    JQueryLocator attributeElements = pjq("input[id$=elementsInput]");
-    JQueryLocator attributeFirst = pjq("input[id$=firstInput]");
-
-    DataGrid dataGrid = new DataGrid(jq("table.rf-dg[id$=richDataGrid]"));
-
-    @Inject
-    @Use(ints = { 3 })
-    Integer columns;
-
-    @Inject
-    @Use(empty = true)
-    Integer elements;
-
-    @Inject
-    @Use(empty = true)
-    Integer first;
-
-    @SuppressWarnings("restriction")
     public TestSimple() throws JAXBException {
-        capitals = Model.unmarshallCapitals();
+        super();
     }
 
     @Override
@@ -85,18 +45,6 @@
         return buildUrl(contextPath, "faces/components/richDataGrid/simple.xhtml");
     }
 
-    @BeforeMethod
-    public void prepareAttributes() {
-        prepareAttribute(attributeColumns, columns);
-        prepareAttribute(attributeElements, elements);
-        prepareAttribute(attributeFirst, first);
-    }
-
-    private void prepareAttribute(ElementLocator<?> inputLocator, Object value) {
-        String v = value == null ? "" : value.toString();
-        guardHttp(selenium).type(inputLocator, v);
-    }
-
     @Test
     @Use(field = "columns", ints = { 1, 3, 11, ELEMENTS_TOTAL / 2, ELEMENTS_TOTAL - 1, ELEMENTS_TOTAL,
         ELEMENTS_TOTAL + 1 })
@@ -118,32 +66,4 @@
         verifyCounts();
         verifyElements();
     }
-
-    private void verifyCounts() {
-        int nFirst = first == null ? 0 : min(ELEMENTS_TOTAL, max(0, first));
-        int nElements = (elements == null ? ELEMENTS_TOTAL : min(elements, ELEMENTS_TOTAL)) - nFirst;
-        int nColumns = columns;
-        double nRows = ceil((float) nElements / columns);
-
-        assertEquals(dataGrid.getElementCount(), (int) nElements);
-        assertEquals(dataGrid.getColumnCount(), (int) nColumns);
-        assertEquals(dataGrid.getRowCount(), (int) nRows);
-    }
-
-    private void verifyElements() {
-        int nFirst = first == null ? 0 : min(ELEMENTS_TOTAL, max(0, first));
-        int nElements = (elements == null ? ELEMENTS_TOTAL : min(elements, ELEMENTS_TOTAL)) - nFirst;
-
-        Iterator<Capital> capitalIterator = capitals.subList(nFirst, nFirst + nElements).iterator();
-        Iterator<JQueryLocator> elementIterator = dataGrid.iterateElements();
-
-        while (capitalIterator.hasNext()) {
-            final Capital capital = capitalIterator.next();
-            if (!elementIterator.hasNext()) {
-                fail("there should be next element for state name: " + capital.getState());
-            }
-            final JQueryLocator element = elementIterator.next().getChild(jq("span"));
-            assertEquals(selenium.getText(element), capital.getState());
-        }
-    }
 }



More information about the richfaces-svn-commits mailing list