3 Replies Latest reply on Sep 7, 2009 8:17 AM by lpiccoli.lucio.asteriski.com

    SeamTest newbie problems

    lpiccoli.lucio.asteriski.com

      hi there


      i cant get a simple seamtest to work. i have read the seamtest doc but i dont follow how the FacesRequest test are supposed to work.


      when i run my test the exception seems to indicate that it cant find the component in the EL expression in the invokeApplication method.


      Q1. Does the method expression in invokeMethod refer to the expression in the jsf?


      Q2. if Q1 is true then does the backing bean get instantiated the seamtest?


      what gives, i am lost.



      jsf snippet


           <h:outputLabel value="Note"/>
                 <h:inputTextarea value="#{ActivitySignOffForm.note}" cols="50" rows="5" />
                       
                 <h:commandButton id="activitysignoff" action="#{ActivitySignOffForm.submit}" value="Submit" />
      



      test code



      @Test
      public void test_activity() throws Exception {
      
      new FacesRequest("/itp.signoff.form.xhtml") {
      @Override
           protected void updateModelValues() throws Exception {                    
           //set form input to model attributes
           setValue("#{ActivitySignOffForm.note}","love");
           }
      @Override
           protected void invokeApplication() {
                   //call action methods here
                invokeMethod("#{ActivitySignOffForm.submit}");
                     }
      @Override
      protected void renderResponse() {
            //check model attributes if needed
           assert getValue("#{ActivitySignOffForm.note}").equals("love");
       }
      }.run();
      }
      



      exception



      java.lang.AssertionError: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'ActivitySignOffForm' resolved to null
           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)
      



      -lp

        • 1. Re: SeamTest newbie problems
          jeanluc

          in setValue() you need to pass a valid EL expression. In your case, setValue("#{ActivitySignOffForm.note}","love"); assumes there is a Seam component named ActivitySignOffForm. You haven't posted the form's code so I can't tell if the @Name annotation is indeed defining this name. Note that this name has nothing to do with the class name.


          So the exception is saying there's no Seam component named ActivitySignOffForm

          • 2. Re: SeamTest newbie problems
            lpiccoli.lucio.asteriski.com



            So the exception is saying there's no Seam component named ActivitySignOffForm

            yeah there is a class using the correct @Name annotation.



            @Name("ActivitySignOffForm")
            public class ActivitySignOffFormAction extends ITPBaseAction
            {
                //@Logger private Log log;
            
                @In StatusMessages statusMessages;
                
                @In Actor actor;
                
            .....
            
             public String getNote() {
                 return note;
            }
            
            public void setNote(String note) {
                 this.note = note;
            }
            
            



            i was expecting the setValue to invoke the setNote method. but instead it seems that it cant be found.
            The class is in the eclipse project so unless there is some special 'seamtest' config that i have missed i am most confused as why this doesnt work.


            any help is appreciated.


            -lp

            • 3. Re: SeamTest newbie problems
              lpiccoli.lucio.asteriski.com

              can someone confirm if embedded jboss has started?


              i am simply running the test class with testng with the lib/test added.


              is there any other process or config that is required?


              the log is below.


              16:04:26,140 DEBUG [Ejb3Deployer] ********* Ejb3Deployer Begin Unit: jboss-seam-ui.jar jar: jboss-seam-ui.jar
              16:04:26,182 DEBUG [Ejb3Deployment] EJB3 deployment time took: 41
              16:04:26,183 DEBUG [DeployersImpl] Fully Deployed vfsjar:file:/C:/src/seamitp/lib/jboss-seam.jar!/
              16:04:26,183 DEBUG [DeployersImpl] Fully Deployed vfsjar:file:/C:/src/seamitp/lib/jboss-seam-ui.jar!/
              16:04:28,005 WARN  [PersistentPermissionResolver] no permission store available - please install a PermissionStore with the name 'org.jboss.seam.security.jpaPermissionStore' if persistent permissions are required.
              FAILED: testSearch
              java.lang.AssertionError: 
                   at org.junit.Assert.fail(Assert.java:91)
                   at org.junit.Assert.assertTrue(Assert.java:43)
                   at org.junit.Assert.assertNotNull(Assert.java:524)
                   at org.junit.Assert.assertNotNull(Assert.java:535)
                   at com.asteriski.itpflow.business.ReferenceBusinessTest$1.testComponents(ReferenceBusinessTest.java:23)
                   at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:162)
                   at com.asteriski.itpflow.business.ReferenceBusinessTest.testSearch(ReferenceBusinessTest.java:25)
              ... Removed 22 stack frames