tester.getApplication().mount(
new IndexedParamUrlCodingStrategy("/test2", BookmarkableHomePageLinksPage.class,
"mypagemap"));
tester.setupRequestAndResponse();
WebRequestCycle cycle = tester.createRequestCycle();
PageParameters parameters = new PageParameters();
parameters.add("0", "Integer0");
parameters.add("1", "Integer1");
parameters.add("2", "a:b");
String url1 = cycle.urlFor(
new BookmarkablePageRequestTarget(BookmarkableHomePageLinksPage.class, parameters))
.toString();
String url2 = cycle.urlFor(
new BookmarkablePageRequestTarget("mypagemap", BookmarkableHomePageLinksPage.class,
parameters)).toString();
assertEquals("test1/Integer0/Integer1/a%3Ab", url1);
assertEquals("test2/Integer0/Integer1/a%3Ab/wicket:pageMapName/mypagemap", url2);
tester.setupRequestAndResponse();
tester.getServletRequest().setURL("/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/" + url1);
cycle = tester.createRequestCycle();
IRequestCodingStrategy encoder = cycle.getProcessor().getRequestCodingStrategy();
RequestParameters requestParameters = encoder.decode(tester.getWicketRequest());
IRequestTarget target1 = cycle.getProcessor().resolve(cycle, requestParameters);
if (target1 instanceof BookmarkablePageRequestTarget)
{
assertNull(((BookmarkablePageRequestTarget)target1).getPageMapName());
}
else
{
fail("url: " + url1 + " wasn't resolved to a bookmarkable target: " + target1);
}
PageParameters params = ((BookmarkablePageRequestTarget)target1).getPageParameters();
assertEquals("Integer0", params.getString("0"));
assertEquals("Integer1", params.getString("1"));
assertEquals("a:b", params.getString("2"));
tester.setupRequestAndResponse();
tester.getServletRequest().setURL("/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/" + url2);
cycle = tester.createRequestCycle();
encoder = cycle.getProcessor().getRequestCodingStrategy();
requestParameters = encoder.decode(tester.getWicketRequest());
IRequestTarget target2 = cycle.getProcessor().resolve(cycle, requestParameters);
if (target2 instanceof BookmarkablePageRequestTarget)
{
assertEquals("mypagemap", ((BookmarkablePageRequestTarget)target2).getPageMapName());
}