4 Replies Latest reply on Feb 12, 2010 9:33 AM by Max Rydahl Andersen

    JBT Test Project and running integration tests problem

    Piotr Sobczyk Newbie

      Has anybody succeed with running tests from test project generated by JBoss Tools while using RichFaces? I always end up with exception:

       

      FAILED: testDisplayClients
      java.lang.NullPointerException
          at java.lang.String.startsWith(Unknown Source)
          at java.lang.String.startsWith(Unknown Source)
          at org.ajax4jsf.webapp.WebXml.getFacesResourceKey(WebXml.java:189)
          at org.ajax4jsf.webapp.WebXml.getFacesResourceKey(WebXml.java:222)
          at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:139)
          at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:508)
          at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
          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.servlet.SeamFilter.doFilter(SeamFilter.java:158)
          at org.jboss.seam.mock.AbstractSeamTest$Request.run(AbstractSeamTest.java:491)
          at pl.sobczyk.mitsubishi.crm.test.DisplayClientsTest.testDisplayClients(DisplayClientsTest.java:29)
      ... Removed 22 stack frames

       

      As I said I'm using test project generated by JBT, with no modifications and TestNG plugin. I added very simple test case and test suite descriptor named testng.xml to test-src source folder. I'm running test like in this official seam tutorial: http://docs.jboss.com/seam/latest/reference/en-US/html/gettingstartedwithjbosstools.html by clicking right mouse button on testng.xml -> RunAs -> TestNG. Everything seems to work fine, every seam component is propetly loaded to Embedded JBoss container but when it seems that test is finnaly running above exception occurs.

       

      I tried to debug it and noticed very strange things:

       

      (org.ajax4jsf.webapp.WebXml.getFacesResourceKey.java)

      public String getFacesResourceKey(HttpServletRequest request) {
      String resourcePath = request.getRequestURI().substring(
              request.getContextPath().length());
      return getFacesResourceKey(resourcePath);

      }

      Last line of above code invokes method getFacesResourceKey that throws exception
      (there is null object passed to startsWith method).

      When this method is invoked than:
      request.principalName="gavin"
      resourcePath="ocalhost:8080/myproject/page.seam"

      Obviously I have no user in my test named gavin and there is no page /mypoject/page.xhtml in my project.
      It seems like some example test is launching along with mine but I can't find out why and from where.

      I really don't know whether that issue is realated to Seam or JBoss Tools, I tried to ask about it on Seam forum
      and so did several other people but I never found correct answer. Here are topics:

      http://seamframework.org/Community/TestNGTestBrokenIn21
      http://seamframework.org/Community/RunningSeamMaven2TestNGTests
      http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4252529#4252529
      http://www.seamframework.org/Community/IntegrationTestsUsingTestNGPlugin

      I didn't yet try to launch my tests from ant task, before that I would have to create full ant build script to
      my project and up to now using JBT Builder to build project was just enough for me.

      I tried both Seam 2.1.2 and 2.2.0 GA versions. I also recreated test project with newest JBT version. Nothing helped .
        • 1. Re: JBT Test Project and running integration tests problem
          Piotr Sobczyk Newbie

          Allright, I've just managed to adapt a test piece of standard seam-gen build script to JBT project and launched my test - everything went allright.  Exception from RichFaces code didn't occur. My ant target took advantage of JBT test project so it seems that test project generated in JBT is allritght. However the issue seems to be related with JBoss Tools or TestNG Eclipse Plugin

          • 2. Re: JBT Test Project and running integration tests problem
            Max Rydahl Andersen Master

            So what is the difference between your two launches ?

            • 3. Re: JBT Test Project and running integration tests problem
              Piotr Sobczyk Newbie

              Thanks Max.

               

              I really tried to figure it out but I have too small knowledge. Especially I don't know what is the difference between execution of testng Ant task vs execution of TestNG plugin. I also don't know nothing about configuration stuff inside test-project/bootstrap directory.

               

              What is strange for me though is why any RichFaces/Ajax4JSF code is at all invoked. From what I know, Seam integration tests (extending SeamTest class) don't try to simulate any view rendering. They just test application logic and simulate container infrastructure (dependency injection, otujection, component scopes, conversations, etc). So ajax4jsf filter isn't needed at all in testing enviroment. So I disabled this filter in my components.xml file (<web:ajax4jsf-filter disabled="true"/>) but suprisingly the same exception still occurs wchich means that that filter is still in use.

               

              That makes me thinking that there is somewhere something hardcoded just like "Gavin" and "ocalhost:8080/mypage/page.xhtml" stuff that I found in first post. I just don't know where it comes from .

               

              Did you manage to reproduce this exception, Max? If not I can try to create minimal JBT project in wchich it occurs and attach it along with my build script that makes it working.

              • 4. Re: JBT Test Project and running integration tests problem
                Max Rydahl Andersen Master

                piotr.sobczyk wrote:

                 

                Thanks Max.

                 

                I really tried to figure it out but I have too small knowledge. Especially I don't know what is the difference between execution of testng Ant task vs execution of TestNG plugin. I also don't know nothing about configuration stuff inside test-project/bootstrap directory.

                 

                you can see what the command used to launch from Eclipse is by right clicking the process in the Debug view and click Properties and in here the full command line should be present.

                 

                But it could also be something in the embedded jboss, but that is just a copy from seam-gen so should be the same.

                 

                 

                Did you manage to reproduce this exception, Max? If not I can try to create minimal JBT project in wchich it occurs and attach it along with my build script that makes it working.

                No, I haven't had a free minute to reproduce this (trying to get CR2 ready). Best thing you can do is as you say create minimal jbt project and open jira - then we can explore it together.