3 Replies Latest reply on Aug 28, 2008 11:16 AM by Stan Silvert

    Beta3 ant jsfunitwar task

    Tim Evers Master

      I'm not sure if the jsfunitwar task is responsible for this but..... I was hoping that it would take care of adding all required libraries to the war for running jsf unit tests.
      If I don't add the libraries to the war manually myself I get the following exception.

      java.lang.NoClassDefFoundError: org/apache/xerces/xni/XNIException
       at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:127)
       at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:101)
       at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:440)
       at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:338)
       at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:388)
       at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:375)
       at org.jboss.jsfunit.framework.SimpleInitialRequestStrategy.doInitialRequest(SimpleInitialRequestStrategy.java:47)
       at org.jboss.jsfunit.framework.WebClientSpec.doInitialRequest(WebClientSpec.java:232)
       at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:80)
       at gekko.web.jsfunit.pages.AbstractGekkoWebTest.afterSetUp(AbstractGekkoWebTest.java:49)
       at gekko.web.jsfunit.pages.AbstractGekkoWebTest.setUp(AbstractGekkoWebTest.java:39)
       at junit.framework.TestCase.runBare(TestCase.java:132)
       at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
       at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
       at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
       at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)
       at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
       at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
       at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:217)
       at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
       at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doPost(JSFUnitServletRedirector.java:42)
       at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
       at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:217)
       at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
       at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doGet(JSFUnitServletRedirector.java:48)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:122)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:42)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:302)
       at org.ajax4jsf.Filter.doFilter(Filter.java:175)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
       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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
       at org.ajax4jsf.Filter.doFilter(Filter.java:175)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)
      


      Am I doing/referencing something wrong?

        • 1. Re: Beta3 ant jsfunitwar task
          Stan Silvert Master

          No, you didn't do anything wrong. Right now it doesn't add xerces because some containers already include xerces in the classpath. Sometimes there are problems with adding xerces to the WAR when it is already present. So, you will need to add it like in my test:

          <!-- Xerces is required for Tomcat, but not Jetty -->
          <property name="xercesImpl.jar" location="${jsfunit.lib.dir}/xercesImpl-2.6.2.jar" />
          
          <!-- Xalan needed by htmlunit, but often included in app server -->
          <property name="xalan.jar" location="${jsfunit.lib.dir}/xalan-2.7.0.jar" />
          
          <jsfunitwar srcfile="${src.war}" destfile="${dest.war}" autoaddjars="true">
           <TestRunner />
           <classes dir="${classes.test}" includes="**/*.class" />
           <lib file="${xercesImpl.jar}" />
           <lib file="${xalan.jar}" />
          </jsfunitwar>


          That made me think of a nice feature. Maybe if we allow you to specify the target container we can decide which jars should be added automatically.

          https://jira.jboss.org/jira/browse/JSFUNIT-161

          Stan

          • 2. Re: Beta3 ant jsfunitwar task
            Thomas Peeters Newbie

            Hey,

            Something might be off with automatic library adding on my end. I can't seem to get my initial test off the ground.
            After getting an error exception during the startup of the test I started to add libraries manually by looking them up on the htmlunit page. And so different errors start to come up every time I added another one in my project pom. Right now I'm getting one I can't seem to resolve so easily.

            call
            
            java.lang.NoSuchMethodError: call
            at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.initialize(JavaScriptEngine.java:167)
            at com.gargoylesoftware.htmlunit.WebClient.initialize(WebClient.java:1084)
            at com.gargoylesoftware.htmlunit.WebWindowImpl.setEnclosedPage(WebWindowImpl.java:115)
            at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:238)
            at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:116)
            at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:89)
            at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:450)
            at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:359)
            at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:407)
            at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:395)
            at org.jboss.jsfunit.framework.SimpleInitialRequestStrategy.doInitialRequest(SimpleInitialRequestStrategy.java:47)
            at org.jboss.jsfunit.framework.WebClientSpec.doInitialRequest(WebClientSpec.java:232)
            at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:80)
            at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:59)
            at be.vlafo.feniks.web.JSFUnitTest.testInitialPageWithLoginAndDefaultDBInfo(JSFUnitTest.java:65)
            at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
            at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
            at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
            at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
            at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)
            at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(Lorg.apache.cactus.spi.server.ImplicitObjects;)V(AbstractWebTestController.java:???)
            at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
            at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)
            at org.apache.cactus.server.ServletTestRedirector.doPost(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(ServletTestRedirector.java:???)
            at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doPost(JSFUnitServletRedirector.java:42)
            at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
            


            This is the simplified test I'm trying to run. I omitted all the other tests. First this one :)
            There might be more problems with this code but the error gets thrown from line 65, which is the declaration of JSFSession object, here on the 4th line.

            public void testInitialPageWithLoginAndDefaultDBInfo() throws IOException,SAXException,TechnicalException {
             JSFClientSession client;
            // JSFSession jsfSession = new JSFSession("/a001/facelets/a001LogIn.jsf");
             JSFSession jsfSession = new JSFSession("/a001/facelets/a001LogIn.jsf");
             client = jsfSession.getJSFClientSession();
             // A JSFServerSession gives you access to JSF state
             JSFServerSession server = jsfSession.getJSFServerSession();
            
             // Test navigation to initial viewID
             assertEquals("/a001/facelets/a001LogIn.xhtml", server.getCurrentViewID());
            
             // Assert that the prompt component is in the component tree and rendered
             UIComponent prompt = server.findComponent("_id18:Rijksregisternummer");
             assertTrue(prompt.isRendered());
             client.setValue("_id18:Rijksregisternummer","53032827321");
             client.setValue("_id18:pincode","123");
             client.click("_id18:_id23");
            
             //testing required fields
             assertEquals("/a001/facelets/a001JSF.xhtml",server.getCurrentViewID());
             assertEquals("TERRIERE", server.getManagedBeanValue("#{A001Bean.naam}"));
             assertEquals("DIRK", server.getManagedBeanValue("#{A001Bean.voorNaam}"));
             assertEquals("Man", server.getManagedBeanValue("#{A001Bean.geslacht}"));
             assertEquals("Gehuwd", server.getManagedBeanValue("#{A001Bean.burgStaat}"));
             }


            • 3. Re: Beta3 ant jsfunitwar task
              Stan Silvert Master

              Fhomasp,

              Please start a new thread for new questions.

              I've moved your question here:
              http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4173106#4173106