Search in sources :

Example 51 with RenderPageRequestHandler

use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.

the class BookmarkableMapperTest method decodePageClassWithPathParameters.

/**
 * https://issues.apache.org/jira/browse/WICKET-5500
 */
@Test
public void decodePageClassWithPathParameters() {
    Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME + ";something=else");
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertTrue(handler instanceof RenderPageRequestHandler);
    IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
    assertEquals(PAGE_CLASS_NAME, page.getClass().getName());
    assertEquals(0, page.getPageParameters().getIndexedCount());
    assertTrue(page.getPageParameters().getNamedKeys().isEmpty());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 52 with RenderPageRequestHandler

use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.

the class CryptoMapperTest method bookmarkablePageDecryptMultipleCryptoMapper.

/**
 * Tests that encrypted URLs for bookmarkable pages are decrypted and passed to the wrapped mapper when there is more than
 * one cryptomapper installed.
 */
@Test
public void bookmarkablePageDecryptMultipleCryptoMapper() {
    Request request = getRequest(Url.parse(ENCRYPTED_BOOKMARKABLE_URL));
    IRequestHandler requestHandler = new CryptoMapper(mapper, tester.getApplication()).mapRequest(request);
    assertNotNull(requestHandler);
    requestHandler = unwrapRequestHandlerDelegate(requestHandler);
    assertThat(requestHandler, instanceOf(RenderPageRequestHandler.class));
    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 53 with RenderPageRequestHandler

use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.

the class CryptoMapperTest method bookmarkablePageDecrypt.

/**
 * Tests that encrypted URLs for bookmarkable pages are decrypted and passed to the wrapped mapper.
 */
@Test
public void bookmarkablePageDecrypt() {
    Request request = getRequest(Url.parse(ENCRYPTED_BOOKMARKABLE_URL));
    IRequestHandler requestHandler = mapper.mapRequest(request);
    assertNotNull(requestHandler);
    requestHandler = unwrapRequestHandlerDelegate(requestHandler);
    assertThat(requestHandler, instanceOf(RenderPageRequestHandler.class));
    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 54 with RenderPageRequestHandler

use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.

the class CryptoMapperTest method pageInstanceDecryptMultipleCryptoMapper.

/**
 * Make sure that encrypted page instance URLs are decrypted and the correct handler resolved.
 */
@Test
public void pageInstanceDecryptMultipleCryptoMapper() {
    IRequestHandler requestHandler = new CryptoMapper(mapper, tester.getApplication()).mapRequest(getRequest(Url.parse(ENCRYPTED_PAGE_INSTANCE_URL)));
    assertNotNull(requestHandler);
    requestHandler = unwrapRequestHandlerDelegate(requestHandler);
    assertThat(requestHandler, instanceOf(RenderPageRequestHandler.class));
    RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
    assertEquals(5, handler.getPageId().intValue());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) Test(org.junit.Test)

Example 55 with RenderPageRequestHandler

use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.

the class CryptoMapperTest method pageInstanceEncrypt.

/**
 * Tests that URLs for page instances are encrypted (/wicket/page?5)
 */
@Test
public void pageInstanceEncrypt() {
    MockPage page = new MockPage(5);
    IRequestHandler requestHandler = new RenderPageRequestHandler(new PageProvider(page));
    assertEquals(PLAIN_PAGE_INSTANCE_URL, mapper.getDelegateMapper().mapHandler(requestHandler).toString());
    assertEquals(ENCRYPTED_PAGE_INSTANCE_URL, mapper.mapHandler(requestHandler).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) MockPage(org.apache.wicket.MockPage) Test(org.junit.Test)

Aggregations

RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)75 IRequestHandler (org.apache.wicket.request.IRequestHandler)64 Test (org.junit.Test)61 Url (org.apache.wicket.request.Url)50 PageProvider (org.apache.wicket.core.request.handler.PageProvider)36 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)32 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)19 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)16 MockPage (org.apache.wicket.MockPage)13 Request (org.apache.wicket.request.Request)6 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)5 IRequestMapper (org.apache.wicket.request.IRequestMapper)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)3 ComponentInfo (org.apache.wicket.request.mapper.info.ComponentInfo)3 PageComponentInfo (org.apache.wicket.request.mapper.info.PageComponentInfo)3 Page (org.apache.wicket.Page)2 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)2 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)2 WebResponse (org.apache.wicket.request.http.WebResponse)2