Search in sources :

Example 41 with IRequestablePage

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

Example 42 with IRequestablePage

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

Example 43 with IRequestablePage

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"));
}
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 44 with IRequestablePage

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());
}
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 45 with IRequestablePage

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"));
}
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)

Aggregations

IRequestablePage (org.apache.wicket.request.component.IRequestablePage)59 Url (org.apache.wicket.request.Url)50 IRequestHandler (org.apache.wicket.request.IRequestHandler)47 Test (org.junit.Test)46 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)31 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)18 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)15 BookmarkableListenerRequestHandler (org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)14 IPageRequestHandler (org.apache.wicket.core.request.handler.IPageRequestHandler)6 Request (org.apache.wicket.request.Request)6 PageComponentInfo (org.apache.wicket.request.mapper.info.PageComponentInfo)5 PageProvider (org.apache.wicket.core.request.handler.PageProvider)4 PageInfo (org.apache.wicket.request.mapper.info.PageInfo)4 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)3 ComponentInfo (org.apache.wicket.request.mapper.info.ComponentInfo)3 Page (org.apache.wicket.Page)2 AccessControlException (java.security.AccessControlException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 ForbiddenException (javax.ws.rs.ForbiddenException)1 Login (org.apache.syncope.client.console.pages.Login)1