Search in sources :

Example 6 with IPageRequestHandler

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

the class BookmarkableMapperTest method decode12.

/**
 * 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#getPageIdentifier()}
 */
@Test
public void decode12() {
    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.getPageIdentifier()).append("?3");
            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 page instance url!", 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 7 with IPageRequestHandler

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

the class BookmarkableMapperTest method decode9.

/**
 */
@Test(expected = StalePageException.class)
public void decode9() {
    Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME + "/i1/i2?15-5.ILinkListener-foo-bar&a=b&b=c");
    context.setNextPageRenderCount(6);
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    ((IPageRequestHandler) handler).getPage();
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) IPageRequestHandler(org.apache.wicket.core.request.handler.IPageRequestHandler) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 8 with IPageRequestHandler

use of org.apache.wicket.core.request.handler.IPageRequestHandler 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 9 with IPageRequestHandler

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

the class MountedMapperTest method decode11.

/**
 */
@Test(expected = StalePageException.class)
public void decode11() {
    Url url = Url.parse("some/mount/path?15-5.4-foo-bar");
    context.setNextPageRenderCount(7);
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    ((IPageRequestHandler) handler).getPage();
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) IPageRequestHandler(org.apache.wicket.core.request.handler.IPageRequestHandler) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 10 with IPageRequestHandler

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

the class PackageMapperTest method decode9.

/**
 */
@Test(expected = StalePageException.class)
public void decode9() {
    Url url = Url.parse(MOUNT_PATH + '/' + PAGE_CLASS_NAME + "/i1/i2?15-5.-foo-bar&a=b&b=c");
    context.setNextPageRenderCount(6);
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    ((IPageRequestHandler) handler).getPage();
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) IPageRequestHandler(org.apache.wicket.core.request.handler.IPageRequestHandler) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

IPageRequestHandler (org.apache.wicket.core.request.handler.IPageRequestHandler)13 IRequestHandler (org.apache.wicket.request.IRequestHandler)11 Url (org.apache.wicket.request.Url)9 Test (org.junit.Test)9 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)6 Request (org.apache.wicket.request.Request)5 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)3 Page (org.apache.wicket.Page)2 ArcAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.ArcAdapter)1 FeatureSupportRegistry (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistry)1 AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)1 VArc (de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.model.VArc)1 VComment (de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.model.VComment)1 VCommentType (de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.model.VCommentType)1 VDocument (de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.model.VDocument)1 TypeUtil (de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.TypeUtil)1 WebAnnoCasUtil.getAddr (de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getAddr)1 WebAnnoCasUtil.selectByAddr (de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectByAddr)1 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)1 ArrayList (java.util.ArrayList)1