Search in sources :

Example 16 with MockWebRequest

use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.

the class UrlRendererTest method test16.

/**
 * prevent another double slash when common prefix is present
 */
@Test
public void test16() {
    UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("private/AdminPage")).setContextPath("context"));
    assertEquals("../signIn;jsessionid=16k3wqa9c4sgq1cnp7fisa20u", r1.renderRelativeUrl(Url.parse("/context/signIn;jsessionid=16k3wqa9c4sgq1cnp7fisa20u")));
}
Also used : MockWebRequest(org.apache.wicket.mock.MockWebRequest) UrlRenderer(org.apache.wicket.request.UrlRenderer) Test(org.junit.Test)

Example 17 with MockWebRequest

use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.

the class UrlRendererTest method renderAbsoluteWithoutSchemeWithPort.

/**
 * https://issues.apache.org/jira/browse/WICKET-5065
 */
@Test
public void renderAbsoluteWithoutSchemeWithPort() {
    Url baseUrl = Url.parse("a/b");
    MockWebRequest request = new MockWebRequest(baseUrl);
    UrlRenderer renderer = new UrlRenderer(request);
    Url absoluteUrl = Url.parse("//host:1234/c/d");
    String encodedRelativeUrl = renderer.renderUrl(absoluteUrl);
    assertEquals("//host:1234/c/d", 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 18 with MockWebRequest

use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.

the class UrlRendererTest method renderAbsoluteWithoutScheme.

/**
 * https://issues.apache.org/jira/browse/WICKET-5065
 */
@Test
public void renderAbsoluteWithoutScheme() {
    Url baseUrl = Url.parse("a/b");
    MockWebRequest request = new MockWebRequest(baseUrl);
    UrlRenderer renderer = new UrlRenderer(request);
    Url absoluteUrl = Url.parse("//host/c/d");
    String encodedRelativeUrl = renderer.renderUrl(absoluteUrl);
    assertEquals("//host/c/d", 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 19 with MockWebRequest

use of org.apache.wicket.mock.MockWebRequest 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 20 with MockWebRequest

use of org.apache.wicket.mock.MockWebRequest 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)

Aggregations

MockWebRequest (org.apache.wicket.mock.MockWebRequest)54 Test (org.junit.Test)52 UrlRenderer (org.apache.wicket.request.UrlRenderer)47 Url (org.apache.wicket.request.Url)29 Locale (java.util.Locale)2 MockServletContext (org.apache.wicket.protocol.http.mock.MockServletContext)2 IRequestHandler (org.apache.wicket.request.IRequestHandler)2 Binder (com.google.inject.Binder)1 Module (com.google.inject.Module)1 Provider (com.google.inject.Provider)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Session (org.apache.wicket.Session)1 MockApplication (org.apache.wicket.mock.MockApplication)1 WebSession (org.apache.wicket.protocol.http.WebSession)1 IExceptionMapper (org.apache.wicket.request.IExceptionMapper)1 IRequestCycle (org.apache.wicket.request.IRequestCycle)1