KickJava   Java API By Example, From Geeks To Geeks.

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


1 package net.sourceforge.jwebunit;
2
3 import junit.framework.TestCase;
4
5 /**
6  * Unit test expected table design.
7  */

8 public class ExpectedTableTest extends TestCase {
9
10     public ExpectedTableTest(String JavaDoc s) {
11         super(s);
12     }
13
14     /**
15      * Should be able to construct with a simple string [][].
16      */

17     public void testConstructionWithStrings() {
18         ExpectedTable table = new ExpectedTable(new Object JavaDoc [][]
19             {{"1_1", "1_2"},{"2_1", "2_2"}});
20         assertEquals(table.toString(), "{{1_1}{1_2}}{{2_1}{2_2}}");
21     }
22
23     /**
24      * Should be able to construct with an object [][] containing
25      * strings and expected cell objects.
26      */

27     public void testConstructionWithExpectedCell() {
28         ExpectedTable table = new ExpectedTable(new Object JavaDoc [][]
29             { {"1_1", "1_2", "1_3"}, {"2_1", new ExpectedCell("2_2-3",2)} } );
30         assertEquals(table.toString(), "{{1_1}{1_2}{1_3}}{{2_1}{2_2-3}{2_2-3}}");
31     }
32
33     /**
34      * Should be able to append expected rows - will make reuse of common
35      * expected table rows in test data easier.
36      */

37     public void testAppendRows() {
38         ExpectedTable table = new ExpectedTable(new Object JavaDoc [][]
39             {{"1_1", "1_2"},{"2_1", "2_2"}});
40         table.appendRows(new Object JavaDoc[][] {{"3_1"}});
41         assertEquals(table.toString(), "{{1_1}{1_2}}{{2_1}{2_2}}{{3_1}}");
42     }
43
44     public void testAppendTables() {
45         ExpectedTable table = new ExpectedTable(new Object JavaDoc [][]
46             {{"1_1", "1_2"},{"2_1", "2_2"}});
47         table.appendRows(new ExpectedTable(new Object JavaDoc[][]{{"3_1"}}));
48         assertEquals(table.toString(), "{{1_1}{1_2}}{{2_1}{2_2}}{{3_1}}");
49     }
50
51 }
52
Popular Tags