416674 run all jetty-ant tests on random ports

This commit is contained in:
Thomas Becker 2013-09-16 18:04:52 +02:00
parent bc69700a5a
commit 6594ee87fa
2 changed files with 14 additions and 14 deletions

View File

@ -21,12 +21,12 @@ package org.eclipse.jetty.ant;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URI; import java.net.URI;
import junit.framework.Assert;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
public class JettyAntTaskTest public class JettyAntTaskTest
{ {
@ -42,9 +42,9 @@ public class JettyAntTaskTest
HttpURLConnection connection = (HttpURLConnection)uri.toURL().openConnection(); HttpURLConnection connection = (HttpURLConnection)uri.toURL().openConnection();
connection.connect(); connection.connect();
Assert.assertEquals(404,connection.getResponseCode()); assertThat("response code is 404", connection.getResponseCode(), is(404));
build.stop(); build.stop();
} }
@ -53,17 +53,17 @@ public class JettyAntTaskTest
public void testWebApp () throws Exception public void testWebApp () throws Exception
{ {
AntBuild build = new AntBuild(MavenTestingUtils.getTestResourceFile("webapp-test.xml").getAbsolutePath()); AntBuild build = new AntBuild(MavenTestingUtils.getTestResourceFile("webapp-test.xml").getAbsolutePath());
build.start(); build.start();
URI uri = new URI("http://" + build.getJettyHost() + ":" + build.getJettyPort() + "/"); URI uri = new URI("http://" + build.getJettyHost() + ":" + build.getJettyPort() + "/");
HttpURLConnection connection = (HttpURLConnection)uri.toURL().openConnection(); HttpURLConnection connection = (HttpURLConnection)uri.toURL().openConnection();
connection.connect(); connection.connect();
Assert.assertEquals(200,connection.getResponseCode()); assertThat("response code is 200", connection.getResponseCode(), is(200));
System.err.println("Stop build!"); System.err.println("Stop build!");
build.stop(); build.stop();
} }

View File

@ -10,7 +10,7 @@
classpathref="jetty.plugin.classpath" loaderref="jetty.loader" /> classpathref="jetty.plugin.classpath" loaderref="jetty.loader" />
<target name="jetty.run"> <target name="jetty.run">
<jetty.run daemon="true" scanIntervalSeconds="10"> <jetty.run daemon="true" scanIntervalSeconds="10" jettyPort="0">
<webapp war="${basedir}/src/test/resources/foo" contextpath="/" /> <webapp war="${basedir}/src/test/resources/foo" contextpath="/" />
</jetty.run> </jetty.run>
</target> </target>