KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Test for DISPL-209 - getListIndex() does not return the real list index. Note: the result is different from the one
15  * expected from the decription in the Jira report, but after the test it was clear that there is no usable way to get
16  * the desired result.
17  * @author Fabrizio Giustina
18  * @version $Id$
19  */

20 public class Displ209Test extends DisplaytagCase
21 {
22
23     /**
24      * @see org.displaytag.test.DisplaytagCase#getJspName()
25      */

26     public String JavaDoc getJspName()
27     {
28         return "DISPL-209.jsp";
29     }
30
31     /**
32      * Check list index/view index values.
33      * @param jspName jsp name, with full path
34      * @throws Exception any axception thrown during test.
35      */

36     public void doTest(String JavaDoc jspName) throws Exception JavaDoc
37     {
38         WebRequest request = new GetMethodWebRequest(jspName);
39         WebResponse response = runner.getResponse(request);
40
41         ParamEncoder encoder = new ParamEncoder("table");
42         request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_PAGE), "2");
43
44         if (log.isDebugEnabled())
45         {
46             log.debug(response.getText());
47         }
48
49         WebTable[] tables = response.getTables();
50         assertEquals("Wrong number of tables in result.", 1, tables.length);
51         assertEquals("Wrong number of rows in result.", 4, tables[0].getRowCount());
52
53         if (log.isDebugEnabled())
54         {
55             log.debug(response.getText());
56         }
57
58         assertEquals("Wrong value", "a", tables[0].getCellAsText(1, 0));
59         assertEquals("Wrong viewIndex", "0", tables[0].getCellAsText(1, 1));
60         assertEquals("Wrong listIndex", "0", tables[0].getCellAsText(1, 2));
61
62         assertEquals("Wrong value", "b", tables[0].getCellAsText(2, 0));
63         assertEquals("Wrong viewIndex", "1", tables[0].getCellAsText(2, 1));
64         assertEquals("Wrong listIndex", "1", tables[0].getCellAsText(2, 2));
65
66         assertEquals("Wrong value", "c", tables[0].getCellAsText(3, 0));
67         assertEquals("Wrong viewIndex", "2", tables[0].getCellAsText(3, 1));
68         assertEquals("Wrong listIndex", "2", tables[0].getCellAsText(3, 2));
69     }
70
71 }
Popular Tags