mirror of https://github.com/apache/activemq.git
Remove dependency on fixed port for these tests.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1423946 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5a0fd5d086
commit
3d6222d188
|
@ -30,12 +30,12 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public abstract class HttpTestSupport extends TestCase {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HttpTestSupport.class);
|
||||
|
@ -52,11 +52,12 @@ public abstract class HttpTestSupport extends TestCase {
|
|||
|
||||
final File homeDir = new File("src/main/webapp/uploads/");
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
server = new Server();
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
connector.setPort(8080);
|
||||
connector.setPort(0);
|
||||
connector.setServer(server);
|
||||
WebAppContext context = new WebAppContext();
|
||||
|
||||
|
@ -68,7 +69,10 @@ public abstract class HttpTestSupport extends TestCase {
|
|||
connector
|
||||
});
|
||||
server.start();
|
||||
waitForJettySocketToAccept("http://localhost:8080");
|
||||
|
||||
int port = connector.getLocalPort();
|
||||
|
||||
waitForJettySocketToAccept("http://localhost:" + port);
|
||||
|
||||
if (createBroker) {
|
||||
broker = new BrokerService();
|
||||
|
@ -79,6 +83,7 @@ public abstract class HttpTestSupport extends TestCase {
|
|||
broker.waitUntilStarted();
|
||||
|
||||
factory = new ActiveMQConnectionFactory("vm://localhost");
|
||||
factory.getBlobTransferPolicy().setDefaultUploadUrl("http://localhost:" + port + "/uploads/");
|
||||
connection = factory.createConnection();
|
||||
connection.start();
|
||||
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
@ -90,6 +95,7 @@ public abstract class HttpTestSupport extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
server.stop();
|
||||
if (createBroker) {
|
||||
|
@ -105,6 +111,7 @@ public abstract class HttpTestSupport extends TestCase {
|
|||
final URL url = new URL(bindLocation);
|
||||
assertTrue("Jetty endpoint is available", Wait.waitFor(new Wait.Condition() {
|
||||
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
boolean canConnect = false;
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue