activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6175 - fix unit test regression SelectiveMBeanRegistrationTest
Date Wed, 27 Apr 2016 11:41:01 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.13.x 94023ebed -> e633e49af


https://issues.apache.org/jira/browse/AMQ-6175 - fix unit test regression SelectiveMBeanRegistrationTest

(cherry picked from commit e313f4098900b717614cc109a1ab028e7bb5fd67)


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/e633e49a
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/e633e49a
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/e633e49a

Branch: refs/heads/activemq-5.13.x
Commit: e633e49aff5754b9ed0efa4d84b3e9084078490c
Parents: 94023eb
Author: gtully <gary.tully@gmail.com>
Authored: Tue Mar 8 11:55:19 2016 +0000
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Wed Apr 27 11:40:20 2016 +0000

----------------------------------------------------------------------
 .../jmx/SelectiveMBeanRegistrationTest.java     | 34 +++-----------------
 1 file changed, 5 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/e633e49a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java
index 834e60c..a1c6aec 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java
@@ -17,13 +17,11 @@
 package org.apache.activemq.broker.jmx;
 
 import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.Destination;
 import javax.jms.Session;
 import javax.management.MBeanServer;
-import javax.management.MBeanServerInvocationHandler;
 import javax.management.ObjectInstance;
 import javax.management.ObjectName;
 import org.apache.activemq.ActiveMQConnectionFactory;
@@ -32,14 +30,11 @@ import org.apache.activemq.util.Wait;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.*;
 
 
 public class SelectiveMBeanRegistrationTest  {
@@ -79,19 +74,18 @@ public class SelectiveMBeanRegistrationTest  {
 
         session.createConsumer(queue);
 
-        ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-        final BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
brokerName, BrokerViewMBean.class, true);
+        final ManagedRegionBroker managedRegionBroker = (ManagedRegionBroker) brokerService.getBroker().getAdaptor(ManagedRegionBroker.class);
 
         // mbean exists
         assertTrue("one sub", Wait.waitFor(new Wait.Condition() {
             @Override
             public boolean isSatisified() throws Exception {
-                return broker.getQueueSubscribers().length == 1;
+                return managedRegionBroker.getQueueSubscribers().length == 1;
             }
         }));
 
         // but it is not registered
-        assertFalse(mbeanServer.isRegistered(broker.getQueueSubscribers()[0]));
+        assertFalse(mbeanServer.isRegistered(managedRegionBroker.getQueueSubscribers()[0]));
 
         // verify dynamicProducer suppressed
         session.createProducer(null);
@@ -101,7 +95,7 @@ public class SelectiveMBeanRegistrationTest  {
         assertTrue("one sub", Wait.waitFor(new Wait.Condition() {
             @Override
             public boolean isSatisified() throws Exception {
-                return broker.getDynamicDestinationProducers().length == 1;
+                return managedRegionBroker.getDynamicDestinationProducers().length == 1;
             }
         }));
 
@@ -128,22 +122,4 @@ public class SelectiveMBeanRegistrationTest  {
         }
     }
 
-    protected ObjectName assertRegisteredObjectName(String name) throws Exception {
-        final ObjectName objectName = new ObjectName(name);
-        final AtomicBoolean result = new AtomicBoolean(false);
-        assertTrue("Bean registered: " + objectName, Wait.waitFor(new Wait.Condition() {
-            @Override
-            public boolean isSatisified() throws Exception {
-                try {
-                    result.set(mbeanServer.isRegistered(objectName));
-                } catch (Exception ignored) {
-                    LOG.debug(ignored.toString());
-                }
-                return result.get();
-            }
-        }));
-        return objectName;
-    }
-
-
 }


Mime
View raw message