Package org.apache.wicket.util.tester

Examples of org.apache.wicket.util.tester.FormTester


    tester.startPage(HomePage.class);

    // assert rendered page class
    tester.assertRenderedPage(HomePage.class);

    FormTester formTester = tester.newFormTester("bookingForm");
    formTester.submit();

    tester.assertErrorMessages("Name is required");
  }
View Full Code Here


  {
    TestPage page = new TestPage();

    tester.startPage(page);

    FormTester ft = tester.newFormTester("form");
    ft.setValue("name", "999999999");
    ft.submit();
    assertEquals(0, tester.getSession().getFeedbackMessages().size());

    MaxLenValidator max = new MaxLenValidator(page.name);
    page.form.add(max);

    ft = tester.newFormTester("form");
    ft.setValue("name", "999999999");
    ft.submit();
    assertEquals(1, tester.getSession().getFeedbackMessages().size());
    assertEquals("MAX", tester.getSession()
      .getFeedbackMessages()
      .iterator()
      .next()
      .getMessage()
      .toString());

    ft = tester.newFormTester("form");
    ft.setValue("name", "22");
    ft.submit();
    assertEquals(0, tester.getSession().getFeedbackMessages().size());

    MinLenValidator min = new MinLenValidator(page.name);
    page.form.add(min);

    ft = tester.newFormTester("form");
    ft.setValue("name", "22");
    ft.submit();
    assertEquals(1, tester.getSession().getFeedbackMessages().size());
    assertEquals("MIN", tester.getSession()
      .getFeedbackMessages()
      .iterator()
      .next()
      .getMessage()
      .toString());

    ft = tester.newFormTester("form");
    ft.setValue("name", "7777777");
    ft.submit();
    assertEquals(0, tester.getSession().getFeedbackMessages().size());

    page.form.remove(min);

    ft = tester.newFormTester("form");
    ft.setValue("name", "22");
    ft.submit();
    assertEquals(0, tester.getSession().getFeedbackMessages().size());

    page.form.remove(max);

    ft = tester.newFormTester("form");
    ft.setValue("name", "999999999");
    ft.submit();
    assertEquals(0, tester.getSession().getFeedbackMessages().size());

  }
View Full Code Here

    // same as above but uses different technique to login
    application.startPage(application.getApplication().getHomePage());
    MockLoginPage loginPage = (MockLoginPage)application.getLastRenderedPage();
    assertEquals(((MyMockWebApplication)application.getApplication()).getLoginPage(),
      loginPage.getClass());
    FormTester form = application.newFormTester("form");
    form.setValue("username", "admin");
    form.submit();
    assertEquals(application.getApplication().getHomePage(), application.getLastRenderedPage()
      .getClass());
  }
View Full Code Here

    application.startPage(application.getApplication().getHomePage());
    MockLoginPage loginPage = (MockLoginPage)application.getLastRenderedPage();
    assertEquals(((MyMockWebApplication)application.getApplication()).getLoginPage(),
      loginPage.getClass());

    FormTester form = application.newFormTester("form");
    form.setValue("username", "admin");
    form.submit();

    assertEquals(application.getApplication().getHomePage(), application.getLastRenderedPage()
      .getClass());

    application.clickLink(application.getLastRenderedPage().get("link"));
View Full Code Here

    tester.startPage(HomePage.class);

    // page's feedback
    tester.assertInfoMessages("info on field", "page onbeforerender");

    FormTester formTester = tester.newFormTester("form");
    formTester.submit();

    // feedback message for LocalizedFeedbackBorder
    // without the fix the same error message was reported for the page's feedback panel too
    tester.assertErrorMessages("Field 'field' is required.");

    // page's feedback
    tester.assertInfoMessages("page onbeforerender");

    formTester = tester.newFormTester("form");
    formTester.setValue("fieldborder:border:fieldborder_body:field", "some text");
    formTester.submit();

    tester.assertErrorMessages();

    // page's feedback
    tester.assertInfoMessages("form submitted", "page onbeforerender");
View Full Code Here

  {
    TestPage page = new TestPage();

    tester.startPage(page);

    FormTester ft = tester.newFormTester("form");
    ft.setValue("name", "999999999");
    ft.submit();
    assertEquals(0, tester.getSession().getFeedbackMessages().size());

    MaxLenValidator max = new MaxLenValidator();
    page.name.add(max);

    ft = tester.newFormTester("form");
    ft.setValue("name", "999999999");
    ft.submit();
    assertEquals(1, tester.getSession().getFeedbackMessages().size());
    assertEquals("MAX", tester.getSession()
      .getFeedbackMessages()
      .iterator()
      .next()
      .getMessage()
      .toString());

    ft = tester.newFormTester("form");
    ft.setValue("name", "22");
    ft.submit();
    assertEquals(0, tester.getSession().getFeedbackMessages().size());

    MinLenValidator min = new MinLenValidator();
    page.name.add(min);

    ft = tester.newFormTester("form");
    ft.setValue("name", "22");
    ft.submit();
    assertEquals(1, tester.getSession().getFeedbackMessages().size());
    assertEquals("MIN", tester.getSession()
      .getFeedbackMessages()
      .iterator()
      .next()
      .getMessage()
      .toString());

    ft = tester.newFormTester("form");
    ft.setValue("name", "7777777");
    ft.submit();
    assertEquals(0, tester.getSession().getFeedbackMessages().size());

    page.name.remove(min);

    ft = tester.newFormTester("form");
    ft.setValue("name", "22");
    ft.submit();
    assertEquals(0, tester.getSession().getFeedbackMessages().size());

    page.name.remove(max);

    ft = tester.newFormTester("form");
    ft.setValue("name", "999999999");
    ft.submit();
    assertEquals(0, tester.getSession().getFeedbackMessages().size());
  }
View Full Code Here

  /**
   *
   */
  public void testWithoutBorder2()
  {
    FormTester formTester = tester.newFormTester("form");
    formTester.setValue("textfield1", "testxxx");
    tester.executeAjaxEvent("form:submit", "onclick");
    tester.assertNoErrorMessage();
    assertFalse(((HomePage)tester.getLastRenderedPage()).hitOnError);
    assertTrue(((HomePage)tester.getLastRenderedPage()).hitOnSubmit);
  }
View Full Code Here

  @Test
  public void login()
  {
    tester.startPage(LOGIN);
    tester.assertRenderedPage(LOGIN);
    FormTester form = tester.newFormTester("signInPanel:signInForm");
    form.setValue("username", "test");
    form.setValue("password", "test");
    form.submit();
    tester.assertRenderedPage(HOME);
  }
View Full Code Here

    tester.assertRenderedPage(LOGIN);
    page = (LoginPage)tester.getLastRenderedPage();
    assertTrue(page.isPageInitialized());
    assertTrue(page.isPanelInitialized());

    FormTester form = tester.newFormTester("signInPanel:signInForm");
    form.setValue("username", "test");
    form.setValue("password", "invalid");
    form.submit();

    tester.assertRenderedPage(LOGIN);
    page = (LoginPage)tester.getLastRenderedPage();
    assertTrue(page.isPageInitialized());
    assertTrue(page.isPanelInitialized());
View Full Code Here

    StatelessPageWithForm.FORM_SUBMITTED.set(false);
    try
    {
      tester.startPage(StatelessPageWithForm.class);
      tester.assertRenderedPage(StatelessPageWithForm.class);
      FormTester form = tester.newFormTester("form");
      assertTrue(tester.getSession().isTemporary());
      form.submit();
      tester.assertRenderedPage(StatelessPageWithForm.class);
      assertTrue(StatelessPageWithForm.FORM_SUBMITTED.get());
      assertTrue(tester.getSession().isTemporary());
    }
    finally
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.tester.FormTester

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.