Reputation: 91
I'm writing integration tests for a web app using the maven-jetty-plugin. I'm using the deploy-war goal inside the pre-integration-test phase. The web app depends on another web application I would like to mock by serving static content from the same jetty instance.
here's the relevant part of my jetty config:
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy-war</goal>
</goals>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>${jetty.port}</port>
</connector>
</connectors>
<daemon>true</daemon>
<webApp>${build.directory}/motown2-war.war</webApp>
<webAppConfig>
<extraClasspath>${basedir}/target/classes/;${basedir}/target/test-classes</extraClasspath>
<contextPath>/${context.path}</contextPath>
</webAppConfig>
<contextHandlers>
<contextHandler implementation="org.mortbay.jetty.webapp.WebAppContext">
<contextPath>/other</contextPath>
<resourceBase>/opt/data</resourceBase>
</contextHandler>
</contextHandlers>
</configuration>
</execution>
I've based this config on http://blog.markfeeney.com/2009/12/scala-lift-jetty-6-static-content-and.html, but the configurations for the context handler seems to be ignored. I can't find a trace of this in the log files, jetty returns 404 instead of static content, the web app itself is running.
What am I missing?
Upvotes: 4
Views: 2179
Reputation: 91
I figured it out:
the resourceHandlers configuration only works for the jetty:run goal, so I'm now working with an empty webapp in my test project, which overlays the webapp to be tested:
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>${jetty.port}</port>
</connector>
</connectors>
<daemon>true</daemon>
<webApp>${build.directory}/motown2-war.war</webApp>
<webAppConfig>
<extraClasspath>${basedir}/target/classes/;${basedir}/target/test-classes</extraClasspath>
<contextPath>/${context.path}</contextPath>
<baseResource implementation="org.mortbay.resource.ResourceCollection">
<resourcesAsCSV>../motown2-war/src/main/webapp,src/main/webapp</resourcesAsCSV>
</baseResource>
</webAppConfig>
<contextHandlers>
<contextHandler implementation="org.mortbay.jetty.webapp.WebAppContext">
<contextPath>/other</contextPath>
<resourceBase>/opt/data</resourceBase>
</contextHandler>
</contextHandlers>
</configuration>
</execution>
Upvotes: 2