KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.displaytag.jsptests;
2
3 import org.displaytag.tags.TableTagParameters;
4 import org.displaytag.test.DisplaytagCase;
5 import org.displaytag.test.URLAssert;
6 import org.displaytag.util.ParamEncoder;
7
8 import com.meterware.httpunit.GetMethodWebRequest;
9 import com.meterware.httpunit.WebLink;
10 import com.meterware.httpunit.WebRequest;
11 import com.meterware.httpunit.WebResponse;
12 import com.meterware.httpunit.WebTable;
13
14
15 /**
16  * Test for DISPL-117 - Allow ColumnTag to generate links to current page.
17  * @author Fabrizio Giustina
18  * @version $Revision: 894 $ ($Author: fgiust $)
19  */

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

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

36     public void doTest(String JavaDoc jspName) throws Exception JavaDoc
37     {
38         WebRequest request = new GetMethodWebRequest(jspName);
39         ParamEncoder encoder = new ParamEncoder("table");
40         request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_ORDER), "2");
41         request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_SORT), "0");
42
43         WebResponse response = runner.getResponse(request);
44
45         if (log.isDebugEnabled())
46         {
47             log.debug(response.getText());
48         }
49
50         WebTable[] tables = response.getTables();
51         assertEquals("Wrong number of tables.", 1, tables.length);
52
53         WebLink[] links = response.getLinks();
54         assertEquals("Wrong number of links in result.", 1, links.length);
55
56         URLAssert.assertEquals("/context/goforit?param=ant&d-148916-s=0&d-148916-o=2", links[0].getURLString());
57     }
58
59 }
Popular Tags