KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.displaytag.jsptests;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.displaytag.test.DisplaytagCase;
5
6 import com.meterware.httpunit.GetMethodWebRequest;
7 import com.meterware.httpunit.WebLink;
8 import com.meterware.httpunit.WebRequest;
9 import com.meterware.httpunit.WebResponse;
10 import com.meterware.httpunit.WebTable;
11
12
13 /**
14  * Test for DISPL-264 - Export to Excel not appending form parameters.
15  * @author Fabrizio Giustina
16  * @version $Id$
17  */

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

24     public String JavaDoc getJspName()
25     {
26         return "DISPL-264.jsp";
27     }
28
29     /**
30      * Check generated links for form parameters.
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         WebRequest request = new GetMethodWebRequest(jspName);
37         request.setParameter("test", "value");
38         WebResponse response = runner.getResponse(request);
39
40         if (log.isDebugEnabled())
41         {
42             log.debug(response.getText());
43         }
44
45         WebTable[] tables = response.getTables();
46         assertEquals("Wrong number of tables in result.", 1, tables.length);
47
48         if (log.isDebugEnabled())
49         {
50             log.debug(response.getText());
51         }
52
53         WebLink[] links = response.getLinks();
54         assertTrue("No links found.", links.length > 0);
55         String JavaDoc url = links[0].getURLString();
56         assertTrue("Expected parameter not found in url " + url, StringUtils.contains(url, "test=value"));
57     }
58
59 }
Popular Tags