Search in sources :

Example 11 with RenderPageRequestHandler

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

the class BookmarkableMapperTest method encode8.

/**
 */
@Test
public void encode8() {
    MockPage page = new MockPage(15);
    page.setBookmarkable(true);
    page.setCreatedBookmarkable(true);
    page.setPageStateless(true);
    IPageProvider provider = new PageProvider(page);
    IRequestHandler handler = new RenderPageRequestHandler(provider);
    Url url = encoder.mapHandler(handler);
    assertEquals("wicket/bookmarkable/" + PAGE_CLASS_NAME, url.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) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 12 with RenderPageRequestHandler

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

the class BookmarkableMapperTest method decode4.

/**
 * The tests resolves pages by id as if they were existed in the page store.
 * These pages have no page parameters (i.e. page.getPageParameters() == null).
 *
 * Since Wicket 7.0.0 (WICKET-4441) if a new request to hybrid url
 * (a url with both mount path and pageId) has different page parameters
 * than the resolved page then a new page instance with the new parameters
 * is created.
 * This way if a user manipulates manually the product id in url like:
 * /wicket/bookmarkable/my.Product?3&id=23
 * to
 * /wicket/bookmarkable/my.Product?3&id=24
 * then Wicket will create a new page that will show product=24
 */
@Test
public void decode4() {
    Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME + "/i1/i2?15&a=b&b=c");
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertThat(handler, instanceOf(RenderPageRequestHandler.class));
    RenderPageRequestHandler h = (RenderPageRequestHandler) handler;
    ((PageProvider) h.getPageProvider()).setPageSource(context);
    IRequestablePage page = h.getPage();
    checkPage(page, 1);
    PageParameters p = page.getPageParameters();
    assertEquals(2, p.getIndexedCount());
    assertEquals(2, p.getNamedKeys().size());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 13 with RenderPageRequestHandler

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

the class BookmarkableMapperTest method decode3.

/**
 * The tests resolves pages by id as if they were existed in the page store.
 * These pages have no page parameters (i.e. page.getPageParameters() == null).
 *
 * The request that the encoder does also has no parameters (neither in the path
 * nor in the query string) so the resolved page is assumed to be valid.
 */
@Test
public void decode3() {
    Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME + "?15");
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertThat(handler, instanceOf(RenderPageRequestHandler.class));
    IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
    checkPage(page, 15);
}
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 14 with RenderPageRequestHandler

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

the class CryptoMapperTest method pageInstanceDecrypt.

/**
 * Make sure that encrypted page instance URLs are decrypted and the correct handler resolved.
 */
@Test
public void pageInstanceDecrypt() {
    IRequestHandler requestHandler = mapper.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 15 with RenderPageRequestHandler

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

the class CryptoMapperTest method pageParameters.

/**
 * Tests that named and indexed parameters are properly (en|de)crypted
 */
@Test
public void pageParameters() {
    String expectedEncrypted = "L7ExSNbPC4sb6TPJDblCAopL53TWmZP5y7BQEaJSJAC05HXod5M5U7gT2yNT0lK5L6L09ZAOoZkGyUhseyPrC4S5tqUUrV6zipc4_Ni877FDOOoE5C_Cd7YCyK1xSScpVhno6LeBz2wiu5oWyf7hB1RKcv6zkhEBmbx8vU7K7-e4xe1_LO8Y3fhEjMSQyU9BVh7Uz4HKzkR2OxFo5LaDzQ/L7E59/yPr6a/5L6ae/OxF2c";
    PageParameters expectedParameters = new PageParameters();
    expectedParameters.add("namedKey1", "namedValue1");
    expectedParameters.add("namedKey2", "namedValue2");
    expectedParameters.set(0, "indexedValue1");
    expectedParameters.set(1, "indexedValue2");
    RenderPageRequestHandler renderPageRequestHandler = new RenderPageRequestHandler(new PageProvider(Page2.class, expectedParameters));
    Url url = mapper.mapHandler(renderPageRequestHandler);
    assertEquals(expectedEncrypted, url.toString());
    Request request = getRequest(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());
    PageParameters actualParameters = handler.getPageParameters();
    assertEquals(expectedParameters, actualParameters);
}
Also used : RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) IRequestHandler(org.apache.wicket.request.IRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) Request(org.apache.wicket.request.Request) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url) 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