Search in sources :

Example 11 with UrlRenderer

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

the class UrlRendererTest method test15.

/**
 * WICKET-4935 prevent another double slash
 */
@Test
public void test15() {
    UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("private/AdminPage")));
    assertEquals("../signIn;jsessionid=16k3wqa9c4sgq1cnp7fisa20u", r1.renderRelativeUrl(Url.parse("/signIn;jsessionid=16k3wqa9c4sgq1cnp7fisa20u")));
}
Also used : MockWebRequest(org.apache.wicket.mock.MockWebRequest) UrlRenderer(org.apache.wicket.request.UrlRenderer) Test(org.junit.Test)

Example 12 with UrlRenderer

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

the class UrlRendererTest method renderUrlWithManyDotsAtTheEnd1.

/**
 * https://issues.apache.org/jira/browse/WICKET-6230
 */
@Test
public void renderUrlWithManyDotsAtTheEnd1() {
    UrlRenderer renderer = new UrlRenderer(new MockWebRequest(Url.parse("a")));
    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 13 with UrlRenderer

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

the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheContextAndFilterPaths.

@Test
public void renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheContextAndFilterPaths() {
    // base url without context path and filter path
    // 'filterPath' here is a normal segment with the same value
    Url baseUrl = Url.parse("filterPath/a/b/c/d");
    // here 'contextPath' is the actual context path and should be ignored
    Url encodedFullUrl = Url.parse("http://host:8080/contextPath/filterPath/a/b;jsessionid=123456");
    MockWebRequest request = new MockWebRequest(baseUrl);
    request.setContextPath("contextPath");
    request.setFilterPath("filterPath");
    UrlRenderer renderer = new UrlRenderer(request);
    String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);
    assertEquals("../../../../a/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 14 with UrlRenderer

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

the class UrlRendererTest method test5.

/**
 */
@Test
public void test5() {
    UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("url")));
    assertEquals("./url?1", r1.renderUrl(Url.parse("url?1")));
}
Also used : MockWebRequest(org.apache.wicket.mock.MockWebRequest) UrlRenderer(org.apache.wicket.request.UrlRenderer) Test(org.junit.Test)

Example 15 with UrlRenderer

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

the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithoutContextAndFilterPaths.

@Test
public void renderFullUrlAsRelativeToBaseUrlWithoutContextAndFilterPaths() {
    // base url without context path and filter path
    Url baseUrl = Url.parse("a/b/c/d");
    Url encodedFullUrl = Url.parse("http://host:8080/contextPath/filterPath/a/b;jsessionid=123456");
    MockWebRequest request = new MockWebRequest(baseUrl);
    request.setContextPath("contextPath");
    request.setFilterPath("filterPath");
    UrlRenderer renderer = new UrlRenderer(request);
    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)

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