From 78022e2b9d289842a46428a8e3de5b1fb5dddd15 Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Thu, 29 Nov 2012 22:05:06 +0000 Subject: [PATCH] fix up use of wrong mbean object name for durable sub - use system assigned port git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1415405 13f79535-47bb-0310-9956-ffa450edef68 --- ...bleSubscriberNonPersistentMessageTest.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriberNonPersistentMessageTest.java b/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriberNonPersistentMessageTest.java index 4d90862f95..fb152395e4 100644 --- a/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriberNonPersistentMessageTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriberNonPersistentMessageTest.java @@ -45,6 +45,7 @@ import junit.framework.TestSuite; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; import org.apache.activemq.store.kahadb.KahaDBStore; import org.apache.activemq.util.Wait; import org.slf4j.Logger; @@ -53,8 +54,8 @@ import org.slf4j.LoggerFactory; public class DurableSubscriberNonPersistentMessageTest extends TestCase { private final Logger LOG = LoggerFactory.getLogger(DurableSubscriberNonPersistentMessageTest.class); - private String brokerURL = "failover:(tcp://localhost:61616)"; - private String consumerBrokerURL = brokerURL + "?jms.prefetchPolicy.all=100"; + private String brokerURL; + private String consumerBrokerURL; int initialMaxMsgs = 10; int cleanupMsgCount = 10; @@ -79,12 +80,15 @@ public class DurableSubscriberNonPersistentMessageTest extends TestCase { protected void setUp() throws Exception { super.setUp(); broker = new BrokerService(); - broker.addConnector("tcp://localhost:61616"); + TransportConnector transportConnector = broker.addConnector("tcp://localhost:0"); KahaDBStore store = new KahaDBStore(); store.setDirectory(new File("data")); broker.setPersistenceAdapter(store); broker.start(); + brokerURL = "failover:(" + transportConnector.getPublishableConnectString() + ")"; + consumerBrokerURL = brokerURL + "?jms.prefetchPolicy.all=100"; + mbeanServer = ManagementFactory.getPlatformMBeanServer(); } @@ -137,15 +141,7 @@ public class DurableSubscriberNonPersistentMessageTest extends TestCase { String brokerVersion = (String) mbeanServer.getAttribute(new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Broker"), "BrokerVersion"); LOG.info("Test run on: " + brokerVersion); - // Fuse and Apache 5.6 use different object strings if the consumer - // is offline, maybe this has something to do with the difference in - // behavior? - String jmxObject = "org.apache.activemq:BrokerName=localhost,Type=Subscription,active=false,name=Jason_MyDurableTopic"; - if (brokerVersion == null || brokerVersion.contains("fuse") || brokerVersion.contains("5.6")) { - jmxObject = "org.apache.activemq:BrokerName=localhost,Type=Subscription,persistentMode=Durable,subscriptionID=MyDurableTopic,destinationType=Topic,destinationName=TEST,clientId=Jason"; - } - - final String theJmxObject = jmxObject; + final String theJmxObject = "org.apache.activemq:BrokerName=localhost,Type=Subscription,persistentMode=Durable,subscriptionID=MyDurableTopic,destinationType=Topic,destinationName=TEST,clientId=Jason"; assertTrue("pendingQueueSize should be zero", Wait.waitFor(new Wait.Condition() { @Override