1 package org.displaytag.jsptests; 2 3 import org.apache.commons.lang.SystemUtils; 4 import org.displaytag.properties.MediaTypeEnum; 5 import org.displaytag.test.DisplaytagCase; 6 7 import com.meterware.httpunit.GetMethodWebRequest; 8 import com.meterware.httpunit.WebLink; 9 import com.meterware.httpunit.WebRequest; 10 import com.meterware.httpunit.WebResponse; 11 import com.meterware.httpunit.WebTable; 12 13 14 19 public class EncodedUriTest extends DisplaytagCase 20 { 21 22 25 public String getJspName() 26 { 27 return "requesturi.jsp"; 28 } 29 30 35 public void doTest(String jspName) throws Exception 36 { 37 WebRequest request = new GetMethodWebRequest(jspName); 38 request.setParameter("city", "München"); 39 40 WebResponse response = runner.getResponse(request); 41 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, links.length); 52 53 if (SystemUtils.isJavaVersionAtLeast(1.4f)) 54 { 55 assertTrue("Encoded parameter in link is wrong: " + links[0].getURLString(), links[0] 56 .getURLString() 57 .indexOf("M%C3%BCnchen") > -1); 58 } 59 else 60 { 61 62 log.info("Warning, jse 1.4 not available. Encoding used in link will be wrong"); 63 assertTrue("Encoded parameter in link is wrong: " + links[0].getURLString(), links[0] 64 .getURLString() 65 .indexOf("M%FCnchen") > -1); 66 } 67 68 } 69 } | Popular Tags |