use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class PackageMapperTest method encodeNamedPageParameters.
/**
*/
@Test
public void encodeNamedPageParameters() {
MockPage page = new MockPage(15);
page.setBookmarkable(true);
page.setCreatedBookmarkable(true);
page.setPageStateless(true);
IPageProvider provider = new PageProvider(page);
page.getPageParameters().set("foo", "fooValue", INamedParameters.Type.PATH);
page.getPageParameters().set("bar", "barValue", INamedParameters.Type.PATH);
IRequestHandler handler = new RenderPageRequestHandler(provider);
Url url = namedParametersEncoder.mapHandler(handler);
assertEquals(MOUNT_PATH + "/fooValue/barValue/" + PAGE_CLASS_NAME, url.toString());
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class PackageMapperTest method decode2.
/**
*/
@Test
public void decode2() {
Url url = Url.parse(MOUNT_PATH + '/' + PAGE_CLASS_NAME + "/indexed1?a=b&b=c");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
assertEquals(PAGE_CLASS_NAME, page.getClass().getSimpleName());
PageParameters p = page.getPageParameters();
assertEquals(1, p.getIndexedCount());
assertEquals("indexed1", p.get(0).toString());
assertEquals(2, p.getNamedKeys().size());
assertEquals("b", p.get("a").toString());
assertEquals("c", p.get("b").toString());
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class PackageMapperTest method decode1CaseInsensitively.
/**
* https://issues.apache.org/jira/browse/WICKET-4994
*/
@Test
public void decode1CaseInsensitively() {
Url url = Url.parse(MOUNT_PATH.replace('o', 'O').replace('p', 'P') + '/' + PAGE_CLASS_NAME);
IRequestHandler handler = encoder.setCaseSensitiveMatch(false).mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
assertEquals(PAGE_CLASS_NAME, page.getClass().getSimpleName());
assertEquals(0, page.getPageParameters().getIndexedCount());
assertTrue(page.getPageParameters().getNamedKeys().isEmpty());
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class PackageMapperTest 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);
assertEquals(MOUNT_PATH + '/' + PAGE_CLASS_NAME + "/i1/i2?15&a=b&b=c", url.toString());
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class PackageMapperTest 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(MOUNT_PATH + '/' + PAGE_CLASS_NAME + "?15");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
checkPage(page, 15);
}
Aggregations