KickJava   Java API By Example, From Geeks To Geeks.

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


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 removal of no-cache headers.
15  * @author Fabrizio Giustina
16  * @version $Revision: 747 $ ($Author: fgiust $)
17  */

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

24     public String JavaDoc getJspName()
25     {
26         return "media.jsp";
27     }
28
29     /**
30      * Test that headers are correctly removed.
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         // test keep
37
WebRequest request = new GetMethodWebRequest(jspName);
38         WebResponse response = runner.getResponse(request);
39
40         // test remove
41
ParamEncoder encoder = new ParamEncoder("table");
42         String JavaDoc mediaParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE);
43
44         request = new GetMethodWebRequest(jspName);
45         request.setParameter(mediaParameter, Integer.toString(MediaTypeEnum.XML.getCode()));
46
47         response = runner.getResponse(request);
48
49         assertNull("Header Cache-Control not overwritten", response.getHeaderField("Cache-Control"));
50         assertNull("Header Expires not overwritten", response.getHeaderField("Expires"));
51         assertNull("Header Pragma not overwritten", response.getHeaderField("Pragma"));
52     }
53
54 }
Popular Tags