use of org.apache.wicket.core.request.handler.PageProvider 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());
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class MountedMapperTest method encode5.
/**
*/
@Test
public void encode5() {
MockPage page = new MockPage(15);
page.getPageParameters().set(0, "i1");
page.getPageParameters().set(1, "i2");
page.getPageParameters().set("a", "b", INamedParameters.Type.QUERY_STRING);
page.getPageParameters().set("b", "c", INamedParameters.Type.QUERY_STRING);
page.setCreatedBookmarkable(false);
IPageProvider provider = new PageProvider(page);
IRequestHandler handler = new RenderPageRequestHandler(provider);
Url url = encoder.mapHandler(handler);
// mounted pages must render mounted url even for page that has not been
// created by
// bookmarkable
// URL
assertEquals("some/mount/path/i1/i2?15&a=b&b=c", url.toString());
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class MountedMapperTest method placeholderEncode3.
/**
* Test Url creation with {@link RenderPageRequestHandler}. Cheat that the page instance is not
* new, this way the produced Url has version '1' in the page info parameter
*/
@Test
public void placeholderEncode3() {
PageParameters parameters = new PageParameters();
parameters.set(0, "i1");
parameters.set(1, "i2");
parameters.set("a", "b", INamedParameters.Type.QUERY_STRING);
parameters.set("b", "c", INamedParameters.Type.QUERY_STRING);
parameters.set("param1", "p1", INamedParameters.Type.PATH);
parameters.set("param2", "p2", INamedParameters.Type.PATH);
PageProvider provider = new PageProvider(MockPage.class, parameters) {
@Override
public boolean isNewPageInstance() {
return false;
}
};
provider.setPageSource(context);
IRequestHandler handler = new RenderPageRequestHandler(provider);
Url url = placeholderEncoder.mapHandler(handler);
assertEquals("some/p1/path/p2/i1/i2?1&a=b&b=c", url.toString());
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class MountedMapperTest method encode1.
/**
*/
@Test
public void encode1() {
PageProvider provider = new PageProvider(MockPage.class, new PageParameters());
provider.setPageSource(context);
IRequestHandler handler = new BookmarkablePageRequestHandler(provider);
Url url = encoder.mapHandler(handler);
assertEquals("some/mount/path", url.toString());
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class MountedMapperTest method optionPlaceholderEncode1.
/**
*/
@Test
public void optionPlaceholderEncode1() {
PageParameters parameters = new PageParameters();
parameters.set(0, "i1");
parameters.set(1, "i2");
parameters.set("a", "b", INamedParameters.Type.QUERY_STRING);
parameters.set("b", "c", INamedParameters.Type.QUERY_STRING);
parameters.set("param1", "p1", INamedParameters.Type.PATH);
parameters.set("param2", "p2", INamedParameters.Type.PATH);
PageProvider provider = new PageProvider(MockPage.class, parameters);
provider.setPageSource(context);
IRequestHandler handler = new BookmarkablePageRequestHandler(provider);
Url url = optionPlaceholderEncoder.mapHandler(handler);
assertEquals("some/p1/path/p2/i1/i2?a=b&b=c", url.toString());
}
Aggregations