KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.displaytag.jsptests;
2
3 import org.displaytag.properties.MediaTypeEnum;
4 import org.displaytag.tags.TableTagParameters;
5 import org.displaytag.test.DisplaytagCase;
6 import org.displaytag.util.ParamEncoder;
7
8 import com.meterware.httpunit.GetMethodWebRequest;
9 import com.meterware.httpunit.WebRequest;
10 import com.meterware.httpunit.WebResponse;
11
12
13 /**
14  * Tests for DISPL-142: Export of nested tables does not work.
15  * @author Fabrizio Giustina
16  * @version $Revision: 780 $ ($Author: fgiust $)
17  */

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

24     public String JavaDoc getJspName()
25     {
26         return "DISPL-142.jsp";
27     }
28
29     /**
30      * Nested tables should be ignored.
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         ParamEncoder encoder = new ParamEncoder("table");
38         String JavaDoc mediaParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE);
39
40         WebRequest request = new GetMethodWebRequest(jspName);
41         request.setParameter(mediaParameter, Integer.toString(MediaTypeEnum.CSV.getCode()));
42
43         WebResponse response = runner.getResponse(request);
44
45         assertEquals("Expected a different content type.", "text/csv", response.getContentType());
46
47         // second column should be empty
48
assertEquals("Wrong content.", "ant,,camel\nant,,camel\n", response.getText());
49
50         // now export a nested table
51
encoder = new ParamEncoder("nested");
52         mediaParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE);
53         request = new GetMethodWebRequest(jspName);
54         request.setParameter(mediaParameter, Integer.toString(MediaTypeEnum.CSV.getCode()));
55         // this test needs the export filter
56
request.setParameter(TableTagParameters.PARAMETER_EXPORTING, "1");
57         response = runner.getResponse(request);
58
59         assertEquals("Expected a different content type.", "text/csv", response.getContentType());
60
61         // second column should be empty
62
assertEquals("Wrong content.", "bee\nbee\n", response.getText());
63     }
64
65 }
Popular Tags