I've been using HttpUnit for some time now--well, mostly ServletUnit--with IntelliJ IDEA. I never bothered to link
in js.jar, because I was using no JavaScript, and everything was fine for my purposes.
Now I wanted to use JavaScript testing, so I added js.jar to the Classpath...and quickly discovered that I needed
more than that. I added nekohtml.jar, xmlParserAPIs.jar, and xercesImpl.jar, and it still doesn't work. In desperation,
I added the rest of the jars shipped with HttpUnit(junit.jar, even though it shouldn't be necessary, tidy.jar and servlet.jar),
and it fails just the same.
The error I'm getting is:
java.lang.reflect.InvocationTargetException
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:41)
at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:244)
at com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1014)
at com.meterware.httpunit.WebResponse$Scriptable.load(WebResponse.java:611)
at com.meterware.httpunit.javascript.JavaScript$Window.initialize(JavaScript.java:424)
at com.meterware.httpunit.javascript.JavaScript.run(JavaScript.java:80)
at com.meterware.httpunit.javascript.JavaScriptEngineFactory.associate(JavaScriptEngineFactory.java:46)
at com.meterware.httpunit.FrameHolder.<init>(FrameHolder.java:44)
at com.meterware.httpunit.WebWindow.<init>(WebWindow.java:218)
at com.meterware.httpunit.WebClient.<init>(WebClient.java:50)
at com.meterware.servletunit.ServletUnitClient.<init>(ServletUnitClient.java:111)
at com.meterware.servletunit.ServletUnitClient.newClient(ServletUnitClient.java:51)
at com.meterware.servletunit.ServletRunner.newClient(ServletRunner.java:156)
at com.kakari.soccer.test.SoccerWebTest.checkFailedLogin(SoccerWebTest.java:46) <---\
at com.kakari.soccer.test.SoccerWebTest.testFailedLogin1(SoccerWebTest.java:38) <---+my test methods
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:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.swingui.TestRunner$16.run(TestRunner.java:623)
I also tried using Xerces 2.6.0, freshly downloaded from their site, instead of that shipped with httpUnit, but it didn't work
either.
I should note that I have not changed any of the tests; they work fine if I remove all the extra jars I added.
The test I'm using(merely the simplest--the rest all fail too) boils down to:
public class SoccerWebTest extends TestCase {
ServletRunner srTest;
public static Test suite() {
return new TestSuite(SoccerWebTest.class);
}
Okay, I fixed the problem, by updating nekohtml.jar to the latest version with Xerces 2.6.0. Now most of my tests run just fine, and any that don't are because they already had JavaScript on them.
So, in sum, the versions of Neko and Xerces currently shipping with httpunit 1.5.4 don't work with IntelliJ Idea 3.0.5.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've been using HttpUnit for some time now--well, mostly ServletUnit--with IntelliJ IDEA. I never bothered to link
in js.jar, because I was using no JavaScript, and everything was fine for my purposes.
Now I wanted to use JavaScript testing, so I added js.jar to the Classpath...and quickly discovered that I needed
more than that. I added nekohtml.jar, xmlParserAPIs.jar, and xercesImpl.jar, and it still doesn't work. In desperation,
I added the rest of the jars shipped with HttpUnit(junit.jar, even though it shouldn't be necessary, tidy.jar and servlet.jar),
and it fails just the same.
The error I'm getting is:
java.lang.reflect.InvocationTargetException
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:41)
at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:244)
at com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1014)
at com.meterware.httpunit.WebResponse$Scriptable.load(WebResponse.java:611)
at com.meterware.httpunit.javascript.JavaScript$Window.initialize(JavaScript.java:424)
at com.meterware.httpunit.javascript.JavaScript.run(JavaScript.java:80)
at com.meterware.httpunit.javascript.JavaScriptEngineFactory.associate(JavaScriptEngineFactory.java:46)
at com.meterware.httpunit.FrameHolder.<init>(FrameHolder.java:44)
at com.meterware.httpunit.WebWindow.<init>(WebWindow.java:218)
at com.meterware.httpunit.WebClient.<init>(WebClient.java:50)
at com.meterware.servletunit.ServletUnitClient.<init>(ServletUnitClient.java:111)
at com.meterware.servletunit.ServletUnitClient.newClient(ServletUnitClient.java:51)
at com.meterware.servletunit.ServletRunner.newClient(ServletRunner.java:156)
at com.kakari.soccer.test.SoccerWebTest.checkFailedLogin(SoccerWebTest.java:46) <---\
at com.kakari.soccer.test.SoccerWebTest.testFailedLogin1(SoccerWebTest.java:38) <---+my test methods
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:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.swingui.TestRunner$16.run(TestRunner.java:623)
I also tried using Xerces 2.6.0, freshly downloaded from their site, instead of that shipped with httpUnit, but it didn't work
either.
I should note that I have not changed any of the tests; they work fine if I remove all the extra jars I added.
The test I'm using(merely the simplest--the rest all fail too) boils down to:
public class SoccerWebTest extends TestCase {
ServletRunner srTest;
public static Test suite() {
return new TestSuite(SoccerWebTest.class);
}
protected void setUp() throws Exception {
srTest = new ServletRunner();
}
public void testFailedLogin1() {
srTest.registerServlet("ShowGames",ShowGames.class.getName());
checkFailedLogin("ShowGames");
}
private void checkFailedLogin(String strServletName) {
ServletUnitClient sucTest;
WebRequest wrqTest;
String strFileName;
sucTest = srTest.newClient();
wrqTest = new PostMethodWebRequest("http://localhost/" + strServletName);
// ....
}
// ....
}
I did a web search on the error I was getting, but did not find anything helpful.
What am I missing?
--Aaron V. Humphrey
Kakari Systems Ltd.
Okay, I fixed the problem, by updating nekohtml.jar to the latest version with Xerces 2.6.0. Now most of my tests run just fine, and any that don't are because they already had JavaScript on them.
So, in sum, the versions of Neko and Xerces currently shipping with httpunit 1.5.4 don't work with IntelliJ Idea 3.0.5.