KickJava   Java API By Example, From Geeks To Geeks.

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


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
11
12 /**
13  * Tests for DISPL-105: https hrefs in Table get generated as http.
14  * @author Fabrizio Giustina
15  * @version $Revision: 722 $ ($Author: fgiust $)
16  */

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

23     public String JavaDoc getJspName()
24     {
25         return "DISPL-105.jsp";
26     }
27
28     /**
29      * Generated link should be https.
30      * @param jspName jsp name, with full path
31      * @throws Exception any axception thrown during test.
32      */

33     public void doTest(String JavaDoc jspName) throws Exception JavaDoc
34     {
35         String JavaDoc httpsUrl = StringUtils.replace(jspName, "http://", "https://");
36         WebRequest request = new GetMethodWebRequest(httpsUrl);
37
38         WebResponse response = runner.getResponse(request);
39
40         WebLink[] links = response.getLinks();
41         assertEquals("Wrong number of generated links.", 1, links.length);
42
43         assertTrue("Generated link doesn't start with https: " + links[0].getURLString(), links[0]
44             .getURLString()
45             .startsWith("https://"));
46
47     }
48
49 }
Popular Tags