Update tests to not use hard coded broker port.
This commit is contained in:
Timothy Bish 2016-05-04 14:39:26 -04:00
parent 231679d936
commit d1e2b76809
2 changed files with 7 additions and 10 deletions

View File

@ -35,7 +35,6 @@ import javax.jms.Session;
import javax.jms.TemporaryQueue; import javax.jms.TemporaryQueue;
import javax.jms.Topic; import javax.jms.Topic;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.region.policy.ConstantPendingMessageLimitStrategy; import org.apache.activemq.broker.region.policy.ConstantPendingMessageLimitStrategy;
@ -54,7 +53,7 @@ public class AdvisoryTempDestinationTests {
protected BrokerService broker; protected BrokerService broker;
protected Connection connection; protected Connection connection;
protected String bindAddress = ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL; protected String connectionURI;
protected int topicCount; protected int topicCount;
@Test(timeout = 60000) @Test(timeout = 60000)
@ -174,9 +173,8 @@ public class AdvisoryTempDestinationTests {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
if (broker == null) { broker = createBroker();
broker = createBroker(); connectionURI = broker.getTransportConnectors().get(0).getPublishableConnectString();
}
ConnectionFactory factory = createConnectionFactory(); ConnectionFactory factory = createConnectionFactory();
connection = factory.createConnection(); connection = factory.createConnection();
connection.start(); connection.start();
@ -191,7 +189,7 @@ public class AdvisoryTempDestinationTests {
} }
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL); ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(connectionURI);
return cf; return cf;
} }
@ -218,7 +216,7 @@ public class AdvisoryTempDestinationTests {
pMap.setPolicyEntries(policyEntries); pMap.setPolicyEntries(policyEntries);
answer.setDestinationPolicy(pMap); answer.setDestinationPolicy(pMap);
answer.addConnector(bindAddress); answer.addConnector("tcp://0.0.0.0:0");
answer.setDeleteAllMessagesOnStartup(true); answer.setDeleteAllMessagesOnStartup(true);
} }

View File

@ -355,8 +355,7 @@ public class AdvisoryTests {
} }
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL); return new ActiveMQConnectionFactory(broker.getTransportConnectorByName("OpenWire").getPublishableConnectString());
return cf;
} }
protected BrokerService createBroker() throws Exception { protected BrokerService createBroker() throws Exception {
@ -386,7 +385,7 @@ public class AdvisoryTests {
answer.setDestinationPolicy(pMap); answer.setDestinationPolicy(pMap);
answer.addConnector("nio://localhost:0"); answer.addConnector("nio://localhost:0");
answer.addConnector(bindAddress); answer.addConnector("tcp://localhost:0").setName("OpenWire");
answer.setDeleteAllMessagesOnStartup(true); answer.setDeleteAllMessagesOnStartup(true);
} }