use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method test2.
/**
*/
@Test
public void test2() {
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("foo/bar/baz?a=b")));
assertEquals("../../foo?x=y", r1.renderUrl(Url.parse("foo?x=y")));
assertEquals("../../aaa?x=y", r1.renderUrl(Url.parse("aaa?x=y")));
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderRelativeUrlWithFragment.
/**
* https://issues.apache.org/jira/browse/WICKET-5970
*/
@Test
public void renderRelativeUrlWithFragment() {
UrlRenderer renderer = new UrlRenderer(new MockWebRequest(Url.parse("authorize")));
Url urlWithFragment = Url.parse("http://localhost:8080/redirect#access_token=123456");
assertEquals("access_token=123456", urlWithFragment.getFragment());
String renderedUrl = renderer.renderRelativeUrl(urlWithFragment);
assertEquals("./redirect#access_token=123456", renderedUrl);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderContextAbsoluteUrlWithNoOpLeadingSegments.
/**
* https://issues.apache.org/jira/browse/WICKET-5774
*/
@Test
public void renderContextAbsoluteUrlWithNoOpLeadingSegments() {
UrlRenderer renderer = new UrlRenderer(new MockWebRequest(Url.parse("any/thing")));
String fullUrl = renderer.renderFullUrl(Url.parse("/./../one/two/three"));
assertEquals("/one/two/three", fullUrl);
fullUrl = renderer.renderFullUrl(Url.parse("/.././one/two/three"));
assertEquals("/one/two/three", fullUrl);
fullUrl = renderer.renderFullUrl(Url.parse("/one/.././two/three"));
assertEquals("/two/three", fullUrl);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderHomeUrl.
/**
* https://issues.apache.org/jira/browse/WICKET-5123
*/
@Test
public void renderHomeUrl() {
Url baseUrl = Url.parse("login");
MockWebRequest request = new MockWebRequest(baseUrl);
UrlRenderer renderer = new UrlRenderer(request);
Url homeUrl = Url.parse("");
String encodedRelativeUrl = renderer.renderUrl(homeUrl);
assertEquals(".", encodedRelativeUrl);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method test10.
/**
*/
@Test
public void test10() {
MockWebRequest request = new MockWebRequest(Url.parse("a/b/q/d/e"), "/contextPath", "/filterPath", "../");
UrlRenderer r = new UrlRenderer(request);
assertEquals("../../../../../", r.renderContextRelativeUrl(""));
assertEquals("../../../../../", r.renderContextRelativeUrl("/"));
assertEquals("../../../../../f", r.renderContextRelativeUrl("/f"));
assertEquals("../../../../../../f", r.renderContextRelativeUrl("../f"));
try {
r.renderContextRelativeUrl(null);
fail("Null 'url' is not allowed!");
} catch (IllegalArgumentException iax) {
assertTrue(true);
}
}
Aggregations