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