use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderAbsoluteUrl.
/**
* Verify that absolute urls are rendered as is, ignoring the current client url and base url
* completely.
*
* https://issues.apache.org/jira/browse/WICKET-4466
*/
@Test
public void renderAbsoluteUrl() {
String absoluteUrl = "http://www.example.com/some/path.ext";
Url url = Url.parse(absoluteUrl);
UrlRenderer renderer = new UrlRenderer(new MockWebRequest(Url.parse("foo/bar")));
String renderedUrl = renderer.renderUrl(url);
assertEquals(absoluteUrl, renderedUrl);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheContextPath.
@Test
public void renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheContextPath() {
// base url without context path and filter path
// 'contextPath' here is a normal segment with the same value
Url baseUrl = Url.parse("contextPath/a/b/c/d");
// here 'contextPath' is the actual context path and should be ignored
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("../../../../a/b;jsessionid=123456", encodedRelativeUrl);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderAbsoluteWithoutHost.
/**
* https://issues.apache.org/jira/browse/WICKET-5065
*/
@Test
public void renderAbsoluteWithoutHost() {
Url baseUrl = Url.parse("a/b");
MockWebRequest request = new MockWebRequest(baseUrl);
UrlRenderer renderer = new UrlRenderer(request);
Url absoluteUrl = Url.parse("/c/d");
String encodedRelativeUrl = renderer.renderUrl(absoluteUrl);
assertEquals("/c/d", encodedRelativeUrl);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithoutComposedContextAndFilterPaths.
@Test
public void renderFullUrlAsRelativeToBaseUrlWithoutComposedContextAndFilterPaths() {
// base url without context path and filter path
Url baseUrl = Url.parse("a/b/c/d");
Url encodedFullUrl = Url.parse("http://host:8080/context/path/filter/path/a/b;jsessionid=123456");
MockWebRequest request = new MockWebRequest(baseUrl);
request.setContextPath("context/path");
request.setFilterPath("filter/path");
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 renderFullUrlAsRelativeToBaseUrlWithoutContextPath.
@Test
public void renderFullUrlAsRelativeToBaseUrlWithoutContextPath() {
// base url without context path and filter path
Url baseUrl = Url.parse("a/b/c/d");
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("../../b;jsessionid=123456", encodedRelativeUrl);
}
Aggregations