Search in sources :

Example 46 with IRequestHandler

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

the class CryptoMapperTest method bookmarkablePageEncrypt.

/**
 * Tests that URLs for bookmarkable pages are encrypted.
 */
@Test
public void bookmarkablePageEncrypt() {
    IRequestHandler renderPage2BookmarkableHandler = new RenderPageRequestHandler(new PageProvider(Page2.class, new PageParameters()));
    Url plainTextUrl = mapper.getDelegateMapper().mapHandler(renderPage2BookmarkableHandler);
    assertEquals(PLAIN_BOOKMARKABLE_URL, plainTextUrl.toString());
    Url encryptedUrl = mapper.mapHandler(renderPage2BookmarkableHandler);
    assertEquals(ENCRYPTED_BOOKMARKABLE_URL, encryptedUrl.toString());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 47 with IRequestHandler

use of org.apache.wicket.request.IRequestHandler 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 48 with IRequestHandler

use of org.apache.wicket.request.IRequestHandler 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 49 with IRequestHandler

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

the class CryptoMapperTest method homePage.

/**
 * Tests that the home page is requestable.
 */
@Test
public void homePage() {
    IRequestHandler requestHandler = mapper.mapRequest(getRequest(Url.parse("")));
    assertNotNull("Unable to map request for home page", requestHandler);
    requestHandler = unwrapRequestHandlerDelegate(requestHandler);
    assertThat(requestHandler, instanceOf(RenderPageRequestHandler.class));
    RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
    assertSame(tester.getApplication().getHomePage(), handler.getPageClass());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) Test(org.junit.Test)

Example 50 with IRequestHandler

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

the class CryptoMapperTest method mountedPage.

/**
 * Tests that mounted pages are still accessible through their mounted URL.
 */
@Test
public void mountedPage() {
    IRequestHandler requestHandler = new RenderPageRequestHandler(new PageProvider(Page1.class));
    assertEquals(MOUNTED_URL, mapper.mapHandler(requestHandler).toString());
    requestHandler = mapper.mapRequest(getRequest(Url.parse(MOUNTED_URL)));
    assertNotNull(requestHandler);
    requestHandler = unwrapRequestHandlerDelegate(requestHandler);
    assertThat(requestHandler, instanceOf(RenderPageRequestHandler.class));
    assertEquals(Page1.class, ((RenderPageRequestHandler) requestHandler).getPageClass());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) Test(org.junit.Test)

Aggregations

IRequestHandler (org.apache.wicket.request.IRequestHandler)188 Test (org.junit.Test)159 Url (org.apache.wicket.request.Url)138 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)65 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)47 PageProvider (org.apache.wicket.core.request.handler.PageProvider)45 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)36 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)32 BookmarkableListenerRequestHandler (org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)28 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)25 Request (org.apache.wicket.request.Request)25 MockPage (org.apache.wicket.MockPage)23 ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)20 PageAndComponentProvider (org.apache.wicket.core.request.handler.PageAndComponentProvider)17 ResourceUrl (org.apache.wicket.request.resource.caching.ResourceUrl)17 BookmarkablePageRequestHandler (org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler)16 IPageRequestHandler (org.apache.wicket.core.request.handler.IPageRequestHandler)11 IRequestableComponent (org.apache.wicket.request.component.IRequestableComponent)10 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)8 Page (org.apache.wicket.Page)6