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());
}
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());
}
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);
}
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());
}
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);
}
Aggregations