use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method removeCommonPrefixesWithJSessionId.
/**
* https://issues.apache.org/jira/browse/WICKET-5202
*/
@Test
public void removeCommonPrefixesWithJSessionId() {
Url baseUrl = new Url(Arrays.asList("", "SomePage;jsessionid=1234"), Arrays.<Url.QueryParameter>asList());
MockWebRequest request = new MockWebRequest(baseUrl);
request.setContextPath("/");
request.setFilterPath("filter");
UrlRenderer renderer = new UrlRenderer(request);
renderer.setBaseUrl(baseUrl);
String rendered = renderer.renderRelativeUrl(Url.parse("/filter;jsessionid=1234"));
assertEquals("../", rendered);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithoutFilterPath.
@Test
public void renderFullUrlAsRelativeToBaseUrlWithoutFilterPath() {
// base url without context path and filter path
Url baseUrl = Url.parse("a/b/c/d");
Url encodedFullUrl = Url.parse("http://host:8080/contextPath/a/b;jsessionid=123456");
MockWebRequest request = new MockWebRequest(baseUrl);
request.setContextPath("contextPath");
UrlRenderer renderer = new UrlRenderer(request);
String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);
assertEquals("../../b;jsessionid=123456", encodedRelativeUrl);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method test14.
/**
* WICKET-4920 prevent double slash
*/
@Test
public void test14() {
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(new Url()));
assertEquals("./;jsessionid=1p87c5424zjuvd57kljcu2bwa?0-1.IBehaviorListener.1-component", r1.renderRelativeUrl(Url.parse("http://localhost:8080/;jsessionid=1p87c5424zjuvd57kljcu2bwa?0-1.IBehaviorListener.1-component")));
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method test13.
/**
* https://issues.apache.org/jira/browse/WICKET-4401
*
* A Url should not ends with '..' because some web containers do not handle it properly. Using
* '../' works better.
*/
@Test
public void test13() {
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("foo/bar")));
assertEquals("../", r1.renderUrl(Url.parse("")));
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheFilterPath.
@Test
public void renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheFilterPath() {
// base url without context path and filter path
// 'filterPath' here is a normal segment with the same value
Url baseUrl = Url.parse("filterPath/a/b/c/d");
// here 'filterPath' is the actual filter path and should be ignored
Url encodedFullUrl = Url.parse("http://host:8080/filterPath/a/b;jsessionid=123456");
MockWebRequest request = new MockWebRequest(baseUrl);
request.setFilterPath("filterPath");
UrlRenderer renderer = new UrlRenderer(request);
String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);
assertEquals("../../../../a/b;jsessionid=123456", encodedRelativeUrl);
}
Aggregations