KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > web > TableTest


1 package com.tonbeller.wcf.web;
2
3 import java.io.IOException JavaDoc;
4
5 import javax.xml.transform.TransformerException JavaDoc;
6
7 import org.jaxen.JaxenException;
8 import org.xml.sax.SAXException JavaDoc;
9
10 import com.meterware.httpunit.GetMethodWebRequest;
11 import com.meterware.httpunit.WebForm;
12
13 public class TableTest extends HttpUnitTestCase {
14
15   public TableTest(String JavaDoc arg0) {
16     super(arg0);
17   }
18
19   private void check(String JavaDoc name) throws JaxenException, IOException JavaDoc, SAXException JavaDoc, TransformerException JavaDoc {
20     utils.check(name, "filter.xsl", "form01");
21   }
22   
23   public void testTable() throws Exception JavaDoc {
24     wc.sendRequest(new GetMethodWebRequest(servletUrl + "/tabledemo.jsp"));
25     check("table-01");
26     
27     // check Hello World 0
28
utils.setCheckBox("form01", "t1", 2, 0, 0, true);
29     // sort integer
30
utils.submitCell("form01", "t1", 1, 4, 0);
31     check("table-02");
32
33     // check Hello World 6
34
utils.setCheckBox("form01", "t1", 3, 0, 0, true);
35     // sort by date
36
utils.submitCell("form01", "t1", 1, 2, 0);
37     check("table-03");
38     // reverse sort by date
39
utils.submitCell("form01", "t1", 1, 2, 0);
40     check("table-04");
41
42     // press edit button
43
utils.submitCell("form01", "t1", 0, 0, 0);
44     check("table-05");
45     // remove "hello world" column
46
utils.setCheckBox("form01", "t1.form.tree", 0, 0, 0, false);
47     // disable paging
48
WebForm wf = wc.getCurrentPage().getFormWithID("form01");
49     wf.removeParameter("t1.form.pagable");
50     wf.submit(wf.getSubmitButtonWithID("t1.form.ok"));
51     check("table-06");
52
53     // press edit button
54
utils.submitCell("form01", "t1", 0, 0, 0);
55     // swap Image 1 and Image 2
56
utils.submitCell("form01", "t1.form.tree", 6, 0, 0);
57     wf.submit(wf.getSubmitButtonWithID("t1.form.ok"));
58     check("table-07");
59   }
60   
61   public void testPages() throws Exception JavaDoc {
62     wc.sendRequest(new GetMethodWebRequest(servletUrl + "/tabledemo.jsp"));
63     // check Hello World 0
64
utils.setCheckBox("form01", "t1", 2, 0, 0, true);
65     // press edit button
66
utils.submitCell("form01", "t1", 0, 0, 0);
67     // set pagesize = 4
68
WebForm wf = wc.getCurrentPage().getFormWithID("form01");
69     wf.setParameter("t1.form.pagesize", "4");
70     wf.submit(wf.getSubmitButtonWithID("t1.form.ok"));
71     check("table-11");
72
73     // next page
74
utils.submitCell("form01", "t1", 6, 0, 0);
75     check("table-12");
76     // last page
77
utils.submitCell("form01", "t1", 6, 0, 3);
78     check("table-13");
79     // prev page
80
utils.submitCell("form01", "t1", 6, 0, 1);
81     check("table-14");
82     // first page
83
utils.submitCell("form01", "t1", 6, 0, 0);
84     check("table-15");
85     gotoPage(4, "table-16");
86     gotoPage(-99, "table-17");
87     gotoPage(99, "table-18");
88   }
89   
90   private void gotoPage(int page, String JavaDoc name) throws Exception JavaDoc {
91     WebForm wf = wc.getCurrentPage().getFormWithID("form01");
92     wf.setParameter("t1.goto.input", "" + page);
93     wf.submit(wf.getSubmitButton("t1.goto.button"));
94     check(name);
95   }
96
97   public void testUndecoratedTable() throws Exception JavaDoc {
98     wc.sendRequest(new GetMethodWebRequest(servletUrl + "/undecorated-table.jsp"));
99     check("table-undecorated-01");
100   }
101   
102   public void testTableStyle() throws Exception JavaDoc {
103     wc.sendRequest(new GetMethodWebRequest(servletUrl + "/tablestyle.jsp"));
104     check("tablestyle-01");
105   }
106   
107   public void testTableReadOnly() throws Exception JavaDoc {
108     wc.sendRequest(new GetMethodWebRequest(servletUrl + "/tabledemo2.jsp"));
109     check("table-readonly");
110   }
111 }
112
Popular Tags