Search in sources :

Example 71 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.

the class HangManTest method testHangmanSuccessWebGame.

/**
 * Tests the webapplication for a successful match.
 */
@Test
public void testHangmanSuccessWebGame() {
    WicketTester tester = new WicketTester(new HangmanApplication());
    try {
        tester.startPage(Home.class, new PageParameters().set("word", "hangman"));
        tester.assertComponent("start", Link.class);
        tester.assertContains("Wicket Examples - hangman");
        tester.clickLink("start");
        tester.assertLabel("guessesRemaining", "5");
        clickLetter(tester, 'f');
        tester.assertLabel("guessesRemaining", "4");
        clickLetter(tester, 'h');
        tester.assertLabel("guessesRemaining", "4");
        clickLetter(tester, 'a');
        clickLetter(tester, 'n');
        clickLetter(tester, 'g');
        clickLetter(tester, 'm');
        tester.assertRenderedPage(Win.class);
    } finally {
        tester.destroy();
    }
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Test(org.junit.jupiter.api.Test)

Example 72 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.

the class HangManTest method testHangmanFailureWebGame.

/**
 * Tests the webapplication for an unsuccessful match.
 */
@Test
public void testHangmanFailureWebGame() {
    WicketTester tester = new WicketTester(new HangmanApplication());
    try {
        tester.startPage(Home.class, new PageParameters().set("word", "hangman"));
        tester.assertComponent("start", Link.class);
        tester.assertContains("Wicket Examples - hangman");
        tester.clickLink("start");
        tester.assertLabel("guessesRemaining", "5");
        clickLetter(tester, 'f');
        tester.assertLabel("guessesRemaining", "4");
        clickLetter(tester, 'e');
        tester.assertLabel("guessesRemaining", "3");
        clickLetter(tester, 't');
        tester.assertLabel("guessesRemaining", "2");
        clickLetter(tester, 'x');
        tester.assertLabel("guessesRemaining", "1");
        clickLetter(tester, 'z');
        tester.assertRenderedPage(Lose.class);
    } finally {
        tester.destroy();
    }
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Test(org.junit.jupiter.api.Test)

Example 73 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.

the class MountedMapper method mapHandler.

@Override
public Url mapHandler(IRequestHandler requestHandler) {
    Url url = super.mapHandler(requestHandler);
    if (url == null && requestHandler instanceof ListenerRequestHandler && getRecreateMountedPagesAfterExpiry()) {
        ListenerRequestHandler handler = (ListenerRequestHandler) requestHandler;
        IRequestablePage page = handler.getPage();
        if (checkPageInstance(page)) {
            Integer renderCount = null;
            if (handler.includeRenderCount()) {
                renderCount = page.getRenderCount();
            }
            String componentPath = handler.getComponentPath();
            PageInfo pageInfo = getPageInfo(handler);
            ComponentInfo componentInfo = new ComponentInfo(renderCount, componentPath, handler.getBehaviorIndex());
            PageComponentInfo pageComponentInfo = new PageComponentInfo(pageInfo, componentInfo);
            PageParameters parameters = newPageParameters();
            parameters.mergeWith(page.getPageParameters());
            UrlInfo urlInfo = new UrlInfo(pageComponentInfo, page.getClass(), parameters.mergeWith(handler.getPageParameters()));
            url = buildUrl(urlInfo);
        }
    }
    return url;
}
Also used : PageInfo(org.apache.wicket.request.mapper.info.PageInfo) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) ComponentInfo(org.apache.wicket.request.mapper.info.ComponentInfo) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo)

Example 74 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.

the class WicketTesterTest method setMultiValueQueryParameter.

/**
 * Asserting that multiple parameters added in request and PageParameters get processed
 */
@Test
void setMultiValueQueryParameter() {
    PageParameters parameters = new PageParameters();
    parameters.add("q_1", "q_1_value_1");
    parameters.add("q_1", "q_1_value_2");
    IPageProvider testPageProvider = new PageProvider(MockPageParametersAware.class, parameters);
    IRequestHandler pageRequestHandler = new BookmarkablePageRequestHandler(testPageProvider);
    Url url = tester.getApplication().getRootRequestMapper().mapHandler(pageRequestHandler);
    tester.getRequest().addParameter("q_2", "q_2_value_1");
    tester.getRequest().addParameter("q_2", "q_2_value_2");
    tester.getRequest().setUrl(url);
    tester.processRequest();
    MockPageParametersAware page = (MockPageParametersAware) tester.getLastRenderedPage();
    IRequestParameters lastQueryParameter = page.getLastQueryParameters();
    List<StringValue> q1ParameterValues = lastQueryParameter.getParameterValues("q_1");
    assertTrue(q1ParameterValues.contains(StringValue.valueOf("q_1_value_1")));
    assertTrue(q1ParameterValues.contains(StringValue.valueOf("q_1_value_2")));
    List<StringValue> q2ParameterValues = lastQueryParameter.getParameterValues("q_2");
    assertTrue(q2ParameterValues.contains(StringValue.valueOf("q_2_value_1")));
    assertTrue(q2ParameterValues.contains(StringValue.valueOf("q_2_value_2")));
}
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) MockPageParametersAware(org.apache.wicket.MockPageParametersAware) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) StringValue(org.apache.wicket.util.string.StringValue) Url(org.apache.wicket.request.Url) IRequestParameters(org.apache.wicket.request.IRequestParameters) Test(org.junit.jupiter.api.Test)

Example 75 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.

the class HtmlImportHeaderItemTest method wicketPageUrl.

@Test
void wicketPageUrl() throws Exception {
    WicketTester tester = new WicketTester();
    PageParameters parameters = new PageParameters();
    parameters.add("foo", "foo");
    parameters.add("bar", "bar");
    CharSequence pageUrl = tester.getRequestCycle().urlFor(SimplePage.class, parameters);
    MetaDataHeaderItem importLink = HtmlImportHeaderItem.forImportLinkTag(SimplePage.class, parameters, "monitor", true);
    assertEquals("<link rel=\"import\" href=\"" + pageUrl + "\" media=\"monitor\" async />\n", importLink.generateString());
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Test(org.junit.jupiter.api.Test)

Aggregations

PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)272 Test (org.junit.jupiter.api.Test)79 Url (org.apache.wicket.request.Url)56 IRequestHandler (org.apache.wicket.request.IRequestHandler)39 PageProvider (org.apache.wicket.core.request.handler.PageProvider)27 StringValue (org.apache.wicket.util.string.StringValue)26 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)23 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)20 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)20 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)18 BookmarkablePageRequestHandler (org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler)17 ResourceUrl (org.apache.wicket.request.resource.caching.ResourceUrl)16 Test (org.junit.Test)16 Page (org.apache.wicket.Page)10 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)10 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)10 ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)10 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)8 IOException (java.io.IOException)8 WebPage (org.apache.wicket.markup.html.WebPage)8