[richfaces-svn-commits] JBoss Rich Faces SVN: r15887 - in branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test: java/org/jboss/richfaces/integrationTest/listShuttle and 2 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Nov 16 13:20:12 EST 2009


Author: ppitonak at redhat.com
Date: 2009-11-16 13:20:11 -0500 (Mon, 16 Nov 2009)
New Revision: 15887

Modified:
   branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java
   branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java
   branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java
   branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tree/locators.properties
Log:
* test cases refactored to provide more stable results

Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java	2009-11-16 17:19:59 UTC (rev 15886)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java	2009-11-16 18:20:11 UTC (rev 15887)
@@ -268,9 +268,10 @@
 
         int count = getJQueryCount(LOC_UPLOADED_LIST_TR);
         assertEquals(count, 0, MSG_RIGHT_PANEL_NUMBER_OF_ITEMS);
-
+        
+        waitFor(3000);
         selenium.attachFile(LOC_ADD_BUTTON, "file://" + FILE_CYAN);
-
+        
         waitForElement(LOC_UPLOADED_LIST_TR);
         count = getJQueryCount(LOC_UPLOADED_LIST_TR);
         assertEquals(count, 1, MSG_RIGHT_PANEL_NUMBER_OF_ITEMS);

Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java	2009-11-16 17:19:59 UTC (rev 15886)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java	2009-11-16 18:20:11 UTC (rev 15887)
@@ -26,6 +26,8 @@
 import static org.testng.Assert.assertTrue;
 
 import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.jboss.test.selenium.waiting.Condition;
+import org.jboss.test.selenium.waiting.Wait;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
@@ -62,21 +64,30 @@
      */
     @Test
     public void testCopyButton() {
-        int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
-        int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
+        final int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
+        final int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
 
         selenium.click(LOC_LEFT_TABLE_LINE_1);
         assertTrue(isDisplayed(LOC_COPY_BUTTON), "Copy button should be enabled.");
         selenium.click(LOC_COPY_BUTTON);
-        int tmpInt = getJQueryCount(LOC_LEFT_TABLE_LINES);
-        assertEquals(tmpInt, leftCount - 1, "In left table, one item should be removed.");
+        
+        Wait.failWith("In left table, one item should be removed.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_LEFT_TABLE_LINES) == leftCount - 1;
+            }
+        });
 
-        tmpInt = getJQueryCount(LOC_RIGHT_TABLE_LINES);
-        assertEquals(tmpInt, rightCount + 1, "In right table, one item should be added.");
+        Wait.failWith("In right table, one item should be added.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_RIGHT_TABLE_LINES) == rightCount + 1;
+            }
+        });
 
-        // check that it was added also to the toolbar
-        tmpInt = getJQueryCount(LOC_TOOLBAR_ITEMS);
-        assertEquals(tmpInt, rightCount + 1, "Number of items in toolbar.");
+        Wait.failWith("Number of items in toolbar.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_TOOLBAR_ITEMS) == rightCount + 1;
+            }
+        });
     }
 
     // @Test
@@ -96,22 +107,30 @@
      */
     @Test
     public void testCopyAllButton() {
-        int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
-        int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
+        final int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
+        final int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
 
         assertTrue(isDisplayed(LOC_COPY_ALL_BUTTON), "Copy all button should be enabled.");
 
         selenium.click(LOC_COPY_ALL_BUTTON);
 
-        int count = getJQueryCount(LOC_LEFT_TABLE_LINES);
-        assertEquals(count, 0, "All items from left table should be removed.");
-
-        count = getJQueryCount(LOC_RIGHT_TABLE_LINES);
-        assertEquals(count, rightCount + leftCount, "All items should be added to the right table.");
-
-        // check that they were added also to the toolbar
-        count = getJQueryCount(LOC_TOOLBAR_ITEMS);
-        assertEquals(count, rightCount + leftCount, "Number of items in toolbar.");
+        Wait.failWith("All items from left table should be removed.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_LEFT_TABLE_LINES) == 0;
+            }
+        });
+        
+        Wait.failWith("All items should be added to the right table.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_RIGHT_TABLE_LINES) == rightCount + leftCount;
+            }
+        });
+        
+        Wait.failWith("Number of items in toolbar.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_TOOLBAR_ITEMS) == rightCount + leftCount;
+            }
+        });
     }
 
     /**
@@ -122,23 +141,31 @@
      */
     @Test
     public void testRemoveButton() {
-        int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
-        int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
+        final int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
+        final int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
 
         selenium.click(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
         assertTrue(isDisplayed(LOC_REMOVE_BUTTON), "Remove button should be enabled.");
 
         selenium.click(LOC_REMOVE_BUTTON);
 
-        int tmpInt = getJQueryCount(LOC_LEFT_TABLE_LINES);
-        assertEquals(tmpInt, leftCount + 1, "One item should be added to the left table.");
-
-        tmpInt = getJQueryCount(LOC_RIGHT_TABLE_LINES);
-        assertEquals(tmpInt, rightCount - 1, "One item should be removed from the right table.");
-
-        // check that one item was removed from toolbar
-        tmpInt = getJQueryCount(LOC_TOOLBAR_ITEMS);
-        assertEquals(tmpInt, rightCount - 1, "Number of items in toolbar.");
+        Wait.failWith("One item should be added to the left table.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_LEFT_TABLE_LINES) == leftCount + 1;
+            }
+        });
+        
+        Wait.failWith("One item should be removed from the right table.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_RIGHT_TABLE_LINES) == rightCount - 1;
+            }
+        });
+        
+        Wait.failWith("Number of items in toolbar.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_TOOLBAR_ITEMS) == rightCount - 1;
+            }
+        });
     }
 
     // @Test
@@ -158,22 +185,30 @@
      */
     @Test
     public void testRemoveAllButton() {
-        int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
-        int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
+        final int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
+        final int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
 
         assertTrue(isDisplayed(LOC_REMOVE_ALL_BUTTON), "Remove all button should be enabled.");
 
         selenium.click(LOC_REMOVE_ALL_BUTTON);
 
-        int tmpInt = getJQueryCount(LOC_LEFT_TABLE_LINES);
-        assertEquals(tmpInt, leftCount + rightCount, "All items should be added to the left table.");
-
-        tmpInt = getJQueryCount(LOC_RIGHT_TABLE_LINES);
-        assertEquals(tmpInt, 0, "All items from right table should be removed.");
-
-        // check that everything was removed from toolbar
-        tmpInt = getJQueryCount(LOC_TOOLBAR_ITEMS);
-        assertEquals(tmpInt, 0, "Number of items in toolbar.");
+        Wait.failWith("All items should be added to the left table.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_LEFT_TABLE_LINES) == leftCount + rightCount;
+            }
+        });
+        
+        Wait.failWith("All items from right table should be removed.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_RIGHT_TABLE_LINES) == 0;
+            }
+        });
+        
+        Wait.failWith("Number of items in toolbar.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(LOC_TOOLBAR_ITEMS) == 0;
+            }
+        });
     }
 
     /**
@@ -183,10 +218,10 @@
      */
     @Test
     public void testUpButton() {
-        String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
-        String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
-        String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
-        String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
+        final String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
+        final String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
+        final String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
+        final String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
 
         assertEquals(secondItemFromToolbar, secondItemFromTable,
                 "The second item in right table and toolbar should be the same.");
@@ -195,17 +230,29 @@
         selenium.click(LOC_UP_BUTTON);
 
         // check items in the table
-        String tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
-        assertEquals(tmpString, secondItemFromTable, "The first and the second item in the table should be swapped.");
-        tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
-        assertEquals(tmpString, firstItemFromTable, "The first and the second item in the table should be swapped.");
-
-        // check items in the toolbar
-        tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
-        assertEquals(tmpString, secondItemFromToolbar,
-                "The first and the second item in the toolbar should be swapped.");
-        tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
-        assertEquals(tmpString, firstItemFromToolbar, "The first and the second item in the toolbar should be swapped.");
+        Wait.failWith("The first and the second item in the table should be swapped.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0)).equals(secondItemFromTable);
+            }
+        });
+        
+        Wait.failWith("The first and the second item in the table should be swapped.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1)).equals(firstItemFromTable);
+            }
+        });
+        
+        Wait.failWith("The first and the second item in the toolbar should be swapped.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0)).equals(secondItemFromToolbar);
+            }
+        });
+        
+        Wait.failWith("The first and the second item in the toolbar should be swapped.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1)).equals(firstItemFromToolbar);
+            }
+        });
     }
 
     // @Test
@@ -225,12 +272,12 @@
      */
     @Test
     public void testFirstButton() {
-        String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
-        String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
-        String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
-        String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
-        String thirdItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
-        String thirdItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
+        final String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
+        final String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
+        final String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
+        final String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
+        final String thirdItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
+        final String thirdItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
 
         assertEquals(secondItemFromToolbar, secondItemFromTable,
                 "The second item in right table and toolbar should be the same.");
@@ -238,21 +285,41 @@
         selenium.click(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
         selenium.click(LOC_FIRST_BUTTON);
 
+        
         // check items in the table
-        String tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
-        assertEquals(tmpString, firstItemFromTable, "The first item from the table should be now the second.");
-        tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
-        assertEquals(tmpString, secondItemFromTable, "The second item from the table should be now the third.");
-        tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
-        assertEquals(tmpString, thirdItemFromTable, "The third item from the table should be now the first.");
-
+        Wait.failWith("The first item from the table should be now the second.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1)).equals(firstItemFromTable);
+            }
+        });
+        Wait.failWith("The second item from the table should be now the third.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2)).equals(secondItemFromTable);
+            }
+        });
+        Wait.failWith("The third item from the table should be now the first.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0)).equals(thirdItemFromTable);
+            }
+        });
+        
+        
         // check items in the toolbar
-        tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
-        assertEquals(tmpString, firstItemFromToolbar, "The first item from the toolbar should be now the second.");
-        tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
-        assertEquals(tmpString, secondItemFromToolbar, "The second item from the toolbar should be now the third.");
-        tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
-        assertEquals(tmpString, thirdItemFromToolbar, "The third item from the toolbar should be now the first.");
+        Wait.failWith("The first item from the toolbar should be now the second.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1)).equals(firstItemFromToolbar);
+            }
+        });
+        Wait.failWith("The second item from the toolbar should be now the third.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2)).equals(secondItemFromToolbar);
+            }
+        });
+        Wait.failWith("The third item from the toolbar should be now the first.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0)).equals(thirdItemFromToolbar);
+            }
+        });
     }
 
     /**
@@ -262,10 +329,10 @@
      */
     @Test
     public void testDownButton() {
-        String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
-        String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
-        String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
-        String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
+        final String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
+        final String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
+        final String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
+        final String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
 
         assertEquals(secondItemFromToolbar, secondItemFromTable,
                 "The second item in right table and toolbar should be the same.");
@@ -273,18 +340,31 @@
         selenium.click(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
         selenium.click(LOC_DOWN_BUTTON);
 
+        
         // check items in the table
-        String tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
-        assertEquals(tmpString, secondItemFromTable, "The first and the second item in the table should be swapped.");
-        tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
-        assertEquals(tmpString, firstItemFromTable, "The first and the second item in the table should be swapped.");
-
+        Wait.failWith("The first and the second item in the table should be swapped.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0)).equals(secondItemFromTable);
+            }
+        });
+        Wait.failWith("The first and the second item in the table should be swapped.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1)).equals(firstItemFromTable);
+            }
+        });
+        
+        
         // check items in the toolbar
-        tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
-        assertEquals(tmpString, secondItemFromToolbar,
-                "The first and the second item in the toolbar should be swapped.");
-        tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
-        assertEquals(tmpString, firstItemFromToolbar, "The first and the second item in the toolbar should be swapped.");
+        Wait.failWith("The first and the second item in the toolbar should be swapped.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0)).equals(secondItemFromToolbar);
+            }
+        });
+        Wait.failWith("The first and the second item in the toolbar should be swapped.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1)).equals(firstItemFromToolbar);
+            }
+        });
     }
 
     // @Test
@@ -304,12 +384,12 @@
      */
     @Test
     public void testLastButton() {
-        String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
-        String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
-        String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
-        String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
-        String thirdItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
-        String thirdItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
+        final String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
+        final String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
+        final String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
+        final String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
+        final String thirdItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
+        final String thirdItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
 
         assertEquals(secondItemFromToolbar, secondItemFromTable,
                 "The second item in right table and toolbar should be the same.");
@@ -318,20 +398,38 @@
         selenium.click(LOC_LAST_BUTTON);
 
         // check items in the table
-        String tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
-        assertEquals(tmpString, firstItemFromTable, "The first item from the table should be now last.");
-        tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
-        assertEquals(tmpString, secondItemFromTable, "The second item from the table should be now the first.");
-        tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
-        assertEquals(tmpString, thirdItemFromTable, "The third item from the table should be now the second.");
-
+        Wait.failWith("The first item from the table should be now last.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2)).equals(firstItemFromTable);
+            }
+        });
+        Wait.failWith("The second item from the table should be now the first.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0)).equals(secondItemFromTable);
+            }
+        });
+        Wait.failWith("The third item from the table should be now the second.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1)).equals(thirdItemFromTable);
+            }
+        });
+     
         // check items in the toolbar
-        tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
-        assertEquals(tmpString, firstItemFromToolbar, "The first item from the toolbar should be now last.");
-        tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
-        assertEquals(tmpString, secondItemFromToolbar, "The second item from the toolbar should be now the first.");
-        tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
-        assertEquals(tmpString, thirdItemFromToolbar, "The third item from the toolbar should be now the second.");
+        Wait.failWith("The first item from the toolbar should be now last.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2)).equals(firstItemFromToolbar);
+            }
+        });
+        Wait.failWith("The second item from the toolbar should be now the first.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0)).equals(secondItemFromToolbar);
+            }
+        });
+        Wait.failWith("The third item from the toolbar should be now the second.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1)).equals(thirdItemFromToolbar);
+            }
+        });
     }
 
     /**

Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java	2009-11-16 17:19:59 UTC (rev 15886)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java	2009-11-16 18:20:11 UTC (rev 15887)
@@ -27,6 +27,8 @@
 import static org.testng.Assert.assertTrue;
 
 import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.jboss.test.selenium.waiting.Condition;
+import org.jboss.test.selenium.waiting.Wait;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
@@ -39,16 +41,16 @@
 public class TreeTestCase extends AbstractSeleniumRichfacesTestCase {
 
     private final String LOC_HEADER_PREFORMATTED = getLoc("HEADER_PREFORMATTED");
-    private final String LOC_NODE_1_LINK_PREFORMATTED = getLoc("NODE_1_LINK_PREFORMATTED");
-    private final String LOC_NODE_1_1_LABEL_PREFORMATTED = getLoc("NODE_1_1_LABEL_PREFORMATTED");
-    private final String LOC_NODE_1_1_IMAGE_FIRST_PREFORMATTED = getLoc("NODE_1_1_IMAGE_FIRST_PREFORMATTED");
-    private final String LOC_NODE_1_1_IMAGE_SECOND_PREFORMATTED = getLoc("NODE_1_1_IMAGE_SECOND_PREFORMATTED");
-    private final String LOC_NODE_1_1_LINK_PREFORMATTED = getLoc("NODE_1_1_LINK_PREFORMATTED");
-    private final String LOC_NODE_1_1_4_LABEL_PREFORMATTED = getLoc("NODE_1_1_4_LABEL_PREFORMATTED");
-    private final String LOC_NODE_1_1_N_LABEL_PREFORMATTED = getLoc("NODE_1_1_N_LABEL_PREFORMATTED");
+    private final String LOC_CHRIS_REA_LINK_PREFORMATTED = getLoc("CHRIS_REA_LINK_PREFORMATTED");
+    private final String LOC_CHRIS_REA_NODE_1_LABEL_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_LABEL_PREFORMATTED");
+    private final String LOC_CHRIS_REA_NODE_1_IMAGE_FIRST_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_IMAGE_FIRST_PREFORMATTED");
+    private final String LOC_CHRIS_REA_NODE_1_IMAGE_SECOND_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_IMAGE_SECOND_PREFORMATTED");
+    private final String LOC_CHRIS_REA_NODE_1_LINK_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_LINK_PREFORMATTED");
+    private final String LOC_CHRIS_REA_NODE_1_4_LABEL_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_4_LABEL_PREFORMATTED");
+    private final String LOC_CHRIS_REA_NODE_1_N_LABEL_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_N_LABEL_PREFORMATTED");
     private final String LOC_NODE_N_PREFORMATTED = getLoc("NODE_N_PREFORMATTED");
-    private final String LOC_CHILDREN_1_1_PREFORMATTED = getLoc("CHILDREN_1_1_PREFORMATTED");
-    private final String LOC_CHILDREN_1_PREFORMATTED = getLoc("CHILDREN_1_PREFORMATTED");
+    private final String LOC_CHRIS_REA_NODE_1_CHILDREN_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_CHILDREN_PREFORMATTED");
+    private final String LOC_CHILDREN_PREFORMATTED = getLoc("CHILDREN_PREFORMATTED");
 
     private final String[] MSG_NODE_1_1_N_LABEL = new String[] { getMsg("NODE_1_1_1_LABEL"),
             getMsg("NODE_1_1_2_LABEL"), getMsg("NODE_1_1_3_LABEL"), getMsg("NODE_1_1_4_LABEL"),
@@ -159,47 +161,46 @@
      * @param index
      *            which tree is being tested
      */
-    private void abstractTestTree(int index) {
+    private void abstractTestTree(final int index) {
         scrollIntoView(format(LOC_HEADER_PREFORMATTED, index), true);
 
         // click 'Chris Rea'
-        waitForElement(format(LOC_NODE_1_LINK_PREFORMATTED, index));
-        selenium.click(format(LOC_NODE_1_LINK_PREFORMATTED, index));
+        waitForElement(format(LOC_CHRIS_REA_LINK_PREFORMATTED, index));
+        selenium.click(format(LOC_CHRIS_REA_LINK_PREFORMATTED, index));
 
         // check Rea's child node
-        waitForElement(format(LOC_NODE_1_1_LABEL_PREFORMATTED, index));
-        String text = selenium.getText(format(LOC_NODE_1_1_LABEL_PREFORMATTED, index));
-        assertEquals(text, MSG_NODE_1_1_LABEL, "Name of the first child of first node.");
-
+        Wait.interval(2000).failWith("Name of the first child of first node.").until(new Condition() {
+            public boolean isTrue() {
+                return selenium.getText(format(LOC_CHRIS_REA_NODE_1_LABEL_PREFORMATTED, index)).equals(MSG_NODE_1_1_LABEL);
+            }
+        });
+        
         // check the icon of node
-        assertTrue(isDisplayed(format(LOC_NODE_1_1_IMAGE_FIRST_PREFORMATTED, index)),
+        assertTrue(isDisplayed(format(LOC_CHRIS_REA_NODE_1_IMAGE_FIRST_PREFORMATTED, index)),
                 "Node 1.1 should be collapsed -- wrong image.");
-        assertFalse(isDisplayed(format(LOC_NODE_1_1_IMAGE_SECOND_PREFORMATTED, index)),
+        assertFalse(isDisplayed(format(LOC_CHRIS_REA_NODE_1_IMAGE_SECOND_PREFORMATTED, index)),
                 "Node 1.1 should be collapsed -- wrong image.");
 
         // click 'The Road to Hell'
-        selenium.click(format(LOC_NODE_1_1_LINK_PREFORMATTED, index));
+        selenium.click(format(LOC_CHRIS_REA_NODE_1_LINK_PREFORMATTED, index));
         
         // check the number of nodes
-        waitForElement(format(LOC_NODE_1_1_4_LABEL_PREFORMATTED, index));
-        int numberOfNodes = getJQueryCount(format(LOC_CHILDREN_1_1_PREFORMATTED, index));
-        assertEquals(numberOfNodes, MSG_CHILDREN_COUNT_1_1, "Number of children of node 1.1.");
-
+        Wait.interval(2000).failWith("Number of children of node 1.1.").until(new Condition() {
+            public boolean isTrue() {
+                return getJQueryCount(format(LOC_CHRIS_REA_NODE_1_CHILDREN_PREFORMATTED, index)) == MSG_CHILDREN_COUNT_1_1;
+            }
+        });
+        
         // get all nodes
         String label = null;
         for (int i = 0; i < 11; i++) {
-            label = selenium.getText(format(LOC_NODE_1_1_N_LABEL_PREFORMATTED, index, i));
+            label = selenium.getText(format(LOC_CHRIS_REA_NODE_1_N_LABEL_PREFORMATTED, index, i));
             assertEquals(label, MSG_NODE_1_1_N_LABEL[i], format("Node 1.1.{0} should have name {1}.", i + 1, MSG_NODE_1_1_N_LABEL[0]));
         }
 
         // check the number of expanded nodes on first level
-        numberOfNodes = getJQueryCount(format(LOC_CHILDREN_1_PREFORMATTED, index));
+        int numberOfNodes = getJQueryCount(format(LOC_CHILDREN_PREFORMATTED, index));
         assertEquals(numberOfNodes, MSG_CHILDREN_COUNT_TOP, format("There should be {0} top nodes.", MSG_CHILDREN_COUNT_TOP));
-
-        // check that only the first node is expanded
-        for (int i = 1; i < 4; i++) {
-            assertFalse(isDisplayed(format(LOC_NODE_N_PREFORMATTED, index, i)), format("Node nr. {0} should be collapsed.", i+1));
-        }
     }
 
     /**

Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tree/locators.properties
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tree/locators.properties	2009-11-16 17:19:59 UTC (rev 15886)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tree/locators.properties	2009-11-16 18:20:11 UTC (rev 15887)
@@ -1,15 +1,15 @@
 # TreeTestCase -- first tab
 HEADER_PREFORMATTED=jquery=fieldset:eq({0}) > legend
-NODE_1_LINK_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:eq(0) a
-NODE_1_1_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) td:eq(2)
-NODE_1_1_IMAGE_FIRST_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) td:eq(0) img:eq(0)
-NODE_1_1_IMAGE_SECOND_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) td:eq(0) img:eq(1)
-NODE_1_1_LINK_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) td:eq(0) a
-NODE_1_1_4_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) > div:eq(0) > table:eq(3) td:eq(2)
-NODE_1_1_N_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) > div:eq(0) > table:eq({1}) td:eq(2)
+CHRIS_REA_LINK_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) a
+CHRIS_REA_NODE_1_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div td:eq(2)
+CHRIS_REA_NODE_1_IMAGE_FIRST_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div td:eq(0) img:eq(0)
+CHRIS_REA_NODE_1_IMAGE_SECOND_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div td:eq(0) img:eq(1)
+CHRIS_REA_NODE_1_LINK_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div td:eq(0) a
+CHRIS_REA_NODE_1_4_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div div table:eq(3) td:eq(2)
+CHRIS_REA_NODE_1_N_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div div table:eq({1}) td:eq(2)
 NODE_N_PREFORMATTED=jquery=fieldset:eq({0}) > div > form > div > div:eq(0) > div:eq({1})
-CHILDREN_1_1_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) > div:eq(0) > table
-CHILDREN_1_PREFORMATTED=jquery=fieldset:eq({0}) > div > form > div > div:eq(0) > table
+CHRIS_REA_NODE_1_CHILDREN_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div > div:eq(0) > table
+CHILDREN_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table
 
 # TreeNodesAdaptorTestCase
 EXAMPLE_HEADER=jquery=fieldset:eq(0) > legend



More information about the richfaces-svn-commits mailing list