use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method test12.
/**
* <a href="https://issues.apache.org/jira/browse/WICKET-3567">WICKET-3567</a>
*/
@Test
public void test12() {
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("?0")));
assertEquals("./", r1.renderUrl(Url.parse("")));
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderFullUrlWithNoOpLeadingSegments.
/**
* https://issues.apache.org/jira/browse/WICKET-5774
*/
@Test
public void renderFullUrlWithNoOpLeadingSegments() {
UrlRenderer renderer = new UrlRenderer(new MockWebRequest(Url.parse("any/thing")));
String fullUrl = renderer.renderFullUrl(Url.parse("http://www.example.com:8888/./../one/two/three"));
assertEquals("http://www.example.com:8888/one/two/three", fullUrl);
fullUrl = renderer.renderFullUrl(Url.parse("http://www.example.com:8888/.././one/two/three"));
assertEquals("http://www.example.com:8888/one/two/three", fullUrl);
fullUrl = renderer.renderFullUrl(Url.parse("http://www.example.com:8888/one/.././two/three"));
assertEquals("http://www.example.com:8888/two/three", fullUrl);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class ServletWebResponseTest method encodeAbsoluteUrl.
/**
* WICKET-5582 absolute URLs stay absolute after encoding
*/
@Test
public void encodeAbsoluteUrl() {
final String url = "http://localhost:8080/path";
ServletWebRequest webRequest = mock(ServletWebRequest.class);
when(webRequest.isAjax()).thenReturn(Boolean.FALSE);
Url baseUrl = Url.parse("./baseUrl");
baseUrl.setProtocol("http");
baseUrl.setHost("someHost");
baseUrl.setPort(80);
when(webRequest.getClientUrl()).thenReturn(baseUrl);
UrlRenderer renderer = new UrlRenderer(webRequest);
RequestCycle requestCycle = mock(RequestCycle.class);
ThreadContext.setRequestCycle(requestCycle);
when(requestCycle.getUrlRenderer()).thenReturn(renderer);
HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
when(httpServletResponse.encodeURL(Matchers.eq(url))).thenReturn(url + ";foo");
ServletWebResponse webResponse = new ServletWebResponse(webRequest, httpServletResponse);
assertEquals(url + ";foo", webResponse.encodeURL(url));
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method renderFullUrlWithAbsoluteArgument.
/**
* https://issues.apache.org/jira/browse/WICKET-4514
*/
@Test
public void renderFullUrlWithAbsoluteArgument() {
Url baseUrl = Url.parse("one/two/three");
baseUrl.setProtocol("http");
baseUrl.setHost("www.example.com");
baseUrl.setPort(8888);
UrlRenderer renderer = new UrlRenderer(new MockWebRequest(baseUrl));
// this is needed because MockWebRequest cuts data
renderer.setBaseUrl(baseUrl);
// url starting with slash is
String fullUrl = renderer.renderFullUrl(Url.parse("/four"));
// considered absolute
assertEquals("http://www.example.com:8888/four", fullUrl);
}
use of org.apache.wicket.request.UrlRenderer in project wicket by apache.
the class UrlRendererTest method rendersRelativeUrl.
@Test
public void rendersRelativeUrl() {
Url contextRelativeUrl = new Url();
contextRelativeUrl.setProtocol("http");
contextRelativeUrl.setHost("localshot");
contextRelativeUrl.setPort(8080);
contextRelativeUrl.setContextRelative(true);
contextRelativeUrl.getSegments().addAll(asList("", ""));
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(contextRelativeUrl));
assertThat(r1.renderRelativeUrl(Url.parse("foo")), is("../foo"));
}
Aggregations