KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > jwebunit > ExpectedTableAssertionsTest


1 package net.sourceforge.jwebunit;
2
3 /**
4  * Test table equals assertions using expected tables.
5  */

6 public class ExpectedTableAssertionsTest extends JWebUnitTest {
7
8     public void setUp() throws Exception JavaDoc {
9         super.setUp();
10         addTestPage();
11         beginAt("/testPage.html");
12     }
13
14     public void testAssertTableEquals() throws Throwable JavaDoc {
15         ExpectedTable goodTable = new ExpectedTable(new Object JavaDoc[][] {
16             {"table text", ""},
17             {"table text row 2", ""},
18             {"table text row 3", "row 3 col 1"},
19             {new ExpectedCell("row 4", 2)},
20         });
21         assertPass("assertTableEquals", new Object JavaDoc[]{"testTable", goodTable});
22     }
23
24     public void testAssertTableEqualsMissingRows() throws Throwable JavaDoc {
25         ExpectedTable badTable = new ExpectedTable(new Object JavaDoc[][] {
26             {"table text", ""},
27             {new ExpectedCell("row 4", 2)},
28         });
29         assertFail("assertTableEquals", new Object JavaDoc[]{"testTable", badTable});
30     }
31
32     private void addTestPage() {
33         defineWebPage("testPage", "This is a test page." +
34                                   "<table summary=\"testTable\">" +
35                                   "<tr><td>table text</td></tr>" +
36                                   "<tr><td>table text row 2</td></tr>" +
37                                   "<tr><td>table text row 3</td><td>row 3 col 1</td></tr>" +
38                                   "<tr><td colspan=\"2\">row 4</td></tr>" +
39                                   "</table>");
40         defineWebPage("noFormPage", "");
41     }
42
43
44 }
45
Popular Tags