When serverName contains schema, the URIBuilder will throw an UnsupportedOperationException while adding a parameter.

This commit is contained in:
Xu Huisheng 2015-08-04 18:20:31 +08:00
parent 5be3cc5b86
commit c03d7c7980
2 changed files with 15 additions and 1 deletions

View File

@ -126,7 +126,7 @@ public final class URIBuilder {
} catch (final UnsupportedEncodingException e) {
LOGGER.error(e.getMessage(), e);
}
return Collections.emptyList();
return new ArrayList<BasicNameValuePair>();
}
/**

View File

@ -152,6 +152,20 @@ public final class CommonUtilsTests extends TestCase {
assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl);
}
public void testConstructServiceUrlWithParamsCasAndServerNameWithSchema() {
final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/";
final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/");
request.setScheme("https");
request.setSecure(true);
request.setQueryString("service=this&ticket=that&custom=custom");
final MockHttpServletResponse response = new MockHttpServletResponse();
final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "https://www.myserver.com",
Protocol.CAS3.getServiceParameterName(), Protocol.CAS3.getArtifactParameterName() , false);
assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl);
}
public void testConstructServiceUrlWithParamsSaml() {
final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/";