use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderUrlWithFragment.
/**
* https://issues.apache.org/jira/browse/WICKET-5970
*/
@Test
public void renderUrlWithFragment() {
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.renderUrl(urlWithFragment);
assertEquals("http://localhost:8080/redirect#access_token=123456", renderedUrl);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method test1.
/**
*/
@Test
public void test1() {
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("foo/bar/baz?a=b")));
assertEquals("./xyz?x=y", r1.renderUrl(Url.parse("foo/bar/xyz?x=y")));
assertEquals("./baz/xyz?x=y", r1.renderUrl(Url.parse("foo/bar/baz/xyz?x=y")));
assertEquals("../aaa/xyz?x=y", r1.renderUrl(Url.parse("foo/aaa/xyz?x=y")));
assertEquals("../../bbb/aaa/xyz?x=y", r1.renderUrl(Url.parse("bbb/aaa/xyz?x=y")));
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderUrlWithRelativeArgument.
/**
* https://issues.apache.org/jira/browse/WICKET-4561
* https://issues.apache.org/jira/browse/WICKET-4562
*/
@Test
public void renderUrlWithRelativeArgument() {
Url baseUrl = Url.parse("one/two/three");
UrlRenderer renderer = new UrlRenderer(new MockWebRequest(baseUrl));
baseUrl.setProtocol("http");
baseUrl.setHost("www.example.com");
baseUrl.setPort(8888);
renderer.setBaseUrl(baseUrl);
Url newUrl = Url.parse("four");
newUrl.setProtocol("https");
String fullUrl = renderer.renderUrl(newUrl);
assertEquals("https://www.example.com:8888/four", fullUrl);
newUrl = Url.parse("./four");
newUrl.setProtocol("https");
fullUrl = renderer.renderUrl(newUrl);
assertEquals("https://www.example.com:8888/four", fullUrl);
newUrl = Url.parse("./././four");
newUrl.setProtocol("https");
fullUrl = renderer.renderUrl(newUrl);
assertEquals("https://www.example.com:8888/four", fullUrl);
newUrl = Url.parse("../four");
newUrl.setProtocol("https");
fullUrl = renderer.renderUrl(newUrl);
assertEquals("https://www.example.com:8888/four", fullUrl);
newUrl = Url.parse(".././four");
newUrl.setProtocol("https");
fullUrl = renderer.renderUrl(newUrl);
assertEquals("https://www.example.com:8888/four", fullUrl);
newUrl = Url.parse("../../../../four");
newUrl.setProtocol("https");
fullUrl = renderer.renderUrl(newUrl);
assertEquals("https://www.example.com:8888/four", fullUrl);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method test9.
/**
*/
@Test
public void test9() {
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("a/b/q/d/e")));
assertEquals("../../../q/c/d/e", r1.renderUrl(Url.parse("a/q/c/d/e")));
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderFullUrlAsRelativeToAnAbsoluteBaseUrl.
@Test
public void renderFullUrlAsRelativeToAnAbsoluteBaseUrl() {
Url baseUrl = Url.parse("http://host:8080/contextPath/filterPath/a/b/c/d");
Url encodedFullUrl = Url.parse("http://host:8080/contextPath/filterPath/a/b;jsessionid=123456");
UrlRenderer renderer = new UrlRenderer(new MockWebRequest(baseUrl));
String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);
assertEquals("../../b;jsessionid=123456", encodedRelativeUrl);
}
Aggregations