mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
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:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user