1 package com.tonbeller.wcf.web; 2 3 import java.io.IOException ; 4 5 import javax.xml.transform.TransformerException ; 6 7 import org.jaxen.JaxenException; 8 import org.xml.sax.SAXException ; 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 arg0) { 16 super(arg0); 17 } 18 19 private void check(String name) throws JaxenException, IOException , SAXException , TransformerException { 20 utils.check(name, "filter.xsl", "form01"); 21 } 22 23 public void testTable() throws Exception { 24 wc.sendRequest(new GetMethodWebRequest(servletUrl + "/tabledemo.jsp")); 25 check("table-01"); 26 27 utils.setCheckBox("form01", "t1", 2, 0, 0, true); 29 utils.submitCell("form01", "t1", 1, 4, 0); 31 check("table-02"); 32 33 utils.setCheckBox("form01", "t1", 3, 0, 0, true); 35 utils.submitCell("form01", "t1", 1, 2, 0); 37 check("table-03"); 38 utils.submitCell("form01", "t1", 1, 2, 0); 40 check("table-04"); 41 42 utils.submitCell("form01", "t1", 0, 0, 0); 44 check("table-05"); 45 utils.setCheckBox("form01", "t1.form.tree", 0, 0, 0, false); 47 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 utils.submitCell("form01", "t1", 0, 0, 0); 55 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 { 62 wc.sendRequest(new GetMethodWebRequest(servletUrl + "/tabledemo.jsp")); 63 utils.setCheckBox("form01", "t1", 2, 0, 0, true); 65 utils.submitCell("form01", "t1", 0, 0, 0); 67 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 utils.submitCell("form01", "t1", 6, 0, 0); 75 check("table-12"); 76 utils.submitCell("form01", "t1", 6, 0, 3); 78 check("table-13"); 79 utils.submitCell("form01", "t1", 6, 0, 1); 81 check("table-14"); 82 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 name) throws Exception { 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 { 98 wc.sendRequest(new GetMethodWebRequest(servletUrl + "/undecorated-table.jsp")); 99 check("table-undecorated-01"); 100 } 101 102 public void testTableStyle() throws Exception { 103 wc.sendRequest(new GetMethodWebRequest(servletUrl + "/tablestyle.jsp")); 104 check("tablestyle-01"); 105 } 106 107 public void testTableReadOnly() throws Exception { 108 wc.sendRequest(new GetMethodWebRequest(servletUrl + "/tabledemo2.jsp")); 109 check("table-readonly"); 110 } 111 } 112 | Popular Tags |