use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class CryptoMapperTest method bookmarkablePageEncrypt.
/**
* Tests that URLs for bookmarkable pages are encrypted.
*/
@Test
public void bookmarkablePageEncrypt() {
IRequestHandler renderPage2BookmarkableHandler = new RenderPageRequestHandler(new PageProvider(Page2.class, new PageParameters()));
Url plainTextUrl = mapper.getDelegateMapper().mapHandler(renderPage2BookmarkableHandler);
assertEquals(PLAIN_BOOKMARKABLE_URL, plainTextUrl.toString());
Url encryptedUrl = mapper.mapHandler(renderPage2BookmarkableHandler);
assertEquals(ENCRYPTED_BOOKMARKABLE_URL, encryptedUrl.toString());
}
use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class CryptoMapperTest method markedEncryptedUrlDecrypt.
@Test
public void markedEncryptedUrlDecrypt() {
mapper.setMarkEncryptedUrls(true);
Request request = getRequest(Url.parse("crypt." + ENCRYPTED_BOOKMARKABLE_URL));
IRequestHandler requestHandler = mapper.mapRequest(request);
assertNotNull(requestHandler);
requestHandler = unwrapRequestHandlerDelegate(requestHandler);
assertTrue(requestHandler instanceof RenderPageRequestHandler);
RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
assertEquals(Page2.class, handler.getPageClass());
}
use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class CryptoMapperTest method additionalParameters.
/**
* Additional parameters, WICKET-4923
*/
@Test
public void additionalParameters() {
MockPage page = new MockPage();
IRequestableComponent c = page.get("foo:bar");
PageAndComponentProvider provider = new PageAndComponentProvider(page, c);
IRequestHandler handler = new ListenerRequestHandler(provider);
Url url = mapper.mapHandler(handler);
url.addQueryParameter("q", "foo");
Request request = getRequest(url);
IRequestHandler requestHandler = mapper.mapRequest(request);
assertThat(requestHandler, instanceOf(RequestSettingRequestHandler.class));
assertEquals("foo", ((RequestSettingRequestHandler) requestHandler).getRequest().getUrl().getQueryParameterValue("q").toString());
}
use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class CryptoMapperTest method homePage.
/**
* Tests that the home page is requestable.
*/
@Test
public void homePage() {
IRequestHandler requestHandler = mapper.mapRequest(getRequest(Url.parse("")));
assertNotNull("Unable to map request for home page", requestHandler);
requestHandler = unwrapRequestHandlerDelegate(requestHandler);
assertThat(requestHandler, instanceOf(RenderPageRequestHandler.class));
RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
assertSame(tester.getApplication().getHomePage(), handler.getPageClass());
}
use of org.apache.wicket.request.IRequestHandler 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());
}
Aggregations