From 6380bf37627bc6792ac62e11a9880ec2444b387b Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Wed, 4 Mar 2015 18:16:41 -0500 Subject: [PATCH] https://issues.apache.org/jira/browse/PROTON-833 Clean up a couple more tests. --- .../org/apache/activemq/bugs/AMQ4213Test.java | 14 +++---- .../org/apache/activemq/bugs/AMQ4671Test.java | 11 +++-- .../org/apache/activemq/bugs/AMQ4899Test.java | 40 +++++++++---------- 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4213Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4213Test.java index fddb6b12f0..e55ab08976 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4213Test.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4213Test.java @@ -36,27 +36,23 @@ import org.junit.Test; public class AMQ4213Test { private static BrokerService brokerService; - private static String BROKER_ADDRESS = "tcp://localhost:0"; private static String TEST_QUEUE = "testQueue"; private static ActiveMQQueue queue = new ActiveMQQueue(TEST_QUEUE); - private String connectionUri; - @SuppressWarnings("unchecked") @Before public void setUp() throws Exception { brokerService = new BrokerService(); brokerService.setPersistent(false); - brokerService.setUseJmx(true); - brokerService.setDeleteAllMessagesOnStartup(true); - connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString(); + brokerService.setUseJmx(false); + brokerService.setAdvisorySupport(false); brokerService.setPlugins(new BrokerPlugin[]{ new BrokerPluginSupport() { @Override public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception { - throw new javax.jms.JMSSecurityException(connectionUri); + throw new javax.jms.JMSSecurityException(brokerService.getVmConnectorURI().toString()); } } }); @@ -71,9 +67,9 @@ public class AMQ4213Test { brokerService.waitUntilStopped(); } - @Test + @Test(timeout = 30000) public void testExceptionOnProducerCreateThrows() throws Exception { - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri); + ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerService.getVmConnectorURI()); ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection(); Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java index b69ab4716e..e8b967511a 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java @@ -33,7 +33,6 @@ public class AMQ4671Test { private static final transient Logger LOG = LoggerFactory.getLogger(AMQ4671Test.class); private static BrokerService brokerService; - private static String BROKER_ADDRESS = "tcp://localhost:0"; private String connectionUri; @@ -41,12 +40,12 @@ public class AMQ4671Test { public void setUp() throws Exception { brokerService = new BrokerService(); brokerService.setPersistent(false); - brokerService.setUseJmx(true); - brokerService.setDeleteAllMessagesOnStartup(true); - connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString(); - connectionUri = connectionUri + "?trace=true"; + brokerService.setUseJmx(false); + brokerService.setAdvisorySupport(false); brokerService.start(); brokerService.waitUntilStarted(); + + connectionUri = brokerService.getVmConnectorURI().toString(); } @After @@ -55,7 +54,7 @@ public class AMQ4671Test { brokerService.waitUntilStopped(); } - @Test + @Test(timeout = 30000) public void testNonDurableSubscriberInvalidUnsubscribe() throws Exception { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4899Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4899Test.java index 81140ce8e8..019d9050e6 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4899Test.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4899Test.java @@ -16,6 +16,22 @@ */ package org.apache.activemq.bugs; +import static org.junit.Assert.assertEquals; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerPlugin; @@ -31,21 +47,6 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import static org.junit.Assert.assertEquals; - public class AMQ4899Test { protected static final Logger LOG = LoggerFactory.getLogger(AMQ4899Test.class); private static final String QUEUE_NAME="AMQ4899TestQueue"; @@ -55,9 +56,9 @@ public class AMQ4899Test { private static final Integer MESSAGE_LIMIT = 20; public static final String CONSUMER_A_SELECTOR = "Order < " + 10; public static String CONSUMER_B_SELECTOR = "Order >= " + 10; - private CountDownLatch consumersStarted = new CountDownLatch(2); - private CountDownLatch consumerAtoConsumeCount= new CountDownLatch(10); - private CountDownLatch consumerBtoConsumeCount = new CountDownLatch(10); + private final CountDownLatch consumersStarted = new CountDownLatch(2); + private final CountDownLatch consumerAtoConsumeCount= new CountDownLatch(10); + private final CountDownLatch consumerBtoConsumeCount = new CountDownLatch(10); private BrokerService broker; @@ -112,9 +113,7 @@ public class AMQ4899Test { message.setIntProperty("Order", i); LOG.debug("Sending message [{}]", messageText); producer.send(message); - Thread.sleep(100); } - Thread.sleep(1 * 1000); // restart consumerA LOG.debug("Restarting consumerA"); @@ -156,6 +155,7 @@ public class AMQ4899Test { BrokerPlugin[] updatedPlugins = {subQueueSelectorCacheBrokerPlugin}; broker.setPlugins(updatedPlugins); + broker.setUseJmx(false); broker.start(); broker.waitUntilStarted(); } catch (Exception e) {