KickJava   Java API By Example, From Geeks To Geeks.

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


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 for offset/length attributes.
13  * @author Fabrizio Giustina
14  * @version $Revision: 894 $ ($Author: fgiust $)
15  */

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

22     public String JavaDoc getJspName()
23     {
24         return "offset.jsp";
25     }
26
27     /**
28      * Only items from 2 to 4 should show up in the response.
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
35         WebRequest request = new GetMethodWebRequest(jspName);
36
37         WebResponse response = runner.getResponse(request);
38
39         if (log.isDebugEnabled())
40         {
41             log.debug("RESPONSE: " + response.getText());
42         }
43
44         WebTable[] tables = response.getTables();
45
46         assertEquals("Wrong number of tables.", 1, tables.length);
47
48         assertEquals("Bad number of generated rows.", 3, tables[0].getRowCount());
49         assertEquals("Wrong cell content.", "2", tables[0].getCellAsText(1, 0));
50         assertEquals("Wrong cell content.", "3", tables[0].getCellAsText(2, 0));
51     }
52 }
Popular Tags