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