KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > displaytag > jsptests > EmptyTableTest


1 package org.displaytag.jsptests;
2
3 import org.displaytag.test.DisplaytagCase;
4
5 import com.meterware.httpunit.GetMethodWebRequest;
6 import com.meterware.httpunit.WebRequest;
7 import com.meterware.httpunit.WebResponse;
8 import com.meterware.httpunit.WebTable;
9
10
11 /**
12  * Tests with a null list.
13  * @author Fabrizio Giustina
14  * @version $Revision: 765 $ ($Author: fgiust $)
15  */

16 public class EmptyTableTest extends DisplaytagCase
17 {
18
19     /**
20      * @see org.displaytag.test.DisplaytagCase#getJspName()
21      */

22     public String JavaDoc getJspName()
23     {
24         return "empty.jsp";
25     }
26
27     /**
28      * Verifies that the generated page doesn't contain any table (but doesn't crash!).
29      * @param jspName jsp name, with full path
30      * @throws Exception any axception thrown during test.
31      */

32     public void doTest(String JavaDoc jspName) throws Exception JavaDoc
33     {
34         WebRequest request = new GetMethodWebRequest(jspName);
35
36         WebResponse response = runner.getResponse(request);
37
38         if (log.isDebugEnabled())
39         {
40             log.debug(response.getText());
41         }
42
43         WebTable[] tables = response.getTables();
44
45         // only the second table should be shown
46
assertEquals("Wrong number of tables.", 1, tables.length);
47         assertEquals("Empty table message: colspan should be 2", 2, tables[0].getTableCell(1, 0).getColSpan());
48     }
49 }
Popular Tags