Search in sources :

Example 51 with UrlRenderer

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

the class UrlRendererTest method test7.

/**
 */
@Test
public void test7() {
    UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("MyTestPage/indexed1/indexed2/indexed3?10-27.ILinkListener-l2&p1=v1")));
    assertEquals("../../../MyTestPage?10", r1.renderUrl(Url.parse("MyTestPage?10")));
}
Also used : MockWebRequest(org.apache.wicket.mock.MockWebRequest) UrlRenderer(org.apache.wicket.request.UrlRenderer) Test(org.junit.Test)

Example 52 with UrlRenderer

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

the class UrlRendererTest method test8.

/**
 */
@Test
public void test8() {
    UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("en/first-test-page?16-1.ILinkListener-l1")));
    assertEquals("./first-test-page/indexed1/indexed2/indexed3?p1=v1", r1.renderUrl(Url.parse("en/first-test-page/indexed1/indexed2/indexed3?p1=v1")));
}
Also used : MockWebRequest(org.apache.wicket.mock.MockWebRequest) UrlRenderer(org.apache.wicket.request.UrlRenderer) Test(org.junit.Test)

Example 53 with UrlRenderer

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

the class UrlRendererTest method renderFullUrlWithRelativeArgument.

@Test
public void renderFullUrlWithRelativeArgument() {
    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);
    String fullUrl = renderer.renderFullUrl(Url.parse("../four"));
    assertEquals("http://www.example.com:8888/one/four", fullUrl);
}
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