AJaX problems
exosys Oct 25, 2010 12:52 PMDear friends, I ask for your help, please!
I am trying to run a JSFUnit test which works perfectly, but not for AJAX events. In other words, when I click any "h:commandButton" everything goes well, but when I click one "a4j:commandButton" it just stops working. I have noticed that the execution gets locked at the com.gargoylesoftware.htmlunit.javascript.JavascriptEngine class. More precisely, inside of its internal class (HtmlUnitContextAction), at the "public final Object run(final Context cx)" method. Even more precisely, it gets locked at the first line of the following code:
synchronized (htmlPage_) { // 2 scripts can't be executed in parallel for one page final Object response = doRun(cx); doProcessPostponedActions(); return response; }
After that, I created a lower level version, I mean, I used HTMLUnit instead of JSFUnit. I changed from one single JSFUnit click to the following:
HtmlInput btnProc = (HtmlInput) page3.getElementById("button_ID"); final HtmlPage page4 = btnProc.click(); System.out.print(page4.asXml()); page4.refresh();
In the third statement, the following page is printed:
<?xml version="1.0" encoding="ISO-8859-1"?> <html xmlns="http://www.w3.org/1999/xhtml"/>
This is not the output expected. At this point it is clear that something wenty wrong. Finally, in the fourth line of the HTMLUnit code (page4.refresh), my test gets locked exactly like I described above, with JSFUnit. So, I think the locking itself is just a consequence of the "empty" page printed. No exception occurs at any time.
These errors occur with my tests only. If I run the same sequence of clicks with my browser, I have no problems.
My library is composed by the following jar files:
ant-1.5.4.jar apache-mime4j-0.6.jar aspectjrt-1.2.1.jar cactus-13-1.7.1.jar cactus-ant-13-1.7.1.jar cargo-0.5.jar commons-codec-1.4.jar commons-collections-3.2.1.jar commons-fileupload-1.2.1.jar commons-httpclient-2.0.2.jar commons-io-1.4.jar commons-lang-2.4.jar commons-logging-1.1.1.jar cssparser-0.9.5.jar htmlunit-2.8.jar htmlunit-core-js-2.8.jar httpclient-4.0.2.jar httpcore-4.0.1.jar httpmime-4.0.1.jar jboss-jsfunit-core-1.3.0.Final.jar jboss-jsfunit-richfaces-1.3.0.Final.jar jsf-api.jar jsf-facelets.jar jsf-ibm.jar jsf-impl.jar junit-3.8.1.jar nekohtml-1.9.14.jar richfaces-api-3.3.3.Final.jar richfaces-impl-3.3.3.Final.jar richfaces-ui-3.3.3.Final.jar sac-1.3.jar tomahawk-1.1.8.jar
One important information is that my JSFUnit tests worked very well before, when I had the following set of libraries:
ant-1.5.4.jar apache-mime4j-0.6.jar aspectjrt-1.2.1.jar cactus-13-1.7.1.jar cactus-ant-13-1.7.1.jar cargo-0.5.jar commons-codec-1.4.jar commons-collections-3.2.1.jar commons-fileupload-1.2.1.jar commons-httpclient-3.1.jar commons-io-1.4.jar commons-lang-2.4.jar commons-logging-1.1.1.jar cssparser-0.9.5.jar el-api-1.0.jar el-impl-1.0.jar groovy-all-1.5.5.jar htmlunit-2.7.jar htmlunit-core-js-2.7.jar httpclient-4.0.1.jar httpcore-4.0.1.jar httpmime-4.0.1.jar iText-2.1.7.jar jasperreports-3.7.2.jar jboss-jsfunit-core-1.2.0.Final.jar jsf-api.jar jsf-facelets.jar jsf-ibm.jar jsf-impl.jar junit-3.8.1.jar log4j-1.2.7.jar nekohtml-1.9.14.jar richfaces-api-3.1.4.GA.jar richfaces-impl-3.1.4.GA.jar richfaces-ui-3.1.4.GA.jar sac-1.3.jar serializer-2.7.1.jar tomahawk-1.1.8.jar
If you think some other relevant information should be provided, please ask me for and I will post that as soon as possible.
Thanks in advance for your kind support,
Euler Xavier de Oliveira.