WW-1709 fixed nullpointer when scheme is null

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@508880 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Schneider
2007-02-18 06:33:26 +00:00
parent 7d8dfff8a1
commit 3f7dd2ef82
@@ -74,6 +74,26 @@ public class UrlHelperTest extends StrutsTestCase {
assertEquals(expectedUrl, result);
}
public void testForceAddNullSchemeHostAndPort() throws Exception {
String expectedUrl = "http://localhost/contextPath/path1/path2/myAction.action";
Mock mockHttpServletRequest = new Mock(HttpServletRequest.class);
mockHttpServletRequest.expectAndReturn("getScheme", "http");
mockHttpServletRequest.expectAndReturn("getServerName", "localhost");
mockHttpServletRequest.expectAndReturn("getContextPath",
"/contextPath");
Mock mockHttpServletResponse = new Mock(HttpServletResponse.class);
mockHttpServletResponse.expectAndReturn("encodeURL", expectedUrl,
expectedUrl);
String result = UrlHelper.buildUrl("/path1/path2/myAction.action",
(HttpServletRequest) mockHttpServletRequest.proxy(),
(HttpServletResponse) mockHttpServletResponse.proxy(), null,
null, true, true, true);
assertEquals(expectedUrl, result);
mockHttpServletRequest.verify();
}
public void testBuildParametersStringWithUrlHavingSomeExistingParameters() throws Exception {
String expectedUrl = "http://localhost:8080/myContext/myPage.jsp?initParam=initValue&param1=value1&param2=value2";