Search in sources :

Example 36 with PageProvider

use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.

the class PackageMapperTest method encode2.

/**
 */
@Test
public void encode2() {
    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);
    PageProvider provider = new PageProvider(MockPage.class, parameters);
    provider.setPageSource(context);
    IRequestHandler handler = new BookmarkablePageRequestHandler(provider);
    Url url = encoder.mapHandler(handler);
    assertEquals(MOUNT_PATH + '/' + PAGE_CLASS_NAME + "/i1/i2?a=b&b=c", url.toString());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) BookmarkablePageRequestHandler(org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 37 with PageProvider

use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.

the class PackageMapperTest method encode4.

/**
 */
@Test
public void encode4() {
    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(true);
    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());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 38 with PageProvider

use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.

the class PageInstanceMapperTest method encode1.

/**
 */
@Test
public void encode1() {
    MockPage page = new MockPage(15);
    IPageProvider provider = new PageProvider(page);
    IRequestHandler handler = new RenderPageRequestHandler(provider);
    Url url = encoder.mapHandler(handler);
    assertEquals("wicket/page?15", url.toString());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 39 with PageProvider

use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.

the class PageProviderTest method testPageProperties_bookmarkable.

@Test
public void testPageProperties_bookmarkable() {
    PageProvider provider = new PageProvider(StatelessPageTest.class);
    assertTrue(provider.doesProvideNewPage());
    assertFalse(provider.hasPageInstance());
    provider.getPageInstance();
    assertTrue(provider.doesProvideNewPage());
    assertTrue(provider.hasPageInstance());
}
Also used : PageProvider(org.apache.wicket.core.request.handler.PageProvider) Test(org.junit.Test)

Example 40 with PageProvider

use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.

the class PageProviderTest method ignorePageFoundByIdIfItsClassDoesntMatch.

/**
 * https://issues.apache.org/jira/browse/WICKET-4488
 *
 * There is a stored page with id = 0 and class Page1.
 * A following request to page2?0 should not use the stored page with id=0 because
 * the requested and the found page classes do not match.
 */
@Test
public void ignorePageFoundByIdIfItsClassDoesntMatch() {
    TestMapperContext mapperContext = new TestMapperContext();
    Page page = new TestPage();
    mapperContext.getPageManager().touchPage(page);
    mapperContext.getPageManager().commitRequest();
    // by cleaning session cache we make sure of not being testing the same in-memory instance
    mapperContext.cleanSessionCache();
    PageProvider provider = new PageProvider(page.getPageId(), MockPageWithLink.class, 0);
    assertFalse(provider.hasPageInstance());
    assertEquals(MockPageWithLink.class, provider.getPageClass());
    assertTrue(provider.doesProvideNewPage());
}
Also used : PageProvider(org.apache.wicket.core.request.handler.PageProvider) MockPage(org.apache.wicket.MockPage) Page(org.apache.wicket.Page) WebPage(org.apache.wicket.markup.html.WebPage) TestMapperContext(org.apache.wicket.core.request.mapper.TestMapperContext) Test(org.junit.Test)

Aggregations

PageProvider (org.apache.wicket.core.request.handler.PageProvider)60 Test (org.junit.Test)49 IRequestHandler (org.apache.wicket.request.IRequestHandler)45 Url (org.apache.wicket.request.Url)38 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)36 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)34 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)23 BookmarkablePageRequestHandler (org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler)17 MockPage (org.apache.wicket.MockPage)16 Page (org.apache.wicket.Page)5 TestMapperContext (org.apache.wicket.core.request.mapper.TestMapperContext)4 IRequestMapper (org.apache.wicket.request.IRequestMapper)4 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 WebPage (org.apache.wicket.markup.html.WebPage)3 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)3 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)3 MockPageParametersAware (org.apache.wicket.MockPageParametersAware)2 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)2 ExceptionErrorPage (org.apache.wicket.markup.html.pages.ExceptionErrorPage)2