KickJava   Java API By Example, From Geeks To Geeks.

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


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-280 - Sortable header links fail when using external sorting and an integer as the sortName.
15  * @author Fabrizio Giustina
16  * @version $Id$
17  */

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

24     public String JavaDoc getJspName()
25     {
26         return "DISPL-280.jsp";
27     }
28
29     /**
30      * Check sorted column.
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         WebRequest request = new GetMethodWebRequest(jspName);
37
38         ParamEncoder encoder = new ParamEncoder("table");
39         request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_SORT), "1");
40         request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_SORTUSINGNAME), "1");
41
42         WebResponse response = runner.getResponse(request);
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.", 3, tables[0].getRowCount());
52
53         if (log.isDebugEnabled())
54         {
55             log.debug(response.getText());
56         }
57
58         assertEquals("Wrong value in first row. Table incorrectly sorted?", "2", tables[0].getCellAsText(1, 1));
59         assertEquals("Column 1 should not be marked as sorted.", "sortable", tables[0]
60             .getTableCell(0, 1)
61             .getClassName());
62         assertEquals("Column 2 should be marked as sorted.", "sortable sorted order1", tables[0]
63             .getTableCell(0, 2)
64             .getClassName());
65
66     }
67
68 }
Popular Tags