5 Replies Latest reply on Oct 1, 2009 8:49 PM by sergey.sdenisov.gmail.com

    testNG test broken in 2.1

    zeeman

      I'm using Seam 2.1.2.CR1, project is a war file.


      I have below testNG test which I sat up according to readMe.txt from seam-gen.


           
      @Test
      public class loginTest extends SeamTest {
      
           public void testAuthntication() throws Exception {
                new FacesRequest() {
                     @Override
                     protected void invokeApplication() {
                          setValue("#{credentials.username}", "seam");
                          setValue("#{credentials.password}", "seam");
                          invokeAction("#{identity.login}");
                          assert getValue("#{identity.loggedIn}").equals(false);
                     }
                }.run();
      }
      }
      





      classpath setup:




      /bootstrap
      /lib/test/jboss-embedded-all.jar
      /lib/test/hibernate-all.jar
      /lib/test/thirdparty-all.jar
      /lib/jboss-embedded-api.jar
      /lib/jboss-deployers-client-spi.jar
      /lib/jboss-deployers-core-spi.jar
      myProject (default classpath), this has all seam and jboss jars





      It fails with below exception:





      java.lang.NullPointerException
           at java.lang.String.startsWith(String.java:1422)
           at java.lang.String.startsWith(String.java:1451)
           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:510)
           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:58)
           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.sportivity.action.loginTest.testSuccessfulRegisteration(loginTest.java:84)
      ... Removed 22 stack frames



      Any ideas?

        • 1. Re: testNG test broken in 2.1
          jeanluc

          put a breakpoint in WebXml.getFacesResourceKey() and see from there, it should give you some hints what's happening.

          • 2. Re: testNG test broken in 2.1
            zeeman

            This is inside richfaces code. Where do I get richfaces-impl.jar from that matches version Seam 2.1 use?


            This is too much just to get a test to work.



            Jean Luc wrote on Jul 07, 2009 19:28:


            put a breakpoint in WebXml.getFacesResourceKey() and see from there, it should give you some hints what's happening.


            Click HELP for text formatting instructions. Then edit this text and check the preview.

            • 3. Re: testNG test broken in 2.1

              I had the same problem, with Seam 2.1.2. I'm using maven to build my application.


              After banging my head for several hours I discovered that the cause was that the WEB-INF folder is by default under src/main/webapp, and that is not in Eclipse's classpath by default. You have to either set src/main/webapp as a resource folder or copy WEB-INF to src/main/resources.


              I'm just posting this here in case someone faces a similar problem.

              • 4. Re: testNG test broken in 2.1
                pksiv

                Tomas Pollak wrote on Jul 15, 2009 08:17:


                I had the same problem, with Seam 2.1.2. I'm using maven to build my application.

                After banging my head for several hours I discovered that the cause was that the WEB-INF folder is by default under src/main/webapp, and that is not in Eclipse's classpath by default. You have to either set src/main/webapp as a resource folder or copy WEB-INF to src/main/resources.

                I'm just posting this here in case someone faces a similar problem.


                Could you be a bit more specific on what needs to be available in the Eclipse Classpath ?

                • 5. Re: testNG test broken in 2.1
                  sergey.sdenisov.gmail.com

                  Could you be a bit more specific on what needs to be available in the Eclipse Classpath ?


                  You just need to add the root of your web app (a directory that contains WEB-INF) to the classpath. Then it will be used by the ClassLoader to look for resources.