Search in sources :

Example 56 with RenderPageRequestHandler

use of org.apache.wicket.core.request.handler.RenderPageRequestHandler 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"));
}
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 57 with RenderPageRequestHandler

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

the class MountedMapperTest method placeholderEncode4.

/**
 * WICKET-5247 page instantiated without required parameters won't be mapped
 */
@Test
public void placeholderEncode4() {
    PageProvider provider = new PageProvider(MockPage.class) {

        @Override
        public boolean isNewPageInstance() {
            return false;
        }
    };
    provider.setPageSource(context);
    IRequestHandler handler = new RenderPageRequestHandler(provider);
    Url url = placeholderEncoder.mapHandler(handler);
    assertNull(url);
}
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) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 58 with RenderPageRequestHandler

use of org.apache.wicket.core.request.handler.RenderPageRequestHandler 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());
}
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 59 with RenderPageRequestHandler

use of org.apache.wicket.core.request.handler.RenderPageRequestHandler 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"));
}
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 60 with RenderPageRequestHandler

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

the class MountedMapperTest method decode2.

/**
 */
@Test
public void decode2() {
    Url url = Url.parse("some/mount/path/indexed1?a=b&b=c");
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertThat(handler, instanceOf(RenderPageRequestHandler.class));
    IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
    PageParameters p = page.getPageParameters();
    assertEquals(1, p.getIndexedCount());
    assertEquals("indexed1", p.get(0).toString());
    assertEquals(2, p.getNamedKeys().size());
    assertEquals("b", p.get("a").toString());
    assertEquals("c", p.get("b").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) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)75 IRequestHandler (org.apache.wicket.request.IRequestHandler)64 Test (org.junit.Test)61 Url (org.apache.wicket.request.Url)50 PageProvider (org.apache.wicket.core.request.handler.PageProvider)36 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)32 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)19 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)16 MockPage (org.apache.wicket.MockPage)13 Request (org.apache.wicket.request.Request)6 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)5 IRequestMapper (org.apache.wicket.request.IRequestMapper)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)3 ComponentInfo (org.apache.wicket.request.mapper.info.ComponentInfo)3 PageComponentInfo (org.apache.wicket.request.mapper.info.PageComponentInfo)3 Page (org.apache.wicket.Page)2 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)2 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)2 WebResponse (org.apache.wicket.request.http.WebResponse)2