Search in sources :

Example 56 with IRequestHandler

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());
}
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 57 with IRequestHandler

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"));
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 58 with IRequestHandler

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());
}
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 59 with IRequestHandler

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());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Test(org.junit.Test)

Example 60 with IRequestHandler

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));
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

IRequestHandler (org.apache.wicket.request.IRequestHandler)188 Test (org.junit.Test)159 Url (org.apache.wicket.request.Url)138 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)65 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)47 PageProvider (org.apache.wicket.core.request.handler.PageProvider)45 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)36 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)32 BookmarkableListenerRequestHandler (org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)28 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)25 Request (org.apache.wicket.request.Request)25 MockPage (org.apache.wicket.MockPage)23 ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)20 PageAndComponentProvider (org.apache.wicket.core.request.handler.PageAndComponentProvider)17 ResourceUrl (org.apache.wicket.request.resource.caching.ResourceUrl)17 BookmarkablePageRequestHandler (org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler)16 IPageRequestHandler (org.apache.wicket.core.request.handler.IPageRequestHandler)11 IRequestableComponent (org.apache.wicket.request.component.IRequestableComponent)10 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)8 Page (org.apache.wicket.Page)6