use of org.apache.wicket.request.IRequestHandler 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.request.IRequestHandler in project wicket by apache.
the class MountedMapperTest method optionPlaceholderDecode3.
/**
*/
@Test
public void optionPlaceholderDecode3() {
Url url = Url.parse("some/path/p2");
IRequestHandler handler = optionPlaceholderEncoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
assertEquals(0, page.getPageParameters().getIndexedCount());
assertTrue(page.getPageParameters().getNamedKeys().size() == 1);
assertFalse("param1 should not be set", page.getPageParameters().getNamedKeys().contains("param1"));
assertEquals("p2", page.getPageParameters().get("param2").toString());
assertFalse("param3 should not be set", page.getPageParameters().getNamedKeys().contains("param3"));
}
use of org.apache.wicket.request.IRequestHandler 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());
}
use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class MountedMapperTest method optionalPlaceholdersBeforeRequiredPlaceholder.
/**
* WICKET-6461
*/
@Test
public void optionalPlaceholdersBeforeRequiredPlaceholder() throws Exception {
final MountedMapper mapper = new MountedMapper("/params/#{optional1}/#{optional2}/${required}", MockPage.class) {
@Override
protected IMapperContext getContext() {
return context;
}
@Override
boolean getRecreateMountedPagesAfterExpiry() {
return true;
}
};
IRequestHandler handler = mapper.mapRequest(getRequest(Url.parse("params/required")));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
PageParameters p = page.getPageParameters();
assertEquals(1, p.getNamedKeys().size());
assertEquals("required", p.get("required").toString());
handler = mapper.mapRequest(getRequest(Url.parse("params/optional1/required")));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
page = ((RenderPageRequestHandler) handler).getPage();
p = page.getPageParameters();
assertEquals(2, p.getNamedKeys().size());
assertEquals("required", p.get("required").toString());
assertEquals("optional1", p.get("optional1").toString());
handler = mapper.mapRequest(getRequest(Url.parse("params/optional1/optional2/required")));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
page = ((RenderPageRequestHandler) handler).getPage();
p = page.getPageParameters();
assertEquals(3, p.getNamedKeys().size());
assertEquals("required", p.get("required").toString());
assertEquals("optional1", p.get("optional1").toString());
assertEquals("optional2", p.get("optional2").toString());
}
use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class MountedMapperTest method decode9.
/**
*/
@Test
public void decode9() {
// capture the home page
Url url = Url.parse("");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
}
Aggregations