Search in sources :

Example 16 with Request

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

the class CryptoMapperTest method markedEncryptedUrlDecrypt.

@Test
public void markedEncryptedUrlDecrypt() {
    mapper.setMarkEncryptedUrls(true);
    Request request = getRequest(Url.parse("crypt." + ENCRYPTED_BOOKMARKABLE_URL));
    IRequestHandler requestHandler = mapper.mapRequest(request);
    assertNotNull(requestHandler);
    requestHandler = unwrapRequestHandlerDelegate(requestHandler);
    assertTrue(requestHandler instanceof RenderPageRequestHandler);
    RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
    assertEquals(Page2.class, handler.getPageClass());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) Request(org.apache.wicket.request.Request) Test(org.junit.Test)

Example 17 with Request

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

the class CryptoMapperTest method additionalParameters.

/**
 * Additional parameters, WICKET-4923
 */
@Test
public void additionalParameters() {
    MockPage page = new MockPage();
    IRequestableComponent c = page.get("foo:bar");
    PageAndComponentProvider provider = new PageAndComponentProvider(page, c);
    IRequestHandler handler = new ListenerRequestHandler(provider);
    Url url = mapper.mapHandler(handler);
    url.addQueryParameter("q", "foo");
    Request request = getRequest(url);
    IRequestHandler requestHandler = mapper.mapRequest(request);
    assertThat(requestHandler, instanceOf(RequestSettingRequestHandler.class));
    assertEquals("foo", ((RequestSettingRequestHandler) requestHandler).getRequest().getUrl().getQueryParameterValue("q").toString());
}
Also used : IRequestableComponent(org.apache.wicket.request.component.IRequestableComponent) RequestSettingRequestHandler(org.apache.wicket.core.request.handler.RequestSettingRequestHandler) IRequestHandler(org.apache.wicket.request.IRequestHandler) Request(org.apache.wicket.request.Request) PageAndComponentProvider(org.apache.wicket.core.request.handler.PageAndComponentProvider) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) BookmarkableListenerRequestHandler(org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 18 with Request

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

the class CryptoMapperTest method bookmarkablePageDecrypt2.

/**
 * https://issues.apache.org/jira/browse/WICKET-6131
 *
 * Tests that encrypted URLs for bookmarkable pages are decrypted and passed to the wrapped mapper.
 * Extra segments should be ignored.
 */
@Test
public void bookmarkablePageDecrypt2() {
    String encryptedExtraSegments = "/i87b7/i87b7";
    Request request = getRequest(Url.parse(ENCRYPTED_BOOKMARKABLE_URL + encryptedExtraSegments));
    IRequestHandler requestHandler = mapper.mapRequest(request);
    assertNotNull(requestHandler);
    requestHandler = unwrapRequestHandlerDelegate(requestHandler);
    assertTrue(requestHandler instanceof RenderPageRequestHandler);
    RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
    assertEquals(Page2.class, handler.getPageClass());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) Request(org.apache.wicket.request.Request) Test(org.junit.Test)

Example 19 with Request

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

the class MountedMapperTest method exactMountGetsBetterScore_ThanParameterOne.

@Test
public void exactMountGetsBetterScore_ThanParameterOne() throws Exception {
    final Url url = Url.parse("all/sindex");
    final MountedMapper exactMount = new MountedMapper("/all/sindex", MockPage.class);
    final MountedMapper requiredParam = new MountedMapper("/all/${exp}", MockPage.class);
    Request request = getRequest(url);
    final int exactCompatScore = exactMount.getCompatibilityScore(request);
    final int requiredParamScore = requiredParam.getCompatibilityScore(request);
    assertTrue("exactCompatScore should have greater compatibility score than required one" + " got exact = " + exactCompatScore + " and required= " + requiredParamScore, exactCompatScore > requiredParamScore);
}
Also used : WebRequest(org.apache.wicket.request.http.WebRequest) Request(org.apache.wicket.request.Request) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 20 with Request

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

the class MountedMapperTest method optionalParameterGetsLowerScore_ThanExactOne.

/**
 * WICKET-5056
 */
@Test
public void optionalParameterGetsLowerScore_ThanExactOne() throws Exception {
    final Url url = Url.parse("all/sindex");
    final MountedMapper exactMount = new MountedMapper("/all/sindex", MockPage.class);
    final MountedMapper optionalParameter = new MountedMapper("/all/#{exp}", MockPage.class);
    Request request = getRequest(url);
    final int exactCompatScore = exactMount.getCompatibilityScore(request);
    final int optCompatScore = optionalParameter.getCompatibilityScore(request);
    assertTrue("exactCompatScore should have greater compatibility score than optional one" + " got exact = " + exactCompatScore + " and optional = " + optCompatScore, exactCompatScore > optCompatScore);
}
Also used : WebRequest(org.apache.wicket.request.http.WebRequest) Request(org.apache.wicket.request.Request) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

Request (org.apache.wicket.request.Request)61 Test (org.junit.Test)28 IRequestHandler (org.apache.wicket.request.IRequestHandler)26 Url (org.apache.wicket.request.Url)23 WebRequest (org.apache.wicket.request.http.WebRequest)9 Response (org.apache.wicket.request.Response)8 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)8 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)6 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 IPageRequestHandler (org.apache.wicket.core.request.handler.IPageRequestHandler)5 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)5 ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)5 MockApplication (org.apache.wicket.mock.MockApplication)4 MockHttpServletRequest (org.apache.wicket.protocol.http.mock.MockHttpServletRequest)4 Session (org.apache.wicket.Session)3 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)3 Attributes (org.apache.wicket.request.resource.IResource.Attributes)3 PackageResourceReference (org.apache.wicket.request.resource.PackageResourceReference)3 UrlAttributes (org.apache.wicket.request.resource.ResourceReference.UrlAttributes)3