Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 6.0.0beta14
-
Fix Version/s: None
-
Component/s: Maven
-
Labels:None
-
Environment:Maven 2
WinXP
JDK 1.4.2
-
Number of attachments :1
Description
My project is composed of different maven modules.
The module "test-commons" contains JUnit test cases and Html files.
The module "htmlunit-plugin" uses the first module to run its tests and uses embedded Jetty.
When I run "mvn test" in the parent directory, it works. But when I run "mvn test" in the htmlunit-plugin module directory, or when I run "mvn site" (that launch tests), it fails :
[surefire] Running net.sourceforge.jwebunit.htmlunit.JWebUnitTest
:INFO: Logging to STDERR via org.mortbay.log.StdErrLog
:INFO: Extract jar:file:/C:/Documents and Settings/jhenry/.m2/repository/net/sourceforge/jwebunit/commons-tests/1.3-SNAPSHOT/commons-tests-1.3-SNAPSHOT.jar!/testcases to C:\DOCUME~1\jhenry\LOCALS~1\Temp\Jetty__jwebunit\webapp
:WARN: failed ContextHandler@430b6
:INFO: Started SocketConnector @ 0.0.0.0:8082
:WARN: failed Server@18f7386
java.lang.NullPointerException: in is null
at java.util.zip.ZipInputStream.<init>(ZipInputStream.java:55)
at java.util.jar.JarInputStream.<init>(JarInputStream.java:57)
at java.util.jar.JarInputStream.<init>(JarInputStream.java:43)
at org.mortbay.resource.JarResource.extract(JarResource.java:108)
at org.mortbay.jetty.webapp.WebAppContext.resolveWebApp(WebAppContext.java:722)
at org.mortbay.jetty.webapp.WebAppContext.getWebInf(WebAppContext.java:611)
at org.mortbay.jetty.webapp.WebInfConfiguration.configureClassLoader(WebInfConfiguration.java:62)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:364)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:37)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:133)
at org.mortbay.jetty.Server.doStart(Server.java:256)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:37)
...
I don't know if this bug is due to Jetty or Maven, but I hope you can solve it.
Here is how I run Jetty :
jettyServer = new Server();
SocketConnector connector = new SocketConnector();
connector.setPort(JWebUnitAPITestCase.JETTY_PORT);
jettyServer.setConnectors (new Connector[]
);
WebAppContext wah = new WebAppContext();
wah.setServer(jettyServer);
wah.setContextPath(JWebUnitAPITestCase.JETTY_URL);
URL url = this.getClass().getResource("/testcases");
wah.setWar(url.toString());
jettyServer.addHandler(wah);
jettyServer.start();
-
Hide
- commons-tests-1.3-SNAPSHOT.jar
- 02/May/06 6:42 AM
- 53 kB
- Julien HENRY
-
- META-INF/MANIFEST.MF 0.8 kB
- log4j.properties 0.6 kB
- net/.../ExpectedTableAssertionsTest.class 3 kB
- net/sourceforge/.../ExpectedTableTest.class 2 kB
- net/sourceforge/.../FormAssertionsTest.class 7 kB
- net/.../FormSubmissionCheckboxesTest.class 3 kB
- net/sourceforge/.../FormSubmissionTest.class 6 kB
- net/.../FramesAndWindowsTest.class 4 kB
- net/sourceforge/.../HelloWorldTest.class 2 kB
- net/sourceforge/.../HtmlParsingTest.class 2 kB
- net/.../JavaScriptEventsTest.class 4 kB
- net/.../JWebUnitAPITestCase.class 4 kB
- net/sourceforge/.../NavigationTest.class 4 kB
- net/.../TableAssertionsTest.class 8 kB
- net/sourceforge/.../TestContextTest.class 2 kB
- net/sourceforge/.../RajeshNairTest.class 2 kB
- net/sourceforge/.../util/HtmlHelper.class 1 kB
- net/sourceforge/.../util/JettySetup.class 3 kB
- net/sourceforge/.../util/ParamsServlet.class 2 kB
- net/sourceforge/.../WebAssertionsTest.class 7 kB
- net/sourceforge/.../WebCookieTest.class 2 kB
- testcases/.../ExpectedTableAssertionsTestPage.html 0.3 kB
- testcases/.../assertButtonWithText.html 0.2 kB
- testcases/.../noFormPage.html 0.1 kB
- testcases/.../testPage.html 1 kB
- testcases/.../CheckboxForm.html 0.4 kB
- testcases/.../CheckboxFormWithLabels.html 0.8 kB
- testcases/.../InvalidActionForm.html 0.2 kB
- testcases/.../MultiFormPage.html 1 kB
- testcases/.../MultiNamedButtonForm.html 0.3 kB
Activity
Yes, testcases is a directory structure of a webapp, and contains a WEB-INF/web.xml file.
commons-tests-1.3.SNAPSHOT.jar contains :
- META-INF
- net/sourceforge/jwebunit/tests/...
- testcases
I join the jar.
Julien,
the problem is that your URL must end in a "/" to denote a directory, so it should be:
URL url = this.getClass().getResource("/testcases")+"/";
Thanks for your tips, it changes some things, but not all :
I have now :
URL url = this.getClass().getResource("/testcases/"); //url = jar:file:/C:/Documents%20and%20Settings/jhenry/.m2/repository/net/sourceforge/jwebunit/commons-tests/1.3-SNAPSHOT/commons-tests-1.3-SNAPSHOT.jar!/testcases/
wah.setWar(url.toString());
jettyServer.addHandler(wah);
And Jetty is running fine. But the web app is empty, so I get 404 error for each test.
Here is what I see on http://localhost:8082/ :
Contexts known to this server are:
- /jwebunit ---> ContextHandler@3dc0bb {/jwebunit,file:/C:/Documents%20and%20Settings/jhenry/Local%20Settings/Temp/Jetty__jwebunit/webapp/}
But C:/Documents%20and%20Settings/jhenry/Local%20Settings/Temp/Jetty__jwebunit/webapp is empty.
I think the temporary extraction of the Jar failed, but I don't know why...
Julien.
I've checked in a fix for extracting partial contents of a jar:file url. Try doing a build from Jetty svn trunk.
Julien, what is the structure of the commons-tests-1.3.SNAPSHOT.jar file? Is the directory "testcases" a directory structure of a webapp? Can you post the jar file?