8 Replies Latest reply on Jun 18, 2008 10:34 PM by Stan Silvert

    New JSFUnit AJAX support

    Stan Silvert Master

      I'd like to draw your attention to this thread:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=136280

      We are in the in the process of moving from HttpUnit to HtmlUnit, which has much better javascript and AJAX support. We need feedback on the new JSFClientSession API that goes along with this. If you have time to try it out, please give us your feedback. I think you'll agree that HtmlUnit provides much more power to test the client side. It will also allow us to support more JSF component libraries such as RichFaces, Trinidad, Tomahawk, and more.

      Stan

        • 1. Re: New JSFUnit AJAX support
          Stan Silvert Master

          Latest news:

          * I just did a major refactoring of the HtmlUnit-based code, including new authentication support. See http://jira.jboss.com/jira/browse/JSFUNIT-99

          * JSFUNIT-99 also includes the ability to define your own InitialRequestStrategy for complex authentication.

          * RichFaces support now seems to be working as long as you use BrowserVersion.FIREFOX_2. This is now the default instead of IE6.

          * To use RichFaces, you will need to build JSFUnit and HtmlUnit yourself and then change the HtmlUnit version in the main JSFUnit pom. You will just uncomment <!-- 2.2-SNAPSHOT -->.

          * I'm going to try to get a snapshot of both JSFUnit and HtmlUnit into the JBoss snapshot repo to make it easier to try this stuff out.

          Stan

          • 2. Re: New JSFUnit AJAX support
            Tim Evers Master

            When trying to build Htmlunit I'm getting the following errors when it runs the tests. I'm going to see if i can disable the tests but...I'm running out of time :P

            Running com.gargoylesoftware.htmlunit.libraries.Dojo102Test
            ERROR 09:24:55,686 JavaScriptBackgroundJob: Caught exception in Window.setTimeout()
            ======= EXCEPTION START ========
            Exception class=[org.mozilla.javascript.JavaScriptException]
            com.gargoylesoftware.htmlunit.ScriptException: [object Object] (http://localhost:12345/dojo/dojo.js#20(eval)#571)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:534)
             at org.mozilla.javascript.Context.call(Context.java:502)
             at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:445)
             at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:912)
             at com.gargoylesoftware.htmlunit.JavaScriptBackgroundJob.run(JavaScriptBackgroundJob.java:96)
             at java.lang.Thread.run(Thread.java:619)
             at com.gargoylesoftware.htmlunit.ThreadManager$1.run(ThreadManager.java:107)
            Caused by: org.mozilla.javascript.JavaScriptException: [object Object] (http://localhost:12345/dojo/dojo.js#20(eval)#571)
             at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2687)
             at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484)
             at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
             at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
             at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:169)
             at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3004)
             at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:473)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:438)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:530)
             ... 7 more
            JavaScriptException value = [object Object]
            == CALLING JAVASCRIPT ==
            
             function () {
             return _9e[_9f].apply(_9e, arguments || []);
             }
            
            ======= EXCEPTION END ========
            


            Running com.gargoylesoftware.htmlunit.libraries.YuiTest
            ERROR 09:25:42,523 JavaScriptBackgroundJob: Caught exception in Window.setTimeout()
            ======= EXCEPTION START ========
            Exception class=[org.mozilla.javascript.JavaScriptException]
            com.gargoylesoftware.htmlunit.ScriptException: ComparisonFailure: incorrect "to" end value set
            Expected: 10 (number)
            Actual:100 (number) (file:/D:/svn/workspace/htmlunit/target/test-classes/yui/2.3.0/build/yuitest/yuitest-beta.js#732)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:534)
             at org.mozilla.javascript.Context.call(Context.java:502)
             at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:445)
             at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:912)
             at com.gargoylesoftware.htmlunit.JavaScriptBackgroundJob.run(JavaScriptBackgroundJob.java:96)
             at java.lang.Thread.run(Thread.java:619)
             at com.gargoylesoftware.htmlunit.ThreadManager$1.run(ThreadManager.java:107)
            Caused by: org.mozilla.javascript.JavaScriptException: [object Object] (file:/D:/svn/workspace/htmlunit/target/test-classes/yui/2.3.0/build/yuitest/yuitest-beta.js#732)
             at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2687)
             at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484)
             at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
             at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
             at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:169)
             at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3004)
             at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:473)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:438)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:530)
             ... 7 more
            JavaScriptException value = [object Object]
            == CALLING JAVASCRIPT ==
            
             function () {
             for (var i = 0, len = queue.length; i < len; ++i) {
             var tween = queue;
             if (!tween || !tween.isAnimated()) {
             continue;
             }
             if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null) {
             tween.currentFrame += 1;
             if (tween.useSeconds) {
             correctFrame(tween);
             }
             tween._onTween.fire();
             } else {
             YAHOO.util.AnimMgr.stop(tween, i);
             }
             }
             }
            
             ======= EXCEPTION END ========
            


            ERROR 09:25:54,001 HtmlPage: Error loading JavaScript from [http://yui.yahooapis.com/2.3.0/build/dragdrop/dragdrop-min.js].
            java.net.ConnectException: Connection refused: connect
             at java.net.PlainSocketImpl.socketConnect(Native Method)
             at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
             at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
             at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
             at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
             at java.net.Socket.connect(Socket.java:518)
             at java.net.Socket.connect(Socket.java:468)
             at java.net.Socket.<init>(Socket.java:365)
             at java.net.Socket.<init>(Socket.java:239)
             at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
             at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
             at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
             at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.ja
             at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
             at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
             at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
             at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
             at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:98)
             at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1524)
             at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1481)
             at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1002)
             at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:953)
             at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:305)
             at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:205)
             at com.gargoylesoftware.htmlunit.html.DomNode.appendChild(DomNode.java:857)
             at com.gargoylesoftware.htmlunit.javascript.host.Node.jsxFunction_appendChild(Node.java:156)
             at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
             at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:478)
             at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3335)
             at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484)
             at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
             at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
             at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:169)
             at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3004)
             at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:473)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:438)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:530)
             at org.mozilla.javascript.Context.call(Context.java:502)
             at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
             at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:445)
             at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:912)
             at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventListeners(EventListenersContainer.java:126)
             at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:163)
             at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:561)
             at com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:1231)
             at org.mozilla.javascript.Context.call(Context.java:502)
             at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
             at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:1235)
             at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1148)
             at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:164)
             at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:439)
             at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:337)
             at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:387)
             at com.gargoylesoftware.htmlunit.libraries.YuiTest.doTest(YuiTest.java:242)
             at com.gargoylesoftware.htmlunit.libraries.YuiTest.doTest(YuiTest.java:229)
             at com.gargoylesoftware.htmlunit.libraries.YuiTest.doTest(YuiTest.java:221)
             at com.gargoylesoftware.htmlunit.libraries.YuiTest.yuiLoader(YuiTest.java:189)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
             at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
             at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
             at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
             at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
             at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
             at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
             at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
             at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
             at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
             at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
             at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
             at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
             at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
             at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
             at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
             at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
            


            I'm assuming that some of my problems are because I'm behind a proxy.... I don't know. But I would really like to get this working ASAP :)

            Thanks again,
            Tim

            • 3. Re: New JSFUnit AJAX support
              Stan Silvert Master

              When I build HtmlUnit, I do disable the tests:

              mvn install -DskipTests

              Stan

              • 4. Re: New JSFUnit AJAX support
                Tim Evers Master

                Thanks Stan, I'll give that a go. :)

                • 5. Re: New JSFUnit AJAX support
                  Tim Evers Master

                   

                  mvn install -DskipTests


                  This still runs the tests :( and I can't seem to figure out how to turn them off. I don't use maven so I have no idea what I'm doing :P

                  Sorry. But if you could just confirm that that is the correct command that would be great!

                  • 6. Re: New JSFUnit AJAX support
                    Stan Silvert Master

                    That's how you do it. It doesn't run the tests for me.

                    Here's the Maven doco for skipping tests. There's another way to do it that you could try:
                    http://maven.apache.org/plugins/maven-surefire-plugin/examples/skipping-test.html

                    Stan

                    • 7. Re: New JSFUnit AJAX support
                      Tim Evers Master

                      Thanks again Stan,

                      It seems I need to use the

                      mvn install -Dmaven.test.skip=true

                      command line for it to skip tests for me. Strange :)

                      I've now got all my tests running on the latest version of JSFUnit! :)
                      There are a few things I've had to do to get that working:
                      -Use Firefox mode (IE6 causes a CCE - see forum thread on this)
                      -And put a try catch around any usages of client.setChecked - another forum thread for this one too.
                      -Use your work around for clicking on PanelMenuItems

                      Other then that I have been able to check in finally! :D

                      All my menus are working even my drop downs! (This was not working in the old JsfUnit)

                      Excelent work!

                      • 8. Re: New JSFUnit AJAX support
                        Stan Silvert Master

                        That's great to hear. Thanks for all the feedback. I'll be working to smooth out the rough edges.

                        Stan