Clean up a couple more tests.
This commit is contained in:
Timothy Bish 2015-03-04 18:16:41 -05:00
parent 5313ad8a96
commit 6380bf3762
3 changed files with 30 additions and 35 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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) {