[jboss-cvs] JBoss Messaging SVN: r5548 - in trunk: tests/src/org/jboss/messaging/tests/integration/cluster/management and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Dec 19 11:08:08 EST 2008


Author: jmesnil
Date: 2008-12-19 11:08:08 -0500 (Fri, 19 Dec 2008)
New Revision: 5548

Modified:
   trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java
   trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareTestBase.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/AcceptorControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/BroadcastGroupControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/DiscoveryGroupControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/MessageFlowControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/QueueControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java
Log:
refactored tests related to management to use new MBeanServers (created from MBeanServerFactory) instead of the PlatformMBeanServer which is global to the JVM so that tests are better isolated from each other


Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -23,6 +23,8 @@
 
 import java.lang.management.ManagementFactory;
 
+import javax.management.MBeanServer;
+
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
 import org.jboss.messaging.core.management.ManagementService;
@@ -77,7 +79,35 @@
 
       return new MessagingServiceImpl(server, storageManager, remotingService);
    }
+   
+   public static MessagingServiceImpl newNullStorageMessagingService(final Configuration config, MBeanServer mbeanServer)
+   {
+      StorageManager storageManager = new NullStorageManager();
 
+      RemotingService remotingService = new RemotingServiceImpl(config);
+
+      JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);
+
+      ManagementService managementService = new ManagementServiceImpl(mbeanServer,
+                                                                      config.isJMXManagementEnabled());
+      
+      remotingService.setManagementService(managementService);
+      
+      MessagingServer server = new MessagingServerImpl();
+
+      server.setConfiguration(config);
+
+      server.setStorageManager(storageManager);
+
+      server.setRemotingService(remotingService);
+
+      server.setSecurityManager(securityManager);
+
+      server.setManagementService(managementService);
+
+      return new MessagingServiceImpl(server, storageManager, remotingService);
+   }
+
    public static MessagingServiceImpl newMessagingService(final Configuration config)
    {      
       StorageManager storageManager = new JournalStorageManager(config);

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareTestBase.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareTestBase.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -34,21 +34,11 @@
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
-import org.jboss.messaging.core.management.ManagementService;
-import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
-import org.jboss.messaging.core.persistence.StorageManager;
-import org.jboss.messaging.core.persistence.impl.nullpm.NullStorageManager;
-import org.jboss.messaging.core.remoting.RemotingService;
-import org.jboss.messaging.core.remoting.impl.RemotingServiceImpl;
 import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory;
 import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
 import org.jboss.messaging.core.remoting.impl.invm.InVMRegistry;
 import org.jboss.messaging.core.remoting.impl.invm.TransportConstants;
-import org.jboss.messaging.core.security.JBMSecurityManager;
-import org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl;
-import org.jboss.messaging.core.server.MessagingServer;
 import org.jboss.messaging.core.server.MessagingService;
-import org.jboss.messaging.core.server.impl.MessagingServerImpl;
 import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
 
 /**
@@ -91,31 +81,6 @@
          fail("Resource exists: " + objectName);
       }
    }
-
-   protected static MessagingService createNullStorageMessagingServer(final Configuration config, MBeanServer mbeanServer)
-   {
-      StorageManager storageManager = new NullStorageManager();
-      
-      RemotingService remotingService = new RemotingServiceImpl(config);
-
-      JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);
-      
-      ManagementService managementService = new ManagementServiceImpl(mbeanServer, config.isJMXManagementEnabled());
-      
-      MessagingServer server = new MessagingServerImpl();
-      
-      server.setConfiguration(config);
-      
-      server.setStorageManager(storageManager);
-      
-      server.setRemotingService(remotingService);
-      
-      server.setSecurityManager(securityManager);
-      
-      server.setManagementService(managementService);
-      
-      return new MessagingServiceImpl(server, storageManager, remotingService);
-   }
    
    // Constructors --------------------------------------------------
 
@@ -140,7 +105,7 @@
                                                                             backupParams));
       backupConf.setBackup(true);
       backupConf.setJMXManagementEnabled(true);
-      backupService = createNullStorageMessagingServer(backupConf, backupMBeanServer);
+      backupService = MessagingServiceImpl.newNullStorageMessagingService(backupConf, backupMBeanServer);
       backupService.start();
 
       Configuration liveConf = new ConfigurationImpl();
@@ -154,7 +119,7 @@
       liveConf.setConnectorConfigurations(connectors);
       liveConf.setBackupConnectorName(backupTC.getName());
       liveConf.setJMXManagementEnabled(true);
-      liveService = createNullStorageMessagingServer(liveConf, liveMBeanServer);
+      liveService = MessagingServiceImpl.newNullStorageMessagingService(liveConf, liveMBeanServer);
       liveService.start();
    }
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -44,14 +44,14 @@
 import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
-import java.lang.management.ManagementFactory;
-
 import javax.jms.Connection;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
 import javax.management.openmbean.CompositeData;
 import javax.management.openmbean.TabularData;
@@ -61,6 +61,7 @@
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory;
 import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
 import org.jboss.messaging.core.server.MessagingService;
 import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
@@ -91,11 +92,13 @@
 
    private Queue queue;
 
+   private MBeanServer mbeanServer;
+
    // Static --------------------------------------------------------
 
-   private static JMSQueueControlMBean createQueueControl(Queue queue) throws Exception
+   private static JMSQueueControlMBean createQueueControl(Queue queue, MBeanServer mbeanServer) throws Exception
    {
-      JMSQueueControlMBean queueControl = (JMSQueueControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+      JMSQueueControlMBean queueControl = (JMSQueueControlMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
                                                                                                               JMSManagementServiceImpl.getJMSQueueObjectName(queue.getQueueName()),
                                                                                                               JMSQueueControlMBean.class,
                                                                                                               false);
@@ -108,7 +111,7 @@
 
    public void testGetXXXCount() throws Exception
    {
-      JMSQueueControlMBean queueControl = createQueueControl(queue);
+      JMSQueueControlMBean queueControl = createQueueControl(queue, mbeanServer);
 
       assertEquals(0, queueControl.getMessageCount());
       assertEquals(0, queueControl.getConsumerCount());
@@ -139,7 +142,7 @@
 
    public void testRemoveMessage() throws Exception
    {
-      JMSQueueControlMBean queueControl = createQueueControl(queue);
+      JMSQueueControlMBean queueControl = createQueueControl(queue, mbeanServer);
       assertEquals(0, queueControl.getMessageCount());
 
       JMSUtil.sendMessages(queue, 2);
@@ -160,7 +163,7 @@
 
    public void testRemoveAllMessages() throws Exception
    {
-      JMSQueueControlMBean queueControl = createQueueControl(queue);
+      JMSQueueControlMBean queueControl = createQueueControl(queue, mbeanServer);
       assertEquals(0, queueControl.getMessageCount());
 
       JMSUtil.sendMessages(queue, 2);
@@ -177,7 +180,7 @@
 
    public void testRemoveMatchingMessages() throws Exception
    {
-      JMSQueueControlMBean queueControl = createQueueControl(queue);
+      JMSQueueControlMBean queueControl = createQueueControl(queue, mbeanServer);
       assertEquals(0, queueControl.getMessageCount());
 
       JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
@@ -233,7 +236,7 @@
 
    public void testChangeMessagePriority() throws Exception
    {
-      JMSQueueControlMBean queueControl = createQueueControl(queue);
+      JMSQueueControlMBean queueControl = createQueueControl(queue, mbeanServer);
 
       JMSUtil.sendMessages(queue, 1);
 
@@ -258,12 +261,12 @@
 
    public void testExpireMessage() throws Exception
    {
-      JMSQueueControlMBean queueControl = createQueueControl(queue);
+      JMSQueueControlMBean queueControl = createQueueControl(queue, mbeanServer);
       String expiryQueueName = randomString();
       JBossQueue expiryQueue = new JBossQueue(expiryQueueName);
       serverManager.createQueue(expiryQueueName, expiryQueueName);
       queueControl.setExpiryAddress(expiryQueue.getAddress());
-      JMSQueueControlMBean expiryQueueControl = createQueueControl(expiryQueue);
+      JMSQueueControlMBean expiryQueueControl = createQueueControl(expiryQueue, mbeanServer);
 
       JMSUtil.sendMessages(queue, 1);
 
@@ -292,7 +295,7 @@
       long matchingValue = randomLong();
       long unmatchingValue = matchingValue + 1;
 
-      JMSQueueControlMBean queueControl = createQueueControl(queue);
+      JMSQueueControlMBean queueControl = createQueueControl(queue, mbeanServer);
 
       Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
       Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -319,13 +322,13 @@
    @Override
    protected void setUp() throws Exception
    {
-
+      mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.getAcceptorConfigurations()
-          .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory"));
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+          .add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
       serverManager = JMSServerManagerImpl.newJMSServerManagerImpl(service.getServer());

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -24,17 +24,16 @@
 
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
-import java.lang.management.ManagementFactory;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
 import javax.jms.Session;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
-import javax.naming.InitialContext;
 
 import junit.framework.TestCase;
 
@@ -54,7 +53,6 @@
 import org.jboss.messaging.jms.server.management.ConnectionFactoryControlMBean;
 import org.jboss.messaging.jms.server.management.JMSServerControlMBean;
 import org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl;
-import org.jboss.messaging.tests.util.RandomUtil;
 
 /**
  * A QueueControlTest
@@ -71,20 +69,22 @@
 
    // Attributes ----------------------------------------------------
 
+   private MBeanServer mbeanServer;
+
    // Static --------------------------------------------------------
 
-   private static JMSServerControlMBean createJMSServerControl() throws Exception
+   private static JMSServerControlMBean createJMSServerControl(MBeanServer mbeanServer) throws Exception
    {
-      JMSServerControlMBean control = (JMSServerControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+      JMSServerControlMBean control = (JMSServerControlMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
                                                                                                            JMSManagementServiceImpl.getJMSServerObjectName(),
                                                                                                            JMSServerControlMBean.class,
                                                                                                            false);
       return control;
    }
    
-   private static ConnectionFactoryControlMBean createConnectionFactoryControl(String name) throws Exception
+   private static ConnectionFactoryControlMBean createConnectionFactoryControl(String name, MBeanServer mbeanServer) throws Exception
    {
-      ConnectionFactoryControlMBean control = (ConnectionFactoryControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+      ConnectionFactoryControlMBean control = (ConnectionFactoryControlMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
                                                                                                            JMSManagementServiceImpl.getConnectionFactoryObjectName(name),
                                                                                                            ConnectionFactoryControlMBean.class,
                                                                                                            false);
@@ -93,11 +93,12 @@
 
    private MessagingService startMessagingService(String acceptorFactory) throws Exception
    {
+      mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.getAcceptorConfigurations().add(new TransportConfiguration(acceptorFactory));
-      MessagingService service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      MessagingService service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
       JMSServerManagerImpl serverManager = JMSServerManagerImpl.newJMSServerManagerImpl(service.getServer());
@@ -196,14 +197,14 @@
          service = startMessagingService(NettyAcceptorFactory.class.getName());
 
          try {
-            ConnectionFactoryControlMBean cfControl = createConnectionFactoryControl(cfName);
+            ConnectionFactoryControlMBean cfControl = createConnectionFactoryControl(cfName, mbeanServer);
             // invoke an operation on the proxy to check that there is no such mbean
             cfControl.getName();
             fail("no CF was created with name " + cfName);          
          } catch (Exception e)
          {
          }
-         JMSServerControlMBean control = createJMSServerControl();
+         JMSServerControlMBean control = createJMSServerControl(mbeanServer);
          control.createConnectionFactory(cfName,
                                          randomString(),
                                          "localhost",
@@ -234,7 +235,7 @@
                                          ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER,
                                          cfJNDIBinding);     
          
-         ConnectionFactoryControlMBean cfControl = createConnectionFactoryControl(cfName);
+         ConnectionFactoryControlMBean cfControl = createConnectionFactoryControl(cfName, mbeanServer);
          assertEquals(cfName, cfControl.getName());
       }
       finally
@@ -259,7 +260,7 @@
       {
          service = startMessagingService(acceptorFactory);
 
-         JMSServerControlMBean control = createJMSServerControl();
+         JMSServerControlMBean control = createJMSServerControl(mbeanServer);
 
          assertEquals(0, control.listConnectionIDs().length);
 
@@ -299,7 +300,7 @@
       {
          service = startMessagingService(acceptorFactory);
 
-         JMSServerControlMBean control = createJMSServerControl();
+         JMSServerControlMBean control = createJMSServerControl(mbeanServer);
 
          assertEquals(0, control.listConnectionIDs().length);
 
@@ -340,7 +341,7 @@
       {
          service = startMessagingService(acceptorFactory);
 
-         JMSServerControlMBean control = createJMSServerControl();
+         JMSServerControlMBean control = createJMSServerControl(mbeanServer);
 
          assertEquals(0, control.listRemoteAddresses().length);
 
@@ -379,7 +380,7 @@
       {
          service = startMessagingService(acceptorFactory);
 
-         JMSServerControlMBean control = createJMSServerControl();
+         JMSServerControlMBean control = createJMSServerControl(mbeanServer);
 
          assertEquals(0, service.getServer().getConnectionCount());
          assertEquals(0, control.listRemoteAddresses().length);
@@ -429,7 +430,7 @@
       {
          service = startMessagingService(acceptorFactory);
 
-         JMSServerControlMBean control = createJMSServerControl();
+         JMSServerControlMBean control = createJMSServerControl(mbeanServer);
 
          assertEquals(0, service.getServer().getConnectionCount());
          assertEquals(0, control.listRemoteAddresses().length);

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlTest.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlTest.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -25,11 +25,11 @@
 import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
-import java.lang.management.ManagementFactory;
-
 import javax.jms.Connection;
 import javax.jms.Session;
 import javax.jms.Topic;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
 
 import junit.framework.TestCase;
@@ -71,11 +71,13 @@
 
    private Topic topic;
 
+   private MBeanServer mbeanServer;
+
    // Static --------------------------------------------------------
 
-   private static TopicControlMBean createTopicControl(Topic topic) throws Exception
+   private static TopicControlMBean createTopicControl(Topic topic, MBeanServer mbeanServer) throws Exception
    {
-      TopicControlMBean topicControl = (TopicControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+      TopicControlMBean topicControl = (TopicControlMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
                                                                                                         JMSManagementServiceImpl.getJMSTopicObjectName(topic.getTopicName()),
                                                                                                         TopicControlMBean.class,
                                                                                                         false);
@@ -98,7 +100,7 @@
       JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
       JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName + "2");
 
-      TopicControlMBean topicControl = createTopicControl(topic);
+      TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
       assertEquals(3, topicControl.getSubcriptionsCount());
       assertEquals(1, topicControl.getNonDurableSubcriptionsCount());
       assertEquals(2, topicControl.getDurableSubcriptionsCount());
@@ -111,7 +113,7 @@
       JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
       JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName + "2");
 
-      TopicControlMBean topicControl = createTopicControl(topic);
+      TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
 
       assertEquals(0, topicControl.getMessageCount());
       assertEquals(0, topicControl.getNonDurableMessagesCount());
@@ -131,7 +133,7 @@
       JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
       JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName + "2");
 
-      TopicControlMBean topicControl = createTopicControl(topic);
+      TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
       assertEquals(3, topicControl.listAllSubscriptionInfos().length);
       assertEquals(1, topicControl.listNonDurableSubscriptionInfos().length);
       assertEquals(2, topicControl.listDurableSubscriptionInfos().length);
@@ -153,7 +155,7 @@
       JMSUtil.sendMessageWithProperty(session, topic, key, unmatchingValue);
       JMSUtil.sendMessageWithProperty(session, topic, key, matchingValue);
       
-      TopicControlMBean topicControl = createTopicControl(topic);
+      TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
       
       // wiat a little bit to give time for the message to be handled by the server
       Thread.sleep(200);
@@ -168,7 +170,7 @@
    {
       JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
 
-      TopicControlMBean topicControl = createTopicControl(topic);
+      TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
       assertEquals(1, topicControl.getDurableSubcriptionsCount());
 
       topicControl.dropDurableSubscription(clientID, subscriptionName);
@@ -180,7 +182,7 @@
    {
       JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
 
-      TopicControlMBean topicControl = createTopicControl(topic);
+      TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
       assertEquals(1, topicControl.getDurableSubcriptionsCount());
 
       try
@@ -202,7 +204,7 @@
       JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
       JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName + "2");
 
-      TopicControlMBean topicControl = createTopicControl(topic);
+      TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
       assertEquals(3, topicControl.getSubcriptionsCount());
 
       topicControl.dropAllSubscriptions();
@@ -218,12 +220,13 @@
    protected void setUp() throws Exception
    {
 
+      mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.getAcceptorConfigurations()
           .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory"));
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
       serverManager = JMSServerManagerImpl.newJMSServerManagerImpl(service.getServer());

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/AcceptorControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/AcceptorControlTest.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/AcceptorControlTest.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -24,9 +24,10 @@
 
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
-import java.lang.management.ManagementFactory;
 import java.util.HashMap;
 
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
 
 import junit.framework.TestCase;
@@ -65,9 +66,9 @@
 
    // Static --------------------------------------------------------
 
-   private static AcceptorControlMBean createControl(String name) throws Exception
+   private static AcceptorControlMBean createControl(String name, MBeanServer mbeanServer) throws Exception
    {
-      AcceptorControlMBean control = (AcceptorControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+      AcceptorControlMBean control = (AcceptorControlMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
                                                                                                          ManagementServiceImpl.getAcceptorObjectName(name),
                                                                                                          AcceptorControlMBean.class,
                                                                                                          false);
@@ -84,14 +85,15 @@
                                                                          new HashMap<String, Object>(),
                                                                          randomString());
 
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.getAcceptorConfigurations().add(acceptorConfig);
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
-      AcceptorControlMBean acceptorControl = createControl(acceptorConfig.getName());
+      AcceptorControlMBean acceptorControl = createControl(acceptorConfig.getName(), mbeanServer);
       assertEquals(acceptorConfig.getName(), acceptorControl.getName());
       assertEquals(acceptorConfig.getFactoryClassName(), acceptorControl.getFactoryClassName());
    }
@@ -101,15 +103,15 @@
       TransportConfiguration acceptorConfig = new TransportConfiguration(NettyAcceptorFactory.class.getName(),
                                                                          new HashMap<String, Object>(),
                                                                          randomString());
-
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.getAcceptorConfigurations().add(acceptorConfig);
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
-      AcceptorControlMBean acceptorControl = createControl(acceptorConfig.getName());
+      AcceptorControlMBean acceptorControl = createControl(acceptorConfig.getName(), mbeanServer);
       // started by the service
       assertTrue(acceptorControl.isStarted());
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/BroadcastGroupControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/BroadcastGroupControlTest.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/BroadcastGroupControlTest.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -26,10 +26,11 @@
 import static org.jboss.messaging.tests.util.RandomUtil.randomPositiveLong;
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
-import java.lang.management.ManagementFactory;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
 
 import junit.framework.TestCase;
@@ -65,9 +66,9 @@
 
    // Static --------------------------------------------------------
 
-   private static BroadcastGroupControlMBean createControl(String name) throws Exception
+   private static BroadcastGroupControlMBean createControl(String name, MBeanServer mbeanServer) throws Exception
    {
-      BroadcastGroupControlMBean control = (BroadcastGroupControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+      BroadcastGroupControlMBean control = (BroadcastGroupControlMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
                                                                                                                      ManagementServiceImpl.getBroadcastGroupObjectName(name),
                                                                                                                      BroadcastGroupControlMBean.class,
                                                                                                                      false);
@@ -101,16 +102,17 @@
       connectorInfos.add(new Pair<String, String>(connectorConfiguration.getName(), null));
       BroadcastGroupConfiguration broadcastGroupConfig = randomBroadcastGroupConfiguration(connectorInfos);
 
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.setClustered(true);
       conf.getConnectorConfigurations().put(connectorConfiguration.getName(), connectorConfiguration);
       conf.getBroadcastGroupConfigurations().add(broadcastGroupConfig);
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
-      BroadcastGroupControlMBean broadcastGroupControl = createControl(broadcastGroupConfig.getName());
+      BroadcastGroupControlMBean broadcastGroupControl = createControl(broadcastGroupConfig.getName(), mbeanServer);
 
       assertEquals(broadcastGroupConfig.getName(), broadcastGroupControl.getName());
       assertEquals(broadcastGroupConfig.getGroupAddress(), broadcastGroupControl.getGroupAddress());
@@ -126,16 +128,17 @@
       connectorInfos.add(new Pair<String, String>(connectorConfiguration.getName(), null));
       BroadcastGroupConfiguration broadcastGroupConfig = randomBroadcastGroupConfiguration(connectorInfos);
 
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.setClustered(true);
       conf.getConnectorConfigurations().put(connectorConfiguration.getName(), connectorConfiguration);
       conf.getBroadcastGroupConfigurations().add(broadcastGroupConfig);
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
-      BroadcastGroupControlMBean broadcastGroupControl = createControl(broadcastGroupConfig.getName());
+      BroadcastGroupControlMBean broadcastGroupControl = createControl(broadcastGroupConfig.getName(), mbeanServer);
 
       // started by the service
       assertTrue(broadcastGroupControl.isStarted());

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/DiscoveryGroupControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/DiscoveryGroupControlTest.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/DiscoveryGroupControlTest.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -25,8 +25,8 @@
 import static org.jboss.messaging.tests.util.RandomUtil.randomPositiveLong;
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
-import java.lang.management.ManagementFactory;
-
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
 
 import junit.framework.TestCase;
@@ -59,9 +59,9 @@
 
    // Static --------------------------------------------------------
 
-   private static DiscoveryGroupControlMBean createControl(String name) throws Exception
+   private static DiscoveryGroupControlMBean createControl(String name, MBeanServer mbeanServer) throws Exception
    {
-      DiscoveryGroupControlMBean control = (DiscoveryGroupControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+      DiscoveryGroupControlMBean control = (DiscoveryGroupControlMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
                                                                                                                ManagementServiceImpl.getDiscoveryGroupObjectName(name),
                                                                                                                DiscoveryGroupControlMBean.class,
                                                                                                                false);
@@ -76,15 +76,16 @@
    {
       DiscoveryGroupConfiguration discoveryGroupConfig = new DiscoveryGroupConfiguration(randomString(), "231.7.7.7", 2000, randomPositiveLong());
 
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.setClustered(true);
       conf.getDiscoveryGroupConfigurations().put(discoveryGroupConfig.getName(), discoveryGroupConfig);
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
-      DiscoveryGroupControlMBean discoveryGroupControl = createControl(discoveryGroupConfig.getName());
+      DiscoveryGroupControlMBean discoveryGroupControl = createControl(discoveryGroupConfig.getName(), mbeanServer);
 
       assertEquals(discoveryGroupConfig.getName(), discoveryGroupControl.getName());
       assertEquals(discoveryGroupConfig.getGroupAddress(), discoveryGroupControl.getGroupAddress());
@@ -96,15 +97,16 @@
    {
       DiscoveryGroupConfiguration discoveryGroupConfig = new DiscoveryGroupConfiguration(randomString(), "231.7.7.7", 2000, randomPositiveLong());
 
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.setClustered(true);
       conf.getDiscoveryGroupConfigurations().put(discoveryGroupConfig.getName(), discoveryGroupConfig);
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
-      DiscoveryGroupControlMBean discoveryGroupControl = createControl(discoveryGroupConfig.getName());
+      DiscoveryGroupControlMBean discoveryGroupControl = createControl(discoveryGroupConfig.getName(), mbeanServer);
       // started by the service
       assertTrue(discoveryGroupControl.isStarted());
 
@@ -116,15 +118,16 @@
    {
       DiscoveryGroupConfiguration discoveryGroupConfig = new DiscoveryGroupConfiguration(randomString(), "231.7.7.7", 2000, randomPositiveLong());
 
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.setClustered(true);
       conf.getDiscoveryGroupConfigurations().put(discoveryGroupConfig.getName(), discoveryGroupConfig);
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
-      DiscoveryGroupControlMBean discoveryGroupControl = createControl(discoveryGroupConfig.getName());
+      DiscoveryGroupControlMBean discoveryGroupControl = createControl(discoveryGroupConfig.getName(), mbeanServer);
       // started by the service
       assertTrue(discoveryGroupControl.isStarted());
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -39,6 +39,7 @@
 import java.nio.ByteBuffer;
 
 import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.ObjectName;
 
 import junit.framework.TestCase;
@@ -74,7 +75,8 @@
 
    public void testHandleManagementMessageWithAttribute() throws Exception
    {
-      ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), false);
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
+      ManagementService managementService = new ManagementServiceImpl(mbeanServer, false);
       assertNotNull(managementService);
 
       SimpleString address = RandomUtil.randomSimpleString();
@@ -91,11 +93,14 @@
       SimpleString value = (SimpleString)message.getProperty(new SimpleString("Address"));
       assertNotNull(value);
       assertEquals(address, value);
+
+      managementService.stop();
    }
 
    public void testHandleManagementMessageWithOperation() throws Exception
    {
-      ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), false);
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
+      ManagementService managementService = new ManagementServiceImpl(mbeanServer, false);
       assertNotNull(managementService);
 
       Role role = new Role(randomString(), randomBoolean(), randomBoolean(), randomBoolean());
@@ -126,11 +131,14 @@
       assertTrue(success);
 
       verify(resource);
+
+      managementService.stop();
    }
 
    public void testHandleManagementMessageWithOperationWhichFails() throws Exception
    {
-      ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), false);
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
+      ManagementService managementService = new ManagementServiceImpl(mbeanServer, false);
       assertNotNull(managementService);
 
       Role role = new Role(randomString(), randomBoolean(), randomBoolean(), randomBoolean());
@@ -166,11 +174,13 @@
       assertEquals(exceptionMessage, exceptionMsg.toString());
 
       verify(resource);
+
+      managementService.stop();
    }
    
    public void testStop() throws Exception
    {
-      MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       
       ManagementService managementService = new ManagementServiceImpl(mbeanServer, true);
       assertNotNull(managementService);

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/MessageFlowControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/MessageFlowControlTest.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/MessageFlowControlTest.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -28,30 +28,20 @@
 import static org.jboss.messaging.tests.util.RandomUtil.randomPositiveLong;
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
-import java.lang.management.ManagementFactory;
-import java.util.HashMap;
-
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
 
 import junit.framework.TestCase;
 
-import org.jboss.messaging.core.client.ClientSession;
-import org.jboss.messaging.core.client.ClientSessionFactory;
-import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
 import org.jboss.messaging.core.config.Configuration;
-import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.config.cluster.DiscoveryGroupConfiguration;
 import org.jboss.messaging.core.config.cluster.MessageFlowConfiguration;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
-import org.jboss.messaging.core.management.AcceptorControlMBean;
 import org.jboss.messaging.core.management.MessageFlowControlMBean;
 import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
-import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory;
 import org.jboss.messaging.core.server.MessagingService;
 import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
-import org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory;
-import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
-import org.jboss.messaging.tests.util.RandomUtil;
 
 /**
  * A AcceptorControlTest
@@ -73,9 +63,9 @@
 
    // Static --------------------------------------------------------
 
-   private static MessageFlowControlMBean createControl(String name) throws Exception
+   private static MessageFlowControlMBean createControl(String name, MBeanServer mbeanServer) throws Exception
    {
-      MessageFlowControlMBean control = (MessageFlowControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+      MessageFlowControlMBean control = (MessageFlowControlMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
                                                                                                                ManagementServiceImpl.getMessageFlowObjectName(name),
                                                                                                                MessageFlowControlMBean.class,
                                                                                                                false);
@@ -108,16 +98,17 @@
       DiscoveryGroupConfiguration discoveryGroupConfig = new DiscoveryGroupConfiguration(randomString(), "231.7.7.7", 2000, randomPositiveLong());
       MessageFlowConfiguration messageFlowConfig = randomMessageFlowConfigurationWithDiscoveryGroup(discoveryGroupConfig.getName());
 
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.setClustered(true);
       conf.getDiscoveryGroupConfigurations().put(discoveryGroupConfig.getName(), discoveryGroupConfig);
       conf.getMessageFlowConfigurations().add(messageFlowConfig);
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
-      MessageFlowControlMBean messageFlowControl = createControl(messageFlowConfig.getName());
+      MessageFlowControlMBean messageFlowControl = createControl(messageFlowConfig.getName(), mbeanServer);
       assertEquals(messageFlowConfig.getName(), messageFlowControl.getName());
       assertEquals(messageFlowConfig.getDiscoveryGroupName(), messageFlowControl.getDiscoveryGroupName());
    }
@@ -127,16 +118,17 @@
       DiscoveryGroupConfiguration discoveryGroupConfig = new DiscoveryGroupConfiguration(randomString(), "231.7.7.7", 2000, randomPositiveLong());
       MessageFlowConfiguration messageFlowConfig = randomMessageFlowConfigurationWithDiscoveryGroup(discoveryGroupConfig.getName());
 
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.setClustered(true);
       conf.getDiscoveryGroupConfigurations().put(discoveryGroupConfig.getName(), discoveryGroupConfig);
       conf.getMessageFlowConfigurations().add(messageFlowConfig);
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
-      MessageFlowControlMBean messageFlowControl = createControl(messageFlowConfig.getName());
+      MessageFlowControlMBean messageFlowControl = createControl(messageFlowConfig.getName(), mbeanServer);
       // started by the service
       assertTrue(messageFlowControl.isStarted());
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlTest.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlTest.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -24,9 +24,10 @@
 
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
-import java.lang.management.ManagementFactory;
 import java.util.HashMap;
 
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
 import javax.management.openmbean.TabularData;
 
@@ -62,9 +63,9 @@
 
    // Static --------------------------------------------------------
 
-   private static MessagingServerControlMBean createServerControl() throws Exception
+   private static MessagingServerControlMBean createServerControl(MBeanServer mbeanServer) throws Exception
    {
-      MessagingServerControlMBean control = (MessagingServerControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+      MessagingServerControlMBean control = (MessagingServerControlMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
                                                                                                                        ManagementServiceImpl.getMessagingServerObjectName(),
                                                                                                                        MessagingServerControlMBean.class,
                                                                                                                        false);
@@ -77,6 +78,8 @@
 
    public void testGetConnectors() throws Exception
    {
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
+      
       TransportConfiguration connectorConfig = new TransportConfiguration(InVMConnectorFactory.class.getName(),
                                                                           new HashMap<String, Object>(),
                                                                           randomString());
@@ -85,10 +88,10 @@
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.getConnectorConfigurations().put(connectorConfig.getName(), connectorConfig);
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
 
-      MessagingServerControlMBean serverControl = createServerControl();
+      MessagingServerControlMBean serverControl = createServerControl(mbeanServer);
       TabularData acceptorData = serverControl.getConnectors();
       assertNotNull(acceptorData);
       assertEquals(1, acceptorData.size());

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/QueueControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/QueueControlTest.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/QueueControlTest.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -25,8 +25,8 @@
 import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
 import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
 
-import java.lang.management.ManagementFactory;
-
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
 
 import junit.framework.TestCase;
@@ -65,12 +65,14 @@
    // Attributes ----------------------------------------------------
 
    private MessagingService service;
+   
+   private MBeanServer mbeanServer;
 
    // Static --------------------------------------------------------
 
-   private static QueueControlMBean createQueueControl(SimpleString address, SimpleString name) throws Exception
+   private static QueueControlMBean createQueueControl(SimpleString address, SimpleString name, MBeanServer mbeanServer) throws Exception
    {
-      QueueControlMBean queueControl = (QueueControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+      QueueControlMBean queueControl = (QueueControlMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
                                                                                                         ManagementServiceImpl.getQueueObjectName(address,
                                                                                                                                                  name),
                                                                                                         QueueControlMBean.class,
@@ -114,7 +116,7 @@
 
       // wait a little bit to ensure the message is handled by the server
       Thread.sleep(100);
-      QueueControlMBean queueControl = createQueueControl(address, queue);
+      QueueControlMBean queueControl = createQueueControl(address, queue, mbeanServer);
       assertEquals(1, queueControl.getMessageCount());
 
       // moved all messages to otherQueue
@@ -179,7 +181,7 @@
 
       // wait a little bit to ensure the message is handled by the server
       Thread.sleep(100);
-      QueueControlMBean queueControl = createQueueControl(address, queue);
+      QueueControlMBean queueControl = createQueueControl(address, queue, mbeanServer);
       assertEquals(2, queueControl.getMessageCount());
 
       // moved matching messages to otherQueue
@@ -234,7 +236,7 @@
 
       // wait a little bit to ensure the message is handled by the server
       Thread.sleep(100);
-      QueueControlMBean queueControl = createQueueControl(address, queue);
+      QueueControlMBean queueControl = createQueueControl(address, queue, mbeanServer);
       assertEquals(2, queueControl.getMessageCount());
 
       // delete all messages
@@ -286,7 +288,7 @@
 
       // wait a little bit to ensure the message is handled by the server
       Thread.sleep(100);
-      QueueControlMBean queueControl = createQueueControl(address, queue);
+      QueueControlMBean queueControl = createQueueControl(address, queue, mbeanServer);
       assertEquals(2, queueControl.getMessageCount());
 
       // removed matching messages to otherQueue
@@ -339,7 +341,7 @@
 
       // wait a little bit to ensure the message is handled by the server
       Thread.sleep(100);
-      QueueControlMBean queueControl = createQueueControl(address, queue);
+      QueueControlMBean queueControl = createQueueControl(address, queue, mbeanServer);
       assertEquals(3, queueControl.getMessageCount());
 
       assertEquals(2, queueControl.countMessages(key + " =" + matchingValue));
@@ -375,7 +377,7 @@
 
       // wait a little bit to ensure the message is handled by the server
       Thread.sleep(100);
-      QueueControlMBean queueControl = createQueueControl(address, queue);
+      QueueControlMBean queueControl = createQueueControl(address, queue, mbeanServer);
       assertEquals(2, queueControl.getMessageCount());
 
       int expiredMessagesCount = queueControl.expireMessages(key + " =" + matchingValue);
@@ -406,12 +408,13 @@
    @Override
    protected void setUp() throws Exception
    {
-
+      mbeanServer = MBeanServerFactory.createMBeanServer();
+      
       Configuration conf = new ConfigurationImpl();
       conf.setSecurityEnabled(false);
       conf.setJMXManagementEnabled(true);
       conf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
-      service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+      service = MessagingServiceImpl.newNullStorageMessagingService(conf, mbeanServer);
       service.start();
    }
 

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java	2008-12-19 10:47:50 UTC (rev 5547)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java	2008-12-19 16:08:08 UTC (rev 5548)
@@ -30,11 +30,11 @@
 import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
-import java.lang.management.ManagementFactory;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicReference;
 
 import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.Notification;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
@@ -365,7 +365,8 @@
    {
       super.setUp();
 
-      mbeanServer = ManagementFactory.getPlatformMBeanServer();
+      mbeanServer = MBeanServerFactory.createMBeanServer();
+      
       serverON = JMSManagementServiceImpl.getJMSServerObjectName();
    }
 




More information about the jboss-cvs-commits mailing list