4 Replies Latest reply on Mar 12, 2008 1:43 PM by leowenttechie

    Seam Integration Test failing new FacesRequest(){}

    leowenttechie

      i am trying to use SeamTest for integration testing. what I am able to run Unit test cases. When I am trying to run Integration test cases then I am ending up in problem. This is the code snippet which I am trying to run in my test case :


              @Test( alwaysRun=true )
              public void testLoginPage() throws Exception
              {
                      new FacesRequest("/security/login.xhtml")
                      {
                              @Override
                              protected void updateModelValues() throws Exception
                              {
                                      System.out.println("helkjfskljdfsafdasfkhkajsfd");
                                      assert "helo".equals( "helo" );
                              }
                      }.run();
              }
      



      When I am running this test case then this is the exception I am getting. I am not able to understand why is that :


         [testng] FAILED: testLoginPage
         [testng] javax.servlet.ServletException: ServletContext not allow to getResourceAsStream for /WEB-INF/web.xml
         [testng]     at org.ajax4jsf.framework.util.config.WebXml.<init>(WebXml.java:104)
         [testng]     at org.ajax4jsf.framework.resource.ResourceBuilderImpl.init(ResourceBuilderImpl.java:183)
         [testng]     at org.ajax4jsf.framework.resource.InternetResourceService.init(InternetResourceService.java:96)
         [testng]     at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.getResourceService(BaseFilter.java:278)
         [testng]     at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:207)
         [testng]     at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
         [testng]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
         [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.servlet.SeamFilter.doFilter(SeamFilter.java:158)
         [testng]     at org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.java:514)
         [testng]     at com.subexazure.spark.web.app.model.security.LoginTest.testLoginPage(LoginTest.java:11)
         [testng] ... Removed 22 stack frames
      



      What can I do to avoid this.


        • 1. Re: Seam Integration Test failing new FacesRequest(){}
          pmuir

          Make sure that the richfaces-impl.jar isn't on the test classpath iirc.

          • 2. Re: Seam Integration Test failing new FacesRequest(){}
            leowenttechie

            do i have to exclude any other jar from the classpath. I saw in couple of example ant scripts with seam/example, some seam jars were excluded from the test classpath, calling it as jboss-embedded hack. Do I have to do that. Though just to make a point I am not using EJB in my applcation. I am using normal SEAM pojos.


            Also when I see the console I see all the SEAM components being loaded on startup but when I trying accessing them using


            Components.getInstance(xyz.class, ScopeType.CONVERSATION);



            It says there is no Conversation context present. Do I have to anything for that.


            Also for all the test classes I am writing extending from SeamTest loads the Seam environment loading all the Components all over again. Is there any way to avoid that ?

            • 3. Re: Seam Integration Test failing new FacesRequest(){}
              pmuir

              Take a look at what seam-gen generates, it is correct.


              Also for all the test classes I am writing extending from SeamTest loads the Seam environment loading all the Components all over again. Is there any way to avoid that ?


              This is redesigned in Seam 2.1

              • 4. Re: Seam Integration Test failing new FacesRequest(){}
                leowenttechie

                richfaces-impl.jar is not there


                I am not using EJB anywhere and I am deploying my application on tomcat. I dont have the Scopes (session, conversation) available and even I dont have the FacesContext available. One of my class looks for:
                  


                @In (create=true)
                private FacesContext facesContext
                




                It returns facesCOntext as null


                Do we have a documentation which i can follow for configuring test framework for my application.