Package org.apache.wicket.util.tester

Examples of org.apache.wicket.util.tester.FormTester$ChoiceSelector$SearchOptionByIndexVisitor


  {
    TestPage testPage = new TestPage();
    testPage.textField.setType(String.class);
    testPage.textField.setConvertEmptyInputStringToNull(true);
    tester.startPage(testPage);
    FormTester formTester = tester.newFormTester(testPage.form.getId());
    formTester.setValue(testPage.textField.getId(), "");
    formTester.submit();
    assertEquals(null, testPage.textField.getDefaultModelObject());
  }
View Full Code Here


    TestPage testPage = new TestPage();
    testPage.textField.setType(String.class);
    testPage.textField.setRequired(false);
    testPage.textField.add(StringValidator.minimumLength(2));
    tester.startPage(testPage);
    FormTester formTester = tester.newFormTester(testPage.form.getId());
    formTester.setValue(testPage.textField.getId(), "");
    formTester.submit();
    assertEquals(null, testPage.textField.getDefaultModelObject());
    assertTrue(testPage.textField.isValid());
  }
View Full Code Here

    @Test
    public void shouldPassValidationAndRedirectToLoginPageWhenAllRequiredFieldsAreFilled() throws UserExistsException {
        //given
        given(userManager.saveUser(Matchers.<User>anyObject())).willAnswer(createAnswerThatJustReturnPassedUser());
        goToPageAndAssertIfRendered(Signup.class);
        FormTester signupForm = tester.newFormTester("userEditForm");

        //when
        fillRequiredFields(signupForm);
        signupForm.submit("userEditPanel:buttonsGroup:saveButton");

        //then
        tester.assertNoErrorMessage();
        tester.assertRenderedPage(Login.class);
    }
View Full Code Here

    @Test
    @Ignore //Not implemented - https://agilezen.com/project/23613/story/13
    public void shouldReportErrorWhenPasswordAndConfirmPasswordMismatch() {
        //given
        goToPageAndAssertIfRendered(Signup.class);
        FormTester signupForm = tester.newFormTester("userEditForm");

        //when
        fillRequiredFields(signupForm);
        signupForm.setValue("userEditPanel:passwordGroup:confirmPassword", "mismatch");
        signupForm.submit("userEditPanel:buttonsGroup:saveButton");

        //then
        assertRenderedLoginPageWithErrorMessages(Signup.class, "<<some new message>>");
    }
View Full Code Here

    @Test
    public void shouldSaveUserWithEnteredValues() throws UserExistsException {
        //given
        given(userManager.saveUser(Matchers.<User>anyObject())).willAnswer(createAnswerThatJustReturnPassedUser());
        goToPageAndAssertIfRendered(Signup.class);
        FormTester signupForm = tester.newFormTester("userEditForm");

        //when
        fillRequiredFields(signupForm);
        fillOptionalFields(signupForm);
        signupForm.submit("userEditPanel:buttonsGroup:saveButton");

        //then
        tester.assertNoErrorMessage();
//        Note: there is an additional space at the end of a setence in *.properties file
        assertInfoMessage("You have successfully registered for access to this application. ");
View Full Code Here

        assertRenderedLoginPageWithErrorMessages(Login.class,
                getRequiredErrorMessageByField("username"), getRequiredErrorMessageByField("password"));
    }

    private void submitLoginFormWithUsernameAndPassword(String username, String password) {
        FormTester loginForm = tester.newFormTester("loginForm");
        //MZA: Strange construction required after upgrade to Wicket 1.5
        loginForm.setValue("border:border_body:username", username);
        loginForm.setValue("password", password);
        loginForm.submit();
    }
View Full Code Here

        tester.startPage(LotteriesPage.class);

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

        FormTester form = tester.newFormTester("createLotteryForm");
        form.setValue("name", "lottery");
        form.setValue("drawingTimestamp:date", "12/12/09"); // US format :(
        form.setValue("drawingTimestamp:hours", "11");
        form.setValue("drawingTimestamp:minutes", "44");
        form.setValue("prizeAmount", "1000.00");
        form.setValue("ticketPrice", "1.50");
        form.submit();
       
        tester.assertNoErrorMessage();
        verifyMocks();
    }
View Full Code Here

    tester.assertContains("Wicket Examples - guestbook");

    // check if the list of comments is empty
    tester.assertListView("comments", new ArrayList<>());
    tester.assertComponent("commentForm", Form.class);
    FormTester formTester = tester.newFormTester("commentForm");
    formTester.setValue("text", "test-1");
    formTester.submit();

    tester.assertModelValue("comments:0:text", "test-1");

    formTester = tester.newFormTester("commentForm");
    formTester.setValue("text", "test-2");
    formTester.submit();
    tester.assertModelValue("comments:0:text", "test-2");
    tester.assertModelValue("comments:1:text", "test-1");

    formTester = tester.newFormTester("commentForm");
    formTester.setValue("text", "test-3");
    formTester.setValue("comment", "test-3");
    formTester.submit();
    tester.assertModelValue("comments:0:text", "test-2");
    tester.assertModelValue("comments:1:text", "test-1");
    tester.assertErrorMessages("Caught a spammer!!!");
  }
View Full Code Here

  {
    TestPage page = new TestPage();

    tester.startPage(page);

    FormTester ft = tester.newFormTester("form");
    ft.setValue("name", "999999999");
    ft.submit();
    assertEquals(0, new FeedbackCollector(page).collect().size());

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

    ft = tester.newFormTester("form");
    ft.setValue("name", "999999999");
    ft.submit();
    assertEquals(1, new FeedbackCollector(page).collect().size());
    // WICKET-5115 variables in default message are not substituted (was the case in 1.5.x)
    assertEquals("MAX ${len}", new FeedbackCollector(page).collect()
      .get(0)
      .getMessage()
      .toString());

    ft = tester.newFormTester("form");
    ft.setValue("name", "22");
    ft.submit();
    assertEquals(0, new FeedbackCollector(page).collect().size());

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

    ft = tester.newFormTester("form");
    ft.setValue("name", "22");
    ft.submit();
    assertEquals(1, new FeedbackCollector(page).collect().size());
    assertEquals("MINIMUM", new FeedbackCollector(page).collect()
      .get(0)
      .getMessage()
      .toString());

    ft = tester.newFormTester("form");
    ft.setValue("name", "7777777");
    ft.submit();
    assertEquals(0, new FeedbackCollector(page).collect().size());

    page.name.remove(min);

    ft = tester.newFormTester("form");
    ft.setValue("name", "22");
    ft.submit();
    assertEquals(0, new FeedbackCollector(page).collect().size());

    page.name.remove(max);

    ft = tester.newFormTester("form");
    ft.setValue("name", "999999999");
    ft.submit();
    assertEquals(0, new FeedbackCollector(page).collect().size());
  }
View Full Code Here

    {
      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
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.tester.FormTester$ChoiceSelector$SearchOptionByIndexVisitor

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.