Update of /cvsroot/jwebunit/jWebUnit/test/net/sourceforge/jwebunit
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22368/test/net/sourceforge/jwebunit

Modified Files:
        TableAssertionsTest.java WebAssertionsTest.java 
Log Message:
Added support for assertions using regular expressions.

Index: TableAssertionsTest.java
===================================================================
RCS file: 
/cvsroot/jwebunit/jWebUnit/test/net/sourceforge/jwebunit/TableAssertionsTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** TableAssertionsTest.java    15 Apr 2005 04:47:43 -0000      1.7
--- TableAssertionsTest.java    15 May 2005 19:55:13 -0000      1.8
***************
*** 53,56 ****
--- 53,80 ----
        }
  
+     public void testAssertMatchInTable() throws Throwable {
+         assertPassFail("assertMatchInTable",
+                        new Object[]{"testTable", "table [Tt]ext"},
+                        new Object[]{"testTable", "no.*text"});
+     }
+ 
+     public void testAssertNoMatchInTable() throws Throwable {
+         assertPassFail("assertNoMatchInTable",
+                        new Object[]{"testTable", "no.*text"},
+                        new Object[]{"testTable", "table [Tt]ext"});
+     }
+ 
+     public void testAssertMatchArrayInTable() throws Throwable {
+         assertPassFail("assertMatchInTable",
+                        new Object[]{"testTable", new String[]{"table 
[Tt]ext", "table [Tt]ext row 2"}},
+                        new Object[]{"testTable", new String[]{"table 
[Tt]ext", "no.*row 2"}});
+     }
+ 
+     public void testAssertNoMatchArrayInTable() throws Throwable {
+         assertPassFail("assertNoMatchInTable",
+                        new Object[]{"testTable", new String[]{"no.*row 1", 
"no.*row 2"}},
+                        new Object[]{"testTable", new String[]{"no.*row 1", 
"table [Tt]ext row 2"}});
+     }
+ 
        public void testAssertTableEquals() throws Throwable {
                assertPass("assertTableEquals", new Object[] {
***************
*** 129,131 ****
        }
  
! }
\ No newline at end of file
--- 153,224 ----
        }
  
!     public void testAssertTableMatch() throws Throwable {
!         assertPass("assertTableMatch",
!                    new Object[]{"testTable", new String[][]{{"table [Tt]ext", 
""},
!                                                             {"table [Tt]ext 
row 2", "^$"},
!                                                             {"table [Tt]ext 
row 3", "row [0-9] col 1"}}});
!     }
! 
!     public void testAssertTableMatchExtraColumn() throws Throwable {
!         assertFail("assertTableMatch",
!                    new Object[]{"testTable", new String[][]{{"table text", 
"", "extra column"},
!                                                             {"table text row 
2", ""},
!                                                             {"table text row 
3", "row 3 col 1"}}});
!     }
! 
!     public void testAssertTableMatchExtraRow() throws Throwable {
!         assertFail("assertTableMatch",
!                    new Object[]{"testTable", new String[][]{{"table text", 
""},
!                                                             {"table text row 
2", ""},
!                                                             {"table text row 
3", "row 3 col 1"},
!                                                             {"no row 4"}}});
!     }
! 
!     public void testAssertTableMatchInvalidColumnText() throws Throwable {
!         assertFail("assertTableMatch",
!                    new Object[]{"testTable", new String[][]{{"table [Tt]ext", 
""},
!                                                             {"no such [Tt]ext 
in row 2", ""},
!                                                             {"table text row 
3", "row 3 col 1"}}});
!     }
! 
!     public void testAssertTableMatchMissingText() throws Throwable {
!         assertFail("assertTableMatch",
!                    new Object[]{"testTable", new String[][]{{"table text", 
""},
!                                                             {"table text row 
2", ""},
!                                                             {"table text row 
3", "^$"}}});
!     }
! 
!     public void testAssertTableRowsMatch() throws Throwable {
!         assertPass("assertTableRowsMatch",
!                    new Object[]{"testTable",
!                                 new Integer(1),
!                                 new String[][]{{"table text row 2", ""},
!                                                {"table text row 3", "row 3 
col 1"}}});
!     }
! 
!     public void testAssertTableRowsMatchTooManyExpected() throws Throwable {
!         assertFail("assertTableRowsMatch",
!                    new Object[]{"testTable",
!                                 new Integer(2),
!                                 new String[][]{{"table text row 3", "row 3 
col 1"},
!                                                {"unexpected", ""}}});
!     }
!     
!     public void testTableWithSpacesWithCompressionOfEmptyCellsMatch() throws 
Throwable {
!         assertTablePresent("tree");
!         String[][] table = {{"root", "", ""},
!         {"child1", "child2", ""},
!         {"child1.1", "child2.1", "child2.2"}};
!         assertTableMatch("tree", table);
!     }
!     
!     public void testTableWithSpacesUnCompressedMatch() throws Throwable {
!         assertTablePresent("tree");
!         String[][] table = {{"root", "", "", ""},
!         {"child1", "", "child2", ""},
!         {"child1.1", "", "child2.1", "child2.2"}};
!         setTableEmptyCellCompression(false);
!         assertTableMatch("tree", table);
!     }
! 
! }

Index: WebAssertionsTest.java
===================================================================
RCS file: 
/cvsroot/jwebunit/jWebUnit/test/net/sourceforge/jwebunit/WebAssertionsTest.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** WebAssertionsTest.java      15 Apr 2005 04:47:43 -0000      1.18
--- WebAssertionsTest.java      15 May 2005 19:55:13 -0000      1.19
***************
*** 25,32 ****
        }
  
!       public void testAssertTitleEquals() throws Throwable {
!               assertPass("assertTitleEquals", new String[] { "testPage" });
!               assertFail("assertTitleEquals", "wrong title");
!       }
  
        public void testAssertTextPresent() throws Throwable {
--- 25,37 ----
        }
  
!     public void testAssertTitleEquals() throws Throwable {
!         assertPass("assertTitleEquals", new String[] { "testPage" });
!         assertFail("assertTitleEquals", "wrong title");
!     }
! 
!     public void testAssertTitleMatch() throws Throwable {
!         assertPass("assertTitleMatch", new String[] { "test[Pp]age" });
!         assertFail("assertTitleMatch", "[Ww]rong title");
!     }
  
        public void testAssertTextPresent() throws Throwable {
***************
*** 34,37 ****
--- 39,45 ----
                                "no such text");
        }
+     public void testAssertMatch() throws Throwable {
+         assertPassFail("assertMatch", "This (is)* a .* test.", "no.*text");
+     }
  
        public void testAssertTextNotPresent() throws Throwable {
***************
*** 41,44 ****
--- 49,57 ----
        }
  
+     public void testAssertNoMatch() throws Throwable {
+         assertNoMatch("no.*text");
+         //assertPassFail("assertNoMatch", "no.*text", "This (is)* a .* 
page.");
+     }
+ 
        public void testAssertLinkPresentWithText() throws Throwable {
                assertPassFail("assertLinkPresentWithText", "test link", "no 
such link");
***************
*** 113,115 ****
--- 126,168 ----
        }
  
+     public void testAssertNoMatchInElement() throws Throwable {
+         assertNoMatchInElement("outer_id", "no[Ss]uchtext");
+         assertNoMatchInElement("inner_id", "Out+er");
+         assertFail("assertNoMatchInElement", new Object[] {"outer_id", 
"Out+er"});
+     }
+ 
+     public void testAssertMatchInElement() throws Throwable {
+         assertMatchInElement("span_id", "Sp[Aa]n");
+         assertMatchInElement("span_id", "Te+xt");
+         assertMatchInElement("span_id", "Span\\sText");
+         assertFail("assertMatchInElement", new Object[] {"span_id", 
"Not.*Text"});
+     }
+     
+     public void testAssertMatchInElementChild() throws Throwable {
+         assertMatchInElement("outer_id", "Out+er");
+         assertMatchInElement("outer_id", "Texx*t");
+         assertMatchInElement("outer_id", "Inner.*Text");
+     }
+ 
+     public void testAssertFormElementEquals() throws Throwable {
+         assertFormElementEquals("testInputElement", "testValue");
+         assertFail("assertFormElementEquals", new Object[] 
{"testInputElement", "AnotherValue"});
+     }
+ 
+     public void testAssertFormElementMatch() throws Throwable {
+         assertFormElementMatch("testInputElement", "test[Vv]alue");
+         assertFail("assertFormElementMatch", new Object[] 
{"testInputElement", "Another[Vv]alue"});
+     }
+ 
+     public void testAssertOptionEquals() throws Throwable {
+         assertOptionEquals("testSelect", "Value1");
+         assertFail("assertOptionEquals", new Object[] {"testSelect", 
"AnotherValue"});
+     }
+ 
+     public void testAssertOptionMatch() throws Throwable {
+         assertOptionMatch("testSelect", "[Vv]alue1");
+         assertFail("assertOptionMatch", new Object[] {"testSelect", 
"Another[Vv]alue"});
+     }
+ 
+ 
  }
\ No newline at end of file



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to