1 Reply Latest reply on Mar 29, 2008 3:22 PM by Pete Muir

    Trigger a JSF validator in a SeamTest

    Fredrik Forsberg Newbie

      Hi. I use seam 2.0.1 and have a jsf validator/seam test question.


      Assume I have the following test:



      public class RegisterAccountActionBeanFacesTest extends SeamTest {
      
           @Test()
           public void testSuccessfulRegistration() throws Exception {
                new FacesRequest() {
                     @Override
                     protected void updateModelValues() {
                          setValue("#{registeraccount.username}", "ErikEriksson");
                     }
      
                     @Override
                     protected void invokeApplication() {
                          assert invokeMethod("#{registeraccount.register}").equals("success");
                     }
                }.run();
           }
      }




      It is for testing my method 'register' on the Seam component 'RegisterAccount'.


      I have a validator attached to the inputfield for username. The validator is implemented as a Seam component (not implementing the Validator) with the methodsignature


      public void validateUsername(FacesContext context, UIComponent tovalidate, Object value)





      Can I trigger this validator upon the call of the'register' method in the test? or do I have to assert the validator methods instead of
      the register method (that relies on the fact that the validator does its job)?