KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.displaytag.jsptests;
2
3 import org.displaytag.tags.TableTagParameters;
4 import org.displaytag.test.DisplaytagCase;
5 import org.displaytag.util.ParamEncoder;
6
7 import com.meterware.httpunit.GetMethodWebRequest;
8 import com.meterware.httpunit.WebRequest;
9 import com.meterware.httpunit.WebResponse;
10 import com.meterware.httpunit.WebTable;
11
12
13 /**
14  * Tests for column decorators.
15  * @author Fabrizio Giustina
16  * @version $Revision: 894 $ ($Author: fgiust $)
17  */

18 public class ListIndexTableDecoratorTest extends DisplaytagCase
19 {
20
21     /**
22      * @see org.displaytag.test.DisplaytagCase#getJspName()
23      */

24     public String JavaDoc getJspName()
25     {
26         return "listindex.jsp";
27     }
28
29     /**
30      * Checks that the generated page contains decorated values.
31      * @param jspName jsp name, with full path
32      * @throws Exception any axception thrown during test.
33      */

34     public void doTest(String JavaDoc jspName) throws Exception JavaDoc
35     {
36         ParamEncoder encoder = new ParamEncoder("table");
37         String JavaDoc mediaParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_PAGE);
38
39         WebRequest request = new GetMethodWebRequest(jspName);
40         request.setParameter(mediaParameter, "2");
41
42         WebResponse response = runner.getResponse(request);
43
44         if (log.isDebugEnabled())
45         {
46             log.debug("RESPONSE: " + response.getText());
47         }
48
49         WebTable[] tables = response.getTables();
50
51         assertEquals("Wrong number of tables.", 1, tables.length);
52         assertEquals("ViewIndex is wrong", "0", tables[0].getCellAsText(1, 0));
53         assertEquals("ViewIndex is wrong", "1", tables[0].getCellAsText(2, 0));
54
55         assertEquals("ListIndex is wrong", "3", tables[0].getCellAsText(1, 1));
56         assertEquals("ListIndex is wrong", "4", tables[0].getCellAsText(2, 1));
57
58     }
59 }
Popular Tags