2 Replies Latest reply on Sep 22, 2009 2:47 PM by blabno

    SeamTest FacesRequest

    Sai Krishna Mohan Susarla Newbie

      I have written a Custom Converter

      following is the code snippet:

      <ice:inputText value="MyController.age">
      <f:converter converterId="MyConverter"/>

      Here MyController.age is of Integer Type. Hence, if I give characters in this field then my converter should be called.

      Now, I am writing a SeamTest. Here is the code snippet:

      @Test(groups = "integration")
          public void testAge() throws Exception
              new FacesRequest("/myPage.xhtml")
                  protected void applyRequestValues() throws Exception
                      setValue("#{MyController.age}", "Invalid Data");
                  protected void updateModelValues() throws Exception
                  protected void renderResponse() throws Exception
                      Object age = getValue("#{MyController.age}");
                      assert "Invalid Data".equalsIgnoreCase(age.toString());

      When i run this test my converter is not being called, instead it is giving me an exception as follows:

      java.lang.AssertionError: javax.el.ELException: Can't set property 'age' on class 'MyConverter' to value 'Invalid Data'.
         [testng] at org.jboss.seam.mock.AbstractSeamTest$Request.onException(AbstractSeamTest.java:455)
         [testng] at org.jboss.seam.mock.AbstractSeamTest$Request$2.doFilter(AbstractSeamTest.java:504)
         [testng] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
         [testng] at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
         [testng] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
         [testng] at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
         [testng] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
         [testng] at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
         [testng] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
         [testng] at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
         [testng] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
         [testng] at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
         [testng] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
         [testng] at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
         [testng] at org.jboss.seam.mock.AbstractSeamTest$Request.run(AbstractSeamTest.java:491)
         [testng] at com.octanner.materialmaster.MyController.testAge(MyController.java:4)

      Can some body tell me how to invoke my custom converter from SeamTest?

        • 1. Re: SeamTest FacesRequest
          judy guglielmin Novice

          I am no SeamTest expert (I use Selenium scripts for testing ICEfaces apps), but it essentially tests the back end (beans), and there are some examples in the icefaces booking example with Seam distribution if that helps (some of the input components use standard jsf converters and there isn't any problem with them).
          However, just quickly looking at your snippet, you need to use the proper el expression with the quote and pound around

          <ice:inputText> value="#{MyController.age}"....

          • 2. Re: SeamTest FacesRequest
            blabno Master

            This is interesting issue. It would be nice if SeamTest would check at converters on facelet and convert the values. I'm thinking about using  NullableStringConverter which trims strings and registering it as class level converter (forClass=String.class).