[jboss-cvs] JBoss Messaging SVN: r4007 - in trunk: src/main/org/jboss/messaging/core/remoting and 12 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 4 07:01:49 EDT 2008


Author: ataylor
Date: 2008-04-04 07:01:48 -0400 (Fri, 04 Apr 2008)
New Revision: 4007

Added:
   trunk/tests/src/org/jboss/messaging/jms/
   trunk/tests/src/org/jboss/messaging/jms/server/
   trunk/tests/src/org/jboss/messaging/jms/server/impl/
   trunk/tests/src/org/jboss/messaging/jms/server/impl/test/
   trunk/tests/src/org/jboss/messaging/jms/server/impl/test/unit/
   trunk/tests/src/org/jboss/messaging/jms/server/impl/test/unit/JMSServerManagerimplTest.java
   trunk/tests/src/org/jboss/test/messaging/tools/container/InVMSingleInitialContextFactory.java
Removed:
   trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java
Modified:
   trunk/docs/examples/embedded/src/org/jboss/example/embedded/EmbeddedManagementExample.java
   trunk/src/main/org/jboss/messaging/core/remoting/ConnectorRegistry.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/ConnectorRegistryImpl.java
   trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
   trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
Log:
moved manager tests and fixed invm transport

Modified: trunk/docs/examples/embedded/src/org/jboss/example/embedded/EmbeddedManagementExample.java
===================================================================
--- trunk/docs/examples/embedded/src/org/jboss/example/embedded/EmbeddedManagementExample.java	2008-04-04 09:40:17 UTC (rev 4006)
+++ trunk/docs/examples/embedded/src/org/jboss/example/embedded/EmbeddedManagementExample.java	2008-04-04 11:01:48 UTC (rev 4007)
@@ -25,10 +25,9 @@
 import org.jboss.messaging.core.server.impl.MessagingServerImpl;
 
 import static org.jboss.messaging.core.remoting.TransportType.TCP;
-import org.jboss.messaging.core.remoting.RemotingConfiguration;
-import org.jboss.messaging.core.remoting.impl.RemotingConfigurationImpl;
 import org.jboss.messaging.core.management.MessagingServerManagement;
 import org.jboss.messaging.core.management.impl.MessagingServerManagementImpl;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
 import org.jboss.messaging.jms.server.JMSServerManager;
 import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
 import org.jnp.server.NamingBeanImpl;
@@ -57,7 +56,10 @@
       mainMBean.setRmiBindAddress("localhost");
       mainMBean.setNamingInfo(namingBean);
       mainMBean.start();
-      RemotingConfigurationImpl remotingConf = new RemotingConfigurationImpl(TCP, "localhost", 5400);
+      ConfigurationImpl remotingConf = new ConfigurationImpl();
+      remotingConf.setPort(5400);
+      remotingConf.setHost("localhost");
+      remotingConf.setTransport(TCP);
       remotingConf.setInvmDisabled(true);
       MessagingServer messagingServer = new MessagingServerImpl(remotingConf);
       messagingServer.start();

Modified: trunk/src/main/org/jboss/messaging/core/remoting/ConnectorRegistry.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/ConnectorRegistry.java	2008-04-04 09:40:17 UTC (rev 4006)
+++ trunk/src/main/org/jboss/messaging/core/remoting/ConnectorRegistry.java	2008-04-04 11:01:48 UTC (rev 4007)
@@ -64,4 +64,6 @@
    int getRegisteredConfigurationSize();
 
    int getConnectorCount(Configuration config);
+
+   void clear();
 }
\ No newline at end of file

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/ConnectorRegistryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/ConnectorRegistryImpl.java	2008-04-04 09:40:17 UTC (rev 4006)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/ConnectorRegistryImpl.java	2008-04-04 11:01:48 UTC (rev 4007)
@@ -195,6 +195,11 @@
       return holder.getCount();
    }
 
+   public void clear()
+   {
+      connectors.clear();
+   }
+
    // Constructors --------------------------------------------------
 
    // Public --------------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java	2008-04-04 09:40:17 UTC (rev 4006)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java	2008-04-04 11:01:48 UTC (rev 4007)
@@ -31,6 +31,7 @@
 import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionResponse;
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.security.SecurityStore;
+import org.jboss.messaging.core.security.JBMSecurityManager;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.core.version.Version;
@@ -80,6 +81,8 @@
    
    SecurityStore getSecurityStore();
 
+   public JBMSecurityManager getSecurityManager();
+
    HierarchicalRepository<QueueSettings> getQueueSettingsRepository();
 
    void setPostOffice(PostOffice postOffice);

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-04-04 09:40:17 UTC (rev 4006)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-04-04 11:01:48 UTC (rev 4007)
@@ -41,6 +41,7 @@
 import org.jboss.messaging.core.postoffice.impl.PostOfficeImpl;
 import org.jboss.messaging.core.remoting.Interceptor;
 import org.jboss.messaging.core.remoting.RemotingService;
+import org.jboss.messaging.core.remoting.ConnectorRegistrySingleton;
 import org.jboss.messaging.core.remoting.impl.mina.MinaService;
 import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionResponse;
 import org.jboss.messaging.core.security.JBMSecurityManager;
@@ -232,6 +233,7 @@
       {
          remotingService.stop();
       }
+      ConnectorRegistrySingleton.REGISTRY.clear();
    }
 
    // MessagingServer implementation -----------------------------------------------------------
@@ -311,6 +313,10 @@
    	return securityStore;
    }
 
+   public JBMSecurityManager getSecurityManager()
+   {
+      return securityManager;
+   }
 
    public void setSecurityManager(JBMSecurityManager securityManager)
    {

Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java	2008-04-04 09:40:17 UTC (rev 4006)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java	2008-04-04 11:01:48 UTC (rev 4007)
@@ -670,4 +670,9 @@
    {
       return messagingServerManagement.getConsumerCountForQueue(queue.getAddress());
    }
+
+   public void setInitialContext(InitialContext initialContext)
+   {
+      this.initialContext = initialContext;
+   }
 }

Added: trunk/tests/src/org/jboss/messaging/jms/server/impl/test/unit/JMSServerManagerimplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/jms/server/impl/test/unit/JMSServerManagerimplTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/jms/server/impl/test/unit/JMSServerManagerimplTest.java	2008-04-04 11:01:48 UTC (rev 4007)
@@ -0,0 +1,983 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005, JBoss Inc., and individual contributors as indicated
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This is free software; you can redistribute it and/or modify it
+   * under the terms of the GNU Lesser General Public License as
+   * published by the Free Software Foundation; either version 2.1 of
+   * the License, or (at your option) any later version.
+   *
+   * This software is distributed in the hope that it will be useful,
+   * but WITHOUT ANY WARRANTY; without even the implied warranty of
+   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   * Lesser General Public License for more details.
+   *
+   * You should have received a copy of the GNU Lesser General Public
+   * License along with this software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+package org.jboss.messaging.jms.server.impl.test.unit;
+
+import junit.framework.TestCase;
+import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.ConnectionInfo;
+import org.jboss.messaging.jms.server.SubscriptionInfo;
+import org.jboss.messaging.jms.server.MessageStatistics;
+import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
+import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.core.management.impl.MessagingServerManagementImpl;
+import static org.jboss.messaging.core.remoting.TransportType.INVM;
+import org.jboss.messaging.core.security.JBMUpdateableSecurityManager;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.test.messaging.tools.container.Constants;
+import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
+
+import javax.jms.*;
+import javax.naming.NameNotFoundException;
+import javax.naming.InitialContext;
+import java.util.Hashtable;
+import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * JMSServerManagerImpl tests
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class JMSServerManagerimplTest extends TestCase
+{
+   private JMSServerManagerImpl jmsServerManager;
+   private InitialContext initialContext;
+   private MessagingServer messagingServer;
+
+   protected void setUp() throws Exception
+   {
+      jmsServerManager = new JMSServerManagerImpl();
+      MessagingServerManagementImpl messagingServerManagement = new MessagingServerManagementImpl();
+      ConfigurationImpl conf = new ConfigurationImpl();
+      conf.setInvmDisabled(false);
+      conf.setTransport(INVM);
+      messagingServer = new MessagingServerImpl(conf);
+      messagingServer.start();
+      jmsServerManager.setMessagingServerManagement(messagingServerManagement);
+      messagingServerManagement.setMessagingServer(messagingServer);
+      Hashtable env = new Hashtable();
+      env.put("java.naming.factory.initial",
+              "org.jboss.test.messaging.tools.container.InVMSingleInitialContextFactory");
+      initialContext = new InitialContext(env);
+      jmsServerManager.setInitialContext(initialContext);
+   }
+
+   protected void tearDown() throws Exception
+   {
+      //InVMInitialContextFactory.reset();
+      messagingServer.stop();
+      jmsServerManager = null;
+      messagingServer = null;
+   }
+
+   public void testIsStarted()
+   {
+      assertTrue(jmsServerManager.isStarted());
+   }
+
+   public void testCreateAndDestroyQueue() throws Exception
+   {
+      jmsServerManager.createQueue("anewtestqueue", "anewtestqueue");
+      Queue q = (Queue) initialContext.lookup("anewtestqueue");
+      assertNotNull(q);
+      jmsServerManager.destroyQueue("anewtestqueue");
+      try
+      {
+         initialContext.lookup("anewtestqueue");
+         fail("should throw eception");
+      }
+      catch (NameNotFoundException e)
+      {
+         //pass
+      }
+      jmsServerManager.createQueue("anewtestqueue", "/anewtestqueue");
+      q = (Queue) initialContext.lookup("/anewtestqueue");
+      assertNotNull(q);
+      jmsServerManager.destroyQueue("anewtestqueue");
+      try
+      {
+         initialContext.lookup("/anewtestqueue");
+         fail("should throw eception");
+      }
+      catch (NameNotFoundException e)
+      {
+         //pass
+      }
+
+      jmsServerManager.createQueue("anewtestqueue", "/queues/anewtestqueue");
+      initialContext.lookup("/queues/anewtestqueue");
+      assertNotNull(q);
+      jmsServerManager.destroyQueue("anewtestqueue");
+      try
+      {
+         initialContext.lookup("/queues/newtestqueue");
+         fail("should throw eception");
+      }
+      catch (NameNotFoundException e)
+      {
+         //pass
+      }
+
+      jmsServerManager.createQueue("anewtestqueue", "/queues/and/anewtestqueue");
+      q = (Queue) initialContext.lookup("/queues/and/anewtestqueue");
+      assertNotNull(q);
+      jmsServerManager.destroyQueue("anewtestqueue");
+      try
+      {
+         initialContext.lookup("/queues/and/anewtestqueue");
+         fail("should throw eception");
+      }
+      catch (NameNotFoundException e)
+      {
+         //pass
+      }
+   }
+
+    public void testCreateAndDestroyTopic() throws Exception
+   {
+      jmsServerManager.createTopic("anewtesttopic", "anewtesttopic");
+      Topic q = (Topic) initialContext.lookup("anewtesttopic");
+      assertNotNull(q);
+      jmsServerManager.destroyTopic("anewtesttopic");
+      try
+      {
+         q = (Topic) initialContext.lookup("anewtesttopic");
+         fail("should throw eception");
+      }
+      catch (NameNotFoundException e)
+      {
+         //pass
+      }
+      jmsServerManager.createTopic("anewtesttopic", "/anewtesttopic");
+      q = (Topic) initialContext.lookup("/anewtesttopic");
+      assertNotNull(q);
+      jmsServerManager.destroyTopic("anewtesttopic");
+      try
+      {
+         q = (Topic) initialContext.lookup("/anewtesttopic");
+         fail("should throw eception");
+      }
+      catch (NameNotFoundException e)
+      {
+         //pass
+      }
+
+      jmsServerManager.createTopic("anewtesttopic", "/topics/anewtesttopic");
+      q = (Topic) initialContext.lookup("/topics/anewtesttopic");
+      assertNotNull(q);
+      jmsServerManager.destroyTopic("anewtesttopic");
+      try
+      {
+         q = (Topic) initialContext.lookup("/topics/newtesttopic");
+         fail("should throw eception");
+      }
+      catch (NameNotFoundException e)
+      {
+         //pass
+      }
+
+      jmsServerManager.createTopic("anewtesttopic", "/topics/and/anewtesttopic");
+      q = (Topic) initialContext.lookup("/topics/and/anewtesttopic");
+      assertNotNull(q);
+      jmsServerManager.destroyTopic("anewtesttopic");
+      try
+      {
+         q = (Topic) initialContext.lookup("/topics/and/anewtesttopic");
+         fail("should throw eception");
+      }
+      catch (NameNotFoundException e)
+      {
+         //pass
+      }
+   }
+
+   public void testListAllQueues() throws Exception
+   {
+      ArrayList queuesAdded = new ArrayList();
+      for(int i = 0; i < 100; i++)
+      {
+         jmsServerManager.createQueue("aq" + i, "/aq"+ i);
+         queuesAdded.add("aq" + i);
+      }
+      Set<String> queueNames = jmsServerManager.listAllQueues();
+      for (Object o : queuesAdded)
+      {
+         assertTrue(queueNames.remove(o));
+      }
+      assertTrue(queueNames.isEmpty());
+   }
+
+   public void testListAllTopics() throws Exception
+   {
+      ArrayList topicsAdded = new ArrayList();
+      for(int i = 0; i < 100; i++)
+      {
+         jmsServerManager.createTopic("at" + i, "/at"+ i);
+         topicsAdded.add("at" + i);
+      }
+      Set<String> topicNames = jmsServerManager.listAllTopics();
+      for (Object o : topicsAdded)
+      {
+         assertTrue(topicNames.remove(o));
+      }
+      assertTrue(topicNames.isEmpty());
+   }
+
+   public void testCreateAndDestroyConnectionFactory() throws Exception
+   {
+      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, "newtestcf");
+      JBossConnectionFactory jbcf = (JBossConnectionFactory) initialContext.lookup("newtestcf");
+      assertNotNull(jbcf);
+      assertNotNull(jbcf.getDelegate());
+      jmsServerManager.destroyConnectionFactory("newtestcf");
+      try
+      {
+         initialContext.lookup("newtestcf");
+         fail("should throw exception");
+      }
+      catch (NameNotFoundException e)
+      {
+         //pass
+      }
+      ArrayList<String> bindings = new ArrayList<String>();
+      bindings.add("oranewtestcf");
+      bindings.add("newtestcf");
+      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, bindings);
+      jbcf = (JBossConnectionFactory) initialContext.lookup("newtestcf");
+      assertNotNull(jbcf);
+      assertNotNull(jbcf.getDelegate());
+      jbcf = (JBossConnectionFactory) initialContext.lookup("oranewtestcf");
+      assertNotNull(jbcf);
+      assertNotNull(jbcf.getDelegate());
+      jmsServerManager.destroyConnectionFactory("newtestcf");
+      try
+      {
+         initialContext.lookup("newtestcf");
+         fail("should throw exception");
+      }
+      catch (NameNotFoundException e)
+      {
+         //pass
+      }
+      try
+      {
+         initialContext.lookup("oranewtestcf");
+         fail("should throw exception");
+      }
+      catch (NameNotFoundException e)
+      {
+         //pass
+      }
+   }
+
+   public void testGetConnections() throws Exception
+   {
+      ArrayList<String> bindings = new ArrayList<String>();
+      bindings.add("cf");
+      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, bindings );
+      JBossConnectionFactory connectionFactory = (JBossConnectionFactory) initialContext.lookup("cf");
+
+      Connection conn = connectionFactory.createConnection("guest", "guest");
+      List<ConnectionInfo> connectionInfos = jmsServerManager.getConnections();
+      assertNotNull(connectionInfos);
+      assertEquals(1, connectionInfos.size());
+      ConnectionInfo connectionInfo = connectionInfos.get(0);
+      assertEquals("guest", connectionInfo.getUser());
+      assertEquals(ConnectionInfo.status.STOPPED, connectionInfo.getStatus());
+      conn.start();
+      // starting a connection is a remoting async operation
+      // wait a little before querying clients infos from the server
+      //sleepIfRemoting(250);
+      connectionInfos = jmsServerManager.getConnections();
+      assertNotNull(connectionInfos);
+      assertEquals(1, connectionInfos.size());
+      connectionInfo = connectionInfos.get(0);
+      assertEquals(ConnectionInfo.status.STARTED, connectionInfo.getStatus());
+      connectionInfo.getAddress();
+      connectionInfo.getTimeCreated();
+      connectionInfo.getAliveTime();
+      conn.close();
+      connectionInfos = jmsServerManager.getConnections();
+      assertNotNull(connectionInfos);
+      assertEquals(0, connectionInfos.size());
+      Connection conn2 = connectionFactory.createConnection("guest", "guest");
+      Connection conn3 = connectionFactory.createConnection("guest", "guest");
+      connectionInfos = jmsServerManager.getConnections();
+      assertNotNull(connectionInfos);
+      assertEquals(2, connectionInfos.size());
+      conn2.close();
+      connectionInfos = jmsServerManager.getConnections();
+      assertNotNull(connectionInfos);
+      assertEquals(1, connectionInfos.size());
+      conn3.close();
+      connectionInfos = jmsServerManager.getConnections();
+      assertNotNull(connectionInfos);
+      assertEquals(0, connectionInfos.size());
+   }
+
+   public void testGetConnectionsForUser() throws Exception
+   {
+      ArrayList<String> bindings = new ArrayList<String>();
+      bindings.add("cf");
+      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, bindings );
+      JBossConnectionFactory connectionFactory = (JBossConnectionFactory) initialContext.lookup("cf");
+
+      Connection conn = connectionFactory.createConnection("guest", "guest");
+      Connection conn2 = connectionFactory.createConnection();
+      Connection conn3 = connectionFactory.createConnection();
+      Connection conn4 = connectionFactory.createConnection("guest", "guest");
+      Connection conn5 = connectionFactory.createConnection("guest", "guest");
+
+      try
+      {
+         List<ConnectionInfo> connectionInfos = jmsServerManager.getConnectionsForUser("guest");
+         assertNotNull(connectionInfos);
+         assertEquals(connectionInfos.size(), 3);
+         for (ConnectionInfo connectionInfo : connectionInfos)
+         {
+            assertEquals(connectionInfo.getUser(), "guest");
+         }
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+         if (conn2 != null)
+         {
+            conn2.close();
+         }
+         if (conn3 != null)
+         {
+            conn3.close();
+         }
+         if (conn4 != null)
+         {
+            conn4.close();
+         }
+         if (conn5 != null)
+         {
+            conn5.close();
+         }
+      }
+
+   }
+
+   public void testDropConnectionForId() throws Exception
+   {
+      JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingServer.getSecurityManager();
+      securityManager.addUser("john", "needle");
+      ArrayList<String> bindings = new ArrayList<String>();
+      bindings.add("cf");
+      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, bindings );
+      JBossConnectionFactory connectionFactory = (JBossConnectionFactory) initialContext.lookup("cf");
+
+      Connection conn = connectionFactory.createConnection("guest", "guest");
+      Connection conn2 = connectionFactory.createConnection();
+      Connection conn3 = connectionFactory.createConnection();
+      Connection conn4 = connectionFactory.createConnection("john", "needle");
+      Connection conn5 = connectionFactory.createConnection("guest", "guest");
+      String id = conn4.getClientID();
+      try
+      {
+
+         List<ConnectionInfo> connectionInfos = jmsServerManager.getConnectionsForUser("john");
+         assertEquals(connectionInfos.size(), 1);
+         jmsServerManager.dropConnection(connectionInfos.get(0).getId());
+         connectionInfos = jmsServerManager.getConnections();
+         assertNotNull(connectionInfos);
+         assertEquals(connectionInfos.size(), 4);
+         for (ConnectionInfo connectionInfo : connectionInfos)
+         {
+            assertNotSame(connectionInfo.getUser(), "john");
+         }
+         try
+         {
+            conn4.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            fail("Should throw exception");
+         }
+         catch (JMSException e)
+         {
+            //pass
+         }
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+         if (conn2 != null)
+         {
+            conn2.close();
+         }
+         if (conn3 != null)
+         {
+            conn3.close();
+         }
+         if (conn5 != null)
+         {
+            conn5.close();
+         }
+      }
+
+   }
+
+   public void testDropConnectionForUser() throws Exception
+   {
+      JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingServer.getSecurityManager();
+      securityManager.addUser("john", "needle");
+      ArrayList<String> bindings = new ArrayList<String>();
+      bindings.add("cf");
+      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, bindings );
+      JBossConnectionFactory connectionFactory = (JBossConnectionFactory) initialContext.lookup("cf");
+
+      Connection conn = connectionFactory.createConnection("guest", "guest");
+      Connection conn2 = connectionFactory.createConnection();
+      Connection conn3 = connectionFactory.createConnection();
+      Connection conn4 = connectionFactory.createConnection("john", "needle");
+      Connection conn5 = connectionFactory.createConnection("guest", "guest");
+      String id = conn4.getClientID();
+      try
+      {
+         jmsServerManager.dropConnectionsForUser("guest");
+         List<ConnectionInfo> connectionInfos = jmsServerManager.getConnections();
+         assertNotNull(connectionInfos);
+         assertEquals(connectionInfos.size(), 3);
+         for (ConnectionInfo connectionInfo : connectionInfos)
+         {
+            assertNotSame(connectionInfo.getUser(), "guest");
+         }
+         try
+         {
+            conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            fail("Should throw exception");
+         }
+         catch (JMSException e)
+         {
+            //pass
+         }
+         try
+         {
+            conn5.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            fail("Should throw exception");
+         }
+         catch (JMSException e)
+         {
+            //pass
+         }
+      }
+      finally
+      {
+         if (conn2 != null)
+         {
+            conn2.close();
+         }
+         if (conn3 != null)
+         {
+            conn3.close();
+         }
+         if (conn4 != null)
+         {
+            conn4.close();
+         }
+      }
+
+   }
+
+   public void testListMessagesForQueue() throws Exception
+   {
+      ArrayList<String> bindings = new ArrayList<String>();
+      bindings.add("cf");
+      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, bindings );
+      JBossConnectionFactory connectionFactory = (JBossConnectionFactory) initialContext.lookup("cf");
+      jmsServerManager.createQueue("Queue1", "/queue1");
+      Queue queue1 = (Queue) initialContext.lookup("/queue1");
+      Connection conn = connectionFactory.createConnection("guest", "guest");
+      try
+      {
+         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageProducer producer = sess.createProducer(queue1);
+         producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+         for (int i = 0; i < 10; i++)
+         {
+            TextMessage message = sess.createTextMessage();
+            message.setIntProperty("count", i);
+            producer.send(message);
+         }
+         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
+         for (int i = 10; i < 20; i++)
+         {
+            TextMessage message = sess.createTextMessage();
+            message.setIntProperty("count", i);
+            producer.send(message);
+         }
+         List<Message> messageList = jmsServerManager.listMessagesForQueue("Queue1");
+         assertEquals(messageList.size(), 20);
+         for (int i = 0; i < messageList.size(); i++)
+         {
+            Message message = messageList.get(i);
+            assertEquals(message.getIntProperty("count"), i);
+            assertTrue(message instanceof TextMessage);
+         }
+         messageList = jmsServerManager.listMessagesForQueue("Queue1", JMSServerManager.ListType.NON_DURABLE);
+         assertEquals(messageList.size(), 10);
+         for (int i = 0; i < messageList.size(); i++)
+         {
+            Message message = messageList.get(i);
+            assertEquals(message.getIntProperty("count"), i);
+            assertTrue(message instanceof TextMessage);
+            assertTrue(message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT);
+         }
+         messageList = jmsServerManager.listMessagesForQueue("Queue1", JMSServerManager.ListType.DURABLE);
+         assertEquals(messageList.size(), 10);
+         for (int i = 10; i < messageList.size() + 10; i++)
+         {
+            Message message = messageList.get(i - 10);
+            assertEquals(message.getIntProperty("count"), i);
+            assertTrue(message instanceof TextMessage);
+            assertTrue(message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT);
+         }
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+   }
+
+   //   public void testRemoveMessageFromQueue() throws Exception
+//   {
+//      Connection conn = getConnectionFactory().createConnection("guest", "guest");
+//      try
+//      {
+//         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//         MessageProducer producer = sess.createProducer(queue1);
+//         Message messageToDelete = null;
+//         for (int i = 0; i < 10; i++)
+//         {
+//            TextMessage message = sess.createTextMessage();
+//            message.setIntProperty("pos", i);
+//            producer.send(message);
+//            if (i == 5)
+//            {
+//               messageToDelete = message;
+//            }
+//         }
+//         jmsServerManager.removeMessageFromQueue("Queue1", messageToDelete.getJMSMessageID());
+//         sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
+//         MessageConsumer consumer = sess.createConsumer(queue1);
+//         conn.start();
+//         int lastPos = -1;
+//         for (int i = 0; i < 9; i++)
+//         {
+//            Message message = consumer.receive();
+//            assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
+//            int pos = message.getIntProperty("pos");
+//            assertTrue("returned in wrong order", pos > lastPos);
+//            lastPos = pos;
+//         }
+//      }
+//      finally
+//      {
+//         if (conn != null)
+//         {
+//            conn.close();
+//         }
+//      }
+//   }
+
+//   public void testRemoveMessageFromTopic() throws Exception
+//   {
+//      Connection conn = getConnectionFactory().createConnection("guest", "guest");
+//      try
+//      {
+//         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//         MessageProducer producer = sess.createProducer(topic1);
+//         MessageConsumer consumer = sess.createConsumer(topic1);
+//         MessageConsumer consumer2 = sess.createConsumer(topic1);
+//         Message messageToDelete = null;
+//         for (int i = 0; i < 10; i++)
+//         {
+//            TextMessage message = sess.createTextMessage();
+//            producer.send(message);
+//            if (i == 5)
+//            {
+//               messageToDelete = message;
+//            }
+//         }
+//         jmsServerManager.removeMessageFromTopic("Topic1", messageToDelete.getJMSMessageID());
+//         conn.start();
+//         for (int i = 0; i < 9; i++)
+//         {
+//            Message message = consumer.receive();
+//            assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
+//            message = consumer2.receive();
+//            assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
+//         }
+//      }
+//      finally
+//      {
+//         if (conn != null)
+//         {
+//            conn.close();
+//         }
+//      }
+//
+//   }
+
+//   public void testRemoveAllMessagesFromQueue() throws Exception
+//   {
+//      Connection conn = getConnectionFactory().createConnection("guest", "guest");
+//
+//      ServerManagement.getServer(0).createQueue("myQueue", null);
+//
+//      Queue queue = (Queue)this.getInitialContext().lookup("/queue/myQueue");
+//
+//      try
+//      {
+//         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//         MessageProducer producer = sess.createProducer(queue);
+//         for (int i = 0; i < 10; i++)
+//         {
+//            TextMessage message = sess.createTextMessage();
+//            producer.send(message);
+//         }
+//         jmsServerManager.removeAllMessagesForQueue("myQueue");
+//         sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
+//         MessageConsumer consumer = sess.createConsumer(queue);
+//         assertEquals("messages still exist", 0, jmsServerManager.getMessageCountForQueue("myQueue"));
+//
+//      }
+//      finally
+//      {
+//         if (conn != null)
+//         {
+//            conn.close();
+//         }
+//
+//         try
+//         {
+//         	ServerManagement.getServer(0).destroyQueue("myQueue", null);
+//         }
+//         catch (Exception ignore)
+//         {
+//         }
+//      }
+//   }
+
+   public void testListMessagesForSubscription() throws Exception
+   {
+      ArrayList<String> bindings = new ArrayList<String>();
+      bindings.add("cf");
+      jmsServerManager.createConnectionFactory("newtestcf", null, 100, true, 1000, -1, 1000, -1, bindings );
+      JBossConnectionFactory connectionFactory = (JBossConnectionFactory) initialContext.lookup("cf");
+      jmsServerManager.createTopic("topic1", "/topic1");
+      Topic topic1 = (Topic) initialContext.lookup("/topic1");
+      Connection conn = connectionFactory.createConnection("guest", "guest");
+      try
+      {
+         String cid = "myclientid";
+         String id = "mysubid";
+         conn.setClientID(cid);
+         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         TopicSubscriber subscriber = sess.createDurableSubscriber(topic1, id);
+         MessageProducer producer = sess.createProducer(topic1);
+
+         producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+         for (int i = 0; i < 10; i++)
+         {
+            TextMessage message = sess.createTextMessage();
+            message.setIntProperty("count", i);
+            producer.send(message);
+         }
+         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
+         for (int i = 10; i < 20; i++)
+         {
+            TextMessage message = sess.createTextMessage();
+            message.setIntProperty("count", i);
+            producer.send(message);
+         }
+
+         assertEquals(20, jmsServerManager.listMessagesForSubscription(cid + "." + id).size());
+         assertEquals(10, jmsServerManager.listMessagesForSubscription(cid + "." + id, JMSServerManager.ListType.DURABLE).size());
+         assertEquals(10, jmsServerManager.listMessagesForSubscription(cid + "." + id, JMSServerManager.ListType.NON_DURABLE).size());
+         subscriber.close();
+         sess.unsubscribe(id);
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+   }
+
+//   public void testMoveMessage() throws Exception
+//   {
+//      Connection conn = getConnectionFactory().createConnection("guest", "guest");
+//      try
+//      {
+//         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//         MessageProducer producer = sess.createProducer(queue1);
+//         Message messageToMove = null;
+//         for (int i = 0; i < 10; i++)
+//         {
+//            TextMessage message = sess.createTextMessage();
+//            producer.send(message);
+//            if (i == 5)
+//            {
+//               messageToMove = message;
+//            }
+//         }
+//         jmsServerManager.moveMessage("Queue1", "Queue2", messageToMove.getJMSMessageID());
+//         MessageConsumer consumer = sess.createConsumer(queue1);
+//         conn.start();
+//         for (int i = 0; i < 9; i++)
+//         {
+//            Message message = consumer.receive();
+//            assertNotSame(messageToMove.getJMSMessageID(), message.getJMSMessageID());
+//         }
+//         consumer.close();
+//         consumer = sess.createConsumer(queue2);
+//         Message message = consumer.receive();
+//         assertEquals(messageToMove.getJMSMessageID(), message.getJMSMessageID());
+//      }
+//      finally
+//      {
+//         if (conn != null)
+//         {
+//            conn.close();
+//         }
+//      }
+//
+//   }
+
+
+   public void testRemoveAllMessagesFromTopic() throws Exception
+   {
+      ArrayList<String> bindings = new ArrayList<String>();
+      bindings.add("cf");
+      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, bindings );
+      JBossConnectionFactory connectionFactory = (JBossConnectionFactory) initialContext.lookup("cf");
+      Connection conn = connectionFactory.createConnection("guest", "guest");
+      jmsServerManager.createTopic("topic1", "/topic1");
+      Topic topic1 = (Topic) initialContext.lookup("/topic1");
+      try
+      {
+         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageProducer producer = sess.createProducer(topic1);
+         MessageConsumer consumer = sess.createConsumer(topic1);
+         MessageConsumer consumer2 = sess.createConsumer(topic1);
+         Message messageToDelete = null;
+         for (int i = 0; i < 10; i++)
+         {
+            TextMessage message = sess.createTextMessage();
+            producer.send(message);
+            if (i == 5)
+            {
+               messageToDelete = message;
+            }
+         }
+         jmsServerManager.removeAllMessagesForTopic("Topic1");
+         List<SubscriptionInfo> subscriptionInfos = jmsServerManager.listSubscriptions("Topic1");
+         for (SubscriptionInfo subscriptionInfo : subscriptionInfos)
+         {
+            assertEquals(0, jmsServerManager.listMessagesForSubscription(subscriptionInfo.getId()).size());
+         }
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+
+   }
+
+//   public void testChangeMessagePriority() throws Exception
+//   {
+//      Connection conn = getConnectionFactory().createConnection("guest", "guest");
+//      try
+//      {
+//         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//         MessageProducer producer = sess.createProducer(queue1);
+//         producer.setPriority(9);
+//         Message messageToMove = null;
+//         for (int i = 0; i < 10; i++)
+//         {
+//            TextMessage message = sess.createTextMessage();
+//
+//            producer.send(message);
+//            if (i == 5)
+//            {
+//               messageToMove = message;
+//            }
+//         }
+//         jmsServerManager.changeMessagePriority("Queue1", messageToMove.getJMSMessageID(), 8);
+//         MessageConsumer consumer = sess.createConsumer(queue1);
+//         conn.start();
+//         for (int i = 0; i < 9; i++)
+//         {
+//            Message message = consumer.receive();
+//            assertNotSame(messageToMove.getJMSMessageID(), message.getJMSMessageID());
+//            System.out.println("message.getJMSPriority() = " + message.getJMSPriority());
+//            assertEquals(9, message.getJMSPriority());
+//         }
+//         Message message = consumer.receive();
+//         assertEquals(8, message.getJMSPriority());
+//         assertEquals(messageToMove.getJMSMessageID(), message.getJMSMessageID());
+//
+//         consumer.close();
+//
+//      }
+//      finally
+//      {
+//         if (conn != null)
+//         {
+//            conn.close();
+//         }
+//      }
+//
+//   }
+
+   
+   public void testExpireMessage() throws Exception
+   {
+      ArrayList<String> bindings = new ArrayList<String>();
+      bindings.add("cf");
+      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, bindings );
+      JBossConnectionFactory connectionFactory = (JBossConnectionFactory) initialContext.lookup("cf");
+      Connection conn = connectionFactory.createConnection("guest", "guest");
+      jmsServerManager.createQueue("QueueWithOwnDLQAndExpiryQueue", "/queue/QueueWithOwnDLQAndExpiryQueue");
+      jmsServerManager.createQueue("PrivateExpiryQueue", "/queue/PrivateExpiryQueue");
+      
+      try
+      {
+         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         Queue q = (Queue) initialContext.lookup("/queue/QueueWithOwnDLQAndExpiryQueue");
+         MessageProducer producer = sess.createProducer(q);
+         Message messageToMove = null;
+         for (int i = 0; i < 10; i++)
+         {
+            TextMessage message = sess.createTextMessage();
+            producer.send(message);
+            if (i == 5)
+            {
+               messageToMove = message;
+            }
+         }
+         jmsServerManager.expireMessage("QueueWithOwnDLQAndExpiryQueue", messageToMove.getJMSMessageID());
+         MessageConsumer consumer = sess.createConsumer(q);
+         conn.start();
+         for (int i = 0; i < 9; i++)
+         {
+            Message message = consumer.receive();
+            assertNotSame(messageToMove.getJMSMessageID(), message.getJMSMessageID());
+         }
+         consumer.close();
+         Queue expQueue = (Queue) initialContext.lookup("/queue/PrivateExpiryQueue");
+         consumer = sess.createConsumer(expQueue);
+         Message message = consumer.receive();
+         assertEquals(messageToMove.getJMSMessageID(), message.getJMSMessageID());
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+
+   }
+
+   public void testMessageStatistics() throws Exception
+   {
+      ArrayList<String> bindings = new ArrayList<String>();
+      bindings.add("cf");
+      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, bindings );
+      JBossConnectionFactory connectionFactory = (JBossConnectionFactory) initialContext.lookup("cf");
+      Connection conn = connectionFactory.createConnection("guest", "guest");
+      try
+      {
+         jmsServerManager.createQueue("CountQueue", "/queue/CountQueue");
+         Queue queue1 = (Queue) initialContext.lookup("/queue/CountQueue");
+         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageProducer producer = sess.createProducer(queue1);
+
+         TextMessage message = sess.createTextMessage();
+         for(int i = 0; i < 100; i++)
+         {
+            producer.send(message);
+         }
+         jmsServerManager.startGatheringStatisticsForQueue("CountQueue");
+         for(int i = 0; i < 100; i++)
+         {
+            producer.send(message);
+         }
+         List<MessageStatistics> messageStatistics = jmsServerManager.getStatistics();
+         assertTrue(messageStatistics != null && messageStatistics.size() ==1);
+         assertEquals(messageStatistics.get(0).getCount(), 100);
+         assertEquals(messageStatistics.get(0).getTotalMessageCount(), 200);
+         assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 200);
+         MessageConsumer consumer = sess.createConsumer(queue1);
+         conn.start();
+         for(int i = 0; i < 50; i++)
+         {
+            consumer.receive();
+         }
+         messageStatistics = jmsServerManager.getStatistics();
+         assertEquals(messageStatistics.get(0).getCount(), 100);
+         assertEquals(messageStatistics.get(0).getTotalMessageCount(), 200);
+         assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 150);
+         consumer.close();
+         for(int i = 0; i < 50; i++)
+         {
+            producer.send(message);
+         }
+         messageStatistics = jmsServerManager.getStatistics();
+         assertEquals(messageStatistics.get(0).getCount(), 150);
+         assertEquals(messageStatistics.get(0).getTotalMessageCount(), 250);
+         assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 200);
+
+         consumer = sess.createConsumer(queue1);
+         conn.start();
+         for(int i = 0; i < 200; i++)
+         {
+            consumer.receive();
+         }
+         messageStatistics = jmsServerManager.getStatistics();
+         assertEquals(messageStatistics.get(0).getCount(), 150);
+         assertEquals(messageStatistics.get(0).getTotalMessageCount(), 250);
+         assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 0);
+         consumer.close();
+         jmsServerManager.stopGatheringStatisticsForQueue("CountQueue");
+         messageStatistics = jmsServerManager.getStatistics();
+         assertTrue(messageStatistics != null && messageStatistics.size() == 0);
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+
+   }
+}

Deleted: trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java	2008-04-04 09:40:17 UTC (rev 4006)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java	2008-04-04 11:01:48 UTC (rev 4007)
@@ -1,914 +0,0 @@
-/*
-   * JBoss, Home of Professional Open Source
-   * Copyright 2005, JBoss Inc., and individual contributors as indicated
-   * by the @authors tag. See the copyright.txt in the distribution for a
-   * full listing of individual contributors.
-   *
-   * This is free software; you can redistribute it and/or modify it
-   * under the terms of the GNU Lesser General Public License as
-   * published by the Free Software Foundation; either version 2.1 of
-   * the License, or (at your option) any later version.
-   *
-   * This software is distributed in the hope that it will be useful,
-   * but WITHOUT ANY WARRANTY; without even the implied warranty of
-   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   * Lesser General Public License for more details.
-   *
-   * You should have received a copy of the GNU Lesser General Public
-   * License along with this software; if not, write to the Free
-   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-   */
-package org.jboss.test.messaging.jms.server;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicSubscriber;
-import javax.naming.NameNotFoundException;
-
-import org.jboss.messaging.jms.client.JBossConnectionFactory;
-import org.jboss.messaging.jms.server.ConnectionInfo;
-import org.jboss.messaging.jms.server.JMSServerManager;
-import org.jboss.messaging.jms.server.MessageStatistics;
-import org.jboss.messaging.jms.server.SubscriptionInfo;
-import org.jboss.test.messaging.JBMServerTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-
-/**
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class JMSServerManagerTest extends JBMServerTestCase
-{
-   JMSServerManager jmsServerManager;
-
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-      jmsServerManager = getJmsServerManager();
-   }
-
-   public void testIsStarted()
-   {
-      assertTrue(jmsServerManager.isStarted());
-   }
-
-
-   public void testCreateAndDestroyQueue() throws Exception
-   {
-      jmsServerManager.createQueue("anewtestqueue", "anewtestqueue");
-      Queue q = (Queue) getInitialContext().lookup("anewtestqueue");
-      assertNotNull(q);
-      jmsServerManager.destroyQueue("anewtestqueue");
-      try
-      {
-         getInitialContext().lookup("anewtestqueue");
-         fail("should throw eception");
-      }
-      catch (NameNotFoundException e)
-      {
-         //pass
-      }
-      jmsServerManager.createQueue("anewtestqueue", "/anewtestqueue");
-      q = (Queue) getInitialContext().lookup("/anewtestqueue");
-      assertNotNull(q);
-      jmsServerManager.destroyQueue("anewtestqueue");
-      try
-      {
-         getInitialContext().lookup("/anewtestqueue");
-         fail("should throw eception");
-      }
-      catch (NameNotFoundException e)
-      {
-         //pass
-      }
-
-      jmsServerManager.createQueue("anewtestqueue", "/queues/anewtestqueue");
-      getInitialContext().lookup("/queues/anewtestqueue");
-      assertNotNull(q);
-      jmsServerManager.destroyQueue("anewtestqueue");
-      try
-      {
-         getInitialContext().lookup("/queues/newtestqueue");
-         fail("should throw eception");
-      }
-      catch (NameNotFoundException e)
-      {
-         //pass
-      }
-
-      jmsServerManager.createQueue("anewtestqueue", "/queues/and/anewtestqueue");
-      q = (Queue) getInitialContext().lookup("/queues/and/anewtestqueue");
-      assertNotNull(q);
-      jmsServerManager.destroyQueue("anewtestqueue");
-      try
-      {
-         getInitialContext().lookup("/queues/and/anewtestqueue");
-         fail("should throw eception");
-      }
-      catch (NameNotFoundException e)
-      {
-         //pass
-      }
-   }
-
-   public void testCreateAndDestroyTopic() throws Exception
-   {
-      jmsServerManager.createTopic("anewtesttopic", "anewtesttopic");
-      Topic q = (Topic) getInitialContext().lookup("anewtesttopic");
-      assertNotNull(q);
-      jmsServerManager.destroyTopic("anewtesttopic");
-      try
-      {
-         q = (Topic) getInitialContext().lookup("anewtesttopic");
-         fail("should throw eception");
-      }
-      catch (NameNotFoundException e)
-      {
-         //pass
-      }
-      jmsServerManager.createTopic("anewtesttopic", "/anewtesttopic");
-      q = (Topic) getInitialContext().lookup("/anewtesttopic");
-      assertNotNull(q);
-      jmsServerManager.destroyTopic("anewtesttopic");
-      try
-      {
-         q = (Topic) getInitialContext().lookup("/anewtesttopic");
-         fail("should throw eception");
-      }
-      catch (NameNotFoundException e)
-      {
-         //pass
-      }
-
-      jmsServerManager.createTopic("anewtesttopic", "/topics/anewtesttopic");
-      q = (Topic) getInitialContext().lookup("/topics/anewtesttopic");
-      assertNotNull(q);
-      jmsServerManager.destroyTopic("anewtesttopic");
-      try
-      {
-         q = (Topic) getInitialContext().lookup("/topics/newtesttopic");
-         fail("should throw eception");
-      }
-      catch (NameNotFoundException e)
-      {
-         //pass
-      }
-
-      jmsServerManager.createTopic("anewtesttopic", "/topics/and/anewtesttopic");
-      q = (Topic) getInitialContext().lookup("/topics/and/anewtesttopic");
-      assertNotNull(q);
-      jmsServerManager.destroyTopic("anewtesttopic");
-      try
-      {
-         q = (Topic) getInitialContext().lookup("/topics/and/anewtesttopic");
-         fail("should throw eception");
-      }
-      catch (NameNotFoundException e)
-      {
-         //pass
-      }
-   }
-
-   public void testListAllQueues()
-   {
-      Set<String> queueNames = jmsServerManager.listAllQueues();
-      for (String queueName : queueNames)
-      {
-         System.out.println("queueName = " + queueName);
-      }
-   }
-
-   public void testListAllTopics()
-   {
-      Set<String> topics = jmsServerManager.listAllTopics();
-      for (String queueName : topics)
-      {
-         System.out.println("queueName = " + queueName);
-      }
-   }
-
-   public void testCreateAndDestroyConectionFactory() throws Exception
-   {
-      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, "newtestcf");
-      JBossConnectionFactory jbcf = (JBossConnectionFactory) getInitialContext().lookup("newtestcf");
-      assertNotNull(jbcf);
-      assertNotNull(jbcf.getDelegate());
-      jmsServerManager.destroyConnectionFactory("newtestcf");
-      try
-      {
-         getInitialContext().lookup("newtestcf");
-         fail("should throw exception");
-      }
-      catch (NameNotFoundException e)
-      {
-         //pass
-      }
-      ArrayList<String> bindings = new ArrayList<String>();
-      bindings.add("oranewtestcf");
-      bindings.add("newtestcf");
-      jmsServerManager.createConnectionFactory("newtestcf", "anid", 100, true, 1000, -1, 1000, -1, bindings);
-      jbcf = (JBossConnectionFactory) getInitialContext().lookup("newtestcf");
-      assertNotNull(jbcf);
-      assertNotNull(jbcf.getDelegate());
-      jbcf = (JBossConnectionFactory) getInitialContext().lookup("oranewtestcf");
-      assertNotNull(jbcf);
-      assertNotNull(jbcf.getDelegate());
-      jmsServerManager.destroyConnectionFactory("newtestcf");
-      try
-      {
-         getInitialContext().lookup("newtestcf");
-         fail("should throw exception");
-      }
-      catch (NameNotFoundException e)
-      {
-         //pass
-      }
-      try
-      {
-         getInitialContext().lookup("oranewtestcf");
-         fail("should throw exception");
-      }
-      catch (NameNotFoundException e)
-      {
-         //pass
-      }
-   }
-
-   public void testGetConnections() throws Exception
-   {
-      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-      List<ConnectionInfo> connectionInfos = jmsServerManager.getConnections();
-      assertNotNull(connectionInfos);
-      assertEquals(1, connectionInfos.size());
-      ConnectionInfo connectionInfo = connectionInfos.get(0);
-      assertEquals("guest", connectionInfo.getUser());
-      assertEquals(ConnectionInfo.status.STOPPED, connectionInfo.getStatus());
-      conn.start();
-      // starting a connection is a remoting async operation
-      // wait a little before querying clients infos from the server
-      sleepIfRemoting(250);
-      connectionInfos = jmsServerManager.getConnections();
-      assertNotNull(connectionInfos);
-      assertEquals(1, connectionInfos.size());
-      connectionInfo = connectionInfos.get(0);
-      assertEquals(ConnectionInfo.status.STARTED, connectionInfo.getStatus());
-      connectionInfo.getAddress();
-      connectionInfo.getTimeCreated();
-      connectionInfo.getAliveTime();
-      conn.close();
-      connectionInfos = jmsServerManager.getConnections();
-      assertNotNull(connectionInfos);
-      assertEquals(0, connectionInfos.size());
-      Connection conn2 = getConnectionFactory().createConnection("guest", "guest");
-      Connection conn3 = getConnectionFactory().createConnection("guest", "guest");
-      connectionInfos = jmsServerManager.getConnections();
-      assertNotNull(connectionInfos);
-      assertEquals(2, connectionInfos.size());
-      conn2.close();
-      connectionInfos = jmsServerManager.getConnections();
-      assertNotNull(connectionInfos);
-      assertEquals(1, connectionInfos.size());
-      conn3.close();
-      connectionInfos = jmsServerManager.getConnections();
-      assertNotNull(connectionInfos);
-      assertEquals(0, connectionInfos.size());
-   }
-
-   public void testGetConnectionsForUser() throws Exception
-   {
-      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-      Connection conn2 = getConnectionFactory().createConnection();
-      Connection conn3 = getConnectionFactory().createConnection();
-      Connection conn4 = getConnectionFactory().createConnection("guest", "guest");
-      Connection conn5 = getConnectionFactory().createConnection("guest", "guest");
-
-      try
-      {
-         List<ConnectionInfo> connectionInfos = jmsServerManager.getConnectionsForUser("guest");
-         assertNotNull(connectionInfos);
-         assertEquals(connectionInfos.size(), 3);
-         for (ConnectionInfo connectionInfo : connectionInfos)
-         {
-            assertEquals(connectionInfo.getUser(), "guest");
-         }
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-         if (conn2 != null)
-         {
-            conn2.close();
-         }
-         if (conn3 != null)
-         {
-            conn3.close();
-         }
-         if (conn4 != null)
-         {
-            conn4.close();
-         }
-         if (conn5 != null)
-         {
-            conn5.close();
-         }
-      }
-
-   }
-
-   public void testDropConnectionForId() throws Exception
-   {
-      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-      Connection conn2 = getConnectionFactory().createConnection();
-      Connection conn3 = getConnectionFactory().createConnection();
-      Connection conn4 = getConnectionFactory().createConnection("john", "needle");
-      Connection conn5 = getConnectionFactory().createConnection("guest", "guest");
-      String id = conn4.getClientID();
-      try
-      {
-
-         List<ConnectionInfo> connectionInfos = jmsServerManager.getConnectionsForUser("john");
-         assertEquals(connectionInfos.size(), 1);
-         jmsServerManager.dropConnection(connectionInfos.get(0).getId());
-         connectionInfos = jmsServerManager.getConnections();
-         assertNotNull(connectionInfos);
-         assertEquals(connectionInfos.size(), 4);
-         for (ConnectionInfo connectionInfo : connectionInfos)
-         {
-            assertNotSame(connectionInfo.getUser(), "john");
-         }
-         try
-         {
-            conn4.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            fail("Should throw exception");
-         }
-         catch (JMSException e)
-         {
-            //pass
-         }
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-         if (conn2 != null)
-         {
-            conn2.close();
-         }
-         if (conn3 != null)
-         {
-            conn3.close();
-         }
-         if (conn5 != null)
-         {
-            conn5.close();
-         }
-      }
-
-   }
-
-   public void testDropConnectionForUser() throws Exception
-   {
-      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-      Connection conn2 = getConnectionFactory().createConnection();
-      Connection conn3 = getConnectionFactory().createConnection();
-      Connection conn4 = getConnectionFactory().createConnection("john", "needle");
-      Connection conn5 = getConnectionFactory().createConnection("guest", "guest");
-      String id = conn4.getClientID();
-      try
-      {
-         jmsServerManager.dropConnectionsForUser("guest");
-         List<ConnectionInfo> connectionInfos = jmsServerManager.getConnections();
-         assertNotNull(connectionInfos);
-         assertEquals(connectionInfos.size(), 3);
-         for (ConnectionInfo connectionInfo : connectionInfos)
-         {
-            assertNotSame(connectionInfo.getUser(), "guest");
-         }
-         try
-         {
-            conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            fail("Should throw exception");
-         }
-         catch (JMSException e)
-         {
-            //pass
-         }
-         try
-         {
-            conn5.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            fail("Should throw exception");
-         }
-         catch (JMSException e)
-         {
-            //pass
-         }
-      }
-      finally
-      {
-         if (conn2 != null)
-         {
-            conn2.close();
-         }
-         if (conn3 != null)
-         {
-            conn3.close();
-         }
-         if (conn4 != null)
-         {
-            conn4.close();
-         }
-      }
-
-   }
-
-   public void test() throws Exception
-   {
-      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-      Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-      sess.createConsumer(queue1);
-      jmsServerManager.createQueue("Queue1", "binding");
-      jmsServerManager.getConsumerCountForQueue("Queue1");
-      sess.createConsumer(queue1);
-      sess.createConsumer(queue1);
-      sess.createConsumer(queue1);
-      sess.createConsumer(queue1);
-      sess.createConsumer(queue1);
-      assertEquals(jmsServerManager.getConsumerCountForQueue("Queue1"), 6);
-      conn.close();
-      assertEquals(jmsServerManager.getConsumerCountForQueue("Queue1"), 0);
-      conn = getConnectionFactory().createConnection("guest", "guest");
-      sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-      sess.createConsumer(topic1);
-      conn.close();
-   }
-
-   public void testListMessagesForQueue() throws Exception
-   {
-      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-      try
-      {
-         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = sess.createProducer(queue1);
-         producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-         for (int i = 0; i < 10; i++)
-         {
-            TextMessage message = sess.createTextMessage();
-            message.setIntProperty("count", i);
-            producer.send(message);
-         }
-         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-         for (int i = 10; i < 20; i++)
-         {
-            TextMessage message = sess.createTextMessage();
-            message.setIntProperty("count", i);
-            producer.send(message);
-         }
-         List<Message> messageList = jmsServerManager.listMessagesForQueue("Queue1");
-         assertEquals(messageList.size(), 20);
-         for (int i = 0; i < messageList.size(); i++)
-         {
-            Message message = messageList.get(i);
-            assertEquals(message.getIntProperty("count"), i);
-            assertTrue(message instanceof TextMessage);
-         }
-         messageList = jmsServerManager.listMessagesForQueue("Queue1", JMSServerManager.ListType.NON_DURABLE);
-         assertEquals(messageList.size(), 10);
-         for (int i = 0; i < messageList.size(); i++)
-         {
-            Message message = messageList.get(i);
-            assertEquals(message.getIntProperty("count"), i);
-            assertTrue(message instanceof TextMessage);
-            assertTrue(message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT);
-         }
-         messageList = jmsServerManager.listMessagesForQueue("Queue1", JMSServerManager.ListType.DURABLE);
-         assertEquals(messageList.size(), 10);
-         for (int i = 10; i < messageList.size() + 10; i++)
-         {
-            Message message = messageList.get(i - 10);
-            assertEquals(message.getIntProperty("count"), i);
-            assertTrue(message instanceof TextMessage);
-            assertTrue(message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT);
-         }
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-   }
-
-   public void testListMessagesForSubscription() throws Exception
-   {
-      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-      try
-      {
-         String cid = "myclientid";
-         String id = "mysubid";
-         conn.setClientID(cid);
-         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         TopicSubscriber subscriber = sess.createDurableSubscriber(topic1, id);
-         MessageProducer producer = sess.createProducer(topic1);
-
-         producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-         for (int i = 0; i < 10; i++)
-         {
-            TextMessage message = sess.createTextMessage();
-            message.setIntProperty("count", i);
-            producer.send(message);
-         }
-         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-         for (int i = 10; i < 20; i++)
-         {
-            TextMessage message = sess.createTextMessage();
-            message.setIntProperty("count", i);
-            producer.send(message);
-         }
-
-         assertEquals(20, jmsServerManager.listMessagesForSubscription(cid + "." + id).size());
-         assertEquals(10, jmsServerManager.listMessagesForSubscription(cid + "." + id, JMSServerManager.ListType.DURABLE).size());
-         assertEquals(10, jmsServerManager.listMessagesForSubscription(cid + "." + id, JMSServerManager.ListType.NON_DURABLE).size());
-         subscriber.close();
-         sess.unsubscribe(id);
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-   }
-
-//   public void testRemoveMessageFromQueue() throws Exception
-//   {
-//      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-//      try
-//      {
-//         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//         MessageProducer producer = sess.createProducer(queue1);
-//         Message messageToDelete = null;
-//         for (int i = 0; i < 10; i++)
-//         {
-//            TextMessage message = sess.createTextMessage();
-//            message.setIntProperty("pos", i);
-//            producer.send(message);
-//            if (i == 5)
-//            {
-//               messageToDelete = message;
-//            }
-//         }
-//         jmsServerManager.removeMessageFromQueue("Queue1", messageToDelete.getJMSMessageID());
-//         sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-//         MessageConsumer consumer = sess.createConsumer(queue1);
-//         conn.start();
-//         int lastPos = -1;
-//         for (int i = 0; i < 9; i++)
-//         {
-//            Message message = consumer.receive();
-//            assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
-//            int pos = message.getIntProperty("pos");
-//            assertTrue("returned in wrong order", pos > lastPos);
-//            lastPos = pos;
-//         }
-//      }
-//      finally
-//      {
-//         if (conn != null)
-//         {
-//            conn.close();
-//         }
-//      }
-//   }
-
-//   public void testRemoveMessageFromTopic() throws Exception
-//   {
-//      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-//      try
-//      {
-//         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//         MessageProducer producer = sess.createProducer(topic1);
-//         MessageConsumer consumer = sess.createConsumer(topic1);
-//         MessageConsumer consumer2 = sess.createConsumer(topic1);
-//         Message messageToDelete = null;
-//         for (int i = 0; i < 10; i++)
-//         {
-//            TextMessage message = sess.createTextMessage();
-//            producer.send(message);
-//            if (i == 5)
-//            {
-//               messageToDelete = message;
-//            }
-//         }
-//         jmsServerManager.removeMessageFromTopic("Topic1", messageToDelete.getJMSMessageID());
-//         conn.start();
-//         for (int i = 0; i < 9; i++)
-//         {
-//            Message message = consumer.receive();
-//            assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
-//            message = consumer2.receive();
-//            assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
-//         }
-//      }
-//      finally
-//      {
-//         if (conn != null)
-//         {
-//            conn.close();
-//         }
-//      }
-//
-//   }
-
-//   public void testRemoveAllMessagesFromQueue() throws Exception
-//   {
-//      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-//      
-//      ServerManagement.getServer(0).createQueue("myQueue", null);
-//      
-//      Queue queue = (Queue)this.getInitialContext().lookup("/queue/myQueue");
-//      
-//      try
-//      {
-//         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//         MessageProducer producer = sess.createProducer(queue);
-//         for (int i = 0; i < 10; i++)
-//         {
-//            TextMessage message = sess.createTextMessage();
-//            producer.send(message);
-//         }
-//         jmsServerManager.removeAllMessagesForQueue("myQueue");
-//         sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-//         MessageConsumer consumer = sess.createConsumer(queue);
-//         assertEquals("messages still exist", 0, jmsServerManager.getMessageCountForQueue("myQueue"));
-//
-//      }
-//      finally
-//      {
-//         if (conn != null)
-//         {
-//            conn.close();
-//         }
-//         
-//         try
-//         {
-//         	ServerManagement.getServer(0).destroyQueue("myQueue", null);
-//         }
-//         catch (Exception ignore)
-//         {         	
-//         }
-//      }
-//   }
-
-   public void testRemoveAllMessagesFromTopic() throws Exception
-   {
-      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-      try
-      {
-         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = sess.createProducer(topic1);
-         MessageConsumer consumer = sess.createConsumer(topic1);
-         MessageConsumer consumer2 = sess.createConsumer(topic1);
-         Message messageToDelete = null;
-         for (int i = 0; i < 10; i++)
-         {
-            TextMessage message = sess.createTextMessage();
-            producer.send(message);
-            if (i == 5)
-            {
-               messageToDelete = message;
-            }
-         }
-         jmsServerManager.removeAllMessagesForTopic("Topic1");
-         List<SubscriptionInfo> subscriptionInfos = jmsServerManager.listSubscriptions("Topic1");
-         for (SubscriptionInfo subscriptionInfo : subscriptionInfos)
-         {
-            assertEquals(0, jmsServerManager.listMessagesForSubscription(subscriptionInfo.getId()).size());
-         }
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-
-   }
-
-//   public void testMoveMessage() throws Exception
-//   {
-//      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-//      try
-//      {
-//         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//         MessageProducer producer = sess.createProducer(queue1);
-//         Message messageToMove = null;
-//         for (int i = 0; i < 10; i++)
-//         {
-//            TextMessage message = sess.createTextMessage();
-//            producer.send(message);
-//            if (i == 5)
-//            {
-//               messageToMove = message;
-//            }
-//         }
-//         jmsServerManager.moveMessage("Queue1", "Queue2", messageToMove.getJMSMessageID());
-//         MessageConsumer consumer = sess.createConsumer(queue1);
-//         conn.start();
-//         for (int i = 0; i < 9; i++)
-//         {
-//            Message message = consumer.receive();
-//            assertNotSame(messageToMove.getJMSMessageID(), message.getJMSMessageID());
-//         }
-//         consumer.close();
-//         consumer = sess.createConsumer(queue2);
-//         Message message = consumer.receive();
-//         assertEquals(messageToMove.getJMSMessageID(), message.getJMSMessageID());
-//      }
-//      finally
-//      {
-//         if (conn != null)
-//         {
-//            conn.close();
-//         }
-//      }
-//
-//   }
-
-   public void testExpireMessage() throws Exception
-   {
-      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-      try
-      {
-         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         Queue q = (Queue) getInitialContext().lookup("/queue/QueueWithOwnDLQAndExpiryQueue");
-         MessageProducer producer = sess.createProducer(q);
-         Message messageToMove = null;
-         for (int i = 0; i < 10; i++)
-         {
-            TextMessage message = sess.createTextMessage();
-            producer.send(message);
-            if (i == 5)
-            {
-               messageToMove = message;
-            }
-         }
-         jmsServerManager.expireMessage("QueueWithOwnDLQAndExpiryQueue", messageToMove.getJMSMessageID());
-         MessageConsumer consumer = sess.createConsumer(q);
-         conn.start();
-         for (int i = 0; i < 9; i++)
-         {
-            Message message = consumer.receive();
-            assertNotSame(messageToMove.getJMSMessageID(), message.getJMSMessageID());
-         }
-         consumer.close();
-         Queue expQueue = (Queue) getInitialContext().lookup("/queue/PrivateExpiryQueue");
-         consumer = sess.createConsumer(expQueue);
-         Message message = consumer.receive();
-         assertEquals(messageToMove.getJMSMessageID(), message.getJMSMessageID());
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-
-   }
-
-//   public void testChangeMessagePriority() throws Exception
-//   {
-//      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-//      try
-//      {
-//         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//         MessageProducer producer = sess.createProducer(queue1);
-//         producer.setPriority(9);
-//         Message messageToMove = null;
-//         for (int i = 0; i < 10; i++)
-//         {
-//            TextMessage message = sess.createTextMessage();
-//
-//            producer.send(message);
-//            if (i == 5)
-//            {
-//               messageToMove = message;
-//            }
-//         }
-//         jmsServerManager.changeMessagePriority("Queue1", messageToMove.getJMSMessageID(), 8);
-//         MessageConsumer consumer = sess.createConsumer(queue1);
-//         conn.start();
-//         for (int i = 0; i < 9; i++)
-//         {
-//            Message message = consumer.receive();
-//            assertNotSame(messageToMove.getJMSMessageID(), message.getJMSMessageID());
-//            System.out.println("message.getJMSPriority() = " + message.getJMSPriority());
-//            assertEquals(9, message.getJMSPriority());
-//         }
-//         Message message = consumer.receive();
-//         assertEquals(8, message.getJMSPriority());
-//         assertEquals(messageToMove.getJMSMessageID(), message.getJMSMessageID());
-//
-//         consumer.close();
-//
-//      }
-//      finally
-//      {
-//         if (conn != null)
-//         {
-//            conn.close();
-//         }
-//      }
-//
-//   }
-
-   public void testMessageStatistics() throws Exception
-   {
-      Connection conn = getConnectionFactory().createConnection("guest", "guest");
-      try
-      {
-         jmsServerManager.createQueue("CountQueue", "/queue/CountQueue");
-         Queue queue1 = (Queue) getInitialContext().lookup("/queue/CountQueue");
-         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = sess.createProducer(queue1);
-
-         TextMessage message = sess.createTextMessage();
-         for(int i = 0; i < 100; i++)
-         {
-            producer.send(message);
-         }
-         jmsServerManager.startGatheringStatisticsForQueue("CountQueue");
-         for(int i = 0; i < 100; i++)
-         {
-            producer.send(message);
-         }
-         List<MessageStatistics> messageStatistics = jmsServerManager.getStatistics();
-         assertTrue(messageStatistics != null && messageStatistics.size() ==1);
-         assertEquals(messageStatistics.get(0).getCount(), 100);
-         assertEquals(messageStatistics.get(0).getTotalMessageCount(), 200);
-         assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 200);
-         MessageConsumer consumer = sess.createConsumer(queue1);
-         conn.start();
-         for(int i = 0; i < 50; i++)
-         {
-            consumer.receive();
-         }
-         messageStatistics = jmsServerManager.getStatistics();
-         assertEquals(messageStatistics.get(0).getCount(), 100);
-         assertEquals(messageStatistics.get(0).getTotalMessageCount(), 200);
-         assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 150);
-         consumer.close();
-         for(int i = 0; i < 50; i++)
-         {
-            producer.send(message);
-         }
-         messageStatistics = jmsServerManager.getStatistics();
-         assertEquals(messageStatistics.get(0).getCount(), 150);
-         assertEquals(messageStatistics.get(0).getTotalMessageCount(), 250);
-         assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 200);
-
-         consumer = sess.createConsumer(queue1);
-         conn.start();
-         for(int i = 0; i < 200; i++)
-         {
-            consumer.receive();
-         }
-         messageStatistics = jmsServerManager.getStatistics();
-         assertEquals(messageStatistics.get(0).getCount(), 150);
-         assertEquals(messageStatistics.get(0).getTotalMessageCount(), 250);
-         assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 0);
-         consumer.close();
-         jmsServerManager.stopGatheringStatisticsForQueue("CountQueue");
-         messageStatistics = jmsServerManager.getStatistics();
-         assertTrue(messageStatistics != null && messageStatistics.size() == 0);
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-
-   }
-}

Added: trunk/tests/src/org/jboss/test/messaging/tools/container/InVMSingleInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/InVMSingleInitialContextFactory.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/InVMSingleInitialContextFactory.java	2008-04-04 11:01:48 UTC (rev 4007)
@@ -0,0 +1,38 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005, JBoss Inc., and individual contributors as indicated
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This is free software; you can redistribute it and/or modify it
+   * under the terms of the GNU Lesser General Public License as
+   * published by the Free Software Foundation; either version 2.1 of
+   * the License, or (at your option) any later version.
+   *
+   * This software is distributed in the hope that it will be useful,
+   * but WITHOUT ANY WARRANTY; without even the implied warranty of
+   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   * Lesser General Public License for more details.
+   *
+   * You should have received a copy of the GNU Lesser General Public
+   * License along with this software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+package org.jboss.test.messaging.tools.container;
+
+import javax.naming.spi.InitialContextFactory;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import java.util.Hashtable;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class InVMSingleInitialContextFactory implements InitialContextFactory
+{
+   public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException
+   {
+      return new InVMContext();
+   }
+}




More information about the jboss-cvs-commits mailing list