use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class BookmarkableMapperTest method decode11.
/**
* WICKET-5071
*
* Decodes a request to
* {@link org.apache.wicket.core.request.mapper.IMapperContext#getBookmarkableIdentifier()}
* /com.example.MyPage when the current base url is
* {@link org.apache.wicket.core.request.mapper.IMapperContext#getNamespace()} /
* {@link org.apache.wicket.core.request.mapper.IMapperContext#getBookmarkableIdentifier()}
*/
@Test
public void decode11() {
final Url url = Url.parse(context.getBookmarkableIdentifier() + "/" + PAGE_CLASS_NAME);
Request request = new Request() {
@Override
public Url getUrl() {
return url;
}
@Override
public Locale getLocale() {
return null;
}
@Override
public Charset getCharset() {
return Charset.forName("UTF-8");
}
@Override
public Url getClientUrl() {
StringBuilder url = new StringBuilder();
url.append(context.getNamespace()).append('/').append(context.getBookmarkableIdentifier()).append('/').append("com.example.MyPage");
return Url.parse(url.toString());
}
@Override
public Object getContainerRequest() {
return null;
}
};
IRequestHandler handler = encoder.mapRequest(request);
assertNotNull("A handler should be resolved for relative url to a bookmarkable page!", handler);
IRequestablePage page = ((IPageRequestHandler) handler).getPage();
assertEquals(page.getClass().getName(), PAGE_CLASS_NAME);
}
use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class MountedMapperTest method decode7.
/**
*/
@Test
public void decode7() {
Url url = Url.parse("some/mount/path?param1=value1&15-.4-foo-bar");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(ListenerRequestHandler.class));
ListenerRequestHandler h = (ListenerRequestHandler) handler;
IRequestablePage page = h.getPage();
checkPage(page, 15);
assertEquals("foo:bar", h.getComponent().getPageRelativePath());
assertEquals((Object) 4, h.getBehaviorIndex());
}
use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class MountedMapperTest method optionPlaceholderDecode2.
/**
*/
@Test
public void optionPlaceholderDecode2() {
Url url = Url.parse("some/p1/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() == 2);
assertEquals("p1", page.getPageParameters().get("param1").toString());
assertEquals("p2", page.getPageParameters().get("param2").toString());
assertFalse("param3 should not be set", page.getPageParameters().getNamedKeys().contains("param3"));
}
use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class MountedMapperTest method optionPlaceholderDecodeWithIndexParams.
/**
*/
@Test
public void optionPlaceholderDecodeWithIndexParams() {
Url url = Url.parse("some/path/p2/p3/p4");
IRequestHandler handler = optionPlaceholderEncoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
assertEquals(1, page.getPageParameters().getIndexedCount());
assertEquals(2, page.getPageParameters().getNamedKeys().size());
assertFalse("param1 should not be set", page.getPageParameters().getNamedKeys().contains("param1"));
assertEquals("p2", page.getPageParameters().get("param2").toString());
assertEquals("p3", page.getPageParameters().get("param3").toString());
assertEquals("p4", page.getPageParameters().get(0).toString());
}
use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class MountedMapperTest method optionPlaceholderDecodeEagerMatchParameters.
/**
*/
@Test
public void optionPlaceholderDecodeEagerMatchParameters() {
Url url = Url.parse("some/path/path/path");
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() == 2);
assertEquals("path", page.getPageParameters().get("param1").toString());
assertEquals("path", page.getPageParameters().get("param2").toString());
assertFalse("param3 should not be set", page.getPageParameters().getNamedKeys().contains("param3"));
}
Aggregations