KickJava   Java API By Example, From Geeks To Geeks.

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


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.test.URLAssert;
7 import org.displaytag.util.ParamEncoder;
8
9 import com.meterware.httpunit.GetMethodWebRequest;
10 import com.meterware.httpunit.WebLink;
11 import com.meterware.httpunit.WebRequest;
12 import com.meterware.httpunit.WebResponse;
13 import com.meterware.httpunit.WebTable;
14
15
16 /**
17  * Tests for requestUri column attribute.
18  * @author Fabrizio Giustina
19  * @version $Revision: 907 $ ($Author: fgiust $)
20  */

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

27     public String JavaDoc getJspName()
28     {
29         return "requesturi.jsp";
30     }
31
32     /**
33      * Test link generated using requestUri.
34      * @param jspName jsp name, with full path
35      * @throws Exception any axception thrown during test.
36      */

37     public void doTest(String JavaDoc jspName) throws Exception JavaDoc
38     {
39         WebRequest request = new GetMethodWebRequest(jspName);
40
41         WebResponse response = runner.getResponse(request);
42         if (log.isDebugEnabled())
43         {
44             log.debug(response.getText());
45         }
46
47         WebTable[] tables = response.getTables();
48         assertEquals("Wrong number of tables.", 1, tables.length);
49
50         WebLink[] links = response.getLinks();
51         assertEquals("Wrong number of links in result.", MediaTypeEnum.getSize() - 1 // MediaTypeEnum also lists html
52
,
53             links.length);
54
55         URLAssert.assertEquals(CONTEXT
56             + "/goforit?"
57             + new ParamEncoder("table").encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE)
58             + "=1&"
59             + TableTagParameters.PARAMETER_EXPORTING
60             + "=1", links[0].getURLString());
61     }
62
63 }
Popular Tags