use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class Issue3989Test method ajaxRenderOfTransparentlyResolvedLabel.
/**
* This will fail unless the markup sourcing strategies look for the label {@code innerpanel} in
* the transparent markup container.
*/
@Test
public void ajaxRenderOfTransparentlyResolvedLabel() {
WicketTester tester = new WicketTester();
tester.startPage(HomePage.class);
tester.assertRenderedPage(HomePage.class);
tester.clickLink("panel:link");
tester.assertComponentOnAjaxResponse("panel:innerpanel");
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class Signin2Test method testSignIn2.
/**
* Test page.
*/
@Test
public void testSignIn2() {
WicketTester tester = new WicketTester(new SignIn2Application());
try {
tester.startPage(Home.class);
tester.assertRenderedPage(SignIn2.class);
FormTester formTester = tester.newFormTester("signInPanel:signInForm");
formTester.setValue("username", "wicket");
formTester.setValue("password", "wicket");
formTester.setValue("rememberMeContainer:rememberMe", "true");
formTester.submit();
tester.assertRenderedPage(Home.class);
// a) With wicket submitting a form will result in a temporary redirect,
// with the redirect setting the Cookie.
// b) jWebUnits Cookie test methods are all using the http response
// object only
// c) Like a browser, jwebunit will automatically handle the redirect
// request
// Hence dumpCookie will not print an Cookie and assertCookiePresent
// will
// fail.
// The only mean available is to indirectly test the cookies. Indirectly
// because
// the screen flow depends on the cookies.
// this.dumpCookies(System.err);
// this.assertCookiePresent("signInPanel.signInForm.username");
// this.assertCookiePresent("signInPanel.signInForm.password");
Collection<Cookie> cookies = tester.getLastResponse().getCookies();
for (Cookie cookie : cookies) {
if ("signInPanel.signInForm.username".equals(cookie.getName())) {
assertEquals("wicket", cookie.getValue());
}
}
tester.startPage(SignOut.class);
tester.assertRenderedPage(SignOut.class);
tester.startPage(Home.class);
tester.assertRenderedPage(SignIn2.class);
} finally {
tester.destroy();
}
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class TemplateTest method test_1.
/**
* Test page.
*/
@Test
public void test_1() {
WicketTester tester = new WicketTester(new TemplateApplication());
tester.startPage(tester.getApplication().getHomePage());
String doc = tester.getLastResponse().getDocument();
tester.assertContains("Wicket Examples - template");
tester.assertContains("This example shows two different ways of building your page up from shared parts.");
tester.startPage(org.apache.wicket.examples.template.pageinheritance.Page1.class);
doc = tester.getLastResponse().getDocument();
tester.assertContains("Template example, page 1 - page inheritance");
tester.assertContains("This is some concrete content from a panel.");
tester.startPage(org.apache.wicket.examples.template.border.Page1.class);
tester.assertRenderedPage(org.apache.wicket.examples.template.border.Page1.class);
doc = tester.getLastResponse().getDocument();
tester.assertContains("Template example, page 1 - border");
tester.assertContains("contents here");
tester.destroy();
}
use of org.apache.wicket.util.tester.WicketTester 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.util.tester.WicketTester 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();
}
}
Aggregations