You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2016/03/08 12:56:14 UTC

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

Repository: activemq
Updated Branches:
  refs/heads/master 67ae2bd8a -> e313f4098


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


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

Branch: refs/heads/master
Commit: e313f4098900b717614cc109a1ab028e7bb5fd67
Parents: 67ae2bd
Author: gtully <ga...@gmail.com>
Authored: Tue Mar 8 11:55:19 2016 +0000
Committer: gtully <ga...@gmail.com>
Committed: Tue Mar 8 11:55:46 2016 +0000

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


http://git-wip-us.apache.org/repos/asf/activemq/blob/e313f409/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;
-    }
-
-
 }