11 Replies Latest reply on Dec 19, 2008 9:08 AM by ssilvert

    Exception while running JSFUnitTest

      I created two maven projects 'JSFUnitMaven' and 'JSFUnitMavenTest' for the testing of jsfUnit. All the jsfunit test classes are in JSFUnitMavenTest and jsf that i want to test is in JSFUnitMaven project.
      I configured everything that is required to mentioned in http://www.jboss.org/community/docs/DOC-10977

      Pom.xml for the project JSFUnitMaven

      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      
       <modelVersion>4.0.0</modelVersion>
       <groupId>JSFUnitMavenGroup</groupId>
       <artifactId>JSFUnitMaven</artifactId>
       <packaging>war</packaging>
       <version>0.0.1-SNAPSHOT</version>
       <name>JSFUnitMaven Maven Webapp</name>
       <url>http://maven.apache.org</url>
      
       <dependencies>
       <dependency>
       <groupId>javax.faces</groupId>
       <artifactId>jsf-api</artifactId>
       <scope>provided</scope>
       <version>1.2_02</version>
       </dependency>
       <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
       <version>2.4</version>
       <scope>provided</scope>
       </dependency>
       </dependencies>
      
       <modules>
       <module>JSFUnitMavenTest</module>
       </modules>
      </project>


      pom.xml for JSFUnitMavenTest
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
       <modelVersion>4.0.0</modelVersion>
       <groupId>JSFUnitMavenGroup</groupId>
       <artifactId>JSFUnitMavenTest</artifactId>
       <packaging>war</packaging>
       <version>0.0.1-SNAPSHOT</version>
       <name>JSFUnitMavenTest Maven Webapp</name>
       <url>http://maven.apache.org</url>
       <dependencies>
      
      
       <dependency>
       <groupId>JSFUnitMavenGroup</groupId>
       <artifactId>JSFUnitMaven</artifactId>
       <version>${project.version}</version>
       <type>war</type>
       <scope>runtime</scope>
       </dependency>
      
       <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.2</version>
       <scope>test</scope>
       </dependency>
      
       <dependency>
       <groupId>jboss-jsfunit-core</groupId>
       <artifactId>jboss-jsfunit-core</artifactId>
       <version>1.0.0.Beta3</version>
       <scope>compile</scope>
       </dependency>
      
       <dependency>
       <groupId>javax.faces</groupId>
       <artifactId>jsf-api</artifactId>
       <scope>provided</scope>
       <version>1.2_02</version>
       </dependency>
      
       <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
       <version>2.4</version>
       <scope>provided</scope>
       </dependency>
      
       <dependency>
       <groupId>cactus</groupId>
       <artifactId>cactus</artifactId>
       <version>13-1.7.2</version>
       </dependency>
      
       <dependency>
       <groupId>aspectj</groupId>
       <artifactId>aspectjrt</artifactId>
       <version>1.5.4</version>
       </dependency>
       <dependency>
       <groupId>htmlunit</groupId>
       <artifactId>htmlunit</artifactId>
       <version>1.14</version>
       </dependency>
      
      
      
      
       </dependencies>
      
       <build>
       <finalName>JSFUnitMavenTest</finalName>
       <plugins>
       <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-compiler-plugin</artifactId>
       <configuration>
       <source>1.5</source>
       <target>1.5</target>
       </configuration>
       </plugin>
      
      
       <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-surefire-plugin</artifactId>
      
       <executions>
       <execution>
       <id>surefire-it</id>
       <phase>integration-test</phase>
       <goals>
       <goal>test</goal>
       </goals>
       <configuration>
       <skip>false</skip>
       <systemProperties>
       <property>
       <name>cactus.contextURL</name>
       <value>http://localhost:9083/JSFUnitMavenTest</value>
       </property>
       </systemProperties>
       </configuration>
       </execution>
       </executions>
       </plugin>
      
       <plugin>
       <groupId>org.codehaus.cargo</groupId>
       <artifactId>cargo-maven2-plugin</artifactId>
       <configuration>
       <wait>false</wait>
       <configuration>
       <deployables>
       <deployable>
       <location>${project.build.directory}/${artifactId}.war</location>
       <type>war</type>
       </deployable>
       </deployables>
       </configuration>
       </configuration>
       <executions>
       <execution>
       <id>start-container</id>
       <phase>pre-integration-test</phase>
       <goals>
       <goal>start</goal>
       </goals>
       </execution>
       <execution>
       <id>stop-container</id>
       <phase>post-integration-test</phase>
       <goals>
       <goal>stop</goal>
       </goals>
       </execution>
       </executions>
       </plugin>
       </plugins>
       </build>
       </project>


      When i execute 'mvn package' for the project JSFUnitMaven, it is running successfully but when i execute 'mvn package' for JSFUnitMavenTest it is giving exception.

      Below is the stack trace of the exception that i am getting:
      -------------------------------------------------------------------------------
      Test set: jsfunitmaventest.CommonJSFUnitTest
      -------------------------------------------------------------------------------
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.391 sec <<< FAILURE!
      testinputNamejsf(jsfunitmaventest.CommonJSFUnitTest) Time elapsed: 0.266 sec <<< ERROR!
      org.apache.cactus.util.ChainedRuntimeException: Failed to get the test results at [http://localhost:9083/JSFUnitMaven/ServletRedirector]
      at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody0(DefaultHttpClient.java:92)
      at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody1$advice(DefaultHttpClient.java:306)
      at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest(DefaultHttpClient.java)
      at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runWebTest(HttpProtocolHandler.java:159)
      at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody0(HttpProtocolHandler.java:80)
      at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody1$advice(HttpProtocolHandler.java:306)
      at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest(HttpProtocolHandler.java)
      at org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTestCaseCaller.java:144)
      at org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(AbstractCactusTestCase.java:215)
      at org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactusTestCase.java:133)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:120)
      at junit.framework.TestSuite.runTest(TestSuite.java:230)
      at junit.framework.TestSuite.run(TestSuite.java:225)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:618)
      at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
      at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:618)
      at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
      at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
      org.apache.cactus.internal.client.ParsingException: Not a valid response [404 Not Found]
      at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.callGetResult(DefaultHttpClient.java:211)
      at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody0(DefaultHttpClient.java:87)
      at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody1$advice(DefaultHttpClient.java:306)
      at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest(DefaultHttpClient.java)
      at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runWebTest(HttpProtocolHandler.java:159)
      at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody0(HttpProtocolHandler.java:80)
      at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody1$advice(HttpProtocolHandler.java:306)
      at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest(HttpProtocolHandler.java)
      at org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTestCaseCaller.java:144)
      at org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(AbstractCactusTestCase.java:215)
      at org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactusTestCase.java:133)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:120)
      at junit.framework.TestSuite.runTest(TestSuite.java:230)
      at junit.framework.TestSuite.run(TestSuite.java:225)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:618)
      at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
      at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:618)
      at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
      at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)

      Please help me in solving this problem.

      Regards,
      Mritunjay




        • 1. Re: Exception while running JSFUnitTest
          ssilvert

          That error means that Cactus was unable to connect with the server.
          http://jakarta.apache.org/cactus/faq.html#faq_failed_to_get_test_results

          It looks like you are using the default container for Cargo, which is Jetty with a port of 8080. So you need to change the port of the cactus.contextURL.

          Also, you need to look at your dependencies and versions. HtmlUnit should be version 2.3, but you shouldn't need to specify it because it will be brought in as a dependency of JSFUnit core. For the same reason, you shouldn't need to add Cactus or AspectJ as a dependency either.

          Stan

          • 2. Re: Exception while running JSFUnitTest

            I created one cactus.properties file and defined one property 'cactus.contextURL=http://localhost:9083/JSFUnitMavenTest'.
            Now the cactus.ContextURL is correct.
            If i define dependency like

            <dependency>
             <groupId>org.jboss.jsfunit</groupId>
             <artifactId>jboss-jsfunit-core</artifactId>
             <version>1.0.0.Beta3</version>
             <scope>compile</scope>
            </dependency>


            It was giving exception thats why i manually downloaded the file 'jboss-jsfunit-core-1.0.0.Beta3.jar' and kept it in location
            .m2\repository\jboss-jsfunit-core\jboss-jsfunit-core\1.0.0.Beta3.

            I tried to solve this issue but it is futile.
            Please suggest me to solve this issue.
            I am using websphere process server.
            If you want i can send you my whole projecty so we can look into the pom.xml and help me in solving the problem.

            Regards,
            Mritunjay

            • 3. Re: Exception while running JSFUnitTest
              ssilvert

              For WebSphere, you need this workaround. Have you done this?
              http://www.jboss.org/community/docs/DOC-10969

              Stan

              • 4. Re: Exception while running JSFUnitTest

                Yes i had done this.
                I created war for the JSFUnitMaven (having jsf which i want to test) and deployed it on server.
                For JSFUnitMavenTest(having jsfunit test cases), i am executing 'mvn clean install', at that time i am getting this exception.
                If you want i can send you whole PI(project interchange) for my project.

                Regards,
                Mritunjay

                • 5. Re: Exception while running JSFUnitTest
                  ssilvert

                  You shouldn't manually put things in the Maven repository. You put the jar in the wrong place. Let Maven do it and then post the error if you get one. Perhaps you didn't declare the JBoss Maven repository in your pom?

                  Feel free to send me your pom.xml file. I have no idea what a PI is.

                  Stan

                  • 6. Re: Exception while running JSFUnitTest
                    ssilvert

                    Also, when you post code or XML, highlight the code and push the Code button above. Otherwise, the XML doesn't show up in your post properly and I have to edit it for you.

                    Stan

                    • 7. Re: Exception while running JSFUnitTest

                      I sent the pom and projects to you mail id i.e. stan.silvert@jboss.com.

                      If in pom I define dependency like.

                      <dependency>
                       <groupId>org.jboss.jsfunit</groupId>
                       <artifactId>jboss-jsfunit-core</artifactId>
                       <version>1.0.0.Beta3</version>
                       <scope>compile</scope>
                      </dependency>


                      POM was not compiling, it was giving error saying ‘Missing artifact jboss-jsfunit-core:jar:1.0.0.Beta3.compile’.
                      That’s why i manually downloaded the file 'jboss-jsfunit-core-1.0.0.Beta3.jar' and kept it in location
                      .m2\repository\jboss-jsfunit-core\jboss-jsfunit-core\1.0.0.Beta3.

                      Regards,
                      Mritunjay




                      • 8. Re: Exception while running JSFUnitTest
                        ssilvert

                        I looked at your POM. Like I said in my previous post, you have to declare the JBoss Maven repository in your POM.

                         <repositories>
                         <repository>
                         <id>jboss</id>
                         <name>JBoss Repository</name>
                         <url>http://repository.jboss.org/maven2</url>
                         <snapshots>
                         <enabled>false</enabled>
                         </snapshots>
                         </repository>
                         </repositories>


                        Also, you have Cargo configured with the default container, which is Jetty. It will start Jetty listening on port 8080. So you need to either change your cactus.contextURL to use port 8080 or you need to configure Cargo to start WebSphere. If you continue to use Jetty then you should not use the WebSphere workaround I showed earlier.

                        Stan

                        • 9. Re: Exception while running JSFUnitTest

                          Stan,

                          I added the jboss repository, and run the 'mvn package' again. and still it is giving the same exception. I don't have idea about 'how to use cargo for web sphere application server'. I Visited the site http://cargo.codehaus.org and in the Contanier section, websphere is not mentioned.
                          Does cargo supports Websphere and if yes please tell me.

                          Stan, i have one another doubt. Cargo will deploy the war for the JSFUnitMavenTest project(having the test cases) . JSFs that i want to test is in 'JSFUnitMaven' project. How cargo will test the jsf that are not in the same project as jsfunit test project.

                          Regards,
                          Mritunjay

                          • 10. Re: Exception while running JSFUnitTest
                            ssilvert

                            You really need to learn more about Maven if you are going to use it. Please read the Maven documentation.

                            If WAR A depends on WAR B then all of WAR B's content will be included in WAR A by default. Read the documentation on the Maven WAR plugin.

                            Stan

                            • 11. Re: Exception while running JSFUnitTest
                              ssilvert

                              Also, Google "cargo websphere"