Search in sources :

Example 21 with UrlRenderer

use of org.apache.wicket.request.UrlRenderer in project wicket by apache.

the class UrlRendererTest method renderUrlWithManyDotsAtTheEnd2.

/**
 * https://issues.apache.org/jira/browse/WICKET-6230
 */
@Test
public void renderUrlWithManyDotsAtTheEnd2() {
    UrlRenderer renderer = new UrlRenderer(new MockWebRequest(Url.parse("a/b")));
    String renderedUrl = renderer.renderUrl(Url.parse("abc..."));
    assertEquals("../abc...", renderedUrl);
}
Also used : MockWebRequest(org.apache.wicket.mock.MockWebRequest) UrlRenderer(org.apache.wicket.request.UrlRenderer) Test(org.junit.Test)

Example 22 with UrlRenderer

use of org.apache.wicket.request.UrlRenderer in project wicket by apache.

the class WebPageRendererTest method before.

/**
 * Common setup
 */
@Before
public void before() {
    provider = mock(IPageProvider.class);
    page = mock(IRequestablePage.class);
    when(provider.getPageInstance()).thenReturn(page);
    handler = new RenderPageRequestHandler(provider);
    requestCycle = mock(RequestCycle.class);
    urlRenderer = mock(UrlRenderer.class);
    when(requestCycle.getUrlRenderer()).thenReturn(urlRenderer);
    request = mock(WebRequest.class);
    when(requestCycle.getRequest()).thenReturn(request);
    response = mock(WebResponse.class);
    when(requestCycle.getResponse()).thenReturn(response);
}
Also used : BufferedWebResponse(org.apache.wicket.protocol.http.BufferedWebResponse) WebResponse(org.apache.wicket.request.http.WebResponse) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) WebRequest(org.apache.wicket.request.http.WebRequest) RequestCycle(org.apache.wicket.request.cycle.RequestCycle) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) UrlRenderer(org.apache.wicket.request.UrlRenderer) Before(org.junit.Before)

Example 23 with UrlRenderer

use of org.apache.wicket.request.UrlRenderer in project wicket by apache.

the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithoutSchemeHostnameAndPort.

@Test
public void renderFullUrlAsRelativeToBaseUrlWithoutSchemeHostnameAndPort() {
    Url baseUrl = Url.parse("/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);
}
Also used : MockWebRequest(org.apache.wicket.mock.MockWebRequest) UrlRenderer(org.apache.wicket.request.UrlRenderer) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 24 with UrlRenderer

use of org.apache.wicket.request.UrlRenderer in project wicket by apache.

the class UrlRendererTest method test3.

/**
 */
@Test
public void test3() {
    UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("?a=b")));
    assertEquals("./a/b/c?x=y", r1.renderUrl(Url.parse("a/b/c?x=y")));
}
Also used : MockWebRequest(org.apache.wicket.mock.MockWebRequest) UrlRenderer(org.apache.wicket.request.UrlRenderer) Test(org.junit.Test)

Example 25 with UrlRenderer

use of org.apache.wicket.request.UrlRenderer in project wicket by apache.

the class UrlRendererTest method removeCommonPrefixesWicket5073.

/**
 * https://issues.apache.org/jira/browse/WICKET-5073
 */
@Test
public void removeCommonPrefixesWicket5073() {
    Url baseUrl = new Url(Arrays.asList(""), Arrays.<Url.QueryParameter>asList());
    MockWebRequest request = new MockWebRequest(baseUrl);
    request.setContextPath("/qs");
    request.setFilterPath("");
    UrlRenderer renderer = new UrlRenderer(request);
    renderer.setBaseUrl(baseUrl);
    String rendered = renderer.renderRelativeUrl(Url.parse("wicket/resource/org.apache.wicket.Application/x.css"));
    assertEquals("./wicket/resource/org.apache.wicket.Application/x.css", rendered);
}
Also used : MockWebRequest(org.apache.wicket.mock.MockWebRequest) UrlRenderer(org.apache.wicket.request.UrlRenderer) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

UrlRenderer (org.apache.wicket.request.UrlRenderer)53 Test (org.junit.Test)49 MockWebRequest (org.apache.wicket.mock.MockWebRequest)47 Url (org.apache.wicket.request.Url)30 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 MockHttpServletResponse (org.apache.wicket.protocol.http.mock.MockHttpServletResponse)2 Before (org.junit.Before)2 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)1 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)1 IHeaderResponse (org.apache.wicket.markup.head.IHeaderResponse)1 HeaderResponse (org.apache.wicket.markup.head.internal.HeaderResponse)1 BufferedWebResponse (org.apache.wicket.protocol.http.BufferedWebResponse)1 IRequestHandler (org.apache.wicket.request.IRequestHandler)1 Request (org.apache.wicket.request.Request)1 Response (org.apache.wicket.request.Response)1 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)1 WebRequest (org.apache.wicket.request.http.WebRequest)1 WebResponse (org.apache.wicket.request.http.WebResponse)1 IResource (org.apache.wicket.request.resource.IResource)1