use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheContextAndFilterPaths.
@Test
public void renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheContextAndFilterPaths() {
// 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 'contextPath' is the actual context path and should be ignored
Url encodedFullUrl = Url.parse("http://host:8080/contextPath/filterPath/a/b;jsessionid=123456");
MockWebRequest request = new MockWebRequest(baseUrl);
request.setContextPath("contextPath");
request.setFilterPath("filterPath");
UrlRenderer renderer = new UrlRenderer(request);
String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);
assertEquals("../../../../a/b;jsessionid=123456", encodedRelativeUrl);
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method test5.
/**
*/
@Test
public void test5() {
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("url")));
assertEquals("./url?1", r1.renderUrl(Url.parse("url?1")));
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithoutContextAndFilterPaths.
@Test
public void renderFullUrlAsRelativeToBaseUrlWithoutContextAndFilterPaths() {
// base url without context path and filter path
Url baseUrl = Url.parse("a/b/c/d");
Url encodedFullUrl = Url.parse("http://host:8080/contextPath/filterPath/a/b;jsessionid=123456");
MockWebRequest request = new MockWebRequest(baseUrl);
request.setContextPath("contextPath");
request.setFilterPath("filterPath");
UrlRenderer renderer = new UrlRenderer(request);
String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);
assertEquals("../../b;jsessionid=123456", encodedRelativeUrl);
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithoutComposedContextPath.
@Test
public void renderFullUrlAsRelativeToBaseUrlWithoutComposedContextPath() {
// base url without context path and filter path
Url baseUrl = Url.parse("a/b/c/d");
Url encodedFullUrl = Url.parse("http://host:8080/filter/path/a/b;jsessionid=123456");
MockWebRequest request = new MockWebRequest(baseUrl);
request.setFilterPath("filter/path");
UrlRenderer renderer = new UrlRenderer(request);
String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);
assertEquals("../../b;jsessionid=123456", encodedRelativeUrl);
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method renderUrlWithManyDotsAtTheBeginning1.
/**
* https://issues.apache.org/jira/browse/WICKET-6230
*/
@Test
public void renderUrlWithManyDotsAtTheBeginning1() {
UrlRenderer renderer = new UrlRenderer(new MockWebRequest(Url.parse("a")));
String renderedUrl = renderer.renderUrl(Url.parse("...abc"));
assertEquals("./...abc", renderedUrl);
}
Aggregations