In-process Web Integration Tests with Jetty and JWebUnit
Do you speak test? In that case: Hello web application:
public class WebIntegrationTest extends net.sourceforge.jwebunit.WebTestCase {
public void testIndex() {
beginAt("/index.html");
assertTextPresent("Hello world");
}
private org.mortbay.jetty.Server server;
protected void setUp() throws Exception {
server = new org.mortbay.jetty.Server(0);
server.addHandler(
new org.mortbay.jetty.webapp.WebAppContext("src/main/webapp", "/my-context"));
server.start();
int actualPort = server.getConnectors()[0].getLocalPort();
getTestContext().setBaseUrl("http://localhost:" + actualPort + "/my-context");
}
}
This code runs with no application server, no separate deployment step, just like that.
If this looks interesting, see my full-sized article on java.net
This work is licensed under a
Creative Commons Attribution 3.0 License.
Print This Post
Add New Comment
Viewing 2 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Ok, so I know this is a bit childish :) but I guess you've been using some other IDE of which doesn't provide proper XSD validation(?).
Anyhow, the following fragment (slightly revised) is valid:
<servlet-mapping>
<servlet-name>my</servlet-name>
<url-pattern>/my/*</url-pattern>
</servlet-mapping>
Do you already have an account? Log in and claim this comment.
Add New Comment