5 Replies Latest reply on Oct 1, 2009 10:41 AM by lucio piccoli

    help with '@In attribute requires non-null' in seamTest

    lucio piccoli Newbie

      hi all


      i have am having getting a simply integration test to work with @In variable.


      the Injection of value 'currentUser' is not being set and the error


      @In attribute requires non-null value: LotForm.currentUser



      is being thrown.


      The other @In members are being set. In the test case i am setting the @In value like so


      setValue("#{currentUser}", currentUser);



      But it does not get set when involving the action method


       invokeAction("#{LotForm.create}");




      The error when running with testNG


      java.lang.AssertionError: org.jboss.seam.RequiredException: @In attribute requires non-null value: LotForm.currentUser
           at org.jboss.seam.mock.AbstractSeamTest$Request.onException(AbstractSeamTest.java:455)
           at org.jboss.seam.mock.AbstractSeamTest$Request$2.doFilter(AbstractSeamTest.java:504)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.jboss.seam.mock.AbstractSeamTest$Request.run(AbstractSeamTest.java:491)
           at com.asteriski.itpflow.business.action.LotFormActionTest.createProcess(LotFormActionTest.java:45)




      The class that is being tested.


      @Name("LotForm")
      public class LotFormAction
      {
          @Logger private Log log;
      
          
          @In(value="LotBusiness", create=true)
          LotBusiness lotBusiness;
            
          @In(value="currentUser")
          Person currentUser;
      
      ...
      



      The test case


      @Test  
      public void createProcess() throws Exception{
       new FacesRequest() {
       @Override  protected void applyRequestValues() throws Exception {
                Person currentUser = new Person();
             currentUser.setFirstName("John");                               
             setValue("#{currentUser}", currentUser);
         }
      
        @Override
        protected void invokeApplication() throws Exception
        {
           invokeAction("#{LotForm.create}");
        }          
       }.run();
       }




      I have tried


      setValue("#{LotForm.currentUser}", currentUser);



      but get same result.


      how do i set the @In value for a integration test?


      any help is appreciated.


      -lp