KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.displaytag.jsptests;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.displaytag.test.DisplaytagCase;
5 import org.displaytag.test.KnownValue;
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 different kind of "data sources".
15  * @author Fabrizio Giustina
16  * @version $Revision: 907 $ ($Author: fgiust $)
17  */

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

24     public String JavaDoc getJspName()
25     {
26         return "map_autocolumn.jsp";
27     }
28
29     /**
30      * Test with a Map[] with automatically discoverd 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
37         WebRequest request = new GetMethodWebRequest(jspName);
38
39         WebResponse response = runner.getResponse(request);
40
41         if (log.isDebugEnabled())
42         {
43             log.debug("RESPONSE: " + response.getText());
44         }
45
46         WebTable[] tables = response.getTables();
47
48         assertEquals("Wrong number of tables.", 1, tables.length);
49
50         assertEquals("Bad number of generated columns.", 3, tables[0].getColumnCount());
51
52         assertEquals("Bad value in column header.", //
53
StringUtils.capitalize(KnownValue.ANT),
54             tables[0].getCellAsText(0, 0));
55         assertEquals("Bad value in column header.", //
56
StringUtils.capitalize(KnownValue.BEE),
57             tables[0].getCellAsText(0, 1));
58         assertEquals("Bad value in column header.", //
59
"camel title",
60             tables[0].getCellAsText(0, 2)); // localized text
61

62         assertEquals("Bad value in column content.", KnownValue.ANT, tables[0].getCellAsText(1, 0));
63         assertEquals("Bad value in column content.", KnownValue.BEE, tables[0].getCellAsText(1, 1));
64         assertEquals("Bad value in column content.", KnownValue.CAMEL, tables[0].getCellAsText(1, 2));
65     }
66 }
Popular Tags