[jboss-cvs] JBoss Messaging SVN: r2830 - in trunk/tests/src/org/jboss/test/messaging: core/plugin/postoffice and 10 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 3 13:35:17 EDT 2007


Author: timfox
Date: 2007-07-03 13:35:17 -0400 (Tue, 03 Jul 2007)
New Revision: 2830

Added:
   trunk/tests/src/org/jboss/test/messaging/core/postoffice/
   trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java
   trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPostOfficeTest.java
   trunk/tests/src/org/jboss/test/messaging/core/postoffice/PostOfficeTest.java
   trunk/tests/src/org/jboss/test/messaging/core/postoffice/SimpleJChannelFactory.java
   trunk/tests/src/org/jboss/test/messaging/jms/JMSTestBase.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java
   trunk/tests/src/org/jboss/test/messaging/jms/message/MessageTestBase.java
   trunk/tests/src/org/jboss/test/messaging/jms/stress/StressTestBase.java
Removed:
   trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java
   trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/ClusteredPostOfficeTest.java
   trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/PostOfficeTest.java
   trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/SimpleJChannelFactory.java
   trunk/tests/src/org/jboss/test/messaging/jms/base/JMSTestBase.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
   trunk/tests/src/org/jboss/test/messaging/jms/message/base/MessageTestBase.java
   trunk/tests/src/org/jboss/test/messaging/jms/stress/base/StressTestBase.java
Modified:
   trunk/tests/src/org/jboss/test/messaging/core/PostOfficeTestBase.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/MergeQueueTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/RecoverDeliveryTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/message/BytesMessageTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/message/MapMessageTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/message/StreamMessageTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/message/TextMessageTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/message/foreign/ForeignMessageTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/stress/ConnectionConsumerStressTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/stress/QueueStressTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/stress/TopicStressTest.java
Log:
Simplified test directory structure


Modified: trunk/tests/src/org/jboss/test/messaging/core/PostOfficeTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/PostOfficeTestBase.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/core/PostOfficeTestBase.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -45,7 +45,7 @@
 import org.jboss.messaging.core.impl.tx.Transaction;
 import org.jboss.messaging.core.impl.tx.TransactionRepository;
 import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.core.plugin.postoffice.ClusteredPersistenceServiceConfigFileJChannelFactory;
+import org.jboss.test.messaging.core.postoffice.ClusteredPersistenceServiceConfigFileJChannelFactory;
 import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.test.messaging.tools.jmx.ServiceContainer;
 import org.jboss.test.messaging.util.CoreMessageFactory;

Deleted: trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -1,194 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.messaging.core.plugin.postoffice;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.JChannelFactory;
-import org.jboss.messaging.core.impl.jchannelfactory.MultiplexerJChannelFactory;
-import org.jboss.messaging.util.XMLUtil;
-import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
-import org.jboss.test.messaging.tools.jboss.ServiceDeploymentDescriptor;
-import org.jboss.test.messaging.tools.jmx.ServiceConfigHelper;
-import org.jgroups.JChannel;
-import org.w3c.dom.Element;
-
-/**
- * A JChannelFactory that reads the configuration of its synchronous/asynchronous JChannels from a
- * Messaging-style clustered persistence service configuration file (usually shipped with a
- * Messaging installation). The idea is to test with priority whatever we ship.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ClusteredPersistenceServiceConfigFileJChannelFactory implements JChannelFactory
-{
-   // Constants ------------------------------------------------------------------------------------
-
-   public static final Logger log =
-      Logger.getLogger(ClusteredPersistenceServiceConfigFileJChannelFactory.class);
-
-   // Static ---------------------------------------------------------------------------------------
-
-   // Attributes -----------------------------------------------------------------------------------
-
-   private String configFilePath;
-
-   // we're either using a delegate MultiplexerJChannelFactory, if we find one configured in the
-   // file ...
-   private JChannelFactory multiplexorDelegate;
-
-   // ... or just plain XML configuration.
-   private Element controlConfig;
-   private Element dataConfig;
-
-   // Constructors ---------------------------------------------------------------------------------
-
-   /**
-    * @param configFilePath - the configuration file to read JGroups stack configurations from. Must
-    *        be relative to classpath components in order to be found.
-    * @param skipMultiplex - if true, ignore multiplex option, even if a channel factory name is
-    *        found in the configuration file. Otherwise, the channel factory will take priority
-    *        if found.
-    * @param mbeanServer - the MBeanServer instance, needed in case a channel factory name is found
-    *        in the configuration file. In this situation, the channel factory is preferred.
-    *        Irrelevant if skipMultiplex is true.
-    */
-   public ClusteredPersistenceServiceConfigFileJChannelFactory(String configFilePath,
-                                                               boolean skipMultiplex,
-                                                               MBeanServer mbeanServer)
-      throws Exception
-   {
-      this.configFilePath = configFilePath;
-      init(configFilePath, skipMultiplex, mbeanServer);
-   }
-
-   // JChannelFactory ------------------------------------------------------------------------------
-
-   public JChannel createControlChannel() throws Exception
-   {
-      if (multiplexorDelegate != null)
-      {
-         return multiplexorDelegate.createControlChannel();
-      }
-      else
-      {
-         return new JChannel(controlConfig);
-      }
-   }
-
-   public JChannel createDataChannel() throws Exception
-   {
-      if (multiplexorDelegate != null)
-      {
-         return multiplexorDelegate.createDataChannel();
-      }
-      else
-      {
-         return new JChannel(dataConfig);
-      }
-   }
-
-   // Public ---------------------------------------------------------------------------------------
-
-   public String toString()
-   {
-      return "ClusteredPersistenceServiceConfigFileJChannelFactory[" + configFilePath + "]";
-   }
-
-   // Package protected ----------------------------------------------------------------------------
-
-   // Protected ------------------------------------------------------------------------------------
-
-   // Private --------------------------------------------------------------------------------------
-
-   private void init(String configFilePath, boolean skipMultiplex, MBeanServer mbeanServer)
-      throws Exception
-   {
-      log.debug("using configuration file " + configFilePath);
-
-      MBeanConfigurationElement postOfficeConfig =
-         ServiceConfigHelper.loadServiceConfiguration(configFilePath, "PostOffice");
-
-      // first, we try to use a channel factory service, if we find one configured
-      String s = (String)postOfficeConfig.getAttributeValue("ChannelFactoryName");
-
-      if (s != null && !skipMultiplex)
-      {
-         // there's a chance we can use a multiplexer service
-         ObjectName channelFactoryName = new ObjectName(s);
-
-         String channelPartitionName =
-            (String)postOfficeConfig.getAttributeValue("ChannelPartitionName");
-
-         if (channelPartitionName == null)
-         {
-            throw new IllegalStateException("Cannot find ChannelPartitionName");
-         }
-
-         String controlChannelName = (String)postOfficeConfig.getAttributeValue("ControlChannelName");
-
-         if (controlChannelName == null)
-         {
-            throw new IllegalStateException("Cannot find ControlChannelName");
-         }
-
-         String dataChannelName = (String)postOfficeConfig.getAttributeValue("DataChannelName");
-
-         if (dataChannelName == null)
-         {
-            throw new IllegalStateException("Cannot find DataChannelName");
-         }
-
-         try
-         {
-            if(mbeanServer.getMBeanInfo(channelFactoryName) != null)
-            {
-               multiplexorDelegate =
-                  new MultiplexerJChannelFactory(mbeanServer, channelFactoryName,
-                                                 channelPartitionName, controlChannelName,
-                                                 dataChannelName);
-
-               // initialization ends here, we've found what we were looking for
-               return;
-            }
-         }
-         catch (Exception e)
-         {
-            // that's alright, no multiplexer there, use the regular XML configuration
-            log.debug("Wasn't able to find " + s);
-         }
-      }
-
-      // the only chance now is to use the XML configurations
-
-      s = (String)postOfficeConfig.getAttributeValue("ControlChannelConfig");
-
-      if (s == null)
-      {
-         throw new IllegalStateException("Cannot find ControlChannelConfig");
-      }
-
-      controlConfig = XMLUtil.stringToElement(s);
-
-      s = (String)postOfficeConfig.getAttributeValue("DataChannelConfig");
-
-      if (s == null)
-      {
-         throw new IllegalStateException("Cannot find DataChannelConfig");
-      }
-
-      dataConfig = XMLUtil.stringToElement(s);
-   }
-
-   // Inner classes --------------------------------------------------------------------------------
-
-}

Deleted: trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/ClusteredPostOfficeTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/ClusteredPostOfficeTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/ClusteredPostOfficeTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -1,2851 +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.core.plugin.postoffice;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.messaging.core.contract.Binding;
-import org.jboss.messaging.core.contract.Condition;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.contract.MessageReference;
-import org.jboss.messaging.core.contract.PostOffice;
-import org.jboss.messaging.core.contract.Queue;
-import org.jboss.messaging.core.impl.MessagingQueue;
-import org.jboss.messaging.core.impl.tx.Transaction;
-import org.jboss.test.messaging.core.PostOfficeTestBase;
-import org.jboss.test.messaging.core.SimpleCondition;
-import org.jboss.test.messaging.core.SimpleFilter;
-import org.jboss.test.messaging.core.SimpleReceiver;
-import org.jboss.test.messaging.util.CoreMessageFactory;
-
-/**
- * 
- * A DefaultClusteredPostOfficeTest
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 2386 $</tt>
- *
- * $Id: DefaultPostOfficeTest.java 2386 2007-02-21 18:07:44Z timfox $
- *
- */
-public class ClusteredPostOfficeTest extends PostOfficeTestBase
-{
-   // Constants ------------------------------------------------------------------------------------
-
-   // Static ---------------------------------------------------------------------------------------
-   
-   // Attributes -----------------------------------------------------------------------------------
-    
-   // Constructors ---------------------------------------------------------------------------------
-
-   public ClusteredPostOfficeTest(String name)
-   {
-      super(name);
-   }
-
-   // Public ---------------------------------------------------------------------------------------
-
-   public final void testSimpleJoinLeave() throws Throwable
-   {
-      PostOffice office1 = null;
-      PostOffice office2 = null;
-      PostOffice office3 = null;
-      
-      try
-      {         
-         office1 = createClusteredPostOffice(1, "testgroup");
-
-         office2 = createClusteredPostOffice(2, "testgroup");
-                  
-         office3 = createClusteredPostOffice(3, "testgroup");
-         
-         Thread.sleep(1000);
-         
-         Set nodes = office1.nodeIDView();         
-         assertTrue(nodes.contains(new Integer(1)));
-         assertTrue(nodes.contains(new Integer(2)));
-         assertTrue(nodes.contains(new Integer(3)));
-         
-         nodes = office2.nodeIDView();         
-         assertTrue(nodes.contains(new Integer(1)));
-         assertTrue(nodes.contains(new Integer(2)));
-         assertTrue(nodes.contains(new Integer(3)));
-         
-         nodes = office3.nodeIDView();         
-         assertTrue(nodes.contains(new Integer(1)));
-         assertTrue(nodes.contains(new Integer(2)));
-         assertTrue(nodes.contains(new Integer(3)));
-         
-         office1.stop();
-         office1 = null;
-         
-         office2.stop();
-         office2 = null;
-         
-         office3.stop();
-         office3 = null;
-      }
-      finally
-      {
-         if (office1 != null)
-         {
-            office1.stop();
-         }
-         
-         if (office2 != null)
-         {
-            office2.stop();
-         }
-         
-         if (office3 != null)
-         {
-            office3.stop();
-         }         
-      }
-         
-   }
-   
-   public final void testGetFailoverMap() throws Throwable
-   {
-      PostOffice office1 = null;
-      PostOffice office2 = null;
-      PostOffice office3 = null;
-      
-      try
-      {         
-         office1 = createClusteredPostOffice(1, "testgroup");
-
-         office2 = createClusteredPostOffice(2, "testgroup");
-                  
-         office3 = createClusteredPostOffice(3, "testgroup");
-         
-         Thread.sleep(1000);
-         
-         Map failoverMap1 = office1.getFailoverMap();
-         
-         Map failoverMap2 = office2.getFailoverMap();
-         
-         Map failoverMap3 = office3.getFailoverMap();
-         
-         assertEquals(failoverMap1, failoverMap2);
-         
-         assertEquals(failoverMap2, failoverMap3);
-         
-         office1.stop();
-         office1 = null;
-         
-         office2.stop();
-         office2 = null;
-         
-         office3.stop();
-         office3 = null;
-      }
-      finally
-      {
-         if (office1 != null)
-         {
-            office1.stop();
-         }
-         
-         if (office2 != null)
-         {
-            office2.stop();
-         }
-         
-         if (office3 != null)
-         {
-            office3.stop();
-         }         
-      }
-         
-   }
-   
-   public final void testClusteredBindUnbind() throws Throwable
-   {
-      PostOffice office1 = null;
-      PostOffice office2 = null;
-      PostOffice office3 = null;
-      
-      try
-      {         
-         // Start one office
-         
-         office1 = createClusteredPostOffice(1, "testgroup");
-          
-         // Add a couple of queues
-         
-         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue1.activate();
-
-         Condition condition1 = new SimpleCondition("condition1");
-         
-         boolean added = office1.addBinding(new Binding(condition1, queue1, false), false);
-         assertTrue(added);
-               
-         Queue queue2 = new MessagingQueue(1, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue2.activate();
-
-         added = office1.addBinding(new Binding(condition1, queue2, false), false);
-         assertTrue(added);
-               
-         // Start another office - make sure it picks up the bindings from the first node
-         
-         office2 = createClusteredPostOffice(2, "testgroup");
-           
-         // Should return all queues
-         Collection queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(2, queues.size());
-         assertTrue(queues.contains(queue1));
-         assertTrue(queues.contains(queue2));
-                
-         
-         // Add another queue on node 2
-         
-         Queue queue3 = new MessagingQueue(2, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue3.activate();
-
-         added = office2.addBinding(new Binding(condition1, queue3, false), false);
-         assertTrue(added);
-  
-         // Make sure both nodes pick it up
-         
-         queues = office1.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(3, queues.size());
-         assertTrue(queues.contains(queue1));
-         assertTrue(queues.contains(queue2));
-         assertTrue(queues.contains(queue3));
-         
-         queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(3, queues.size());
-         assertTrue(queues.contains(queue1));
-         assertTrue(queues.contains(queue2));
-         assertTrue(queues.contains(queue3));
-        
-
-         // Add another binding on node 2
-         
-         Queue queue4 = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue4.activate();
-
-         added = office2.addBinding(new Binding(condition1, queue4, false), false);
-         assertTrue(added);
-         
-         // Make sure both nodes pick it up
-         
-         queues = office1.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(4, queues.size());
-         assertTrue(queues.contains(queue1));
-         assertTrue(queues.contains(queue2));
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         
-         queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(4, queues.size());
-         assertTrue(queues.contains(queue1));
-         assertTrue(queues.contains(queue2));
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         
-         // Unbind binding 1 and binding 2
-         Binding removed = office1.removeBinding(queue1.getName(), false);
-         assertNotNull(removed);
-                  
-         removed = office1.removeBinding(queue2.getName(), false);
-         assertNotNull(removed);
-         
-         // Make sure bindings are not longer available on either node
-         
-         queues = office1.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(2, queues.size());
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         
-         queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(2, queues.size());
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         
-         
-         // Add a third office
-                  
-         office3 = createClusteredPostOffice(3, "testgroup");
-         
-         // Maks sure it picks up the bindings
-         
-         queues = office3.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(2, queues.size());
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         
-         // Add another binding on node 3
-                  
-         Queue queue5 = new MessagingQueue(3, "sub5", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue5.activate();
-         
-         added = office3.addBinding(new Binding(condition1, queue5, false), false);
-         assertTrue(added);
-         
-         // Make sure all nodes pick it up
-         
-         queues = office1.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(3, queues.size());
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         assertTrue(queues.contains(queue5));
-         
-         queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(3, queues.size());
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         assertTrue(queues.contains(queue5));
-         
-         queues = office3.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(3, queues.size());
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         assertTrue(queues.contains(queue5));
-         
-         // Add a durable and a non durable binding on node 1
-         
-         Queue queue6 = new MessagingQueue(1, "sub6", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queue6.activate();
-         
-         added = office1.addBinding(new Binding(condition1, queue6, false), false);
-         assertTrue(added);
-         
-         Queue queue7 = new MessagingQueue(1, "sub7", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue7.activate();
-         
-         added = office1.addBinding(new Binding(condition1, queue7, false), false);
-         assertTrue(added);
-         
-         
-         // Make sure all nodes pick them up
-         
-         queues = office1.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(5, queues.size());
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         assertTrue(queues.contains(queue5));
-         assertTrue(queues.contains(queue6));
-         assertTrue(queues.contains(queue7));
-         
-         queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(5, queues.size());
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         assertTrue(queues.contains(queue5));
-         assertTrue(queues.contains(queue6));
-         assertTrue(queues.contains(queue7));
-         
-         queues = office3.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(5, queues.size());
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         assertTrue(queues.contains(queue5));
-         assertTrue(queues.contains(queue6));
-         assertTrue(queues.contains(queue7));
-               
-         // Stop office 1
-         office1.stop();
-  
-         // Need to sleep since it may take some time for the view changed request to reach the
-         // members which causes the bindings to be removed.
-         
-         Thread.sleep(1000);
-         
-         // All it's bindings should be removed from the other nodes, including durable
-         
-         queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(3, queues.size());
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         assertTrue(queues.contains(queue5));
-         
-         queues = office3.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(3, queues.size());
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         assertTrue(queues.contains(queue5));
-         
-         // Stop office 2
-         office2.stop();
-         
-         queues = office3.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(1, queues.size());
-         assertTrue(queues.contains(queue5));
-         
-         // Restart office 1 and office 2
-         office1.start();
-         
-         office2.start();
-                  
-         queues = office1.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(2, queues.size());
-         assertTrue(queues.contains(queue5));
-         assertTrue(queues.contains(queue6));
-         
-         queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(2, queues.size());
-         assertTrue(queues.contains(queue5));
-         assertTrue(queues.contains(queue6));
-         
-         queues = office3.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(2, queues.size());
-         assertTrue(queues.contains(queue5));
-         assertTrue(queues.contains(queue6));
-
-         // Stop all offices
-         
-         office1.stop();
-         office2.stop();
-         office3.stop();
-         
-         // Start them all
-         office1.start();
-         office2.start();
-         office3.start();
-         
-         // Only the durable queue should survive
-         
-         queues = office1.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(1, queues.size());
-         assertTrue(queues.contains(queue6));
-         
-         queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(1, queues.size());
-         assertTrue(queues.contains(queue6));
-         
-         queues = office3.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(1, queues.size());
-         assertTrue(queues.contains(queue6));       
-         
-         //Unbind it
-         
-         removed = office1.removeBinding(queue6.getName(), false);
-         assertNotNull(removed);
-         
-         queues = office1.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertTrue(queues.isEmpty());
-         
-         queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertTrue(queues.isEmpty());
-         
-         queues = office3.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertTrue(queues.isEmpty());     
-         
-         
-         //Bind another few more clustered
-                           
-         Queue queue8 = new MessagingQueue(1, "sub8", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue8.activate();
-         
-         Queue queue9 = new MessagingQueue(2, "sub9", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue9.activate();
-         
-         Queue queue10 = new MessagingQueue(2, "sub10", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue10.activate();
-         
-         //Bind on different conditions
-         
-         added = office1.addBinding(new Binding(condition1, queue8, false), false);
-         assertTrue(added);
-         
-         added = office2.addBinding(new Binding(condition1, queue9, false), false);
-         assertTrue(added);
-         
-         Condition condition2 = new SimpleCondition("condition2");
-         
-         added = office2.addBinding(new Binding(condition2, queue10, false), false);
-         assertTrue(added);
-         
-         queues = office1.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(2, queues.size());
-         assertTrue(queues.contains(queue8));
-         assertTrue(queues.contains(queue9));
-         
-         queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(2, queues.size());
-         assertTrue(queues.contains(queue8));
-         assertTrue(queues.contains(queue9));
-         
-         queues = office3.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(2, queues.size());
-         assertTrue(queues.contains(queue8));
-         assertTrue(queues.contains(queue9));
-         
-         //Now a couple of non clustered queues
-         
-         Queue queue11 = new MessagingQueue(1, "sub11", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue11.activate();
-         
-         Queue queue12 = new MessagingQueue(2, "sub12", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue12.activate();
-         
-         added = office1.addBinding(new Binding(condition1, queue11, false), false);
-         assertTrue(added);
-         
-         added = office2.addBinding(new Binding(condition1, queue12, false), false);
-         assertTrue(added);
-         
-         queues = office1.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(3, queues.size());
-         assertTrue(queues.contains(queue8));
-         assertTrue(queues.contains(queue9));
-         assertTrue(queues.contains(queue11));
-         
-         queues = office2.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(3, queues.size());
-         assertTrue(queues.contains(queue8));
-         assertTrue(queues.contains(queue9));
-         assertTrue(queues.contains(queue12));
-         
-         queues = office3.getQueuesForCondition(condition1, false);
-         assertNotNull(queues);
-         assertEquals(2, queues.size());
-         assertTrue(queues.contains(queue8));
-         assertTrue(queues.contains(queue9));                   
-      }
-      finally
-      {
-         if (office1 != null)
-         {
-            office1.stop();
-         }
-         
-         if (office2 != null)
-         {
-            office2.stop();
-         }
-         
-         if (office3 != null)
-         {
-            office3.stop();
-         }
-         
-         if (checkNoBindingData())
-         {
-            fail("data still in database");
-         }
-      }
-   }
-   
-   public void testBindUnbindAll1() throws Throwable
-   {
-   	/*
-      * 1.
-      * a) queue is not known by cluster
-      * b) bind all
-      * c) verify all nodes get queue
-      * d) unbind - verify unbound from all nodes
-      * e) close down all nodes
-      * f) start all nodes
-      * g) verify queue is not known
-      * */
-   	
-      PostOffice office1 = null;
-      PostOffice office2 = null;
-      PostOffice office3 = null;
-      
-      try
-      {                          
-         office1 = createClusteredPostOffice(1, "testgroup");
-         office2 = createClusteredPostOffice(2, "testgroup");
-         office3 = createClusteredPostOffice(3, "testgroup");         
-                             
-         //Durable
-         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queue1.activate();
-
-         Condition condition1 = new SimpleCondition("condition1");
-         
-         //Add all binding
-         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
-         assertTrue(added);
-         
-         Thread.sleep(1000);
-          
-         Collection bindings = office1.getAllBindings();         
-         assertGotAll(1, bindings, queue1.getName());
-         
-         bindings = office2.getAllBindings();         
-         assertGotAll(2, bindings, queue1.getName());
-         
-         bindings = office3.getAllBindings();         
-         assertGotAll(3, bindings, queue1.getName());
-         
-         //Now unbind same node
-         
-         Binding removed = office1.removeBinding(queue1.getName(), true);
-         assertNotNull(removed);
-         
-         Thread.sleep(1000);
-         
-         bindings = office1.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office2.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office3.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         //Bind again different node
-         Queue queue2 = new MessagingQueue(2, "sub2", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queue2.activate();
-         
-         added = office2.addBinding(new Binding(condition1, queue2, true), true);
-         assertTrue(added);
-         
-         Thread.sleep(1000);
-         
-         bindings = office1.getAllBindings();         
-         assertGotAll(1, bindings, queue2.getName());
-         
-         bindings = office2.getAllBindings();         
-         assertGotAll(2, bindings, queue2.getName());
-         
-         bindings = office3.getAllBindings();         
-         assertGotAll(3, bindings, queue2.getName());
-         
-         //Close down all nodes
-         
-         office1.stop();
-         
-         dumpNodeIDView(office2);
-         
-         office2.stop();
-         
-         dumpNodeIDView(office3);
-         
-         office3.stop();        
-         
-         //Start all nodes
-         
-         office1.start();
-         office2.start();
-         office3.start();
-         
-         Thread.sleep(1000);
-         
-         //Verify the binding is there
-         
-         bindings = office1.getAllBindings();         
-         assertGotAll(1, bindings, queue2.getName());
-         
-         bindings = office2.getAllBindings();         
-         assertGotAll(2, bindings, queue2.getName());
-         
-         bindings = office3.getAllBindings();         
-         assertGotAll(3, bindings, queue2.getName());
-         
-         //Unbind different node
-         
-         removed = office3.removeBinding(queue2.getName(), true);
-         assertNotNull(removed);
-         
-         Thread.sleep(1000);
-         
-         bindings = office1.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office2.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office3.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         if (checkNoBindingData())
-         {
-            fail("data still in database");
-         }                                  
-      }
-      finally
-      {
-      	if (office1 != null)
-      	{
-      		try
-      		{
-      			office1.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office2 != null)
-      	{
-      		try
-      		{
-      			office2.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office3 != null)
-      	{
-      		try
-      		{
-      			office3.stop();
-      		}         
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-      }
-   }
-   
-   public void testBindUnbindAll2() throws Throwable
-   {
-      /* 
-      * a) queue is known by cluster
-      * b) bind all
-      * c) verify nothing changes on cluster
-      */
-   	
-      PostOffice office1 = null;
-      PostOffice office2 = null;
-      PostOffice office3 = null;
-      
-      try
-      {                          
-         office1 = createClusteredPostOffice(1, "testgroup");
-         office2 = createClusteredPostOffice(2, "testgroup");
-         office3 = createClusteredPostOffice(3, "testgroup");         
-                           
-         //Durable
-         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queue1.activate();
-
-         Condition condition1 = new SimpleCondition("condition1");
-         
-         //Add all binding
-         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
-         assertTrue(added);
-         
-         Thread.sleep(1000);
-          
-         Collection bindings = office1.getAllBindings();         
-         assertGotAll(1, bindings, queue1.getName());
-         
-         bindings = office2.getAllBindings();         
-         assertGotAll(2, bindings, queue1.getName());
-         
-         bindings = office3.getAllBindings();         
-         assertGotAll(3, bindings, queue1.getName());
-         
-         //Bind again
-         added = office1.addBinding(new Binding(condition1, queue1, true), true);
-         assertFalse(added);
-         
-         Thread.sleep(1000);
-          
-         bindings = office1.getAllBindings();         
-         assertGotAll(1, bindings, queue1.getName());
-         
-         bindings = office2.getAllBindings();         
-         assertGotAll(2, bindings, queue1.getName());
-         
-         bindings = office3.getAllBindings();         
-         assertGotAll(3, bindings, queue1.getName());
-                  
-         //Now unbind same node
-         
-         Binding removed = office1.removeBinding(queue1.getName(), true);
-         assertNotNull(removed);
-         
-         removed = office1.removeBinding(queue1.getName(), true);
-         assertNull(removed);
-         
-         Thread.sleep(1000);
-         
-         bindings = office1.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office2.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office3.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-                  
-         if (checkNoBindingData())
-         {
-            fail("data still in database");
-         }                                  
-      }
-      finally
-      {
-      	if (office1 != null)
-      	{
-      		try
-      		{
-      			office1.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office2 != null)
-      	{
-      		try
-      		{
-      			office2.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office3 != null)
-      	{
-      		try
-      		{
-      			office3.stop();
-      		}         
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-      }
-   }
-   
-   public void testBindUnbindAll3() throws Throwable
-   {
-      /* a) start one node
-      * b) queue is not known to cluster
-      * c) bind all
-      * d) start other nodes
-      * d) verify other nodes pick it up
-      */
-   	
-      PostOffice office1 = null;
-      PostOffice office2 = null;
-      PostOffice office3 = null;
-      
-      try
-      {                          
-         office1 = createClusteredPostOffice(1, "testgroup");       
-                              
-         //Durable
-         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queue1.activate();
-
-         Condition condition1 = new SimpleCondition("condition1");
-         
-         //Add all binding
-         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
-         assertTrue(added);
-         
-         Thread.sleep(1000);
-          
-         office2 = createClusteredPostOffice(2, "testgroup");       
-         office3 = createClusteredPostOffice(3, "testgroup");       
-                  
-         Thread.sleep(1000);
-         
-         Collection bindings = office1.getAllBindings();         
-         assertGotAll(1, bindings, queue1.getName());
-         
-         bindings = office2.getAllBindings();         
-         assertGotAll(2, bindings, queue1.getName());
-         
-         bindings = office3.getAllBindings();         
-         assertGotAll(3, bindings, queue1.getName());
-               
-         //Unbind
-         
-         Binding removed = office1.removeBinding(queue1.getName(), true);
-         assertNotNull(removed);
-         
-         Thread.sleep(1000);
-         
-         bindings = office1.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office2.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office3.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         if (checkNoBindingData())
-         {
-            fail("data still in database");
-         }                                  
-      }
-      finally
-      {
-      	if (office1 != null)
-      	{
-      		try
-      		{
-      			office1.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office2 != null)
-      	{
-      		try
-      		{
-      			office2.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office3 != null)
-      	{
-      		try
-      		{
-      			office3.stop();
-      		}         
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-      }
-   }
-   
-   public void testBindUnbindAll4() throws Throwable
-   {
-      /* a) start one node
-      * b) queue is not known to cluster
-      * c) bind all
-      * d) shutdown all nodes
-      * e) startup all nodes
-      * f) verify queue is on all nodes
-      */
-   	
-      PostOffice office1 = null;
-      PostOffice office2 = null;
-      PostOffice office3 = null;
-      
-      try
-      {                          
-         office1 = createClusteredPostOffice(1, "testgroup");       
-                           
-         //Durable
-         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queue1.activate();
-
-         Condition condition1 = new SimpleCondition("condition1");
-         
-         //Add all binding
-         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
-         assertTrue(added);
-         
-         Thread.sleep(1000);
-         
-         office1.stop();
-         
-         //office1 = createClusteredPostOffice(1, "testgroup"); 
-         office1.start();
-         office2 = createClusteredPostOffice(2, "testgroup"); 
-         office3 = createClusteredPostOffice(3, "testgroup"); 
-          
-         Thread.sleep(1000);
-         
-         Collection bindings = office1.getAllBindings();         
-         assertGotAll(1, bindings, queue1.getName());
-         
-         bindings = office2.getAllBindings();         
-         assertGotAll(2, bindings, queue1.getName());
-         
-         bindings = office3.getAllBindings();         
-         assertGotAll(3, bindings, queue1.getName());
-         
-         //Now unbind same node
-         
-         Binding removed = office1.removeBinding(queue1.getName(), true);
-         assertNotNull(removed);
-         
-         Thread.sleep(1000);
-         
-         bindings = office1.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office2.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office3.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         
-         if (checkNoBindingData())
-         {
-            fail("data still in database");
-         }                                  
-      }
-      finally
-      {
-      	if (office1 != null)
-      	{
-      		try
-      		{
-      			office1.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office2 != null)
-      	{
-      		try
-      		{
-      			office2.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office3 != null)
-      	{
-      		try
-      		{
-      			office3.stop();
-      		}         
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-      }
-   }
-   
-   public void testBindUnbindAll5() throws Throwable
-   {
-   	/*
-    * a) start one node
-    * b) queue is not known
-    * c) bind all
-    * d) shutdown node
-    * e) start other nodes
-    * f) verify queue is not known
-    * g) restart first node, verify queue is now known
-      * */
-   	
-      PostOffice office1 = null;
-      PostOffice office2 = null;
-      PostOffice office3 = null;
-      
-      try
-      {                          
-         office1 = createClusteredPostOffice(1, "testgroup");
-                                   
-         //Durable
-         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queue1.activate();
-
-         Condition condition1 = new SimpleCondition("condition1");
-         
-         //Add all binding
-         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
-         assertTrue(added);
-         
-         Thread.sleep(1000);
-         
-         office1.stop();
-         
-         office2 = createClusteredPostOffice(2, "testgroup");
-         office3 = createClusteredPostOffice(3, "testgroup");
-         
-         Collection bindings = office2.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office3.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-             
-         office1.start();
-         
-         Thread.sleep(1000);
-            
-         bindings = office1.getAllBindings();         
-         assertGotAll(1, bindings, queue1.getName());
-         
-         bindings = office2.getAllBindings();         
-         assertGotAll(2, bindings, queue1.getName());
-         
-         bindings = office3.getAllBindings();         
-         assertGotAll(3, bindings, queue1.getName());
-         
-         //Now unbind same node                  
-         
-         Binding removed = office1.removeBinding(queue1.getName(), true);
-         assertNotNull(removed);
-
-         Thread.sleep(1000);
-         
-         bindings = office1.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office2.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office3.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         if (checkNoBindingData())
-         {
-            fail("data still in database");
-         }                                  
-      }
-      finally
-      {
-      	if (office1 != null)
-      	{
-      		try
-      		{
-      			office1.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office2 != null)
-      	{
-      		try
-      		{
-      			office2.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office3 != null)
-      	{
-      		try
-      		{
-      			office3.stop();
-      		}         
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-      }
-   }
-   
-   public void testBindUnbindAll6() throws Throwable
-   {
-   	/*
-      * 1.
-    * a) bind all non durable
-    * b) make sure is picked up by all nodes
-    * c) close down all nodes
-    * d) restart them all - make sure is not there
-    * e) bind again
-    * f) make sure is picked up
-    * g) take down one node
-    * h) bring it back up
-    * i) make sure it has quuee again
-      * */
-   	
-      PostOffice office1 = null;
-      PostOffice office2 = null;
-      PostOffice office3 = null;
-      
-      try
-      {                          
-         office1 = createClusteredPostOffice(1, "testgroup");
-         office2 = createClusteredPostOffice(2, "testgroup");
-         office3 = createClusteredPostOffice(3, "testgroup");         
-                           
-         //Durable
-         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue1.activate();
-
-         Condition condition1 = new SimpleCondition("condition1");
-         
-         //Add all binding
-         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
-         assertTrue(added);
-         
-         Thread.sleep(1000);
-          
-         Collection bindings = office1.getAllBindings();         
-         assertGotAll(1, bindings, queue1.getName());
-         
-         bindings = office2.getAllBindings();         
-         assertGotAll(2, bindings, queue1.getName());
-         
-         bindings = office3.getAllBindings();         
-         assertGotAll(3, bindings, queue1.getName());
-         
-         office1.stop();
-         office2.stop();
-         office3.stop();
-      
-         office1.start();
-         office2.start();
-         office3.start();
-         
-         Thread.sleep(1000);
-         
-         bindings = office1.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office2.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         bindings = office3.getAllBindings();         
-         assertTrue(bindings.isEmpty());
-         
-         added = office1.addBinding(new Binding(condition1, queue1, true), true);
-         assertTrue(added);
-         
-         Thread.sleep(1000);
-         
-         bindings = office1.getAllBindings();         
-         assertGotAll(1, bindings, queue1.getName());
-         
-         bindings = office2.getAllBindings();         
-         assertGotAll(2, bindings, queue1.getName());
-         
-         bindings = office3.getAllBindings();         
-         assertGotAll(3, bindings, queue1.getName());
-         
-         office3.stop();
-
-         Thread.sleep(1000);
-          
-         bindings = office1.getAllBindings();         
-         assertEquals(2, bindings.size());
-         
-         office3.start();
-
-         Thread.sleep(1000);
-         
-         bindings = office1.getAllBindings();         
-         assertGotAll(1, bindings, queue1.getName());
-         
-         bindings = office2.getAllBindings();         
-         assertGotAll(2, bindings, queue1.getName());
-         
-         bindings = office3.getAllBindings();         
-         assertGotAll(3, bindings, queue1.getName());
-         
-                  
-         if (checkNoBindingData())
-         {
-            fail("data still in database");
-         }                                  
-      }
-      finally
-      {
-      	if (office1 != null)
-      	{
-      		try
-      		{
-      			office1.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office2 != null)
-      	{
-      		try
-      		{
-      			office2.stop();
-      		}
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-
-      	if (office3 != null)
-      	{
-      		try
-      		{
-      			office3.stop();
-      		}         
-      		catch (Exception ignore)
-      		{         		
-      		}
-      	}
-      }
-   }
-   
-  
-   public final void testClusteredRoutePersistent() throws Throwable
-   {
-      clusteredRoute(true);
-   }
-   
-   public final void testClusteredRouteNonPersistent() throws Throwable
-   {
-      clusteredRoute(false);
-   }
-
-   public void testClusteredRouteWithFilterNonPersistent() throws Throwable
-   {
-      this.clusteredRouteWithFilter(false);
-   }
-   
-   public void testClusteredRouteWithFilterPersistent() throws Throwable
-   {
-      this.clusteredRouteWithFilter(true);
-   }
-   
-   public void testRouteSharedQueuePersistent() throws Throwable
-   {
-      this.routeSharedQueue(true);
-   }
-   
-   public void testRouteSharedQueueNonPersistent() throws Throwable
-   {
-      this.routeSharedQueue(false);
-   }
-   
-   public void testClusteredTransactionalRoutePersistent() throws Throwable
-   {
-   	this.clusteredTransactionalRoute(true);
-   }
-   
-   public void testClusteredTransactionalRouteNonPersistent() throws Throwable
-   {
-   	this.clusteredTransactionalRoute(false);
-   }
-   
-   public void testClusteredRouteFourNodesPersistent() throws Throwable
-   {
-   	this.clusteredRouteFourNodes(true);
-   }
-   
-   public void testClusteredRouteFourNodesNonPersistent() throws Throwable
-   {
-   	this.clusteredRouteFourNodes(false);
-   }
-   
-   public void testStartTxInternally() throws Throwable
-   {
-   	PostOffice office1 = null;
-
-   	try
-   	{   
-   		office1 = createClusteredPostOffice(1, "testgroup");
-
-   		Queue queue1 =  new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, true, -1, null, true);
-   		queue1.activate();
-   		boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
-   		assertTrue(added);
-   		
-   		Queue queue2 =  new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, true, -1, null, true);
-   		queue2.activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue2, false), false);
-   		assertTrue(added);
-   		
-   		Queue queue3 =  new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, true, -1, null, true);
-   		queue3.activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue3, false), false);
-   		assertTrue(added);
-   		
-   		Queue queue4 =  new MessagingQueue(1, "queue4", channelIDManager.getID(), ms, pm, true, -1, null, true);
-   		queue4.activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue4, false), false);
-   		assertTrue(added);
-
-   		SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue1.getLocalDistributor().add(receiver1);
-
-   		SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue2.getLocalDistributor().add(receiver2);
-
-   		SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue3.getLocalDistributor().add(receiver3);
-   		
-   		SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue4.getLocalDistributor().add(receiver4);
-
-   		Message msg1 = CoreMessageFactory.createCoreMessage(1, true, null);      
-   		MessageReference ref1 = ms.reference(msg1);  
-   		boolean routed = office1.route(ref1, new SimpleCondition("condition1"), null);   
-   		assertTrue(routed);
-
-   		Message msg2 = CoreMessageFactory.createCoreMessage(2, true, null);      
-   		MessageReference ref2 = ms.reference(msg2);         
-   		routed = office1.route(ref2, new SimpleCondition("condition1"), null);      
-   		assertTrue(routed);
-
-   		Message msg3 = CoreMessageFactory.createCoreMessage(3, true, null);      
-   		MessageReference ref3 = ms.reference(msg3);         
-   		routed = office1.route(ref3, new SimpleCondition("condition1"), null);      
-   		assertTrue(routed);
-
-   		Thread.sleep(1000);
-   		
-   		List msgs = receiver1.getMessages();
-   		assertNotNull(msgs);
-   		assertEquals(3, msgs.size());
-   		Message msgRec1 = (Message)msgs.get(0);
-   		assertTrue(msg1 == msgRec1);
-   		Message msgRec2 = (Message)msgs.get(1);
-   		assertTrue(msg2 == msgRec2);
-   		Message msgRec3 = (Message)msgs.get(2);
-   		assertTrue(msg3 == msgRec3);
-
-   		receiver1.acknowledge(msgRec1, null);
-   		receiver1.acknowledge(msgRec2, null);
-   		receiver1.acknowledge(msgRec3, null);
-   		msgs = queue1.browse(null);
-   		assertNotNull(msgs);
-   		assertTrue(msgs.isEmpty()); 
-   		
-   		msgs = receiver2.getMessages();
-   		assertNotNull(msgs);
-   		assertEquals(3, msgs.size());
-   		msgRec1 = (Message)msgs.get(0);
-   		assertTrue(msg1 == msgRec1);
-   		msgRec2 = (Message)msgs.get(1);
-   		assertTrue(msg2 == msgRec2);
-   		msgRec3 = (Message)msgs.get(2);
-   		assertTrue(msg3 == msgRec3);
-
-   		receiver2.acknowledge(msgRec1, null);
-   		receiver2.acknowledge(msgRec2, null);
-   		receiver2.acknowledge(msgRec3, null);
-   		msgs = queue2.browse(null);
-   		assertNotNull(msgs);
-   		assertTrue(msgs.isEmpty()); 
-
-   		msgs = receiver3.getMessages();
-   		assertNotNull(msgs);
-   		assertEquals(3, msgs.size());
-   		msgRec1 = (Message)msgs.get(0);
-   		assertTrue(msg1 == msgRec1);
-   		msgRec2 = (Message)msgs.get(1);
-   		assertTrue(msg2 == msgRec2);
-   		msgRec3 = (Message)msgs.get(2);
-   		assertTrue(msg3 == msgRec3);
-
-   		receiver3.acknowledge(msgRec1, null);
-   		receiver3.acknowledge(msgRec2, null);
-   		receiver3.acknowledge(msgRec3, null);
-   		msgs = queue3.browse(null);
-   		assertNotNull(msgs);
-   		assertTrue(msgs.isEmpty()); 
-   		
-   		msgs = receiver4.getMessages();
-   		assertNotNull(msgs);
-   		assertEquals(3, msgs.size());
-   		msgRec1 = (Message)msgs.get(0);
-   		assertTrue(msg1 == msgRec1);
-   		msgRec2 = (Message)msgs.get(1);
-   		assertTrue(msg2 == msgRec2);
-   		msgRec3 = (Message)msgs.get(2);
-   		assertTrue(msg3 == msgRec3);
-
-   		receiver4.acknowledge(msgRec1, null);
-   		receiver4.acknowledge(msgRec2, null);
-   		receiver4.acknowledge(msgRec3, null);
-   		msgs = queue4.browse(null);
-   		assertNotNull(msgs);
-   		assertTrue(msgs.isEmpty()); 
-   		
-   		if (checkNoMessageData())
-   		{
-   			fail("Message data still in database");
-   		}
-   	}
-   	finally
-   	{
-   		if (office1 != null)
-   		{
-   			office1.stop();
-   		}
-   	}
-   }
- 
-   public void testBindSameName() throws Throwable
-   {
-      PostOffice office1 = null;
-      
-      PostOffice office2 = null;
-          
-      try
-      {   
-         office1 = createClusteredPostOffice(1, "testgroup");
-         
-         office2 = createClusteredPostOffice(2, "testgroup");
-         
-         Queue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue1.activate();
-         
-         Condition condition1 = new SimpleCondition("queue1");
-         
-         boolean added = office1.addBinding(new Binding(condition1, queue1, false), false);
-         assertTrue(added);
-
-         Queue queue2 = new MessagingQueue(2, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue2.activate();
-
-         added = office2.addBinding(new Binding(condition1, queue2, false), false);
-         assertTrue(added);
-
-         Queue queue3 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue3.activate();
-         
-         added = office1.addBinding(new Binding(condition1, queue3, false), false);         
-         assertFalse(added);
-
-         Queue queue4 =  new MessagingQueue(2, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queue4.activate();
-         
-         added = office2.addBinding(new Binding(condition1, queue4, false), false);
-         assertFalse(added);
-         
-         Binding removed = office1.removeBinding("does not exist", false);
-         assertNull(removed);
-         
-         removed = office1.removeBinding(queue1.getName(), false);
-         assertNotNull(removed);
-
-         removed = office2.removeBinding(queue2.getName(), false);                
-         assertNotNull(removed);                  
-      }
-      finally
-      {
-         if (office1 != null)
-         {            
-            office1.stop();
-         }
-         
-         if (office2 != null)
-         {
-            office2.stop();
-         }
-      }
-   }
-   
- 
-   // Package protected ----------------------------------------------------------------------------
-
-   // Protected ------------------------------------------------------------------------------------
-   
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-   }
-
-   protected void tearDown() throws Exception
-   {
-      super.tearDown();
-   }
-
-   // Private --------------------------------------------------------------------------------------
-
-   private void clusteredTransactionalRoute(boolean persistent) throws Throwable
-   {
-      PostOffice office1 = null;
-      
-      PostOffice office2 = null;
-      
-      try
-      {   
-         //Start two offices
-         
-         office1 = createClusteredPostOffice(1, "testgroup");
-         office2 = createClusteredPostOffice(2, "testgroup");
-     
-         Queue[] queues = new Queue[16];
-         
-         //condition1
-
-         queues[0] = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queues[0].activate();
-         boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[0], false), false);
-         assertTrue(added);
-         
-         queues[1] = new MessagingQueue(1, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queues[1].activate();
-         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[1], false), false);
-         assertTrue(added);
-         
-         queues[2] = new MessagingQueue(2, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queues[2].activate();
-         added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[2], false), false);
-         assertTrue(added);
-         
-         queues[3] = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queues[3].activate();
-         added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[3], false), false);
-         assertTrue(added);
-         
-         queues[4] = new MessagingQueue(2, "sub5", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queues[4].activate();
-         added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[4], false), false);
-         assertTrue(added);
-         
-         queues[5] = new MessagingQueue(1, "sub6", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queues[5].activate();
-         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[5], false), false);
-         assertTrue(added);
-         
-         queues[6] = new MessagingQueue(1, "sub7", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queues[6].activate();
-         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[6], false), false);
-         assertTrue(added);
-         
-         queues[7] = new MessagingQueue(1, "sub8", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queues[7].activate();
-         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[7], false), false);
-         assertTrue(added);
-         
-         //condition2
-         
-         queues[8] = new MessagingQueue(1, "sub9", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queues[8].activate();
-         added= office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[8], false), false);
-         assertTrue(added);
-         
-         queues[9] = new MessagingQueue(1, "sub10", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queues[9].activate();
-         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[9], false), false);
-         assertTrue(added);
-         
-         queues[10] = new MessagingQueue(2, "sub11", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queues[10].activate();
-         added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[10], false), false);
-         assertTrue(added);
-         
-         queues[11] = new MessagingQueue(2, "sub12", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queues[11].activate();
-         added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[11], false), false);
-         assertTrue(added);
-         
-         queues[12] = new MessagingQueue(2, "sub13", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queues[12].activate();
-         added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[12], false), false);
-         assertTrue(added);
-         
-         queues[13] = new MessagingQueue(1, "sub14", channelIDManager.getID(), ms, pm, false, -1, null, true);
-         queues[13].activate();
-         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[13], false), false);
-         assertTrue(added);
-         
-         queues[14] = new MessagingQueue(1, "sub15", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queues[14].activate();
-         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[14], false), false);
-         assertTrue(added);
-         
-         queues[15] = new MessagingQueue(1, "sub16", channelIDManager.getID(), ms, pm, true, -1, null, true);
-         queues[15].activate();
-         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[15], false), false);
-         assertTrue(added);
-
-         SimpleReceiver[] receivers = new SimpleReceiver[16];
-         
-         for (int i = 0; i < 16; i++)
-         {
-            receivers[i] = new SimpleReceiver("blah" + i, SimpleReceiver.ACCEPTING);
-            queues[i].getLocalDistributor().add(receivers[i]);
-         }
-         
-         //First for topic 1
-         
-         Message msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);;      
-         MessageReference ref1 = ms.reference(msg1);
-         
-         Message msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);;      
-         MessageReference ref2 = ms.reference(msg2);
-         
-         Transaction tx = tr.createTransaction();
-
-         boolean routed = office1.route(ref1, new SimpleCondition("condition1"), tx);         
-         assertTrue(routed);
-         routed = office1.route(ref2, new SimpleCondition("condition1"), tx);         
-         assertTrue(routed);
-         
-         for (int i = 0; i < 16; i++)
-         {
-         	log.info("i is " + i);
-            List msgs = receivers[i].getMessages();
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-            msgs = queues[i].browse(null);
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-         }
-         
-         log.info("committing");
-         tx.commit();
-         log.info("committed");
-         
-         //Messages are sent asych so may take some finite time to arrive
-         Thread.sleep(1000);
-         
-         for (int i = 0; i < 16; i++)
-         {
-         	if (i >= 8 || (queues[i].getNodeID() == 2 && queues[i].isRecoverable()))
-         	{     
-         		//Shouldn't get message
-         		List msgs = receivers[i].getMessages();
-         		assertNotNull(msgs);
-         		assertTrue(msgs.isEmpty());
-         		msgs = queues[i].browse(null);
-         		assertNotNull(msgs);
-         		assertTrue(msgs.isEmpty());
-         	}
-         	else
-         	{
-         		//Should get message
-         		log.info("is is " + i);
-         		log.info("trying with receiver " + receivers[i]);
-         		List msgs = receivers[i].getMessages();
-         		assertNotNull(msgs);
-         		assertEquals(2, msgs.size());
-         		Message msgRec1 = (Message)msgs.get(0);
-         		assertEquals(msg1.getMessageID(), msgRec1.getMessageID());
-         		Message msgRec2 = (Message)msgs.get(1);
-         		assertEquals(msg2.getMessageID(), msgRec2.getMessageID());            
-         		receivers[i].acknowledge(msgRec1, null);
-         		receivers[i].acknowledge(msgRec2, null);
-         		msgs = queues[i].browse(null);
-         		assertNotNull(msgs);            
-         		assertTrue(msgs.isEmpty());                        
-         		receivers[i].clear();
-         	}
-         }
-         
-         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);;      
-         ref1 = ms.reference(msg1);
-         
-         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);;      
-         ref2 = ms.reference(msg2);
-         
-         tx = tr.createTransaction();
-
-         routed = office1.route(ref1, new SimpleCondition("condition1"), tx);         
-         assertTrue(routed);
-         routed = office1.route(ref2, new SimpleCondition("condition1"), tx);         
-         assertTrue(routed);
-         
-         //Messages are sent asych so may take some finite time to arrive
-         Thread.sleep(1000);         
-         
-         for (int i = 0; i < 16; i++)
-         {
-            List msgs = receivers[i].getMessages();
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-            msgs = queues[i].browse(null);
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-         }
-         
-         tx.rollback();
-         
-         for (int i = 0; i < 16; i++)
-         {
-            List msgs = receivers[i].getMessages();
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-            msgs = queues[i].browse(null);
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-         }
-         
-         
-         // Now for topic 2
-         
-         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);    
-         ref1 = ms.reference(msg1);
-         
-         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);     
-         ref2 = ms.reference(msg2);
-         
-         tx = tr.createTransaction();
-
-         routed = office2.route(ref1, new SimpleCondition("condition2"), tx);         
-         assertTrue(routed);
-         routed = office2.route(ref2, new SimpleCondition("condition2"), tx);         
-         assertTrue(routed);
-                           
-         for (int i = 0; i < 16; i++)
-         {
-            List msgs = receivers[i].getMessages();
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-            msgs = queues[i].browse(null);
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-         }
-         
-         tx.commit();
-         
-         //Messages are sent asych so may take some finite time to arrive
-         Thread.sleep(1000);
-         
-         for (int i = 8; i < 16; i++)
-         { 
-	         if (i < 8 || (queues[i].getNodeID() == 1 && queues[i].isRecoverable()))
-	      	{     
-	         	//	Shouldn't get message
-	      		List msgs = receivers[i].getMessages();
-	      		assertNotNull(msgs);
-	      		assertTrue(msgs.isEmpty());
-	      		msgs = queues[i].browse(null);
-	      		assertNotNull(msgs);
-	      		assertTrue(msgs.isEmpty());
-	      	}
-	      	else
-	      	{
-	      		// Should get message
-	      		log.info("is is " + i);
-	      		log.info("trying with receiver " + receivers[i]);
-	      		List msgs = receivers[i].getMessages();
-	      		assertNotNull(msgs);
-	      		assertEquals(2, msgs.size());
-	      		Message msgRec1 = (Message)msgs.get(0);
-	      		assertEquals(msg1.getMessageID(), msgRec1.getMessageID());
-	      		Message msgRec2 = (Message)msgs.get(1);
-	      		assertEquals(msg2.getMessageID(), msgRec2.getMessageID());            
-	      		receivers[i].acknowledge(msgRec1, null);
-	      		receivers[i].acknowledge(msgRec2, null);
-	      		msgs = queues[i].browse(null);
-	      		assertNotNull(msgs);            
-	      		assertTrue(msgs.isEmpty());                        
-	      		receivers[i].clear();
-	      	}
-         }
-               
-         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);;      
-         ref1 = ms.reference(msg1);
-         
-         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);;      
-         ref2 = ms.reference(msg2);
-         
-         tx = tr.createTransaction();
-
-         routed = office1.route(ref1, new SimpleCondition("condition1"), tx);         
-         assertTrue(routed);
-         routed = office1.route(ref2, new SimpleCondition("condition1"), tx);         
-         assertTrue(routed);
-         
-         for (int i = 0; i < 16; i++)
-         {
-            List msgs = receivers[i].getMessages();
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-            msgs = queues[i].browse(null);
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-         }
-         
-         tx.rollback();
-         
-         for (int i = 0; i < 16; i++)
-         {
-            List msgs = receivers[i].getMessages();
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-            msgs = queues[i].browse(null);
-            assertNotNull(msgs);
-            assertTrue(msgs.isEmpty());
-         }
-         
-        
-         if (checkNoMessageData())
-         {
-            fail("Message data still in database");
-         }
-      }
-      finally
-      {
-         if (office1 != null)
-         {
-            try
-            {
-               office1.removeBinding("sub7", false);
-               office1.removeBinding("sub8", false);           
-               office1.removeBinding("sub15", false);
-               office1.removeBinding("sub16", false);
-            }
-            catch (Exception ignore)
-            {
-               ignore.printStackTrace();
-            }
-                        
-            office1.stop();
-         }
-         
-         if (office2 != null)
-         {
-            try
-            {
-               office2.removeBinding("sub5", false);
-               office2.removeBinding("sub13", false);
-            }
-            catch (Exception ignore)
-            {
-               ignore.printStackTrace();
-            }
-            
-            office2.stop();
-         }
-      }
-   }
-   
-   private void clusteredRouteWithFilter(boolean persistentMessage) throws Throwable
-   {
-   	PostOffice office1 = null;
-
-   	PostOffice office2 = null;
-
-   	try
-   	{   
-   		office1 = createClusteredPostOffice(1, "testgroup");
-   		office2 = createClusteredPostOffice(2, "testgroup");
-
-   		SimpleFilter filter1 = new SimpleFilter(2);
-   		SimpleFilter filter2 = new SimpleFilter(3);
-
-   		Queue queue1 =  new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, filter1, true);
-   		queue1.activate();
-   		boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
-   		assertTrue(added);
-
-   		Queue queue2 = new MessagingQueue(2, "queue2", channelIDManager.getID(), ms, pm, false, -1, filter2, true);
-   		queue2.activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue2, false), false);
-   		assertTrue(added);
-
-   		Queue queue3 = new MessagingQueue(2, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue3.activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue3, false), false);
-   		assertTrue(added);
-
-   		SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue1.getLocalDistributor().add(receiver1);
-
-   		SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue2.getLocalDistributor().add(receiver2);
-
-   		SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue3.getLocalDistributor().add(receiver3);
-
-   		Message msg1 = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
-   		MessageReference ref1 = ms.reference(msg1);  
-   		boolean routed = office1.route(ref1, new SimpleCondition("condition1"), null);   
-   		assertTrue(routed);
-
-
-   		Message msg2 = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
-   		MessageReference ref2 = ms.reference(msg2);         
-   		routed = office1.route(ref2, new SimpleCondition("condition1"), null);      
-   		assertTrue(routed);
-
-   		Message msg3 = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);      
-   		MessageReference ref3 = ms.reference(msg3);         
-   		routed = office1.route(ref3, new SimpleCondition("condition1"), null);      
-   		assertTrue(routed);
-
-   		Thread.sleep(1000);
-
-   		List msgs = receiver1.getMessages();
-   		assertNotNull(msgs);
-   		assertEquals(1, msgs.size());
-   		Message msgRec = (Message)msgs.get(0);
-   		assertTrue(msg2 == msgRec);
-   		receiver1.acknowledge(msgRec, null);
-   		msgs = queue1.browse(null);
-   		assertNotNull(msgs);
-   		assertTrue(msgs.isEmpty());  
-
-   		msgs = receiver2.getMessages();
-   		assertNotNull(msgs);
-   		assertEquals(1, msgs.size());
-   		msgRec = (Message)msgs.get(0);
-   		assertTrue(msg3 == msgRec);
-   		receiver2.acknowledge(msgRec, null);
-   		msgs = queue2.browse(null);
-   		assertNotNull(msgs);
-   		assertTrue(msgs.isEmpty());  
-
-   		msgs = receiver3.getMessages();
-   		assertNotNull(msgs);
-   		assertEquals(3, msgs.size());
-   		Message msgRec1 = (Message)msgs.get(0);
-   		assertTrue(msg1 == msgRec1);
-   		Message msgRec2 = (Message)msgs.get(1);
-   		assertTrue(msg2 == msgRec2);
-   		Message msgRec3 = (Message)msgs.get(2);
-   		assertTrue(msg3 == msgRec3);
-
-   		receiver3.acknowledge(msgRec1, null);
-   		receiver3.acknowledge(msgRec2, null);
-   		receiver3.acknowledge(msgRec3, null);
-   		msgs = queue3.browse(null);
-   		assertNotNull(msgs);
-   		assertTrue(msgs.isEmpty()); 
-
-   		if (checkNoMessageData())
-   		{
-   			fail("Message data still in database");
-   		}
-   	}
-   	finally
-   	{
-   		if (office1 != null)
-   		{
-   			office1.stop();
-   		}
-
-   		if (office2 != null)
-   		{
-   			office2.stop();
-   		}
-
-   	}
-   }
-   
-   private void clusteredRouteFourNodes(boolean persistentMessage) throws Throwable
-   {
-   	PostOffice office1 = null;
-
-   	PostOffice office2 = null;
-   	
-   	PostOffice office3 = null;
-
-   	PostOffice office4 = null;
-
-   	try
-   	{   
-   		office1 = createClusteredPostOffice(1, "testgroup");
-   		office2 = createClusteredPostOffice(2, "testgroup");
-   		office3 = createClusteredPostOffice(3, "testgroup");
-   		office4 = createClusteredPostOffice(4, "testgroup");
-
-   		Queue queue1 =  new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue1.activate();
-   		boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
-   		assertTrue(added);
-   		
-   		Queue queue2 =  new MessagingQueue(2, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue2.activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue2, false), false);
-   		assertTrue(added);
-   		
-   		Queue queue3 =  new MessagingQueue(3, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue3.activate();
-   		added = office3.addBinding(new Binding(new SimpleCondition("condition1"), queue3, false), false);
-   		assertTrue(added);
-   		
-   		Queue queue4 =  new MessagingQueue(4, "queue4", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue4.activate();
-   		added = office4.addBinding(new Binding(new SimpleCondition("condition1"), queue4, false), false);
-   		assertTrue(added);
-
-   		SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue1.getLocalDistributor().add(receiver1);
-
-   		SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue2.getLocalDistributor().add(receiver2);
-
-   		SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue3.getLocalDistributor().add(receiver3);
-   		
-   		SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue4.getLocalDistributor().add(receiver4);
-
-   		Message msg1 = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
-   		MessageReference ref1 = ms.reference(msg1);  
-   		boolean routed = office1.route(ref1, new SimpleCondition("condition1"), null);   
-   		assertTrue(routed);
-
-   		Message msg2 = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
-   		MessageReference ref2 = ms.reference(msg2);         
-   		routed = office1.route(ref2, new SimpleCondition("condition1"), null);      
-   		assertTrue(routed);
-
-   		Message msg3 = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);      
-   		MessageReference ref3 = ms.reference(msg3);         
-   		routed = office1.route(ref3, new SimpleCondition("condition1"), null);      
-   		assertTrue(routed);
-
-   		Thread.sleep(1000);
-   		
-   		List msgs = receiver1.getMessages();
-   		assertNotNull(msgs);
-   		assertEquals(3, msgs.size());
-   		Message msgRec1 = (Message)msgs.get(0);
-   		assertTrue(msg1 == msgRec1);
-   		Message msgRec2 = (Message)msgs.get(1);
-   		assertTrue(msg2 == msgRec2);
-   		Message msgRec3 = (Message)msgs.get(2);
-   		assertTrue(msg3 == msgRec3);
-
-   		receiver1.acknowledge(msgRec1, null);
-   		receiver1.acknowledge(msgRec2, null);
-   		receiver1.acknowledge(msgRec3, null);
-   		msgs = queue1.browse(null);
-   		assertNotNull(msgs);
-   		assertTrue(msgs.isEmpty()); 
-   		
-   		msgs = receiver2.getMessages();
-   		assertNotNull(msgs);
-   		assertEquals(3, msgs.size());
-   		msgRec1 = (Message)msgs.get(0);
-   		assertTrue(msg1 == msgRec1);
-   		msgRec2 = (Message)msgs.get(1);
-   		assertTrue(msg2 == msgRec2);
-   		msgRec3 = (Message)msgs.get(2);
-   		assertTrue(msg3 == msgRec3);
-
-   		receiver2.acknowledge(msgRec1, null);
-   		receiver2.acknowledge(msgRec2, null);
-   		receiver2.acknowledge(msgRec3, null);
-   		msgs = queue2.browse(null);
-   		assertNotNull(msgs);
-   		assertTrue(msgs.isEmpty()); 
-
-   		msgs = receiver3.getMessages();
-   		assertNotNull(msgs);
-   		assertEquals(3, msgs.size());
-   		msgRec1 = (Message)msgs.get(0);
-   		assertTrue(msg1 == msgRec1);
-   		msgRec2 = (Message)msgs.get(1);
-   		assertTrue(msg2 == msgRec2);
-   		msgRec3 = (Message)msgs.get(2);
-   		assertTrue(msg3 == msgRec3);
-
-   		receiver3.acknowledge(msgRec1, null);
-   		receiver3.acknowledge(msgRec2, null);
-   		receiver3.acknowledge(msgRec3, null);
-   		msgs = queue3.browse(null);
-   		assertNotNull(msgs);
-   		assertTrue(msgs.isEmpty()); 
-   		
-   		msgs = receiver4.getMessages();
-   		assertNotNull(msgs);
-   		assertEquals(3, msgs.size());
-   		msgRec1 = (Message)msgs.get(0);
-   		assertTrue(msg1 == msgRec1);
-   		msgRec2 = (Message)msgs.get(1);
-   		assertTrue(msg2 == msgRec2);
-   		msgRec3 = (Message)msgs.get(2);
-   		assertTrue(msg3 == msgRec3);
-
-   		receiver4.acknowledge(msgRec1, null);
-   		receiver4.acknowledge(msgRec2, null);
-   		receiver4.acknowledge(msgRec3, null);
-   		msgs = queue4.browse(null);
-   		assertNotNull(msgs);
-   		assertTrue(msgs.isEmpty()); 
-   		
-   		if (checkNoMessageData())
-   		{
-   			fail("Message data still in database");
-   		}
-   	}
-   	finally
-   	{
-   		if (office1 != null)
-   		{
-   			office1.stop();
-   		}
-
-   		if (office2 != null)
-   		{
-   			office2.stop();
-   		}
-   		
-   		if (office3 != null)
-   		{
-   			office3.stop();
-   		}
-
-   		if (office4 != null)
-   		{
-   			office4.stop();
-   		}
-
-   	}
-   }
-   
-   
-
-   private void clusteredRoute(boolean persistentMessage) throws Throwable
-   {
-   	PostOffice office1 = null;
-
-   	PostOffice office2 = null;
-
-   	try
-   	{   
-   		office1 = createClusteredPostOffice(1, "testgroup");
-   		office2 = createClusteredPostOffice(2, "testgroup");
-
-   		//A mixture of durable and non durable queues
-
-   		Queue[] queues = new Queue[16];
-
-   		//condition1
-
-   		queues[0] = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queues[0].activate();
-   		boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[0], false), false);
-   		assertTrue(added);
-
-   		queues[1] = new MessagingQueue(1, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queues[1].activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[1], false), false);
-   		assertTrue(added);
-
-   		queues[2] = new MessagingQueue(2, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queues[2].activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[2], false), false);
-   		assertTrue(added);
-
-   		queues[3] = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queues[3].activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[3], false), false);
-   		assertTrue(added);
-
-   		//durable
-
-   		queues[4] = new MessagingQueue(2, "sub5", channelIDManager.getID(), ms, pm, true, -1, null, true);
-   		queues[4].activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[4], false), false);
-   		assertTrue(added);
-
-   		queues[5] = new MessagingQueue(1, "sub6", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queues[5].activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[5], false), false);
-   		assertTrue(added);
-
-   		//durable
-
-   		queues[6] = new MessagingQueue(1, "sub7", channelIDManager.getID(), ms, pm, true, -1, null, true);
-   		queues[6].activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[6], false), false);
-   		assertTrue(added);
-
-   		//durable
-
-   		queues[7] = new MessagingQueue(1, "sub8", channelIDManager.getID(), ms, pm, true, -1, null, true);
-   		queues[7].activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[7], false), false);
-   		assertTrue(added);
-
-   		//condition2
-
-
-   		queues[8] = new MessagingQueue(1, "sub9", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queues[8].activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[8], false), false);
-   		assertTrue(added);
-
-   		queues[9] = new MessagingQueue(1, "sub10", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queues[9].activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[9], false), false);
-   		assertTrue(added);
-
-   		queues[10] = new MessagingQueue(2, "sub11", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queues[10].activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[10], false), false);
-   		assertTrue(added);
-
-   		queues[11] = new MessagingQueue(2, "sub12", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queues[11].activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[11], false), false);
-   		assertTrue(added);
-
-   		//durable
-
-   		queues[12] = new MessagingQueue(2, "sub13", channelIDManager.getID(), ms, pm, true, -1, null, true);
-   		queues[12].activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[12], false), false);
-   		assertTrue(added);
-
-   		queues[13] = new MessagingQueue(1, "sub14", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queues[13].activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[13], false), false);
-   		assertTrue(added);
-
-   		//durable
-
-   		queues[14] = new MessagingQueue(1, "sub15", channelIDManager.getID(), ms, pm, true, -1, null, true);
-   		queues[14].activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[14], false), false);
-   		assertTrue(added);
-
-   		queues[15] = new MessagingQueue(1, "sub16", channelIDManager.getID(), ms, pm, true, -1, null, true);
-   		queues[15].activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[15], false), false);
-   		assertTrue(added);
-
-   		SimpleReceiver[] receivers = new SimpleReceiver[16];
-
-   		for (int i = 0; i < 16; i++)
-   		{
-   			receivers[i] = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   			queues[i].getLocalDistributor().add(receivers[i]);
-   		}
-
-   		Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
-   		MessageReference ref = ms.reference(msg);         
-
-   		boolean routed = office1.route(ref, new SimpleCondition("condition1"), null);         
-   		assertTrue(routed);
-
-   		//Messages are sent asych so may take some finite time to arrive
-   		Thread.sleep(1000);
-
-   		//Durable queues on remote node should never get the message
-
-   		for (int i = 0; i < 16; i++)
-   		{
-   			if (i >= 8 || (queues[i].getNodeID() == 2 && queues[i].isRecoverable()))
-   			{
-   				this.checkNotGetsMessage(queues[i], receivers[i]);
-   			}
-   			else
-   			{
-   				//Should get the message
-   				this.checkGetsMessage(queues[i], receivers[i], msg);
-   			}
-
-   		}
-
-   		//Now route to condition2
-
-   		msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);;      
-   		ref = ms.reference(msg);         
-
-   		routed = office2.route(ref, new SimpleCondition("condition2"), null);         
-   		assertTrue(routed);
-   		//Messages are sent asych so may take some finite time to arrive
-   		Thread.sleep(1000);
-
-   		for (int i = 0; i < 16; i++)
-   		{
-   			if (i < 8 || (queues[i].getNodeID() == 1 && queues[i].isRecoverable()))
-   			{
-   				//Shouldn't get the message
-   				this.checkNotGetsMessage(queues[i], receivers[i]);
-   			}
-   			else
-   			{
-   				//Should get the message
-   				this.checkGetsMessage(queues[i], receivers[i], msg);
-   			}
-
-   		}
-
-   		if (checkNoMessageData())
-   		{
-   			fail("Message data still in database");
-   		}
-   	}
-   	finally
-   	{
-   		if (office1 != null)
-   		{
-   			try
-   			{              
-   				office1.removeBinding("sub7", false);
-   				office1.removeBinding("sub8", false);               
-   				office1.removeBinding("sub15", false);
-   				office1.removeBinding("sub16", false);
-   			}
-   			catch (Exception ignore)
-   			{
-   				ignore.printStackTrace();
-   			}
-
-   			office1.stop();
-   		}
-
-   		if (office2 != null)
-   		{
-   			try
-   			{
-   				office2.removeBinding("sub5", false);
-   				office2.removeBinding("sub13", false);
-   			}
-   			catch (Exception ignore)
-   			{     
-   				ignore.printStackTrace();
-   			}
-   			office2.stop();
-   		}
-
-   	}
-   }
-
-
-
-   /*
-    * Queues with same name on different nodes of the cluster.
-    * If queue is routed to locally it shouldn't be routed to on other nodes
-    * 
-    */
-   private void routeSharedQueue(boolean persistentMessage) throws Throwable
-   {
-   	PostOffice office1 = null;
-
-   	PostOffice office2 = null;
-
-   	try
-   	{   
-   		office1 = createClusteredPostOffice(1, "testgroup");
-   		office2 = createClusteredPostOffice(2, "testgroup");
-
-   		//queue1
-
-   		Queue queue0 = new MessagingQueue(1, "myqueue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue0.activate();
-   		boolean added = office1.addBinding(new Binding(new SimpleCondition("myqueue1"), queue0, false), false);
-   		assertTrue(added);
-
-   		Queue queue1 = new MessagingQueue(2, "myqueue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue1.activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("myqueue1"), queue1, false), false);
-   		assertTrue(added);
-
-
-   		//queue2
-
-   		Queue queue2 = new MessagingQueue(1, "myqueue2", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue2.activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("myqueue2"), queue2, false), false);
-   		assertTrue(added);
-
-   		Queue queue3 = new MessagingQueue(2, "myqueue2", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue3.activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("myqueue2"), queue3, false), false);
-   		assertTrue(added);
-
-
-   		SimpleReceiver receiver0 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue0.getLocalDistributor().add(receiver0);
-
-   		SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue1.getLocalDistributor().add(receiver1);
-
-   		SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue2.getLocalDistributor().add(receiver2);
-
-   		SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue3.getLocalDistributor().add(receiver3);
-
-   		//Route to myqueue1 from office1         
-
-   		Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
-   		MessageReference ref = ms.reference(msg);         
-
-   		boolean routed = office1.route(ref, new SimpleCondition("myqueue1"), null);         
-   		assertTrue(routed);
-
-   		//Messages are sent asych so may take some finite time to arrive
-   		Thread.sleep(1000);
-
-   		//Only queue0 should get the message
-   		checkGetsMessage(queue0, receiver0, msg);
-
-   		checkNotGetsMessage(queue1, receiver1);
-
-   		checkNotGetsMessage(queue2, receiver2);
-
-   		checkNotGetsMessage(queue3, receiver3);
-
-   		//	Route to myqueue1 from office 2      
-
-   		msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
-   		ref = ms.reference(msg);         
-
-   		routed = office2.route(ref, new SimpleCondition("myqueue1"), null);         
-   		assertTrue(routed);
-
-   		//Messages are sent asych so may take some finite time to arrive
-   		Thread.sleep(1000);
-
-   		//Only queue1 should get the message
-   		checkGetsMessage(queue1, receiver1, msg);
-
-   		checkNotGetsMessage(queue0, receiver0);
-
-   		checkNotGetsMessage(queue2, receiver2);
-
-   		checkNotGetsMessage(queue3, receiver3);
-
-
-   		//Now route to condition2 from office 1
-
-   		msg = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);;      
-   		ref = ms.reference(msg);         
-
-   		routed = office1.route(ref, new SimpleCondition("myqueue2"), null);         
-   		assertTrue(routed);
-   		//Messages are sent asych so may take some finite time to arrive
-   		Thread.sleep(1000);
-
-   		// Only queue2 should get the message
-   		checkGetsMessage(queue2, receiver2, msg);
-
-   		checkNotGetsMessage(queue1, receiver1);
-
-   		checkNotGetsMessage(queue0, receiver0);
-
-   		checkNotGetsMessage(queue3, receiver3);
-
-
-   		//Now route to condition2 from office 2
-
-   		msg = CoreMessageFactory.createCoreMessage(4, persistentMessage, null);;      
-   		ref = ms.reference(msg);         
-
-   		routed = office2.route(ref, new SimpleCondition("myqueue2"), null);         
-   		assertTrue(routed);
-   		//Messages are sent asych so may take some finite time to arrive
-   		Thread.sleep(1000);
-
-   		// Only queue3 should get the message
-   		checkGetsMessage(queue3, receiver3, msg);
-
-   		checkNotGetsMessage(queue1, receiver1);
-
-   		checkNotGetsMessage(queue0, receiver0);
-
-   		checkNotGetsMessage(queue2, receiver2);
-
-
-
-   		if (checkNoMessageData())
-   		{
-   			fail("Message data still in database");
-   		}
-   	}
-   	finally
-   	{
-   		if (office1 != null)
-   		{
-   			office1.stop();
-   		}
-
-   		if (office2 != null)
-   		{
-
-   			office2.stop();
-   		}
-
-   	}
-   }
-
-
-   private void routeWithFilter(boolean persistentMessage) throws Throwable
-   {
-   	PostOffice office1 = null;
-
-   	PostOffice office2 = null;
-
-   	try
-   	{   
-   		office1 = createClusteredPostOffice(1, "testgroup");
-   		office2 = createClusteredPostOffice(2, "testgroup");
-
-
-   		Queue queue0 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue0.activate();
-   		boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue0, false), false);
-   		assertTrue(added);
-
-   		Queue queue1 = new MessagingQueue(2, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue1.activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
-   		assertTrue(added);
-
-
-   		Queue queue2 = new MessagingQueue(1, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue2.activate();
-   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queue2, false), false);
-   		assertTrue(added);
-
-   		Queue queue3 = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
-   		queue3.activate();
-   		added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queue3, false), false);
-   		assertTrue(added);
-
-
-   		SimpleReceiver receiver0 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue0.getLocalDistributor().add(receiver0);
-
-   		SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue1.getLocalDistributor().add(receiver1);
-
-   		SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue2.getLocalDistributor().add(receiver2);
-
-   		SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-   		queue3.getLocalDistributor().add(receiver3);
-
-   		//Route to condition1 from office1         
-
-   		Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
-   		MessageReference ref = ms.reference(msg);         
-
-   		boolean routed = office1.route(ref, new SimpleCondition("myqueue1"), null);         
-   		assertTrue(routed);
-
-   		//Messages are sent asych so may take some finite time to arrive
-   		Thread.sleep(1000);
-
-   		//Only queue0 should get the message
-   		checkGetsMessage(queue0, receiver0, msg);
-
-   		checkNotGetsMessage(queue1, receiver1);
-
-   		checkNotGetsMessage(queue2, receiver2);
-
-   		checkNotGetsMessage(queue3, receiver3);
-
-   		//	Route to myqueue1 from office 2      
-
-   		msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
-   		ref = ms.reference(msg);         
-
-   		routed = office2.route(ref, new SimpleCondition("myqueue1"), null);         
-   		assertTrue(routed);
-
-   		//Messages are sent asych so may take some finite time to arrive
-   		Thread.sleep(1000);
-
-   		//Only queue1 should get the message
-   		checkGetsMessage(queue1, receiver1, msg);
-
-   		checkNotGetsMessage(queue0, receiver0);
-
-   		checkNotGetsMessage(queue2, receiver2);
-
-   		checkNotGetsMessage(queue3, receiver3);
-
-
-   		//Now route to condition2 from office 1
-
-   		msg = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);;      
-   		ref = ms.reference(msg);         
-
-   		routed = office1.route(ref, new SimpleCondition("myqueue2"), null);         
-   		assertTrue(routed);
-   		//Messages are sent asych so may take some finite time to arrive
-   		Thread.sleep(1000);
-
-   		// Only queue2 should get the message
-   		checkGetsMessage(queue2, receiver2, msg);
-
-   		checkNotGetsMessage(queue1, receiver1);
-
-   		checkNotGetsMessage(queue0, receiver0);
-
-   		checkNotGetsMessage(queue3, receiver3);
-
-
-   		//Now route to condition2 from office 2
-
-   		msg = CoreMessageFactory.createCoreMessage(4, persistentMessage, null);;      
-   		ref = ms.reference(msg);         
-
-   		routed = office2.route(ref, new SimpleCondition("myqueue2"), null);         
-   		assertTrue(routed);
-   		//Messages are sent asych so may take some finite time to arrive
-   		Thread.sleep(1000);
-
-   		// Only queue3 should get the message
-   		checkGetsMessage(queue3, receiver3, msg);
-
-   		checkNotGetsMessage(queue1, receiver1);
-
-   		checkNotGetsMessage(queue0, receiver0);
-
-   		checkNotGetsMessage(queue2, receiver2);
-
-
-
-   		if (checkNoMessageData())
-   		{
-   			fail("Message data still in database");
-   		}
-   	}
-   	finally
-   	{
-   		if (office1 != null)
-   		{
-   			office1.stop();
-   		}
-
-   		if (office2 != null)
-   		{
-
-   			office2.stop();
-   		}
-
-   	}
-   }
-
-   private void dumpNodeIDView(PostOffice postOffice)
-   {
-   	Set view = postOffice.nodeIDView();
-
-   	log.info("=== node id view ==");
-
-   	Iterator iter = view.iterator();
-
-   	while (iter.hasNext())
-   	{
-   		log.info("Node:" + iter.next());
-   	}
-
-   	log.info("==================");
-   }
-
-   private void assertGotAll(int nodeId, Collection bindings, String queueName)
-   {
-
-   	log.info("============= dumping bindings ========");
-
-   	Iterator iter = bindings.iterator();
-
-   	while (iter.hasNext())
-   	{
-   		Binding binding = (Binding)iter.next();
-
-   		log.info("Binding: " + binding);
-   	}
-
-   	log.info("========= end dump==========");
-
-   	assertEquals(3, bindings.size());
-
-   	iter = bindings.iterator();
-
-   	boolean got1 = false;
-   	boolean got2 = false;
-   	boolean got3 = false;         
-   	while (iter.hasNext())
-   	{
-   		Binding binding = (Binding)iter.next();
-
-   		log.info("binding node id " + binding.queue.getNodeID());
-
-   		assertEquals(queueName, binding.queue.getName());
-   		if (binding.queue.getNodeID() == nodeId)
-   		{
-   			assertTrue(binding.allNodes);
-   		}
-   		else
-   		{
-   			assertFalse(binding.allNodes);
-   		}
-
-   		if (binding.queue.getNodeID() == 1)
-   		{
-   			got1 = true;
-   		}
-   		if (binding.queue.getNodeID() == 2)
-   		{
-   			got2 = true;
-   		}
-   		if (binding.queue.getNodeID() == 3)
-   		{
-   			got3 = true;
-   		}    	
-   	}         
-   	assertTrue(got1 && got2 && got3);
-   }
-
-
-   private void checkGetsMessage(Queue queue, SimpleReceiver receiver, Message msg) throws Throwable
-   {
-   	List msgs = receiver.getMessages();
-   	assertNotNull(msgs);
-   	assertEquals(1, msgs.size());
-   	Message msgRec = (Message)msgs.get(0);
-   	assertEquals(msg.getMessageID(), msgRec.getMessageID());
-   	receiver.acknowledge(msgRec, null);
-   	msgs = queue.browse(null);
-   	assertNotNull(msgs);
-   	assertTrue(msgs.isEmpty()); 
-   	receiver.clear();
-   }
-
-   private void checkNotGetsMessage(Queue queue, SimpleReceiver receiver) throws Throwable
-   {
-   	List msgs = receiver.getMessages();
-   	assertNotNull(msgs);
-   	assertTrue(msgs.isEmpty());
-   	msgs = queue.browse(null);
-   	assertNotNull(msgs);
-   	assertTrue(msgs.isEmpty());
-   }
-   
-   // Inner classes --------------------------------------------------------------------------------
-
-}
-
-
-

Deleted: trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/PostOfficeTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/PostOfficeTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/PostOfficeTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -1,1284 +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.core.plugin.postoffice;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.jboss.messaging.core.contract.Binding;
-import org.jboss.messaging.core.contract.Condition;
-import org.jboss.messaging.core.contract.Message;
-import org.jboss.messaging.core.contract.MessageReference;
-import org.jboss.messaging.core.contract.PostOffice;
-import org.jboss.messaging.core.contract.Queue;
-import org.jboss.messaging.core.impl.MessagingQueue;
-import org.jboss.messaging.core.impl.tx.Transaction;
-import org.jboss.test.messaging.core.PostOfficeTestBase;
-import org.jboss.test.messaging.core.SimpleCondition;
-import org.jboss.test.messaging.core.SimpleFilter;
-import org.jboss.test.messaging.core.SimpleReceiver;
-import org.jboss.test.messaging.util.CoreMessageFactory;
-
-/**
- * 
- * A PostOfficeTest
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 2386 $</tt>
- *
- * $Id: DefaultPostOfficeTest.java 2386 2007-02-21 18:07:44Z timfox $
- *
- */
-public class PostOfficeTest extends PostOfficeTestBase
-{
-   // Constants -----------------------------------------------------
-
-   // Static --------------------------------------------------------
-   
-   // Attributes ----------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public PostOfficeTest(String name)
-   {
-      super(name);
-   }
-
-   // Public --------------------------------------------------------
-   
-   public final void testBindUnbind() throws Throwable
-   {
-      PostOffice office1 = null;
-      
-      PostOffice office2 = null;
-      
-      PostOffice office3 = null;
-      
-      try
-      {             
-         office1 = createNonClusteredPostOffice();
-         
-         //Bind one durable
-             
-         MessagingQueue queue1 =
-            new MessagingQueue(1, "durableQueue", channelIDManager.getID(), ms, pm, true, -1, null, false);
-         queue1.activate();
-         
-         Condition condition1 = new SimpleCondition("condition1");
-                  
-         office1.addBinding(new Binding(condition1, queue1, false), false);
-         
-         //Binding twice with the same name should fail      
-         try
-         {
-            office1.addBinding(new Binding(condition1, queue1, false), false);
-            fail();
-         }
-         catch (IllegalArgumentException e)
-         {
-            //Ok
-         }
-         
-         //Can't bind a queue from another node
-         
-         try
-         {
-         
-	         MessagingQueue queuexx =
-	            new MessagingQueue(777, "durableQueue", channelIDManager.getID(), ms, pm, true, -1, null, false);
-	         queuexx.activate();
-	         office1.addBinding(new Binding(condition1, queuexx, false), false);
-            fail();
-         }
-         catch (IllegalArgumentException e)
-         {
-            //Ok
-         }
-         
-               
-         //Bind one non durable
-         MessagingQueue queue2 =
-            new MessagingQueue(1, "nonDurableQueue", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue2.activate();
-         
-         Condition condition2 = new SimpleCondition("condition2");         
-         
-         office1.addBinding(new Binding(condition2, queue2, false), false);
-         
-         //Check they're there
-         
-         Collection queues = office1.getQueuesForCondition(condition1, true);
-         assertNotNull(queues);
-         assertEquals(1, queues.size());
-         Queue rqueue1 = (Queue)queues.iterator().next();
-         assertEquals(queue1, rqueue1);
-         
-         queues = office1.getQueuesForCondition(condition2, true);
-         assertNotNull(queues);
-         assertEquals(1, queues.size());
-         Queue rqueue2 = (Queue)queues.iterator().next();
-         assertEquals(queue2, rqueue2);
-         
-         
-         
-         office1.stop();
-         
-         //Throw away the office and create another
-         office2 = createNonClusteredPostOffice();
-         
-         //Only one binding should be there
-         queues = office2.getQueuesForCondition(condition1, true);
-         assertNotNull(queues);
-         assertEquals(1, queues.size());
-         rqueue1 = (Queue)queues.iterator().next();
-         assertEquals(queue1, rqueue1);
-         
-         queues = office2.getQueuesForCondition(condition2, true);
-         assertNotNull(queues);
-         assertTrue(queues.isEmpty());
-         
-         //Unbind the binding
-         office2.removeBinding(queue1.getName(), false);
-         
-         
-         //Make sure no longer there
-         queues = office2.getQueuesForCondition(condition1, true);
-         assertNotNull(queues);
-         assertTrue(queues.isEmpty());
-         
-         queues = office2.getQueuesForCondition(condition2, true);
-         assertNotNull(queues);
-         assertTrue(queues.isEmpty());
-         
-         office2.stop();
-         
-         //Throw away office and start another
-         office3 = createNonClusteredPostOffice();
-         
-         //Make sure not there
-         queues = office3.getQueuesForCondition(condition1, true);
-         assertNotNull(queues);
-         assertTrue(queues.isEmpty());
-         
-         queues = office3.getQueuesForCondition(condition2, true);
-         assertNotNull(queues);
-         assertTrue(queues.isEmpty());
-                  
-      }
-      finally
-      {
-         if (office1 != null)
-         {
-            office1.stop();
-         }
-         
-         if (office2 != null)
-         {
-            office2.stop();
-         }
-         
-         if (office3 != null)
-         {
-            office2.stop();
-         }
-         
-         if (checkNoBindingData())
-         {
-            fail("Binding data still in database");
-         }
-      }
-            
-   }
-   
-   public final void testGetQueuesForCondition() throws Throwable
-   {
-      PostOffice office = null;
-      
-      try
-      {      
-         office = createNonClusteredPostOffice();
-         
-         Condition condition1 = new SimpleCondition("condition1");
-         
-         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue1.activate();
-         
-         office.addBinding(new Binding(condition1, queue1, false), false);
-         
-         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue2.activate();
-         
-         office.addBinding(new Binding(condition1, queue2, false), false);
-         
-         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue3.activate();
-         
-         office.addBinding(new Binding(condition1, queue3, false), false);
-         
-         MessagingQueue queue4 = new MessagingQueue(1, "queue4", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue4.activate();
-         
-         office.addBinding(new Binding(condition1, queue4, false), false);
-         
-         MessagingQueue queue5 = new MessagingQueue(1, "queue5", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue5.activate();
-         
-         Condition condition2 = new SimpleCondition("condition2");         
-         
-         office.addBinding(new Binding(condition2, queue5, false), false);
-         
-         MessagingQueue queue6 = new MessagingQueue(1, "queue6", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue6.activate();
-         
-         office.addBinding(new Binding(condition2, queue6, false), false);
-         
-         MessagingQueue queue7 = new MessagingQueue(1, "queue7", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue7.activate();
-         
-         office.addBinding(new Binding(condition2, queue7, false), false);
-         
-         MessagingQueue queue8 = new MessagingQueue(1, "queue8", channelIDManager.getID(), ms, pm,  false, -1, null, false);
-         queue8.activate();
-         
-         office.addBinding(new Binding(condition2, queue8, false), false);
-                  
-         Collection queues = office.getQueuesForCondition(new SimpleCondition("dummy"), true);
-         assertNotNull(queues);
-         assertTrue(queues.isEmpty());
-                           
-         //We don't match on substrings
-         queues = office.getQueuesForCondition(new SimpleCondition("condition123"), true);
-         assertNotNull(queues);
-         assertTrue(queues.isEmpty());
-         
-         //We don't currently support hierarchies
-         queues = office.getQueuesForCondition(new SimpleCondition("condition1.subcondition"), true);
-         assertNotNull(queues);
-         assertTrue(queues.isEmpty());
-         
-         //Lookup the queues
-         
-         queues = office.getQueuesForCondition(condition1, true);
-         assertNotNull(queues);
-         assertEquals(4, queues.size());
-         
-         assertTrue(queues.contains(queue1));
-         assertTrue(queues.contains(queue2));
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         
-         queues = office.getQueuesForCondition(condition2, true);
-         assertNotNull(queues);
-         assertEquals(4, queues.size());
-         
-         assertTrue(queues.contains(queue5));
-         assertTrue(queues.contains(queue6));
-         assertTrue(queues.contains(queue7));
-         assertTrue(queues.contains(queue8));
-         
-         //Lookup should work on new instance too
-         
-         queues = office.getQueuesForCondition(new SimpleCondition("condition1"), true);
-         assertNotNull(queues);
-         assertEquals(4, queues.size());
-         
-         assertTrue(queues.contains(queue1));
-         assertTrue(queues.contains(queue2));
-         assertTrue(queues.contains(queue3));
-         assertTrue(queues.contains(queue4));
-         
-         queues = office.getQueuesForCondition(new SimpleCondition("condition2"), true);
-         assertNotNull(queues);
-         assertEquals(4, queues.size());
-         
-         assertTrue(queues.contains(queue5));
-         assertTrue(queues.contains(queue6));
-         assertTrue(queues.contains(queue7));
-         assertTrue(queues.contains(queue8));
-         
-      }
-      finally
-      {
-         if (office != null)
-         {
-            office.stop();
-         }
-         
-         if (checkNoBindingData())
-         {
-            fail("Binding data still in database");
-         }
-      }
-         
-   }
-   
-   public void testGetBindingForQueueName() throws Throwable
-   {   	
-      PostOffice office = null;
-      
-      try
-      {      
-         office = createNonClusteredPostOffice();
-                  
-         Condition condition1 = new SimpleCondition("condition1");  
-         
-         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         office.addBinding(new Binding(condition1, queue1, false), false);
-                         
-         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         office.addBinding(new Binding(condition1, queue2, false), false);
-         
-         Condition condition2 = new SimpleCondition("condition2");  
-                  
-         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         office.addBinding(new Binding(condition2, queue3, false), false);
-         
-         Binding b1 = office.getBindingForQueueName("queue1");
-         assertNotNull(b1);
-         assertEquals(queue1, b1.queue);
-         assertEquals(condition1, b1.condition);
-         
-         Binding b2 = office.getBindingForQueueName("queue2");
-         assertNotNull(b2);
-         assertEquals(queue2, b2.queue);
-         assertEquals(condition1, b2.condition);
-         
-         Binding b3 = office.getBindingForQueueName("queue3");
-         assertNotNull(b3);
-         assertEquals(queue3, b3.queue);
-         assertEquals(condition2, b3.condition);
-         
-         office.removeBinding("queue1", false);
-         
-         b1 = office.getBindingForQueueName("queue1");
-         assertNull(b1);
-
-         b2 = office.getBindingForQueueName("queue2");
-         assertNotNull(b2);
-         assertEquals(queue2, b2.queue);
-         assertEquals(condition1, b2.condition);
-         
-         b3 = office.getBindingForQueueName("queue3");
-         assertNotNull(b3);
-         assertEquals(queue3, b3.queue);
-         assertEquals(condition2, b3.condition);
-         
-         office.removeBinding("queue2", false);
-         office.removeBinding("queue3", false);
-         
-         b1 = office.getBindingForQueueName("queue1");
-         assertNull(b1);
-
-         b2 = office.getBindingForQueueName("queue2");
-         assertNull(b2);
- 
-         b3 = office.getBindingForQueueName("queue3");
-         assertNull(b3);                     
-      }
-      finally
-      {
-         if (office != null)
-         {
-            office.stop();
-         }
-         
-         if (checkNoBindingData())
-         {
-            fail("Binding data still in database");
-         }
-      }
-         
-   }
-   
-   public void testGetBindingForChannelID() throws Throwable
-   {   	
-      PostOffice office = null;
-      
-      try
-      {      
-         office = createNonClusteredPostOffice();
-                  
-         Condition condition1 = new SimpleCondition("condition1");  
-         
-         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         office.addBinding(new Binding(condition1, queue1, false), false);
-                         
-         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         office.addBinding(new Binding(condition1, queue2, false), false);
-         
-         Condition condition2 = new SimpleCondition("condition2");  
-                  
-         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         office.addBinding(new Binding(condition2, queue3, false), false);
-         
-         Binding b1 = office.getBindingForChannelID(queue1.getChannelID());
-         assertNotNull(b1);
-         assertEquals(queue1, b1.queue);
-         assertEquals(condition1, b1.condition);
-         
-         Binding b2 = office.getBindingForChannelID(queue2.getChannelID());
-         assertNotNull(b2);
-         assertEquals(queue2, b2.queue);
-         assertEquals(condition1, b2.condition);
-         
-         Binding b3 = office.getBindingForChannelID(queue3.getChannelID());
-         assertNotNull(b3);
-         assertEquals(queue3, b3.queue);
-         assertEquals(condition2, b3.condition);
-         
-         office.removeBinding("queue1", false);
-         
-         b1 = office.getBindingForChannelID(queue1.getChannelID());
-         assertNull(b1);
-
-         b2 =office.getBindingForChannelID(queue2.getChannelID());
-         assertNotNull(b2);
-         assertEquals(queue2, b2.queue);
-         assertEquals(condition1, b2.condition);
-         
-         b3 = office.getBindingForChannelID(queue3.getChannelID());
-         assertNotNull(b3);
-         assertEquals(queue3, b3.queue);
-         assertEquals(condition2, b3.condition);
-         
-         office.removeBinding("queue2", false);
-         office.removeBinding("queue3", false);
-         
-         b1 = office.getBindingForChannelID(queue1.getChannelID());
-         assertNull(b1);
-
-         b2 = office.getBindingForChannelID(queue2.getChannelID());
-         assertNull(b2);
- 
-         b3 = office.getBindingForChannelID(queue3.getChannelID());
-         assertNull(b3);                     
-      }
-      finally
-      {
-         if (office != null)
-         {
-            office.stop();
-         }
-         
-         if (checkNoBindingData())
-         {
-            fail("Binding data still in database");
-         }
-      }
-         
-   }
-
-   public void testRouteNonPersistentWithFilter() throws Throwable
-   {
-      routeWithFilter(false);
-   }
-   
-   public void testRoutePersistentWithFilter() throws Throwable
-   {
-      routeWithFilter(true);
-   }
-   
-   public final void testRoutePersistent() throws Throwable
-   {
-      route(true);
-   }
-   
-   public final void testRouteNonPersistent() throws Throwable
-   {
-      route(false);
-   }
-   
-   public final void testRouteTransactionalPersistent() throws Throwable
-   {
-      routeTransactional(true);
-   }
-   
-   public final void testRouteTransactionalNonPersistent() throws Throwable
-   {
-      routeTransactional(false);
-   }
-         
-   public final void testRouteInactive() throws Throwable
-   {
-      PostOffice postOffice = null;
-      
-      try
-      {      
-         postOffice = createNonClusteredPostOffice();
-         
-         Condition condition1 = new SimpleCondition("topic1");
-         
-         MessagingQueue queue1 =  new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue1.activate();
-         
-         postOffice.addBinding(new Binding(condition1, queue1, false), false);
-         
-         MessagingQueue queue2 =  new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue2.activate();
-         
-         postOffice.addBinding(new Binding(condition1, queue2, false), false);
-         
-         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue3.activate();
-         
-         postOffice.addBinding(new Binding(condition1, queue3, false), false);
-         
-         MessagingQueue queue4 = new MessagingQueue(1, "queue4", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue4.activate();
-         
-         Condition condition2 = new SimpleCondition("topic2");
-         
-         
-         postOffice.addBinding(new Binding(condition2, queue4, false), false);
-         
-         MessagingQueue queue5 = new MessagingQueue(1, "queue5", channelIDManager.getID(), ms, pm, false,-1, null, false);
-         queue5.activate();
-         
-         postOffice.addBinding(new Binding(condition2, queue5, false), false);
-         
-         MessagingQueue queue6 = new MessagingQueue(1, "queue6", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue6.activate();
-         
-         postOffice.addBinding(new Binding(condition2, queue6, false), false);
-      
-         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-         queue1.getLocalDistributor().add(receiver1);
-         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-         queue2.getLocalDistributor().add(receiver2);
-         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-         queue3.getLocalDistributor().add(receiver3);
-         SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-         queue4.getLocalDistributor().add(receiver4);
-         SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-         queue5.getLocalDistributor().add(receiver5);
-         SimpleReceiver receiver6 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-         queue6.getLocalDistributor().add(receiver6);
-         
-         queue1.deactivate();
-         queue2.deactivate();
-         queue5.deactivate();
-         queue6.deactivate();
-         
-         assertFalse(queue1.isActive());      
-         assertFalse(queue2.isActive());
-         assertFalse(queue5.isActive());
-         assertFalse(queue6.isActive()); 
-         assertTrue(queue3.isActive());
-         assertTrue(queue4.isActive());      
-         
-         Message msg1 = CoreMessageFactory.createCoreMessage(1);      
-         MessageReference ref1 = ms.reference(msg1);
-         
-         boolean routed = postOffice.route(ref1, condition1, null);      
-         assertTrue(routed);
-         
-         List msgs = receiver1.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver2.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver3.getMessages();
-         assertNotNull(msgs);
-         assertEquals(1, msgs.size());
-         Message msgRec = (Message)msgs.get(0);
-         assertTrue(msg1 == msgRec);
-         receiver3.acknowledge(msgRec, null);
-         msgs = queue3.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());  
-         
-         msgs = receiver4.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver5.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver6.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         receiver3.clear();
-                     
-         Message msg2 = CoreMessageFactory.createCoreMessage(2);      
-         MessageReference ref2 = ms.reference(msg2);
-         
-         routed = postOffice.route(ref2, condition2, null);      
-         assertTrue(routed);
-         
-         msgs = receiver1.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver2.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver3.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());      
-         
-         msgs = receiver4.getMessages();
-         assertNotNull(msgs);
-         assertEquals(1, msgs.size());
-         msgRec = (Message)msgs.get(0);
-         assertTrue(msg2 == msgRec);
-         receiver4.acknowledge(msgRec, null);
-         msgs = queue4.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());  
-         
-         msgs = receiver5.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver6.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         if (checkNoMessageData())
-         {
-            fail("data still in database");
-         }
-      }
-      finally
-      {
-         if (postOffice != null)
-         {
-            postOffice.stop();
-         }
-         
-      }
-   
-   }
-
-   public final void testRouteNoQueue() throws Throwable
-   {
-      PostOffice postOffice = null;
-      
-      try
-      {      
-         postOffice = createNonClusteredPostOffice();
-         
-         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue1.activate();
-         
-         postOffice.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
-              
-         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
-         
-         queue1.getLocalDistributor().add(receiver1);
-   
-         assertTrue(queue1.isActive());
-   
-         Message msg1 = CoreMessageFactory.createCoreMessage(1);      
-         
-         MessageReference ref1 = ms.reference(msg1);
-         
-         boolean routed = postOffice.route(ref1, new SimpleCondition("this won't match anything"), null);
-         
-         assertFalse(routed);
-               
-         List msgs = receiver1.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());  
-         
-         if (checkNoMessageData())
-         {
-            fail("data still in database");
-         }
-         
-      }
-      finally
-      {
-         if (postOffice != null)
-         {
-            postOffice.stop();
-         }
-         
-      }
-   }
-   
-   
-   
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-   
-   protected void routeWithFilter(boolean persistentMessage) throws Throwable
-   {
-      PostOffice postOffice = null;
-      
-      try
-      {      
-         postOffice = createNonClusteredPostOffice();
-         
-         SimpleFilter filter = new SimpleFilter(2);
-         
-         Condition condition1 = new SimpleCondition("topic1");
-      
-         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, filter, false);
-         queue1.activate();
-         
-         postOffice.addBinding(new Binding(condition1, queue1, false), false);
-         
-         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue2.activate();
-         
-         postOffice.addBinding(new Binding(condition1, queue2, false), false);
-         
-         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue3.activate();
-         
-         postOffice.addBinding(new Binding(condition1, queue3, false), false);
-         
-         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-         queue1.getLocalDistributor().add(receiver1);
-         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-         queue2.getLocalDistributor().add(receiver2);
-         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
-         queue3.getLocalDistributor().add(receiver3);
-         
-         Message msg1 = CoreMessageFactory.createCoreMessage(1);      
-         MessageReference ref1 = ms.reference(msg1);         
-         boolean routed = postOffice.route(ref1, condition1, null);      
-         assertTrue(routed);
-         Message msg2 = CoreMessageFactory.createCoreMessage(2);      
-         MessageReference ref2 = ms.reference(msg2);         
-         routed = postOffice.route(ref2, condition1, null);      
-         assertTrue(routed);
-         Message msg3 = CoreMessageFactory.createCoreMessage(3);      
-         MessageReference ref3 = ms.reference(msg3);         
-         routed = postOffice.route(ref3, condition1, null);      
-         assertTrue(routed);
-         
-         List msgs = receiver1.getMessages();
-         assertNotNull(msgs);           
-         assertEquals(1, msgs.size());                  
-         Message msgRec = (Message)msgs.get(0);
-         assertTrue(msg2 == msgRec);
-         receiver1.acknowledge(msgRec, null);
-         msgs = queue1.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());  
-         
-         msgs = receiver2.getMessages();
-         assertNotNull(msgs);
-         assertEquals(3, msgs.size());
-         Message msgRec1 = (Message)msgs.get(0);
-         assertTrue(msg1 == msgRec1);
-         Message msgRec2 = (Message)msgs.get(1);
-         assertTrue(msg2 == msgRec2);
-         Message msgRec3 = (Message)msgs.get(2);
-         assertTrue(msg3 == msgRec3);
-          
-         receiver2.acknowledge(msgRec1, null);
-         receiver2.acknowledge(msgRec2, null);
-         receiver2.acknowledge(msgRec3, null);
-         msgs = queue2.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());  
-         
-         msgs = receiver3.getMessages();
-         assertNotNull(msgs);
-         assertEquals(3, msgs.size());
-         msgRec1 = (Message)msgs.get(0);
-         assertTrue(msg1 == msgRec1);
-         msgRec2 = (Message)msgs.get(1);
-         assertTrue(msg2 == msgRec2);
-         msgRec3 = (Message)msgs.get(2);
-         assertTrue(msg3 == msgRec3);
-          
-         receiver3.acknowledge(msgRec1, null);
-         receiver3.acknowledge(msgRec2, null);
-         receiver3.acknowledge(msgRec3, null);
-         msgs = queue3.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty()); 
-         
-         if (checkNoMessageData())
-         {
-            fail("data still in database");
-         }
-         
-      }
-      finally
-      {
-         if (postOffice != null)
-         {
-            postOffice.stop();
-         }
-        
-      }
-   }
-   
-   protected void route(boolean persistentMessage) throws Throwable
-   {
-      PostOffice postOffice = null;
-      
-      try
-      {      
-         postOffice = createNonClusteredPostOffice();
-      
-         Condition condition1 = new SimpleCondition("topic1");
-         
-         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue1.activate();
-         
-         postOffice.addBinding(new Binding(condition1, queue1, false), false);
-         
-         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue2.activate();
-         
-         postOffice.addBinding(new Binding(condition1, queue2, false), false);
-         
-         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue3.activate();
-         
-         postOffice.addBinding(new Binding(condition1, queue3, false), false);
-         
-         MessagingQueue queue4 = new MessagingQueue(1, "queue4", channelIDManager.getID(), ms, pm, true, -1, null, false);
-         queue4.activate();
-         
-         Condition condition2 = new SimpleCondition("topic2");
-         
-         postOffice.addBinding(new Binding(condition2, queue4, false), false);
-         
-         MessagingQueue queue5 = new MessagingQueue(1, "queue5", channelIDManager.getID(), ms, pm, true, -1, null, false);
-         queue5.activate();
-         
-         postOffice.addBinding(new Binding(condition2, queue5, false), false);
-         
-         MessagingQueue queue6 = new MessagingQueue(1, "queue6", channelIDManager.getID(), ms, pm, true, -1, null, false);
-         queue6.activate();
-         
-         postOffice.addBinding(new Binding(condition2, queue6, false), false);
-      
-         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
-         queue1.getLocalDistributor().add(receiver1);
-         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
-         queue2.getLocalDistributor().add(receiver2);
-         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
-         queue3.getLocalDistributor().add(receiver3);
-         SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
-         queue4.getLocalDistributor().add(receiver4);
-         SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
-         queue5.getLocalDistributor().add(receiver5);
-         SimpleReceiver receiver6 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
-         queue6.getLocalDistributor().add(receiver6);
-         
-         assertTrue(queue1.isActive());      
-         assertTrue(queue2.isActive());
-         assertTrue(queue3.isActive());      
-         assertTrue(queue4.isActive());
-         assertTrue(queue5.isActive());      
-         assertTrue(queue6.isActive());
-         
-         Message msg1 = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
-         MessageReference ref1 = ms.reference(msg1);
-         
-         boolean routed = postOffice.route(ref1, condition1, null);      
-         assertTrue(routed);
-         
-         List msgs = receiver1.getMessages();
-         assertNotNull(msgs);
-         assertEquals(1, msgs.size());
-         Message msgRec = (Message)msgs.get(0);
-         assertTrue(msg1 == msgRec);
-         receiver1.acknowledge(msgRec, null);
-         msgs = queue1.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver2.getMessages();
-         assertNotNull(msgs);
-         assertEquals(1, msgs.size());
-         msgRec = (Message)msgs.get(0);
-         assertTrue(msg1 == msgRec);
-         receiver2.acknowledge(msgRec, null);
-         msgs = queue2.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver3.getMessages();
-         assertNotNull(msgs);
-         assertEquals(1, msgs.size());
-         msgRec = (Message)msgs.get(0);
-         assertTrue(msg1 == msgRec);
-         receiver3.acknowledge(msgRec, null);
-         msgs = queue3.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver4.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver5.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver6.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         receiver1.clear();
-         receiver2.clear();
-         receiver3.clear();
-         
-         
-         Message msg2 = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
-         MessageReference ref2 = ms.reference(msg2);
-         
-         routed = postOffice.route(ref2, condition2, null);      
-         assertTrue(routed);
-         
-         msgs = receiver4.getMessages();
-         assertNotNull(msgs);
-         assertEquals(1, msgs.size());
-         msgRec = (Message)msgs.get(0);
-         assertTrue(msg2 == msgRec);
-         receiver4.acknowledge(msgRec, null);
-         msgs = queue4.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver5.getMessages();
-         assertNotNull(msgs);
-         assertEquals(1, msgs.size());
-         msgRec = (Message)msgs.get(0);
-         assertTrue(msg2 == msgRec);
-         receiver5.acknowledge(msgRec, null);
-         msgs = queue5.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver6.getMessages();
-         assertNotNull(msgs);
-         assertEquals(1, msgs.size());
-         msgRec = (Message)msgs.get(0);
-         assertTrue(msg2 == msgRec);
-         receiver6.acknowledge(msgRec, null);
-         msgs = queue6.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());    
-         
-         msgs = receiver1.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver2.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = receiver3.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-      }
-      finally
-      {
-         if (postOffice != null)
-         {
-            postOffice.stop();
-         }
-         
-         if (checkNoMessageData())
-         {
-            fail("data still in database");
-         }
-      }
-   }
-   
-   protected void routeTransactional(boolean persistentMessage) throws Throwable
-   {
-      PostOffice postOffice = null;
-      
-      try
-      {      
-         postOffice = createNonClusteredPostOffice();
-         
-         Condition condition1 = new SimpleCondition("topic1");
-      
-         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
-         queue1.activate();
-         
-         postOffice.addBinding(new Binding(condition1, queue1, false), false);
-         
-         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, true,-1, null, false);
-         queue2.activate();
-         
-         postOffice.addBinding(new Binding(condition1, queue2, false), false);
-          
-         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
-         queue1.getLocalDistributor().add(receiver1);
-
-         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
-         queue2.getLocalDistributor().add(receiver2);
-   
-         assertTrue(queue1.isActive());
-         assertTrue(queue2.isActive());
-   
-         Message msg1 = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
-         MessageReference ref1 = ms.reference(msg1);
-         
-         Message msg2 = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
-         MessageReference ref2 = ms.reference(msg2);
-         
-         Transaction tx = tr.createTransaction();
-         
-         boolean routed = postOffice.route(ref1, condition1, tx);            
-         assertTrue(routed);
-         routed = postOffice.route(ref2, condition1, tx);            
-         assertTrue(routed);
-               
-         List msgs = queue1.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         msgs = queue2.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         tx.commit();
-         
-         msgs = receiver1.getMessages();
-         assertNotNull(msgs);
-         assertEquals(2, msgs.size());
-         Message msgRec1 = (Message)msgs.get(0);
-         Message msgRec2 = (Message)msgs.get(1);
-         assertTrue(msgRec1 == msg1);
-         assertTrue(msgRec2 == msg2);
-         
-         msgs = receiver2.getMessages();
-         assertNotNull(msgs);
-         assertEquals(2, msgs.size());
-         msgRec1 = (Message)msgs.get(0);
-         msgRec2 = (Message)msgs.get(1);
-         assertTrue(msgRec1 == msg1);
-         assertTrue(msgRec2 == msg2);
-         
-         //Acknowledge
-         receiver1.acknowledge(msgRec1, null);
-         receiver1.acknowledge(msgRec2, null);
-         
-         receiver2.acknowledge(msgRec1, null);
-         receiver2.acknowledge(msgRec2, null);
-   
-         msgs = queue1.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty()); 
-         
-         receiver1.clear();
-         
-         msgs = queue2.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty()); 
-         
-         receiver2.clear();
-              
-         Message msg3 = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);      
-         MessageReference ref3 = ms.reference(msg3);
-         
-         Message msg4 = CoreMessageFactory.createCoreMessage(4, persistentMessage, null);      
-         MessageReference ref4 = ms.reference(msg4);
-         
-         tx = tr.createTransaction();
-         
-         routed = postOffice.route(ref3, condition1, tx);            
-         assertTrue(routed);
-         routed = postOffice.route(ref4, condition1, tx);            
-         assertTrue(routed);
-               
-         msgs = queue1.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty()); 
-         
-         msgs = queue2.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty()); 
-         
-         tx.rollback();
-         
-         msgs = receiver1.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         receiver1.clear();
-         
-         msgs = receiver2.getMessages();
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-         
-         receiver2.clear();
-         
-         
-         Message msg5 = CoreMessageFactory.createCoreMessage(5, persistentMessage, null);      
-         MessageReference ref5 = ms.reference(msg5);
-         
-         Message msg6 = CoreMessageFactory.createCoreMessage(6, persistentMessage, null);      
-         MessageReference ref6 = ms.reference(msg6);
-               
-         routed = postOffice.route(ref5, new SimpleCondition("topic1"), null);            
-         assertTrue(routed);
-         routed = postOffice.route(ref6, new SimpleCondition("topic1"), null);            
-         assertTrue(routed);
-         
-         msgs = receiver1.getMessages();
-         assertNotNull(msgs);
-         assertEquals(2, msgs.size());
-         msgRec1 = (Message)msgs.get(0);
-         msgRec2 = (Message)msgs.get(1);
-         assertTrue(msgRec1 == msg5);
-         assertTrue(msgRec2 == msg6);
-         
-         msgs = receiver2.getMessages();
-         assertNotNull(msgs);
-         assertEquals(2, msgs.size());
-         msgRec1 = (Message)msgs.get(0);
-         msgRec2 = (Message)msgs.get(1);
-         assertTrue(msgRec1 == msg5);
-         assertTrue(msgRec2 == msg6);
-         
-         //Acknowledge transactionally
-         
-         tx = tr.createTransaction();
-         
-         receiver1.acknowledge(msgRec1, tx);
-         receiver1.acknowledge(msgRec2, tx);
-         
-         receiver2.acknowledge(msgRec1, tx);
-         receiver2.acknowledge(msgRec2, tx);
-         
-         int deliveringCount = queue1.getDeliveringCount();
-         assertEquals(2, deliveringCount);
-         
-         deliveringCount = queue2.getDeliveringCount();
-         assertEquals(2, deliveringCount);
-         
-         tx.commit();
-         
-         msgs = queue1.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-               
-         receiver1.clear();
-         
-         msgs = queue2.browse(null);
-         assertNotNull(msgs);
-         assertTrue(msgs.isEmpty());
-               
-         receiver2.clear();
-         
-         Message msg7 = CoreMessageFactory.createCoreMessage(7, persistentMessage, null);      
-         MessageReference ref7 = ms.reference(msg7);
-         
-         Message msg8 = CoreMessageFactory.createCoreMessage(8, persistentMessage, null);      
-         MessageReference ref8 = ms.reference(msg8);
-               
-         routed = postOffice.route(ref7, new SimpleCondition("topic1"), null);            
-         assertTrue(routed);
-         routed = postOffice.route(ref8, new SimpleCondition("topic1"), null);            
-         assertTrue(routed);
-         
-         msgs = receiver1.getMessages();
-         assertNotNull(msgs);
-         assertEquals(2, msgs.size());
-         msgRec1 = (Message)msgs.get(0);
-         msgRec2 = (Message)msgs.get(1);
-         assertTrue(msgRec1 == msg7);
-         assertTrue(msgRec2 == msg8);
-         
-         msgs = receiver2.getMessages();
-         assertNotNull(msgs);
-         assertEquals(2, msgs.size());
-         msgRec1 = (Message)msgs.get(0);
-         msgRec2 = (Message)msgs.get(1);
-         assertTrue(msgRec1 == msg7);
-         assertTrue(msgRec2 == msg8);
-         
-         //Acknowledge transactionally
-         
-         tx = tr.createTransaction();
-         
-         receiver1.acknowledge(msgRec1, tx);
-         receiver1.acknowledge(msgRec2, tx);
-         
-         receiver2.acknowledge(msgRec1, tx);
-         receiver2.acknowledge(msgRec2, tx);
-         
-         deliveringCount = queue1.getDeliveringCount();
-         assertEquals(2, deliveringCount);
-         
-         deliveringCount = queue2.getDeliveringCount();
-         assertEquals(2, deliveringCount);
-         
-         tx.rollback();
-         
-         deliveringCount = queue1.getDeliveringCount();
-         assertEquals(2, deliveringCount);                  
-         
-         receiver1.acknowledge(msgRec1, null);
-         receiver1.acknowledge(msgRec2, null);
-         
-         deliveringCount = queue2.getDeliveringCount();
-         assertEquals(2, deliveringCount);     
-         
-         
-         receiver2.acknowledge(msgRec1, null);
-         receiver2.acknowledge(msgRec2, null);
-         
-         if (checkNoMessageData())
-         {
-            fail("data still in database");
-         }
-      }
-      finally
-      {
-         if (postOffice != null)
-         {
-            postOffice.stop();
-         }         
-      }
-   }
-
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-
-   }
-
-   protected void tearDown() throws Exception
-   {
-      super.tearDown();
-   }
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-
-}
-

Deleted: trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/SimpleJChannelFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/SimpleJChannelFactory.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/SimpleJChannelFactory.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -1,97 +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.core.plugin.postoffice;
-
-import org.jgroups.JChannel;
-import org.jboss.messaging.core.contract.JChannelFactory;
-
-/**
- * A JChannelFactory that will use String JChannel configurations to create JChannel instances.
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class SimpleJChannelFactory implements JChannelFactory
-{
-   // Constants ------------------------------------------------------------------------------------
-
-   // Static ---------------------------------------------------------------------------------------
-
-   // Attributes -----------------------------------------------------------------------------------
-
-   String asyncConfig;
-   String syncConfig;
-
-   // Constructors ---------------------------------------------------------------------------------
-
-   public SimpleJChannelFactory(String syncConfig, String asyncConfig)
-   {
-      this.syncConfig = syncConfig;
-      this.asyncConfig = asyncConfig;
-   }
-
-   // JChannelFactory ------------------------------------------------------------------------------
-
-   public JChannel createControlChannel() throws Exception
-   {
-      return new JChannel(syncConfig);
-   }
-
-   public JChannel createDataChannel() throws Exception
-   {
-      return new JChannel(asyncConfig);
-   }
-
-   // Public ---------------------------------------------------------------------------------------
-
-   public String getAsyncConfig()
-   {
-      return asyncConfig;
-   }
-
-   public void setAsyncConfig(String asyncConfig)
-   {
-      this.asyncConfig = asyncConfig;
-   }
-
-   public String getSyncConfig()
-   {
-      return syncConfig;
-   }
-
-   public void setSyncConfig(String syncConfig)
-   {
-      this.syncConfig = syncConfig;
-   }
-
-   // Package protected ----------------------------------------------------------------------------
-
-   // Protected ------------------------------------------------------------------------------------
-
-   // Private --------------------------------------------------------------------------------------
-
-   // Inner classes --------------------------------------------------------------------------------
-
-}

Copied: trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java (from rev 2829, trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -0,0 +1,194 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.core.postoffice;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.contract.JChannelFactory;
+import org.jboss.messaging.core.impl.jchannelfactory.MultiplexerJChannelFactory;
+import org.jboss.messaging.util.XMLUtil;
+import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
+import org.jboss.test.messaging.tools.jboss.ServiceDeploymentDescriptor;
+import org.jboss.test.messaging.tools.jmx.ServiceConfigHelper;
+import org.jgroups.JChannel;
+import org.w3c.dom.Element;
+
+/**
+ * A JChannelFactory that reads the configuration of its synchronous/asynchronous JChannels from a
+ * Messaging-style clustered persistence service configuration file (usually shipped with a
+ * Messaging installation). The idea is to test with priority whatever we ship.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class ClusteredPersistenceServiceConfigFileJChannelFactory implements JChannelFactory
+{
+   // Constants ------------------------------------------------------------------------------------
+
+   public static final Logger log =
+      Logger.getLogger(ClusteredPersistenceServiceConfigFileJChannelFactory.class);
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   private String configFilePath;
+
+   // we're either using a delegate MultiplexerJChannelFactory, if we find one configured in the
+   // file ...
+   private JChannelFactory multiplexorDelegate;
+
+   // ... or just plain XML configuration.
+   private Element controlConfig;
+   private Element dataConfig;
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   /**
+    * @param configFilePath - the configuration file to read JGroups stack configurations from. Must
+    *        be relative to classpath components in order to be found.
+    * @param skipMultiplex - if true, ignore multiplex option, even if a channel factory name is
+    *        found in the configuration file. Otherwise, the channel factory will take priority
+    *        if found.
+    * @param mbeanServer - the MBeanServer instance, needed in case a channel factory name is found
+    *        in the configuration file. In this situation, the channel factory is preferred.
+    *        Irrelevant if skipMultiplex is true.
+    */
+   public ClusteredPersistenceServiceConfigFileJChannelFactory(String configFilePath,
+                                                               boolean skipMultiplex,
+                                                               MBeanServer mbeanServer)
+      throws Exception
+   {
+      this.configFilePath = configFilePath;
+      init(configFilePath, skipMultiplex, mbeanServer);
+   }
+
+   // JChannelFactory ------------------------------------------------------------------------------
+
+   public JChannel createControlChannel() throws Exception
+   {
+      if (multiplexorDelegate != null)
+      {
+         return multiplexorDelegate.createControlChannel();
+      }
+      else
+      {
+         return new JChannel(controlConfig);
+      }
+   }
+
+   public JChannel createDataChannel() throws Exception
+   {
+      if (multiplexorDelegate != null)
+      {
+         return multiplexorDelegate.createDataChannel();
+      }
+      else
+      {
+         return new JChannel(dataConfig);
+      }
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   public String toString()
+   {
+      return "ClusteredPersistenceServiceConfigFileJChannelFactory[" + configFilePath + "]";
+   }
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   // Private --------------------------------------------------------------------------------------
+
+   private void init(String configFilePath, boolean skipMultiplex, MBeanServer mbeanServer)
+      throws Exception
+   {
+      log.debug("using configuration file " + configFilePath);
+
+      MBeanConfigurationElement postOfficeConfig =
+         ServiceConfigHelper.loadServiceConfiguration(configFilePath, "PostOffice");
+
+      // first, we try to use a channel factory service, if we find one configured
+      String s = (String)postOfficeConfig.getAttributeValue("ChannelFactoryName");
+
+      if (s != null && !skipMultiplex)
+      {
+         // there's a chance we can use a multiplexer service
+         ObjectName channelFactoryName = new ObjectName(s);
+
+         String channelPartitionName =
+            (String)postOfficeConfig.getAttributeValue("ChannelPartitionName");
+
+         if (channelPartitionName == null)
+         {
+            throw new IllegalStateException("Cannot find ChannelPartitionName");
+         }
+
+         String controlChannelName = (String)postOfficeConfig.getAttributeValue("ControlChannelName");
+
+         if (controlChannelName == null)
+         {
+            throw new IllegalStateException("Cannot find ControlChannelName");
+         }
+
+         String dataChannelName = (String)postOfficeConfig.getAttributeValue("DataChannelName");
+
+         if (dataChannelName == null)
+         {
+            throw new IllegalStateException("Cannot find DataChannelName");
+         }
+
+         try
+         {
+            if(mbeanServer.getMBeanInfo(channelFactoryName) != null)
+            {
+               multiplexorDelegate =
+                  new MultiplexerJChannelFactory(mbeanServer, channelFactoryName,
+                                                 channelPartitionName, controlChannelName,
+                                                 dataChannelName);
+
+               // initialization ends here, we've found what we were looking for
+               return;
+            }
+         }
+         catch (Exception e)
+         {
+            // that's alright, no multiplexer there, use the regular XML configuration
+            log.debug("Wasn't able to find " + s);
+         }
+      }
+
+      // the only chance now is to use the XML configurations
+
+      s = (String)postOfficeConfig.getAttributeValue("ControlChannelConfig");
+
+      if (s == null)
+      {
+         throw new IllegalStateException("Cannot find ControlChannelConfig");
+      }
+
+      controlConfig = XMLUtil.stringToElement(s);
+
+      s = (String)postOfficeConfig.getAttributeValue("DataChannelConfig");
+
+      if (s == null)
+      {
+         throw new IllegalStateException("Cannot find DataChannelConfig");
+      }
+
+      dataConfig = XMLUtil.stringToElement(s);
+   }
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}

Copied: trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPostOfficeTest.java (from rev 2829, trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/ClusteredPostOfficeTest.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPostOfficeTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPostOfficeTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -0,0 +1,2851 @@
+/*
+  * 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.core.postoffice;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.messaging.core.contract.Binding;
+import org.jboss.messaging.core.contract.Condition;
+import org.jboss.messaging.core.contract.Message;
+import org.jboss.messaging.core.contract.MessageReference;
+import org.jboss.messaging.core.contract.PostOffice;
+import org.jboss.messaging.core.contract.Queue;
+import org.jboss.messaging.core.impl.MessagingQueue;
+import org.jboss.messaging.core.impl.tx.Transaction;
+import org.jboss.test.messaging.core.PostOfficeTestBase;
+import org.jboss.test.messaging.core.SimpleCondition;
+import org.jboss.test.messaging.core.SimpleFilter;
+import org.jboss.test.messaging.core.SimpleReceiver;
+import org.jboss.test.messaging.util.CoreMessageFactory;
+
+/**
+ * 
+ * A DefaultClusteredPostOfficeTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 2386 $</tt>
+ *
+ * $Id: DefaultPostOfficeTest.java 2386 2007-02-21 18:07:44Z timfox $
+ *
+ */
+public class ClusteredPostOfficeTest extends PostOfficeTestBase
+{
+   // Constants ------------------------------------------------------------------------------------
+
+   // Static ---------------------------------------------------------------------------------------
+   
+   // Attributes -----------------------------------------------------------------------------------
+    
+   // Constructors ---------------------------------------------------------------------------------
+
+   public ClusteredPostOfficeTest(String name)
+   {
+      super(name);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   public final void testSimpleJoinLeave() throws Throwable
+   {
+      PostOffice office1 = null;
+      PostOffice office2 = null;
+      PostOffice office3 = null;
+      
+      try
+      {         
+         office1 = createClusteredPostOffice(1, "testgroup");
+
+         office2 = createClusteredPostOffice(2, "testgroup");
+                  
+         office3 = createClusteredPostOffice(3, "testgroup");
+         
+         Thread.sleep(1000);
+         
+         Set nodes = office1.nodeIDView();         
+         assertTrue(nodes.contains(new Integer(1)));
+         assertTrue(nodes.contains(new Integer(2)));
+         assertTrue(nodes.contains(new Integer(3)));
+         
+         nodes = office2.nodeIDView();         
+         assertTrue(nodes.contains(new Integer(1)));
+         assertTrue(nodes.contains(new Integer(2)));
+         assertTrue(nodes.contains(new Integer(3)));
+         
+         nodes = office3.nodeIDView();         
+         assertTrue(nodes.contains(new Integer(1)));
+         assertTrue(nodes.contains(new Integer(2)));
+         assertTrue(nodes.contains(new Integer(3)));
+         
+         office1.stop();
+         office1 = null;
+         
+         office2.stop();
+         office2 = null;
+         
+         office3.stop();
+         office3 = null;
+      }
+      finally
+      {
+         if (office1 != null)
+         {
+            office1.stop();
+         }
+         
+         if (office2 != null)
+         {
+            office2.stop();
+         }
+         
+         if (office3 != null)
+         {
+            office3.stop();
+         }         
+      }
+         
+   }
+   
+   public final void testGetFailoverMap() throws Throwable
+   {
+      PostOffice office1 = null;
+      PostOffice office2 = null;
+      PostOffice office3 = null;
+      
+      try
+      {         
+         office1 = createClusteredPostOffice(1, "testgroup");
+
+         office2 = createClusteredPostOffice(2, "testgroup");
+                  
+         office3 = createClusteredPostOffice(3, "testgroup");
+         
+         Thread.sleep(1000);
+         
+         Map failoverMap1 = office1.getFailoverMap();
+         
+         Map failoverMap2 = office2.getFailoverMap();
+         
+         Map failoverMap3 = office3.getFailoverMap();
+         
+         assertEquals(failoverMap1, failoverMap2);
+         
+         assertEquals(failoverMap2, failoverMap3);
+         
+         office1.stop();
+         office1 = null;
+         
+         office2.stop();
+         office2 = null;
+         
+         office3.stop();
+         office3 = null;
+      }
+      finally
+      {
+         if (office1 != null)
+         {
+            office1.stop();
+         }
+         
+         if (office2 != null)
+         {
+            office2.stop();
+         }
+         
+         if (office3 != null)
+         {
+            office3.stop();
+         }         
+      }
+         
+   }
+   
+   public final void testClusteredBindUnbind() throws Throwable
+   {
+      PostOffice office1 = null;
+      PostOffice office2 = null;
+      PostOffice office3 = null;
+      
+      try
+      {         
+         // Start one office
+         
+         office1 = createClusteredPostOffice(1, "testgroup");
+          
+         // Add a couple of queues
+         
+         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue1.activate();
+
+         Condition condition1 = new SimpleCondition("condition1");
+         
+         boolean added = office1.addBinding(new Binding(condition1, queue1, false), false);
+         assertTrue(added);
+               
+         Queue queue2 = new MessagingQueue(1, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue2.activate();
+
+         added = office1.addBinding(new Binding(condition1, queue2, false), false);
+         assertTrue(added);
+               
+         // Start another office - make sure it picks up the bindings from the first node
+         
+         office2 = createClusteredPostOffice(2, "testgroup");
+           
+         // Should return all queues
+         Collection queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(2, queues.size());
+         assertTrue(queues.contains(queue1));
+         assertTrue(queues.contains(queue2));
+                
+         
+         // Add another queue on node 2
+         
+         Queue queue3 = new MessagingQueue(2, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue3.activate();
+
+         added = office2.addBinding(new Binding(condition1, queue3, false), false);
+         assertTrue(added);
+  
+         // Make sure both nodes pick it up
+         
+         queues = office1.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(3, queues.size());
+         assertTrue(queues.contains(queue1));
+         assertTrue(queues.contains(queue2));
+         assertTrue(queues.contains(queue3));
+         
+         queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(3, queues.size());
+         assertTrue(queues.contains(queue1));
+         assertTrue(queues.contains(queue2));
+         assertTrue(queues.contains(queue3));
+        
+
+         // Add another binding on node 2
+         
+         Queue queue4 = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue4.activate();
+
+         added = office2.addBinding(new Binding(condition1, queue4, false), false);
+         assertTrue(added);
+         
+         // Make sure both nodes pick it up
+         
+         queues = office1.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(4, queues.size());
+         assertTrue(queues.contains(queue1));
+         assertTrue(queues.contains(queue2));
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         
+         queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(4, queues.size());
+         assertTrue(queues.contains(queue1));
+         assertTrue(queues.contains(queue2));
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         
+         // Unbind binding 1 and binding 2
+         Binding removed = office1.removeBinding(queue1.getName(), false);
+         assertNotNull(removed);
+                  
+         removed = office1.removeBinding(queue2.getName(), false);
+         assertNotNull(removed);
+         
+         // Make sure bindings are not longer available on either node
+         
+         queues = office1.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(2, queues.size());
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         
+         queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(2, queues.size());
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         
+         
+         // Add a third office
+                  
+         office3 = createClusteredPostOffice(3, "testgroup");
+         
+         // Maks sure it picks up the bindings
+         
+         queues = office3.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(2, queues.size());
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         
+         // Add another binding on node 3
+                  
+         Queue queue5 = new MessagingQueue(3, "sub5", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue5.activate();
+         
+         added = office3.addBinding(new Binding(condition1, queue5, false), false);
+         assertTrue(added);
+         
+         // Make sure all nodes pick it up
+         
+         queues = office1.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(3, queues.size());
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         assertTrue(queues.contains(queue5));
+         
+         queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(3, queues.size());
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         assertTrue(queues.contains(queue5));
+         
+         queues = office3.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(3, queues.size());
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         assertTrue(queues.contains(queue5));
+         
+         // Add a durable and a non durable binding on node 1
+         
+         Queue queue6 = new MessagingQueue(1, "sub6", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queue6.activate();
+         
+         added = office1.addBinding(new Binding(condition1, queue6, false), false);
+         assertTrue(added);
+         
+         Queue queue7 = new MessagingQueue(1, "sub7", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue7.activate();
+         
+         added = office1.addBinding(new Binding(condition1, queue7, false), false);
+         assertTrue(added);
+         
+         
+         // Make sure all nodes pick them up
+         
+         queues = office1.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(5, queues.size());
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         assertTrue(queues.contains(queue5));
+         assertTrue(queues.contains(queue6));
+         assertTrue(queues.contains(queue7));
+         
+         queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(5, queues.size());
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         assertTrue(queues.contains(queue5));
+         assertTrue(queues.contains(queue6));
+         assertTrue(queues.contains(queue7));
+         
+         queues = office3.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(5, queues.size());
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         assertTrue(queues.contains(queue5));
+         assertTrue(queues.contains(queue6));
+         assertTrue(queues.contains(queue7));
+               
+         // Stop office 1
+         office1.stop();
+  
+         // Need to sleep since it may take some time for the view changed request to reach the
+         // members which causes the bindings to be removed.
+         
+         Thread.sleep(1000);
+         
+         // All it's bindings should be removed from the other nodes, including durable
+         
+         queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(3, queues.size());
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         assertTrue(queues.contains(queue5));
+         
+         queues = office3.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(3, queues.size());
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         assertTrue(queues.contains(queue5));
+         
+         // Stop office 2
+         office2.stop();
+         
+         queues = office3.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(1, queues.size());
+         assertTrue(queues.contains(queue5));
+         
+         // Restart office 1 and office 2
+         office1.start();
+         
+         office2.start();
+                  
+         queues = office1.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(2, queues.size());
+         assertTrue(queues.contains(queue5));
+         assertTrue(queues.contains(queue6));
+         
+         queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(2, queues.size());
+         assertTrue(queues.contains(queue5));
+         assertTrue(queues.contains(queue6));
+         
+         queues = office3.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(2, queues.size());
+         assertTrue(queues.contains(queue5));
+         assertTrue(queues.contains(queue6));
+
+         // Stop all offices
+         
+         office1.stop();
+         office2.stop();
+         office3.stop();
+         
+         // Start them all
+         office1.start();
+         office2.start();
+         office3.start();
+         
+         // Only the durable queue should survive
+         
+         queues = office1.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(1, queues.size());
+         assertTrue(queues.contains(queue6));
+         
+         queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(1, queues.size());
+         assertTrue(queues.contains(queue6));
+         
+         queues = office3.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(1, queues.size());
+         assertTrue(queues.contains(queue6));       
+         
+         //Unbind it
+         
+         removed = office1.removeBinding(queue6.getName(), false);
+         assertNotNull(removed);
+         
+         queues = office1.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertTrue(queues.isEmpty());
+         
+         queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertTrue(queues.isEmpty());
+         
+         queues = office3.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertTrue(queues.isEmpty());     
+         
+         
+         //Bind another few more clustered
+                           
+         Queue queue8 = new MessagingQueue(1, "sub8", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue8.activate();
+         
+         Queue queue9 = new MessagingQueue(2, "sub9", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue9.activate();
+         
+         Queue queue10 = new MessagingQueue(2, "sub10", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue10.activate();
+         
+         //Bind on different conditions
+         
+         added = office1.addBinding(new Binding(condition1, queue8, false), false);
+         assertTrue(added);
+         
+         added = office2.addBinding(new Binding(condition1, queue9, false), false);
+         assertTrue(added);
+         
+         Condition condition2 = new SimpleCondition("condition2");
+         
+         added = office2.addBinding(new Binding(condition2, queue10, false), false);
+         assertTrue(added);
+         
+         queues = office1.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(2, queues.size());
+         assertTrue(queues.contains(queue8));
+         assertTrue(queues.contains(queue9));
+         
+         queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(2, queues.size());
+         assertTrue(queues.contains(queue8));
+         assertTrue(queues.contains(queue9));
+         
+         queues = office3.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(2, queues.size());
+         assertTrue(queues.contains(queue8));
+         assertTrue(queues.contains(queue9));
+         
+         //Now a couple of non clustered queues
+         
+         Queue queue11 = new MessagingQueue(1, "sub11", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue11.activate();
+         
+         Queue queue12 = new MessagingQueue(2, "sub12", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue12.activate();
+         
+         added = office1.addBinding(new Binding(condition1, queue11, false), false);
+         assertTrue(added);
+         
+         added = office2.addBinding(new Binding(condition1, queue12, false), false);
+         assertTrue(added);
+         
+         queues = office1.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(3, queues.size());
+         assertTrue(queues.contains(queue8));
+         assertTrue(queues.contains(queue9));
+         assertTrue(queues.contains(queue11));
+         
+         queues = office2.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(3, queues.size());
+         assertTrue(queues.contains(queue8));
+         assertTrue(queues.contains(queue9));
+         assertTrue(queues.contains(queue12));
+         
+         queues = office3.getQueuesForCondition(condition1, false);
+         assertNotNull(queues);
+         assertEquals(2, queues.size());
+         assertTrue(queues.contains(queue8));
+         assertTrue(queues.contains(queue9));                   
+      }
+      finally
+      {
+         if (office1 != null)
+         {
+            office1.stop();
+         }
+         
+         if (office2 != null)
+         {
+            office2.stop();
+         }
+         
+         if (office3 != null)
+         {
+            office3.stop();
+         }
+         
+         if (checkNoBindingData())
+         {
+            fail("data still in database");
+         }
+      }
+   }
+   
+   public void testBindUnbindAll1() throws Throwable
+   {
+   	/*
+      * 1.
+      * a) queue is not known by cluster
+      * b) bind all
+      * c) verify all nodes get queue
+      * d) unbind - verify unbound from all nodes
+      * e) close down all nodes
+      * f) start all nodes
+      * g) verify queue is not known
+      * */
+   	
+      PostOffice office1 = null;
+      PostOffice office2 = null;
+      PostOffice office3 = null;
+      
+      try
+      {                          
+         office1 = createClusteredPostOffice(1, "testgroup");
+         office2 = createClusteredPostOffice(2, "testgroup");
+         office3 = createClusteredPostOffice(3, "testgroup");         
+                             
+         //Durable
+         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queue1.activate();
+
+         Condition condition1 = new SimpleCondition("condition1");
+         
+         //Add all binding
+         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
+         assertTrue(added);
+         
+         Thread.sleep(1000);
+          
+         Collection bindings = office1.getAllBindings();         
+         assertGotAll(1, bindings, queue1.getName());
+         
+         bindings = office2.getAllBindings();         
+         assertGotAll(2, bindings, queue1.getName());
+         
+         bindings = office3.getAllBindings();         
+         assertGotAll(3, bindings, queue1.getName());
+         
+         //Now unbind same node
+         
+         Binding removed = office1.removeBinding(queue1.getName(), true);
+         assertNotNull(removed);
+         
+         Thread.sleep(1000);
+         
+         bindings = office1.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office2.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office3.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         //Bind again different node
+         Queue queue2 = new MessagingQueue(2, "sub2", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queue2.activate();
+         
+         added = office2.addBinding(new Binding(condition1, queue2, true), true);
+         assertTrue(added);
+         
+         Thread.sleep(1000);
+         
+         bindings = office1.getAllBindings();         
+         assertGotAll(1, bindings, queue2.getName());
+         
+         bindings = office2.getAllBindings();         
+         assertGotAll(2, bindings, queue2.getName());
+         
+         bindings = office3.getAllBindings();         
+         assertGotAll(3, bindings, queue2.getName());
+         
+         //Close down all nodes
+         
+         office1.stop();
+         
+         dumpNodeIDView(office2);
+         
+         office2.stop();
+         
+         dumpNodeIDView(office3);
+         
+         office3.stop();        
+         
+         //Start all nodes
+         
+         office1.start();
+         office2.start();
+         office3.start();
+         
+         Thread.sleep(1000);
+         
+         //Verify the binding is there
+         
+         bindings = office1.getAllBindings();         
+         assertGotAll(1, bindings, queue2.getName());
+         
+         bindings = office2.getAllBindings();         
+         assertGotAll(2, bindings, queue2.getName());
+         
+         bindings = office3.getAllBindings();         
+         assertGotAll(3, bindings, queue2.getName());
+         
+         //Unbind different node
+         
+         removed = office3.removeBinding(queue2.getName(), true);
+         assertNotNull(removed);
+         
+         Thread.sleep(1000);
+         
+         bindings = office1.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office2.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office3.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         if (checkNoBindingData())
+         {
+            fail("data still in database");
+         }                                  
+      }
+      finally
+      {
+      	if (office1 != null)
+      	{
+      		try
+      		{
+      			office1.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office2 != null)
+      	{
+      		try
+      		{
+      			office2.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office3 != null)
+      	{
+      		try
+      		{
+      			office3.stop();
+      		}         
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+      }
+   }
+   
+   public void testBindUnbindAll2() throws Throwable
+   {
+      /* 
+      * a) queue is known by cluster
+      * b) bind all
+      * c) verify nothing changes on cluster
+      */
+   	
+      PostOffice office1 = null;
+      PostOffice office2 = null;
+      PostOffice office3 = null;
+      
+      try
+      {                          
+         office1 = createClusteredPostOffice(1, "testgroup");
+         office2 = createClusteredPostOffice(2, "testgroup");
+         office3 = createClusteredPostOffice(3, "testgroup");         
+                           
+         //Durable
+         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queue1.activate();
+
+         Condition condition1 = new SimpleCondition("condition1");
+         
+         //Add all binding
+         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
+         assertTrue(added);
+         
+         Thread.sleep(1000);
+          
+         Collection bindings = office1.getAllBindings();         
+         assertGotAll(1, bindings, queue1.getName());
+         
+         bindings = office2.getAllBindings();         
+         assertGotAll(2, bindings, queue1.getName());
+         
+         bindings = office3.getAllBindings();         
+         assertGotAll(3, bindings, queue1.getName());
+         
+         //Bind again
+         added = office1.addBinding(new Binding(condition1, queue1, true), true);
+         assertFalse(added);
+         
+         Thread.sleep(1000);
+          
+         bindings = office1.getAllBindings();         
+         assertGotAll(1, bindings, queue1.getName());
+         
+         bindings = office2.getAllBindings();         
+         assertGotAll(2, bindings, queue1.getName());
+         
+         bindings = office3.getAllBindings();         
+         assertGotAll(3, bindings, queue1.getName());
+                  
+         //Now unbind same node
+         
+         Binding removed = office1.removeBinding(queue1.getName(), true);
+         assertNotNull(removed);
+         
+         removed = office1.removeBinding(queue1.getName(), true);
+         assertNull(removed);
+         
+         Thread.sleep(1000);
+         
+         bindings = office1.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office2.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office3.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+                  
+         if (checkNoBindingData())
+         {
+            fail("data still in database");
+         }                                  
+      }
+      finally
+      {
+      	if (office1 != null)
+      	{
+      		try
+      		{
+      			office1.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office2 != null)
+      	{
+      		try
+      		{
+      			office2.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office3 != null)
+      	{
+      		try
+      		{
+      			office3.stop();
+      		}         
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+      }
+   }
+   
+   public void testBindUnbindAll3() throws Throwable
+   {
+      /* a) start one node
+      * b) queue is not known to cluster
+      * c) bind all
+      * d) start other nodes
+      * d) verify other nodes pick it up
+      */
+   	
+      PostOffice office1 = null;
+      PostOffice office2 = null;
+      PostOffice office3 = null;
+      
+      try
+      {                          
+         office1 = createClusteredPostOffice(1, "testgroup");       
+                              
+         //Durable
+         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queue1.activate();
+
+         Condition condition1 = new SimpleCondition("condition1");
+         
+         //Add all binding
+         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
+         assertTrue(added);
+         
+         Thread.sleep(1000);
+          
+         office2 = createClusteredPostOffice(2, "testgroup");       
+         office3 = createClusteredPostOffice(3, "testgroup");       
+                  
+         Thread.sleep(1000);
+         
+         Collection bindings = office1.getAllBindings();         
+         assertGotAll(1, bindings, queue1.getName());
+         
+         bindings = office2.getAllBindings();         
+         assertGotAll(2, bindings, queue1.getName());
+         
+         bindings = office3.getAllBindings();         
+         assertGotAll(3, bindings, queue1.getName());
+               
+         //Unbind
+         
+         Binding removed = office1.removeBinding(queue1.getName(), true);
+         assertNotNull(removed);
+         
+         Thread.sleep(1000);
+         
+         bindings = office1.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office2.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office3.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         if (checkNoBindingData())
+         {
+            fail("data still in database");
+         }                                  
+      }
+      finally
+      {
+      	if (office1 != null)
+      	{
+      		try
+      		{
+      			office1.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office2 != null)
+      	{
+      		try
+      		{
+      			office2.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office3 != null)
+      	{
+      		try
+      		{
+      			office3.stop();
+      		}         
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+      }
+   }
+   
+   public void testBindUnbindAll4() throws Throwable
+   {
+      /* a) start one node
+      * b) queue is not known to cluster
+      * c) bind all
+      * d) shutdown all nodes
+      * e) startup all nodes
+      * f) verify queue is on all nodes
+      */
+   	
+      PostOffice office1 = null;
+      PostOffice office2 = null;
+      PostOffice office3 = null;
+      
+      try
+      {                          
+         office1 = createClusteredPostOffice(1, "testgroup");       
+                           
+         //Durable
+         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queue1.activate();
+
+         Condition condition1 = new SimpleCondition("condition1");
+         
+         //Add all binding
+         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
+         assertTrue(added);
+         
+         Thread.sleep(1000);
+         
+         office1.stop();
+         
+         //office1 = createClusteredPostOffice(1, "testgroup"); 
+         office1.start();
+         office2 = createClusteredPostOffice(2, "testgroup"); 
+         office3 = createClusteredPostOffice(3, "testgroup"); 
+          
+         Thread.sleep(1000);
+         
+         Collection bindings = office1.getAllBindings();         
+         assertGotAll(1, bindings, queue1.getName());
+         
+         bindings = office2.getAllBindings();         
+         assertGotAll(2, bindings, queue1.getName());
+         
+         bindings = office3.getAllBindings();         
+         assertGotAll(3, bindings, queue1.getName());
+         
+         //Now unbind same node
+         
+         Binding removed = office1.removeBinding(queue1.getName(), true);
+         assertNotNull(removed);
+         
+         Thread.sleep(1000);
+         
+         bindings = office1.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office2.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office3.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         
+         if (checkNoBindingData())
+         {
+            fail("data still in database");
+         }                                  
+      }
+      finally
+      {
+      	if (office1 != null)
+      	{
+      		try
+      		{
+      			office1.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office2 != null)
+      	{
+      		try
+      		{
+      			office2.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office3 != null)
+      	{
+      		try
+      		{
+      			office3.stop();
+      		}         
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+      }
+   }
+   
+   public void testBindUnbindAll5() throws Throwable
+   {
+   	/*
+    * a) start one node
+    * b) queue is not known
+    * c) bind all
+    * d) shutdown node
+    * e) start other nodes
+    * f) verify queue is not known
+    * g) restart first node, verify queue is now known
+      * */
+   	
+      PostOffice office1 = null;
+      PostOffice office2 = null;
+      PostOffice office3 = null;
+      
+      try
+      {                          
+         office1 = createClusteredPostOffice(1, "testgroup");
+                                   
+         //Durable
+         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queue1.activate();
+
+         Condition condition1 = new SimpleCondition("condition1");
+         
+         //Add all binding
+         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
+         assertTrue(added);
+         
+         Thread.sleep(1000);
+         
+         office1.stop();
+         
+         office2 = createClusteredPostOffice(2, "testgroup");
+         office3 = createClusteredPostOffice(3, "testgroup");
+         
+         Collection bindings = office2.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office3.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+             
+         office1.start();
+         
+         Thread.sleep(1000);
+            
+         bindings = office1.getAllBindings();         
+         assertGotAll(1, bindings, queue1.getName());
+         
+         bindings = office2.getAllBindings();         
+         assertGotAll(2, bindings, queue1.getName());
+         
+         bindings = office3.getAllBindings();         
+         assertGotAll(3, bindings, queue1.getName());
+         
+         //Now unbind same node                  
+         
+         Binding removed = office1.removeBinding(queue1.getName(), true);
+         assertNotNull(removed);
+
+         Thread.sleep(1000);
+         
+         bindings = office1.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office2.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office3.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         if (checkNoBindingData())
+         {
+            fail("data still in database");
+         }                                  
+      }
+      finally
+      {
+      	if (office1 != null)
+      	{
+      		try
+      		{
+      			office1.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office2 != null)
+      	{
+      		try
+      		{
+      			office2.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office3 != null)
+      	{
+      		try
+      		{
+      			office3.stop();
+      		}         
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+      }
+   }
+   
+   public void testBindUnbindAll6() throws Throwable
+   {
+   	/*
+      * 1.
+    * a) bind all non durable
+    * b) make sure is picked up by all nodes
+    * c) close down all nodes
+    * d) restart them all - make sure is not there
+    * e) bind again
+    * f) make sure is picked up
+    * g) take down one node
+    * h) bring it back up
+    * i) make sure it has quuee again
+      * */
+   	
+      PostOffice office1 = null;
+      PostOffice office2 = null;
+      PostOffice office3 = null;
+      
+      try
+      {                          
+         office1 = createClusteredPostOffice(1, "testgroup");
+         office2 = createClusteredPostOffice(2, "testgroup");
+         office3 = createClusteredPostOffice(3, "testgroup");         
+                           
+         //Durable
+         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue1.activate();
+
+         Condition condition1 = new SimpleCondition("condition1");
+         
+         //Add all binding
+         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
+         assertTrue(added);
+         
+         Thread.sleep(1000);
+          
+         Collection bindings = office1.getAllBindings();         
+         assertGotAll(1, bindings, queue1.getName());
+         
+         bindings = office2.getAllBindings();         
+         assertGotAll(2, bindings, queue1.getName());
+         
+         bindings = office3.getAllBindings();         
+         assertGotAll(3, bindings, queue1.getName());
+         
+         office1.stop();
+         office2.stop();
+         office3.stop();
+      
+         office1.start();
+         office2.start();
+         office3.start();
+         
+         Thread.sleep(1000);
+         
+         bindings = office1.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office2.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         bindings = office3.getAllBindings();         
+         assertTrue(bindings.isEmpty());
+         
+         added = office1.addBinding(new Binding(condition1, queue1, true), true);
+         assertTrue(added);
+         
+         Thread.sleep(1000);
+         
+         bindings = office1.getAllBindings();         
+         assertGotAll(1, bindings, queue1.getName());
+         
+         bindings = office2.getAllBindings();         
+         assertGotAll(2, bindings, queue1.getName());
+         
+         bindings = office3.getAllBindings();         
+         assertGotAll(3, bindings, queue1.getName());
+         
+         office3.stop();
+
+         Thread.sleep(1000);
+          
+         bindings = office1.getAllBindings();         
+         assertEquals(2, bindings.size());
+         
+         office3.start();
+
+         Thread.sleep(1000);
+         
+         bindings = office1.getAllBindings();         
+         assertGotAll(1, bindings, queue1.getName());
+         
+         bindings = office2.getAllBindings();         
+         assertGotAll(2, bindings, queue1.getName());
+         
+         bindings = office3.getAllBindings();         
+         assertGotAll(3, bindings, queue1.getName());
+         
+                  
+         if (checkNoBindingData())
+         {
+            fail("data still in database");
+         }                                  
+      }
+      finally
+      {
+      	if (office1 != null)
+      	{
+      		try
+      		{
+      			office1.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office2 != null)
+      	{
+      		try
+      		{
+      			office2.stop();
+      		}
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+
+      	if (office3 != null)
+      	{
+      		try
+      		{
+      			office3.stop();
+      		}         
+      		catch (Exception ignore)
+      		{         		
+      		}
+      	}
+      }
+   }
+   
+  
+   public final void testClusteredRoutePersistent() throws Throwable
+   {
+      clusteredRoute(true);
+   }
+   
+   public final void testClusteredRouteNonPersistent() throws Throwable
+   {
+      clusteredRoute(false);
+   }
+
+   public void testClusteredRouteWithFilterNonPersistent() throws Throwable
+   {
+      this.clusteredRouteWithFilter(false);
+   }
+   
+   public void testClusteredRouteWithFilterPersistent() throws Throwable
+   {
+      this.clusteredRouteWithFilter(true);
+   }
+   
+   public void testRouteSharedQueuePersistent() throws Throwable
+   {
+      this.routeSharedQueue(true);
+   }
+   
+   public void testRouteSharedQueueNonPersistent() throws Throwable
+   {
+      this.routeSharedQueue(false);
+   }
+   
+   public void testClusteredTransactionalRoutePersistent() throws Throwable
+   {
+   	this.clusteredTransactionalRoute(true);
+   }
+   
+   public void testClusteredTransactionalRouteNonPersistent() throws Throwable
+   {
+   	this.clusteredTransactionalRoute(false);
+   }
+   
+   public void testClusteredRouteFourNodesPersistent() throws Throwable
+   {
+   	this.clusteredRouteFourNodes(true);
+   }
+   
+   public void testClusteredRouteFourNodesNonPersistent() throws Throwable
+   {
+   	this.clusteredRouteFourNodes(false);
+   }
+   
+   public void testStartTxInternally() throws Throwable
+   {
+   	PostOffice office1 = null;
+
+   	try
+   	{   
+   		office1 = createClusteredPostOffice(1, "testgroup");
+
+   		Queue queue1 =  new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, true, -1, null, true);
+   		queue1.activate();
+   		boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
+   		assertTrue(added);
+   		
+   		Queue queue2 =  new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, true, -1, null, true);
+   		queue2.activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue2, false), false);
+   		assertTrue(added);
+   		
+   		Queue queue3 =  new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, true, -1, null, true);
+   		queue3.activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue3, false), false);
+   		assertTrue(added);
+   		
+   		Queue queue4 =  new MessagingQueue(1, "queue4", channelIDManager.getID(), ms, pm, true, -1, null, true);
+   		queue4.activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue4, false), false);
+   		assertTrue(added);
+
+   		SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue1.getLocalDistributor().add(receiver1);
+
+   		SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue2.getLocalDistributor().add(receiver2);
+
+   		SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue3.getLocalDistributor().add(receiver3);
+   		
+   		SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue4.getLocalDistributor().add(receiver4);
+
+   		Message msg1 = CoreMessageFactory.createCoreMessage(1, true, null);      
+   		MessageReference ref1 = ms.reference(msg1);  
+   		boolean routed = office1.route(ref1, new SimpleCondition("condition1"), null);   
+   		assertTrue(routed);
+
+   		Message msg2 = CoreMessageFactory.createCoreMessage(2, true, null);      
+   		MessageReference ref2 = ms.reference(msg2);         
+   		routed = office1.route(ref2, new SimpleCondition("condition1"), null);      
+   		assertTrue(routed);
+
+   		Message msg3 = CoreMessageFactory.createCoreMessage(3, true, null);      
+   		MessageReference ref3 = ms.reference(msg3);         
+   		routed = office1.route(ref3, new SimpleCondition("condition1"), null);      
+   		assertTrue(routed);
+
+   		Thread.sleep(1000);
+   		
+   		List msgs = receiver1.getMessages();
+   		assertNotNull(msgs);
+   		assertEquals(3, msgs.size());
+   		Message msgRec1 = (Message)msgs.get(0);
+   		assertTrue(msg1 == msgRec1);
+   		Message msgRec2 = (Message)msgs.get(1);
+   		assertTrue(msg2 == msgRec2);
+   		Message msgRec3 = (Message)msgs.get(2);
+   		assertTrue(msg3 == msgRec3);
+
+   		receiver1.acknowledge(msgRec1, null);
+   		receiver1.acknowledge(msgRec2, null);
+   		receiver1.acknowledge(msgRec3, null);
+   		msgs = queue1.browse(null);
+   		assertNotNull(msgs);
+   		assertTrue(msgs.isEmpty()); 
+   		
+   		msgs = receiver2.getMessages();
+   		assertNotNull(msgs);
+   		assertEquals(3, msgs.size());
+   		msgRec1 = (Message)msgs.get(0);
+   		assertTrue(msg1 == msgRec1);
+   		msgRec2 = (Message)msgs.get(1);
+   		assertTrue(msg2 == msgRec2);
+   		msgRec3 = (Message)msgs.get(2);
+   		assertTrue(msg3 == msgRec3);
+
+   		receiver2.acknowledge(msgRec1, null);
+   		receiver2.acknowledge(msgRec2, null);
+   		receiver2.acknowledge(msgRec3, null);
+   		msgs = queue2.browse(null);
+   		assertNotNull(msgs);
+   		assertTrue(msgs.isEmpty()); 
+
+   		msgs = receiver3.getMessages();
+   		assertNotNull(msgs);
+   		assertEquals(3, msgs.size());
+   		msgRec1 = (Message)msgs.get(0);
+   		assertTrue(msg1 == msgRec1);
+   		msgRec2 = (Message)msgs.get(1);
+   		assertTrue(msg2 == msgRec2);
+   		msgRec3 = (Message)msgs.get(2);
+   		assertTrue(msg3 == msgRec3);
+
+   		receiver3.acknowledge(msgRec1, null);
+   		receiver3.acknowledge(msgRec2, null);
+   		receiver3.acknowledge(msgRec3, null);
+   		msgs = queue3.browse(null);
+   		assertNotNull(msgs);
+   		assertTrue(msgs.isEmpty()); 
+   		
+   		msgs = receiver4.getMessages();
+   		assertNotNull(msgs);
+   		assertEquals(3, msgs.size());
+   		msgRec1 = (Message)msgs.get(0);
+   		assertTrue(msg1 == msgRec1);
+   		msgRec2 = (Message)msgs.get(1);
+   		assertTrue(msg2 == msgRec2);
+   		msgRec3 = (Message)msgs.get(2);
+   		assertTrue(msg3 == msgRec3);
+
+   		receiver4.acknowledge(msgRec1, null);
+   		receiver4.acknowledge(msgRec2, null);
+   		receiver4.acknowledge(msgRec3, null);
+   		msgs = queue4.browse(null);
+   		assertNotNull(msgs);
+   		assertTrue(msgs.isEmpty()); 
+   		
+   		if (checkNoMessageData())
+   		{
+   			fail("Message data still in database");
+   		}
+   	}
+   	finally
+   	{
+   		if (office1 != null)
+   		{
+   			office1.stop();
+   		}
+   	}
+   }
+ 
+   public void testBindSameName() throws Throwable
+   {
+      PostOffice office1 = null;
+      
+      PostOffice office2 = null;
+          
+      try
+      {   
+         office1 = createClusteredPostOffice(1, "testgroup");
+         
+         office2 = createClusteredPostOffice(2, "testgroup");
+         
+         Queue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue1.activate();
+         
+         Condition condition1 = new SimpleCondition("queue1");
+         
+         boolean added = office1.addBinding(new Binding(condition1, queue1, false), false);
+         assertTrue(added);
+
+         Queue queue2 = new MessagingQueue(2, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue2.activate();
+
+         added = office2.addBinding(new Binding(condition1, queue2, false), false);
+         assertTrue(added);
+
+         Queue queue3 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue3.activate();
+         
+         added = office1.addBinding(new Binding(condition1, queue3, false), false);         
+         assertFalse(added);
+
+         Queue queue4 =  new MessagingQueue(2, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queue4.activate();
+         
+         added = office2.addBinding(new Binding(condition1, queue4, false), false);
+         assertFalse(added);
+         
+         Binding removed = office1.removeBinding("does not exist", false);
+         assertNull(removed);
+         
+         removed = office1.removeBinding(queue1.getName(), false);
+         assertNotNull(removed);
+
+         removed = office2.removeBinding(queue2.getName(), false);                
+         assertNotNull(removed);                  
+      }
+      finally
+      {
+         if (office1 != null)
+         {            
+            office1.stop();
+         }
+         
+         if (office2 != null)
+         {
+            office2.stop();
+         }
+      }
+   }
+   
+ 
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+   }
+
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+   }
+
+   // Private --------------------------------------------------------------------------------------
+
+   private void clusteredTransactionalRoute(boolean persistent) throws Throwable
+   {
+      PostOffice office1 = null;
+      
+      PostOffice office2 = null;
+      
+      try
+      {   
+         //Start two offices
+         
+         office1 = createClusteredPostOffice(1, "testgroup");
+         office2 = createClusteredPostOffice(2, "testgroup");
+     
+         Queue[] queues = new Queue[16];
+         
+         //condition1
+
+         queues[0] = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queues[0].activate();
+         boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[0], false), false);
+         assertTrue(added);
+         
+         queues[1] = new MessagingQueue(1, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queues[1].activate();
+         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[1], false), false);
+         assertTrue(added);
+         
+         queues[2] = new MessagingQueue(2, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queues[2].activate();
+         added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[2], false), false);
+         assertTrue(added);
+         
+         queues[3] = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queues[3].activate();
+         added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[3], false), false);
+         assertTrue(added);
+         
+         queues[4] = new MessagingQueue(2, "sub5", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queues[4].activate();
+         added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[4], false), false);
+         assertTrue(added);
+         
+         queues[5] = new MessagingQueue(1, "sub6", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queues[5].activate();
+         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[5], false), false);
+         assertTrue(added);
+         
+         queues[6] = new MessagingQueue(1, "sub7", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queues[6].activate();
+         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[6], false), false);
+         assertTrue(added);
+         
+         queues[7] = new MessagingQueue(1, "sub8", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queues[7].activate();
+         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[7], false), false);
+         assertTrue(added);
+         
+         //condition2
+         
+         queues[8] = new MessagingQueue(1, "sub9", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queues[8].activate();
+         added= office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[8], false), false);
+         assertTrue(added);
+         
+         queues[9] = new MessagingQueue(1, "sub10", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queues[9].activate();
+         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[9], false), false);
+         assertTrue(added);
+         
+         queues[10] = new MessagingQueue(2, "sub11", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queues[10].activate();
+         added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[10], false), false);
+         assertTrue(added);
+         
+         queues[11] = new MessagingQueue(2, "sub12", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queues[11].activate();
+         added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[11], false), false);
+         assertTrue(added);
+         
+         queues[12] = new MessagingQueue(2, "sub13", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queues[12].activate();
+         added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[12], false), false);
+         assertTrue(added);
+         
+         queues[13] = new MessagingQueue(1, "sub14", channelIDManager.getID(), ms, pm, false, -1, null, true);
+         queues[13].activate();
+         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[13], false), false);
+         assertTrue(added);
+         
+         queues[14] = new MessagingQueue(1, "sub15", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queues[14].activate();
+         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[14], false), false);
+         assertTrue(added);
+         
+         queues[15] = new MessagingQueue(1, "sub16", channelIDManager.getID(), ms, pm, true, -1, null, true);
+         queues[15].activate();
+         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[15], false), false);
+         assertTrue(added);
+
+         SimpleReceiver[] receivers = new SimpleReceiver[16];
+         
+         for (int i = 0; i < 16; i++)
+         {
+            receivers[i] = new SimpleReceiver("blah" + i, SimpleReceiver.ACCEPTING);
+            queues[i].getLocalDistributor().add(receivers[i]);
+         }
+         
+         //First for topic 1
+         
+         Message msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);;      
+         MessageReference ref1 = ms.reference(msg1);
+         
+         Message msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);;      
+         MessageReference ref2 = ms.reference(msg2);
+         
+         Transaction tx = tr.createTransaction();
+
+         boolean routed = office1.route(ref1, new SimpleCondition("condition1"), tx);         
+         assertTrue(routed);
+         routed = office1.route(ref2, new SimpleCondition("condition1"), tx);         
+         assertTrue(routed);
+         
+         for (int i = 0; i < 16; i++)
+         {
+         	log.info("i is " + i);
+            List msgs = receivers[i].getMessages();
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+            msgs = queues[i].browse(null);
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+         }
+         
+         log.info("committing");
+         tx.commit();
+         log.info("committed");
+         
+         //Messages are sent asych so may take some finite time to arrive
+         Thread.sleep(1000);
+         
+         for (int i = 0; i < 16; i++)
+         {
+         	if (i >= 8 || (queues[i].getNodeID() == 2 && queues[i].isRecoverable()))
+         	{     
+         		//Shouldn't get message
+         		List msgs = receivers[i].getMessages();
+         		assertNotNull(msgs);
+         		assertTrue(msgs.isEmpty());
+         		msgs = queues[i].browse(null);
+         		assertNotNull(msgs);
+         		assertTrue(msgs.isEmpty());
+         	}
+         	else
+         	{
+         		//Should get message
+         		log.info("is is " + i);
+         		log.info("trying with receiver " + receivers[i]);
+         		List msgs = receivers[i].getMessages();
+         		assertNotNull(msgs);
+         		assertEquals(2, msgs.size());
+         		Message msgRec1 = (Message)msgs.get(0);
+         		assertEquals(msg1.getMessageID(), msgRec1.getMessageID());
+         		Message msgRec2 = (Message)msgs.get(1);
+         		assertEquals(msg2.getMessageID(), msgRec2.getMessageID());            
+         		receivers[i].acknowledge(msgRec1, null);
+         		receivers[i].acknowledge(msgRec2, null);
+         		msgs = queues[i].browse(null);
+         		assertNotNull(msgs);            
+         		assertTrue(msgs.isEmpty());                        
+         		receivers[i].clear();
+         	}
+         }
+         
+         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);;      
+         ref1 = ms.reference(msg1);
+         
+         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);;      
+         ref2 = ms.reference(msg2);
+         
+         tx = tr.createTransaction();
+
+         routed = office1.route(ref1, new SimpleCondition("condition1"), tx);         
+         assertTrue(routed);
+         routed = office1.route(ref2, new SimpleCondition("condition1"), tx);         
+         assertTrue(routed);
+         
+         //Messages are sent asych so may take some finite time to arrive
+         Thread.sleep(1000);         
+         
+         for (int i = 0; i < 16; i++)
+         {
+            List msgs = receivers[i].getMessages();
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+            msgs = queues[i].browse(null);
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+         }
+         
+         tx.rollback();
+         
+         for (int i = 0; i < 16; i++)
+         {
+            List msgs = receivers[i].getMessages();
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+            msgs = queues[i].browse(null);
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+         }
+         
+         
+         // Now for topic 2
+         
+         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);    
+         ref1 = ms.reference(msg1);
+         
+         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);     
+         ref2 = ms.reference(msg2);
+         
+         tx = tr.createTransaction();
+
+         routed = office2.route(ref1, new SimpleCondition("condition2"), tx);         
+         assertTrue(routed);
+         routed = office2.route(ref2, new SimpleCondition("condition2"), tx);         
+         assertTrue(routed);
+                           
+         for (int i = 0; i < 16; i++)
+         {
+            List msgs = receivers[i].getMessages();
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+            msgs = queues[i].browse(null);
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+         }
+         
+         tx.commit();
+         
+         //Messages are sent asych so may take some finite time to arrive
+         Thread.sleep(1000);
+         
+         for (int i = 8; i < 16; i++)
+         { 
+	         if (i < 8 || (queues[i].getNodeID() == 1 && queues[i].isRecoverable()))
+	      	{     
+	         	//	Shouldn't get message
+	      		List msgs = receivers[i].getMessages();
+	      		assertNotNull(msgs);
+	      		assertTrue(msgs.isEmpty());
+	      		msgs = queues[i].browse(null);
+	      		assertNotNull(msgs);
+	      		assertTrue(msgs.isEmpty());
+	      	}
+	      	else
+	      	{
+	      		// Should get message
+	      		log.info("is is " + i);
+	      		log.info("trying with receiver " + receivers[i]);
+	      		List msgs = receivers[i].getMessages();
+	      		assertNotNull(msgs);
+	      		assertEquals(2, msgs.size());
+	      		Message msgRec1 = (Message)msgs.get(0);
+	      		assertEquals(msg1.getMessageID(), msgRec1.getMessageID());
+	      		Message msgRec2 = (Message)msgs.get(1);
+	      		assertEquals(msg2.getMessageID(), msgRec2.getMessageID());            
+	      		receivers[i].acknowledge(msgRec1, null);
+	      		receivers[i].acknowledge(msgRec2, null);
+	      		msgs = queues[i].browse(null);
+	      		assertNotNull(msgs);            
+	      		assertTrue(msgs.isEmpty());                        
+	      		receivers[i].clear();
+	      	}
+         }
+               
+         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);;      
+         ref1 = ms.reference(msg1);
+         
+         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);;      
+         ref2 = ms.reference(msg2);
+         
+         tx = tr.createTransaction();
+
+         routed = office1.route(ref1, new SimpleCondition("condition1"), tx);         
+         assertTrue(routed);
+         routed = office1.route(ref2, new SimpleCondition("condition1"), tx);         
+         assertTrue(routed);
+         
+         for (int i = 0; i < 16; i++)
+         {
+            List msgs = receivers[i].getMessages();
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+            msgs = queues[i].browse(null);
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+         }
+         
+         tx.rollback();
+         
+         for (int i = 0; i < 16; i++)
+         {
+            List msgs = receivers[i].getMessages();
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+            msgs = queues[i].browse(null);
+            assertNotNull(msgs);
+            assertTrue(msgs.isEmpty());
+         }
+         
+        
+         if (checkNoMessageData())
+         {
+            fail("Message data still in database");
+         }
+      }
+      finally
+      {
+         if (office1 != null)
+         {
+            try
+            {
+               office1.removeBinding("sub7", false);
+               office1.removeBinding("sub8", false);           
+               office1.removeBinding("sub15", false);
+               office1.removeBinding("sub16", false);
+            }
+            catch (Exception ignore)
+            {
+               ignore.printStackTrace();
+            }
+                        
+            office1.stop();
+         }
+         
+         if (office2 != null)
+         {
+            try
+            {
+               office2.removeBinding("sub5", false);
+               office2.removeBinding("sub13", false);
+            }
+            catch (Exception ignore)
+            {
+               ignore.printStackTrace();
+            }
+            
+            office2.stop();
+         }
+      }
+   }
+   
+   private void clusteredRouteWithFilter(boolean persistentMessage) throws Throwable
+   {
+   	PostOffice office1 = null;
+
+   	PostOffice office2 = null;
+
+   	try
+   	{   
+   		office1 = createClusteredPostOffice(1, "testgroup");
+   		office2 = createClusteredPostOffice(2, "testgroup");
+
+   		SimpleFilter filter1 = new SimpleFilter(2);
+   		SimpleFilter filter2 = new SimpleFilter(3);
+
+   		Queue queue1 =  new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, filter1, true);
+   		queue1.activate();
+   		boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
+   		assertTrue(added);
+
+   		Queue queue2 = new MessagingQueue(2, "queue2", channelIDManager.getID(), ms, pm, false, -1, filter2, true);
+   		queue2.activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue2, false), false);
+   		assertTrue(added);
+
+   		Queue queue3 = new MessagingQueue(2, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue3.activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue3, false), false);
+   		assertTrue(added);
+
+   		SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue1.getLocalDistributor().add(receiver1);
+
+   		SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue2.getLocalDistributor().add(receiver2);
+
+   		SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue3.getLocalDistributor().add(receiver3);
+
+   		Message msg1 = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
+   		MessageReference ref1 = ms.reference(msg1);  
+   		boolean routed = office1.route(ref1, new SimpleCondition("condition1"), null);   
+   		assertTrue(routed);
+
+
+   		Message msg2 = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
+   		MessageReference ref2 = ms.reference(msg2);         
+   		routed = office1.route(ref2, new SimpleCondition("condition1"), null);      
+   		assertTrue(routed);
+
+   		Message msg3 = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);      
+   		MessageReference ref3 = ms.reference(msg3);         
+   		routed = office1.route(ref3, new SimpleCondition("condition1"), null);      
+   		assertTrue(routed);
+
+   		Thread.sleep(1000);
+
+   		List msgs = receiver1.getMessages();
+   		assertNotNull(msgs);
+   		assertEquals(1, msgs.size());
+   		Message msgRec = (Message)msgs.get(0);
+   		assertTrue(msg2 == msgRec);
+   		receiver1.acknowledge(msgRec, null);
+   		msgs = queue1.browse(null);
+   		assertNotNull(msgs);
+   		assertTrue(msgs.isEmpty());  
+
+   		msgs = receiver2.getMessages();
+   		assertNotNull(msgs);
+   		assertEquals(1, msgs.size());
+   		msgRec = (Message)msgs.get(0);
+   		assertTrue(msg3 == msgRec);
+   		receiver2.acknowledge(msgRec, null);
+   		msgs = queue2.browse(null);
+   		assertNotNull(msgs);
+   		assertTrue(msgs.isEmpty());  
+
+   		msgs = receiver3.getMessages();
+   		assertNotNull(msgs);
+   		assertEquals(3, msgs.size());
+   		Message msgRec1 = (Message)msgs.get(0);
+   		assertTrue(msg1 == msgRec1);
+   		Message msgRec2 = (Message)msgs.get(1);
+   		assertTrue(msg2 == msgRec2);
+   		Message msgRec3 = (Message)msgs.get(2);
+   		assertTrue(msg3 == msgRec3);
+
+   		receiver3.acknowledge(msgRec1, null);
+   		receiver3.acknowledge(msgRec2, null);
+   		receiver3.acknowledge(msgRec3, null);
+   		msgs = queue3.browse(null);
+   		assertNotNull(msgs);
+   		assertTrue(msgs.isEmpty()); 
+
+   		if (checkNoMessageData())
+   		{
+   			fail("Message data still in database");
+   		}
+   	}
+   	finally
+   	{
+   		if (office1 != null)
+   		{
+   			office1.stop();
+   		}
+
+   		if (office2 != null)
+   		{
+   			office2.stop();
+   		}
+
+   	}
+   }
+   
+   private void clusteredRouteFourNodes(boolean persistentMessage) throws Throwable
+   {
+   	PostOffice office1 = null;
+
+   	PostOffice office2 = null;
+   	
+   	PostOffice office3 = null;
+
+   	PostOffice office4 = null;
+
+   	try
+   	{   
+   		office1 = createClusteredPostOffice(1, "testgroup");
+   		office2 = createClusteredPostOffice(2, "testgroup");
+   		office3 = createClusteredPostOffice(3, "testgroup");
+   		office4 = createClusteredPostOffice(4, "testgroup");
+
+   		Queue queue1 =  new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue1.activate();
+   		boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
+   		assertTrue(added);
+   		
+   		Queue queue2 =  new MessagingQueue(2, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue2.activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue2, false), false);
+   		assertTrue(added);
+   		
+   		Queue queue3 =  new MessagingQueue(3, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue3.activate();
+   		added = office3.addBinding(new Binding(new SimpleCondition("condition1"), queue3, false), false);
+   		assertTrue(added);
+   		
+   		Queue queue4 =  new MessagingQueue(4, "queue4", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue4.activate();
+   		added = office4.addBinding(new Binding(new SimpleCondition("condition1"), queue4, false), false);
+   		assertTrue(added);
+
+   		SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue1.getLocalDistributor().add(receiver1);
+
+   		SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue2.getLocalDistributor().add(receiver2);
+
+   		SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue3.getLocalDistributor().add(receiver3);
+   		
+   		SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue4.getLocalDistributor().add(receiver4);
+
+   		Message msg1 = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
+   		MessageReference ref1 = ms.reference(msg1);  
+   		boolean routed = office1.route(ref1, new SimpleCondition("condition1"), null);   
+   		assertTrue(routed);
+
+   		Message msg2 = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
+   		MessageReference ref2 = ms.reference(msg2);         
+   		routed = office1.route(ref2, new SimpleCondition("condition1"), null);      
+   		assertTrue(routed);
+
+   		Message msg3 = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);      
+   		MessageReference ref3 = ms.reference(msg3);         
+   		routed = office1.route(ref3, new SimpleCondition("condition1"), null);      
+   		assertTrue(routed);
+
+   		Thread.sleep(1000);
+   		
+   		List msgs = receiver1.getMessages();
+   		assertNotNull(msgs);
+   		assertEquals(3, msgs.size());
+   		Message msgRec1 = (Message)msgs.get(0);
+   		assertTrue(msg1 == msgRec1);
+   		Message msgRec2 = (Message)msgs.get(1);
+   		assertTrue(msg2 == msgRec2);
+   		Message msgRec3 = (Message)msgs.get(2);
+   		assertTrue(msg3 == msgRec3);
+
+   		receiver1.acknowledge(msgRec1, null);
+   		receiver1.acknowledge(msgRec2, null);
+   		receiver1.acknowledge(msgRec3, null);
+   		msgs = queue1.browse(null);
+   		assertNotNull(msgs);
+   		assertTrue(msgs.isEmpty()); 
+   		
+   		msgs = receiver2.getMessages();
+   		assertNotNull(msgs);
+   		assertEquals(3, msgs.size());
+   		msgRec1 = (Message)msgs.get(0);
+   		assertTrue(msg1 == msgRec1);
+   		msgRec2 = (Message)msgs.get(1);
+   		assertTrue(msg2 == msgRec2);
+   		msgRec3 = (Message)msgs.get(2);
+   		assertTrue(msg3 == msgRec3);
+
+   		receiver2.acknowledge(msgRec1, null);
+   		receiver2.acknowledge(msgRec2, null);
+   		receiver2.acknowledge(msgRec3, null);
+   		msgs = queue2.browse(null);
+   		assertNotNull(msgs);
+   		assertTrue(msgs.isEmpty()); 
+
+   		msgs = receiver3.getMessages();
+   		assertNotNull(msgs);
+   		assertEquals(3, msgs.size());
+   		msgRec1 = (Message)msgs.get(0);
+   		assertTrue(msg1 == msgRec1);
+   		msgRec2 = (Message)msgs.get(1);
+   		assertTrue(msg2 == msgRec2);
+   		msgRec3 = (Message)msgs.get(2);
+   		assertTrue(msg3 == msgRec3);
+
+   		receiver3.acknowledge(msgRec1, null);
+   		receiver3.acknowledge(msgRec2, null);
+   		receiver3.acknowledge(msgRec3, null);
+   		msgs = queue3.browse(null);
+   		assertNotNull(msgs);
+   		assertTrue(msgs.isEmpty()); 
+   		
+   		msgs = receiver4.getMessages();
+   		assertNotNull(msgs);
+   		assertEquals(3, msgs.size());
+   		msgRec1 = (Message)msgs.get(0);
+   		assertTrue(msg1 == msgRec1);
+   		msgRec2 = (Message)msgs.get(1);
+   		assertTrue(msg2 == msgRec2);
+   		msgRec3 = (Message)msgs.get(2);
+   		assertTrue(msg3 == msgRec3);
+
+   		receiver4.acknowledge(msgRec1, null);
+   		receiver4.acknowledge(msgRec2, null);
+   		receiver4.acknowledge(msgRec3, null);
+   		msgs = queue4.browse(null);
+   		assertNotNull(msgs);
+   		assertTrue(msgs.isEmpty()); 
+   		
+   		if (checkNoMessageData())
+   		{
+   			fail("Message data still in database");
+   		}
+   	}
+   	finally
+   	{
+   		if (office1 != null)
+   		{
+   			office1.stop();
+   		}
+
+   		if (office2 != null)
+   		{
+   			office2.stop();
+   		}
+   		
+   		if (office3 != null)
+   		{
+   			office3.stop();
+   		}
+
+   		if (office4 != null)
+   		{
+   			office4.stop();
+   		}
+
+   	}
+   }
+   
+   
+
+   private void clusteredRoute(boolean persistentMessage) throws Throwable
+   {
+   	PostOffice office1 = null;
+
+   	PostOffice office2 = null;
+
+   	try
+   	{   
+   		office1 = createClusteredPostOffice(1, "testgroup");
+   		office2 = createClusteredPostOffice(2, "testgroup");
+
+   		//A mixture of durable and non durable queues
+
+   		Queue[] queues = new Queue[16];
+
+   		//condition1
+
+   		queues[0] = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queues[0].activate();
+   		boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[0], false), false);
+   		assertTrue(added);
+
+   		queues[1] = new MessagingQueue(1, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queues[1].activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[1], false), false);
+   		assertTrue(added);
+
+   		queues[2] = new MessagingQueue(2, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queues[2].activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[2], false), false);
+   		assertTrue(added);
+
+   		queues[3] = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queues[3].activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[3], false), false);
+   		assertTrue(added);
+
+   		//durable
+
+   		queues[4] = new MessagingQueue(2, "sub5", channelIDManager.getID(), ms, pm, true, -1, null, true);
+   		queues[4].activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[4], false), false);
+   		assertTrue(added);
+
+   		queues[5] = new MessagingQueue(1, "sub6", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queues[5].activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[5], false), false);
+   		assertTrue(added);
+
+   		//durable
+
+   		queues[6] = new MessagingQueue(1, "sub7", channelIDManager.getID(), ms, pm, true, -1, null, true);
+   		queues[6].activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[6], false), false);
+   		assertTrue(added);
+
+   		//durable
+
+   		queues[7] = new MessagingQueue(1, "sub8", channelIDManager.getID(), ms, pm, true, -1, null, true);
+   		queues[7].activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[7], false), false);
+   		assertTrue(added);
+
+   		//condition2
+
+
+   		queues[8] = new MessagingQueue(1, "sub9", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queues[8].activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[8], false), false);
+   		assertTrue(added);
+
+   		queues[9] = new MessagingQueue(1, "sub10", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queues[9].activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[9], false), false);
+   		assertTrue(added);
+
+   		queues[10] = new MessagingQueue(2, "sub11", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queues[10].activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[10], false), false);
+   		assertTrue(added);
+
+   		queues[11] = new MessagingQueue(2, "sub12", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queues[11].activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[11], false), false);
+   		assertTrue(added);
+
+   		//durable
+
+   		queues[12] = new MessagingQueue(2, "sub13", channelIDManager.getID(), ms, pm, true, -1, null, true);
+   		queues[12].activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[12], false), false);
+   		assertTrue(added);
+
+   		queues[13] = new MessagingQueue(1, "sub14", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queues[13].activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[13], false), false);
+   		assertTrue(added);
+
+   		//durable
+
+   		queues[14] = new MessagingQueue(1, "sub15", channelIDManager.getID(), ms, pm, true, -1, null, true);
+   		queues[14].activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[14], false), false);
+   		assertTrue(added);
+
+   		queues[15] = new MessagingQueue(1, "sub16", channelIDManager.getID(), ms, pm, true, -1, null, true);
+   		queues[15].activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[15], false), false);
+   		assertTrue(added);
+
+   		SimpleReceiver[] receivers = new SimpleReceiver[16];
+
+   		for (int i = 0; i < 16; i++)
+   		{
+   			receivers[i] = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   			queues[i].getLocalDistributor().add(receivers[i]);
+   		}
+
+   		Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
+   		MessageReference ref = ms.reference(msg);         
+
+   		boolean routed = office1.route(ref, new SimpleCondition("condition1"), null);         
+   		assertTrue(routed);
+
+   		//Messages are sent asych so may take some finite time to arrive
+   		Thread.sleep(1000);
+
+   		//Durable queues on remote node should never get the message
+
+   		for (int i = 0; i < 16; i++)
+   		{
+   			if (i >= 8 || (queues[i].getNodeID() == 2 && queues[i].isRecoverable()))
+   			{
+   				this.checkNotGetsMessage(queues[i], receivers[i]);
+   			}
+   			else
+   			{
+   				//Should get the message
+   				this.checkGetsMessage(queues[i], receivers[i], msg);
+   			}
+
+   		}
+
+   		//Now route to condition2
+
+   		msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);;      
+   		ref = ms.reference(msg);         
+
+   		routed = office2.route(ref, new SimpleCondition("condition2"), null);         
+   		assertTrue(routed);
+   		//Messages are sent asych so may take some finite time to arrive
+   		Thread.sleep(1000);
+
+   		for (int i = 0; i < 16; i++)
+   		{
+   			if (i < 8 || (queues[i].getNodeID() == 1 && queues[i].isRecoverable()))
+   			{
+   				//Shouldn't get the message
+   				this.checkNotGetsMessage(queues[i], receivers[i]);
+   			}
+   			else
+   			{
+   				//Should get the message
+   				this.checkGetsMessage(queues[i], receivers[i], msg);
+   			}
+
+   		}
+
+   		if (checkNoMessageData())
+   		{
+   			fail("Message data still in database");
+   		}
+   	}
+   	finally
+   	{
+   		if (office1 != null)
+   		{
+   			try
+   			{              
+   				office1.removeBinding("sub7", false);
+   				office1.removeBinding("sub8", false);               
+   				office1.removeBinding("sub15", false);
+   				office1.removeBinding("sub16", false);
+   			}
+   			catch (Exception ignore)
+   			{
+   				ignore.printStackTrace();
+   			}
+
+   			office1.stop();
+   		}
+
+   		if (office2 != null)
+   		{
+   			try
+   			{
+   				office2.removeBinding("sub5", false);
+   				office2.removeBinding("sub13", false);
+   			}
+   			catch (Exception ignore)
+   			{     
+   				ignore.printStackTrace();
+   			}
+   			office2.stop();
+   		}
+
+   	}
+   }
+
+
+
+   /*
+    * Queues with same name on different nodes of the cluster.
+    * If queue is routed to locally it shouldn't be routed to on other nodes
+    * 
+    */
+   private void routeSharedQueue(boolean persistentMessage) throws Throwable
+   {
+   	PostOffice office1 = null;
+
+   	PostOffice office2 = null;
+
+   	try
+   	{   
+   		office1 = createClusteredPostOffice(1, "testgroup");
+   		office2 = createClusteredPostOffice(2, "testgroup");
+
+   		//queue1
+
+   		Queue queue0 = new MessagingQueue(1, "myqueue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue0.activate();
+   		boolean added = office1.addBinding(new Binding(new SimpleCondition("myqueue1"), queue0, false), false);
+   		assertTrue(added);
+
+   		Queue queue1 = new MessagingQueue(2, "myqueue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue1.activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("myqueue1"), queue1, false), false);
+   		assertTrue(added);
+
+
+   		//queue2
+
+   		Queue queue2 = new MessagingQueue(1, "myqueue2", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue2.activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("myqueue2"), queue2, false), false);
+   		assertTrue(added);
+
+   		Queue queue3 = new MessagingQueue(2, "myqueue2", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue3.activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("myqueue2"), queue3, false), false);
+   		assertTrue(added);
+
+
+   		SimpleReceiver receiver0 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue0.getLocalDistributor().add(receiver0);
+
+   		SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue1.getLocalDistributor().add(receiver1);
+
+   		SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue2.getLocalDistributor().add(receiver2);
+
+   		SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue3.getLocalDistributor().add(receiver3);
+
+   		//Route to myqueue1 from office1         
+
+   		Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
+   		MessageReference ref = ms.reference(msg);         
+
+   		boolean routed = office1.route(ref, new SimpleCondition("myqueue1"), null);         
+   		assertTrue(routed);
+
+   		//Messages are sent asych so may take some finite time to arrive
+   		Thread.sleep(1000);
+
+   		//Only queue0 should get the message
+   		checkGetsMessage(queue0, receiver0, msg);
+
+   		checkNotGetsMessage(queue1, receiver1);
+
+   		checkNotGetsMessage(queue2, receiver2);
+
+   		checkNotGetsMessage(queue3, receiver3);
+
+   		//	Route to myqueue1 from office 2      
+
+   		msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
+   		ref = ms.reference(msg);         
+
+   		routed = office2.route(ref, new SimpleCondition("myqueue1"), null);         
+   		assertTrue(routed);
+
+   		//Messages are sent asych so may take some finite time to arrive
+   		Thread.sleep(1000);
+
+   		//Only queue1 should get the message
+   		checkGetsMessage(queue1, receiver1, msg);
+
+   		checkNotGetsMessage(queue0, receiver0);
+
+   		checkNotGetsMessage(queue2, receiver2);
+
+   		checkNotGetsMessage(queue3, receiver3);
+
+
+   		//Now route to condition2 from office 1
+
+   		msg = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);;      
+   		ref = ms.reference(msg);         
+
+   		routed = office1.route(ref, new SimpleCondition("myqueue2"), null);         
+   		assertTrue(routed);
+   		//Messages are sent asych so may take some finite time to arrive
+   		Thread.sleep(1000);
+
+   		// Only queue2 should get the message
+   		checkGetsMessage(queue2, receiver2, msg);
+
+   		checkNotGetsMessage(queue1, receiver1);
+
+   		checkNotGetsMessage(queue0, receiver0);
+
+   		checkNotGetsMessage(queue3, receiver3);
+
+
+   		//Now route to condition2 from office 2
+
+   		msg = CoreMessageFactory.createCoreMessage(4, persistentMessage, null);;      
+   		ref = ms.reference(msg);         
+
+   		routed = office2.route(ref, new SimpleCondition("myqueue2"), null);         
+   		assertTrue(routed);
+   		//Messages are sent asych so may take some finite time to arrive
+   		Thread.sleep(1000);
+
+   		// Only queue3 should get the message
+   		checkGetsMessage(queue3, receiver3, msg);
+
+   		checkNotGetsMessage(queue1, receiver1);
+
+   		checkNotGetsMessage(queue0, receiver0);
+
+   		checkNotGetsMessage(queue2, receiver2);
+
+
+
+   		if (checkNoMessageData())
+   		{
+   			fail("Message data still in database");
+   		}
+   	}
+   	finally
+   	{
+   		if (office1 != null)
+   		{
+   			office1.stop();
+   		}
+
+   		if (office2 != null)
+   		{
+
+   			office2.stop();
+   		}
+
+   	}
+   }
+
+
+   private void routeWithFilter(boolean persistentMessage) throws Throwable
+   {
+   	PostOffice office1 = null;
+
+   	PostOffice office2 = null;
+
+   	try
+   	{   
+   		office1 = createClusteredPostOffice(1, "testgroup");
+   		office2 = createClusteredPostOffice(2, "testgroup");
+
+
+   		Queue queue0 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue0.activate();
+   		boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue0, false), false);
+   		assertTrue(added);
+
+   		Queue queue1 = new MessagingQueue(2, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue1.activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
+   		assertTrue(added);
+
+
+   		Queue queue2 = new MessagingQueue(1, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue2.activate();
+   		added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queue2, false), false);
+   		assertTrue(added);
+
+   		Queue queue3 = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
+   		queue3.activate();
+   		added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queue3, false), false);
+   		assertTrue(added);
+
+
+   		SimpleReceiver receiver0 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue0.getLocalDistributor().add(receiver0);
+
+   		SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue1.getLocalDistributor().add(receiver1);
+
+   		SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue2.getLocalDistributor().add(receiver2);
+
+   		SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+   		queue3.getLocalDistributor().add(receiver3);
+
+   		//Route to condition1 from office1         
+
+   		Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
+   		MessageReference ref = ms.reference(msg);         
+
+   		boolean routed = office1.route(ref, new SimpleCondition("myqueue1"), null);         
+   		assertTrue(routed);
+
+   		//Messages are sent asych so may take some finite time to arrive
+   		Thread.sleep(1000);
+
+   		//Only queue0 should get the message
+   		checkGetsMessage(queue0, receiver0, msg);
+
+   		checkNotGetsMessage(queue1, receiver1);
+
+   		checkNotGetsMessage(queue2, receiver2);
+
+   		checkNotGetsMessage(queue3, receiver3);
+
+   		//	Route to myqueue1 from office 2      
+
+   		msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
+   		ref = ms.reference(msg);         
+
+   		routed = office2.route(ref, new SimpleCondition("myqueue1"), null);         
+   		assertTrue(routed);
+
+   		//Messages are sent asych so may take some finite time to arrive
+   		Thread.sleep(1000);
+
+   		//Only queue1 should get the message
+   		checkGetsMessage(queue1, receiver1, msg);
+
+   		checkNotGetsMessage(queue0, receiver0);
+
+   		checkNotGetsMessage(queue2, receiver2);
+
+   		checkNotGetsMessage(queue3, receiver3);
+
+
+   		//Now route to condition2 from office 1
+
+   		msg = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);;      
+   		ref = ms.reference(msg);         
+
+   		routed = office1.route(ref, new SimpleCondition("myqueue2"), null);         
+   		assertTrue(routed);
+   		//Messages are sent asych so may take some finite time to arrive
+   		Thread.sleep(1000);
+
+   		// Only queue2 should get the message
+   		checkGetsMessage(queue2, receiver2, msg);
+
+   		checkNotGetsMessage(queue1, receiver1);
+
+   		checkNotGetsMessage(queue0, receiver0);
+
+   		checkNotGetsMessage(queue3, receiver3);
+
+
+   		//Now route to condition2 from office 2
+
+   		msg = CoreMessageFactory.createCoreMessage(4, persistentMessage, null);;      
+   		ref = ms.reference(msg);         
+
+   		routed = office2.route(ref, new SimpleCondition("myqueue2"), null);         
+   		assertTrue(routed);
+   		//Messages are sent asych so may take some finite time to arrive
+   		Thread.sleep(1000);
+
+   		// Only queue3 should get the message
+   		checkGetsMessage(queue3, receiver3, msg);
+
+   		checkNotGetsMessage(queue1, receiver1);
+
+   		checkNotGetsMessage(queue0, receiver0);
+
+   		checkNotGetsMessage(queue2, receiver2);
+
+
+
+   		if (checkNoMessageData())
+   		{
+   			fail("Message data still in database");
+   		}
+   	}
+   	finally
+   	{
+   		if (office1 != null)
+   		{
+   			office1.stop();
+   		}
+
+   		if (office2 != null)
+   		{
+
+   			office2.stop();
+   		}
+
+   	}
+   }
+
+   private void dumpNodeIDView(PostOffice postOffice)
+   {
+   	Set view = postOffice.nodeIDView();
+
+   	log.info("=== node id view ==");
+
+   	Iterator iter = view.iterator();
+
+   	while (iter.hasNext())
+   	{
+   		log.info("Node:" + iter.next());
+   	}
+
+   	log.info("==================");
+   }
+
+   private void assertGotAll(int nodeId, Collection bindings, String queueName)
+   {
+
+   	log.info("============= dumping bindings ========");
+
+   	Iterator iter = bindings.iterator();
+
+   	while (iter.hasNext())
+   	{
+   		Binding binding = (Binding)iter.next();
+
+   		log.info("Binding: " + binding);
+   	}
+
+   	log.info("========= end dump==========");
+
+   	assertEquals(3, bindings.size());
+
+   	iter = bindings.iterator();
+
+   	boolean got1 = false;
+   	boolean got2 = false;
+   	boolean got3 = false;         
+   	while (iter.hasNext())
+   	{
+   		Binding binding = (Binding)iter.next();
+
+   		log.info("binding node id " + binding.queue.getNodeID());
+
+   		assertEquals(queueName, binding.queue.getName());
+   		if (binding.queue.getNodeID() == nodeId)
+   		{
+   			assertTrue(binding.allNodes);
+   		}
+   		else
+   		{
+   			assertFalse(binding.allNodes);
+   		}
+
+   		if (binding.queue.getNodeID() == 1)
+   		{
+   			got1 = true;
+   		}
+   		if (binding.queue.getNodeID() == 2)
+   		{
+   			got2 = true;
+   		}
+   		if (binding.queue.getNodeID() == 3)
+   		{
+   			got3 = true;
+   		}    	
+   	}         
+   	assertTrue(got1 && got2 && got3);
+   }
+
+
+   private void checkGetsMessage(Queue queue, SimpleReceiver receiver, Message msg) throws Throwable
+   {
+   	List msgs = receiver.getMessages();
+   	assertNotNull(msgs);
+   	assertEquals(1, msgs.size());
+   	Message msgRec = (Message)msgs.get(0);
+   	assertEquals(msg.getMessageID(), msgRec.getMessageID());
+   	receiver.acknowledge(msgRec, null);
+   	msgs = queue.browse(null);
+   	assertNotNull(msgs);
+   	assertTrue(msgs.isEmpty()); 
+   	receiver.clear();
+   }
+
+   private void checkNotGetsMessage(Queue queue, SimpleReceiver receiver) throws Throwable
+   {
+   	List msgs = receiver.getMessages();
+   	assertNotNull(msgs);
+   	assertTrue(msgs.isEmpty());
+   	msgs = queue.browse(null);
+   	assertNotNull(msgs);
+   	assertTrue(msgs.isEmpty());
+   }
+   
+   // Inner classes --------------------------------------------------------------------------------
+
+}
+
+
+

Copied: trunk/tests/src/org/jboss/test/messaging/core/postoffice/PostOfficeTest.java (from rev 2829, trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/PostOfficeTest.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/postoffice/PostOfficeTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/core/postoffice/PostOfficeTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -0,0 +1,1285 @@
+/*
+  * 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.core.postoffice;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.messaging.core.contract.Binding;
+import org.jboss.messaging.core.contract.Condition;
+import org.jboss.messaging.core.contract.Message;
+import org.jboss.messaging.core.contract.MessageReference;
+import org.jboss.messaging.core.contract.PostOffice;
+import org.jboss.messaging.core.contract.Queue;
+import org.jboss.messaging.core.impl.MessagingQueue;
+import org.jboss.messaging.core.impl.tx.Transaction;
+import org.jboss.test.messaging.core.PostOfficeTestBase;
+import org.jboss.test.messaging.core.SimpleCondition;
+import org.jboss.test.messaging.core.SimpleFilter;
+import org.jboss.test.messaging.core.SimpleReceiver;
+import org.jboss.test.messaging.util.CoreMessageFactory;
+
+/**
+ * 
+ * A PostOfficeTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 2386 $</tt>
+ *
+ * $Id: DefaultPostOfficeTest.java 2386 2007-02-21 18:07:44Z timfox $
+ *
+ */
+public class PostOfficeTest extends PostOfficeTestBase
+{
+   // Constants -----------------------------------------------------
+
+   // Static --------------------------------------------------------
+   
+   // Attributes ----------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public PostOfficeTest(String name)
+   {
+      super(name);
+   }
+
+   // Public --------------------------------------------------------
+   
+   public final void testBindUnbind() throws Throwable
+   {
+      PostOffice office1 = null;
+      
+      PostOffice office2 = null;
+      
+      PostOffice office3 = null;
+      
+      try
+      {             
+         office1 = createNonClusteredPostOffice();
+         
+         //Bind one durable
+             
+         MessagingQueue queue1 =
+            new MessagingQueue(1, "durableQueue", channelIDManager.getID(), ms, pm, true, -1, null, false);
+         queue1.activate();
+         
+         Condition condition1 = new SimpleCondition("condition1");
+                  
+         office1.addBinding(new Binding(condition1, queue1, false), false);
+         
+         //Binding twice with the same name should fail      
+         try
+         {
+            office1.addBinding(new Binding(condition1, queue1, false), false);
+            fail();
+         }
+         catch (IllegalArgumentException e)
+         {
+            //Ok
+         }
+         
+         //Can't bind a queue from another node
+         
+         try
+         {
+         
+	         MessagingQueue queuexx =
+	            new MessagingQueue(777, "durableQueue", channelIDManager.getID(), ms, pm, true, -1, null, false);
+	         queuexx.activate();
+	         office1.addBinding(new Binding(condition1, queuexx, false), false);
+            fail();
+         }
+         catch (IllegalArgumentException e)
+         {
+            //Ok
+         }
+         
+               
+         //Bind one non durable
+         MessagingQueue queue2 =
+            new MessagingQueue(1, "nonDurableQueue", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue2.activate();
+         
+         Condition condition2 = new SimpleCondition("condition2");         
+         
+         office1.addBinding(new Binding(condition2, queue2, false), false);
+         
+         //Check they're there
+         
+         Collection queues = office1.getQueuesForCondition(condition1, true);
+         assertNotNull(queues);
+         assertEquals(1, queues.size());
+         Queue rqueue1 = (Queue)queues.iterator().next();
+         assertEquals(queue1, rqueue1);
+         
+         queues = office1.getQueuesForCondition(condition2, true);
+         assertNotNull(queues);
+         assertEquals(1, queues.size());
+         Queue rqueue2 = (Queue)queues.iterator().next();
+         assertEquals(queue2, rqueue2);
+         
+         
+         
+         office1.stop();
+         
+         //Throw away the office and create another
+         office2 = createNonClusteredPostOffice();
+         
+         //Only one binding should be there
+         queues = office2.getQueuesForCondition(condition1, true);
+         assertNotNull(queues);
+         assertEquals(1, queues.size());
+         rqueue1 = (Queue)queues.iterator().next();
+         assertEquals(queue1, rqueue1);
+         
+         queues = office2.getQueuesForCondition(condition2, true);
+         assertNotNull(queues);
+         assertTrue(queues.isEmpty());
+         
+         //Unbind the binding
+         office2.removeBinding(queue1.getName(), false);
+         
+         
+         //Make sure no longer there
+         queues = office2.getQueuesForCondition(condition1, true);
+         assertNotNull(queues);
+         assertTrue(queues.isEmpty());
+         
+         queues = office2.getQueuesForCondition(condition2, true);
+         assertNotNull(queues);
+         assertTrue(queues.isEmpty());
+         
+         office2.stop();
+         
+         //Throw away office and start another
+         office3 = createNonClusteredPostOffice();
+         
+         //Make sure not there
+         queues = office3.getQueuesForCondition(condition1, true);
+         assertNotNull(queues);
+         assertTrue(queues.isEmpty());
+         
+         queues = office3.getQueuesForCondition(condition2, true);
+         assertNotNull(queues);
+         assertTrue(queues.isEmpty());
+                  
+      }
+      finally
+      {
+         if (office1 != null)
+         {
+            office1.stop();
+         }
+         
+         if (office2 != null)
+         {
+            office2.stop();
+         }
+         
+         if (office3 != null)
+         {
+            office2.stop();
+         }
+         
+         if (checkNoBindingData())
+         {
+            fail("Binding data still in database");
+         }
+      }
+            
+   }
+   
+   public final void testGetQueuesForCondition() throws Throwable
+   {
+      PostOffice office = null;
+      
+      try
+      {      
+         office = createNonClusteredPostOffice();
+         
+         Condition condition1 = new SimpleCondition("condition1");
+         
+         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue1.activate();
+         
+         office.addBinding(new Binding(condition1, queue1, false), false);
+         
+         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue2.activate();
+         
+         office.addBinding(new Binding(condition1, queue2, false), false);
+         
+         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue3.activate();
+         
+         office.addBinding(new Binding(condition1, queue3, false), false);
+         
+         MessagingQueue queue4 = new MessagingQueue(1, "queue4", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue4.activate();
+         
+         office.addBinding(new Binding(condition1, queue4, false), false);
+         
+         MessagingQueue queue5 = new MessagingQueue(1, "queue5", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue5.activate();
+         
+         Condition condition2 = new SimpleCondition("condition2");         
+         
+         office.addBinding(new Binding(condition2, queue5, false), false);
+         
+         MessagingQueue queue6 = new MessagingQueue(1, "queue6", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue6.activate();
+         
+         office.addBinding(new Binding(condition2, queue6, false), false);
+         
+         MessagingQueue queue7 = new MessagingQueue(1, "queue7", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue7.activate();
+         
+         office.addBinding(new Binding(condition2, queue7, false), false);
+         
+         MessagingQueue queue8 = new MessagingQueue(1, "queue8", channelIDManager.getID(), ms, pm,  false, -1, null, false);
+         queue8.activate();
+         
+         office.addBinding(new Binding(condition2, queue8, false), false);
+                  
+         Collection queues = office.getQueuesForCondition(new SimpleCondition("dummy"), true);
+         assertNotNull(queues);
+         assertTrue(queues.isEmpty());
+                           
+         //We don't match on substrings
+         queues = office.getQueuesForCondition(new SimpleCondition("condition123"), true);
+         assertNotNull(queues);
+         assertTrue(queues.isEmpty());
+         
+         //We don't currently support hierarchies
+         queues = office.getQueuesForCondition(new SimpleCondition("condition1.subcondition"), true);
+         assertNotNull(queues);
+         assertTrue(queues.isEmpty());
+         
+         //Lookup the queues
+         
+         queues = office.getQueuesForCondition(condition1, true);
+         assertNotNull(queues);
+         assertEquals(4, queues.size());
+         
+         assertTrue(queues.contains(queue1));
+         assertTrue(queues.contains(queue2));
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         
+         queues = office.getQueuesForCondition(condition2, true);
+         assertNotNull(queues);
+         assertEquals(4, queues.size());
+         
+         assertTrue(queues.contains(queue5));
+         assertTrue(queues.contains(queue6));
+         assertTrue(queues.contains(queue7));
+         assertTrue(queues.contains(queue8));
+         
+         //Lookup should work on new instance too
+         
+         queues = office.getQueuesForCondition(new SimpleCondition("condition1"), true);
+         assertNotNull(queues);
+         assertEquals(4, queues.size());
+         
+         assertTrue(queues.contains(queue1));
+         assertTrue(queues.contains(queue2));
+         assertTrue(queues.contains(queue3));
+         assertTrue(queues.contains(queue4));
+         
+         queues = office.getQueuesForCondition(new SimpleCondition("condition2"), true);
+         assertNotNull(queues);
+         assertEquals(4, queues.size());
+         
+         assertTrue(queues.contains(queue5));
+         assertTrue(queues.contains(queue6));
+         assertTrue(queues.contains(queue7));
+         assertTrue(queues.contains(queue8));
+         
+      }
+      finally
+      {
+         if (office != null)
+         {
+            office.stop();
+         }
+         
+         if (checkNoBindingData())
+         {
+            fail("Binding data still in database");
+         }
+      }
+         
+   }
+   
+   public void testGetBindingForQueueName() throws Throwable
+   {   	
+      PostOffice office = null;
+      
+      try
+      {      
+         office = createNonClusteredPostOffice();
+                  
+         Condition condition1 = new SimpleCondition("condition1");  
+         
+         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         office.addBinding(new Binding(condition1, queue1, false), false);
+                         
+         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         office.addBinding(new Binding(condition1, queue2, false), false);
+         
+         Condition condition2 = new SimpleCondition("condition2");  
+                  
+         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         office.addBinding(new Binding(condition2, queue3, false), false);
+         
+         Binding b1 = office.getBindingForQueueName("queue1");
+         assertNotNull(b1);
+         assertEquals(queue1, b1.queue);
+         assertEquals(condition1, b1.condition);
+         
+         Binding b2 = office.getBindingForQueueName("queue2");
+         assertNotNull(b2);
+         assertEquals(queue2, b2.queue);
+         assertEquals(condition1, b2.condition);
+         
+         Binding b3 = office.getBindingForQueueName("queue3");
+         assertNotNull(b3);
+         assertEquals(queue3, b3.queue);
+         assertEquals(condition2, b3.condition);
+         
+         office.removeBinding("queue1", false);
+         
+         b1 = office.getBindingForQueueName("queue1");
+         assertNull(b1);
+
+         b2 = office.getBindingForQueueName("queue2");
+         assertNotNull(b2);
+         assertEquals(queue2, b2.queue);
+         assertEquals(condition1, b2.condition);
+         
+         b3 = office.getBindingForQueueName("queue3");
+         assertNotNull(b3);
+         assertEquals(queue3, b3.queue);
+         assertEquals(condition2, b3.condition);
+         
+         office.removeBinding("queue2", false);
+         office.removeBinding("queue3", false);
+         
+         b1 = office.getBindingForQueueName("queue1");
+         assertNull(b1);
+
+         b2 = office.getBindingForQueueName("queue2");
+         assertNull(b2);
+ 
+         b3 = office.getBindingForQueueName("queue3");
+         assertNull(b3);                     
+      }
+      finally
+      {
+         if (office != null)
+         {
+            office.stop();
+         }
+         
+         if (checkNoBindingData())
+         {
+            fail("Binding data still in database");
+         }
+      }
+         
+   }
+   
+   public void testGetBindingForChannelID() throws Throwable
+   {   	
+      PostOffice office = null;
+      
+      try
+      {      
+         office = createNonClusteredPostOffice();
+                  
+         Condition condition1 = new SimpleCondition("condition1");  
+         
+         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         office.addBinding(new Binding(condition1, queue1, false), false);
+                         
+         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         office.addBinding(new Binding(condition1, queue2, false), false);
+         
+         Condition condition2 = new SimpleCondition("condition2");  
+                  
+         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         office.addBinding(new Binding(condition2, queue3, false), false);
+         
+         Binding b1 = office.getBindingForChannelID(queue1.getChannelID());
+         assertNotNull(b1);
+         assertEquals(queue1, b1.queue);
+         assertEquals(condition1, b1.condition);
+         
+         Binding b2 = office.getBindingForChannelID(queue2.getChannelID());
+         assertNotNull(b2);
+         assertEquals(queue2, b2.queue);
+         assertEquals(condition1, b2.condition);
+         
+         Binding b3 = office.getBindingForChannelID(queue3.getChannelID());
+         assertNotNull(b3);
+         assertEquals(queue3, b3.queue);
+         assertEquals(condition2, b3.condition);
+         
+         office.removeBinding("queue1", false);
+         
+         b1 = office.getBindingForChannelID(queue1.getChannelID());
+         assertNull(b1);
+
+         b2 =office.getBindingForChannelID(queue2.getChannelID());
+         assertNotNull(b2);
+         assertEquals(queue2, b2.queue);
+         assertEquals(condition1, b2.condition);
+         
+         b3 = office.getBindingForChannelID(queue3.getChannelID());
+         assertNotNull(b3);
+         assertEquals(queue3, b3.queue);
+         assertEquals(condition2, b3.condition);
+         
+         office.removeBinding("queue2", false);
+         office.removeBinding("queue3", false);
+         
+         b1 = office.getBindingForChannelID(queue1.getChannelID());
+         assertNull(b1);
+
+         b2 = office.getBindingForChannelID(queue2.getChannelID());
+         assertNull(b2);
+ 
+         b3 = office.getBindingForChannelID(queue3.getChannelID());
+         assertNull(b3);                     
+      }
+      finally
+      {
+         if (office != null)
+         {
+            office.stop();
+         }
+         
+         if (checkNoBindingData())
+         {
+            fail("Binding data still in database");
+         }
+      }
+         
+   }
+
+   public void testRouteNonPersistentWithFilter() throws Throwable
+   {
+      routeWithFilter(false);
+   }
+   
+   public void testRoutePersistentWithFilter() throws Throwable
+   {
+      routeWithFilter(true);
+   }
+   
+   public final void testRoutePersistent() throws Throwable
+   {
+      route(true);
+   }
+   
+   public final void testRouteNonPersistent() throws Throwable
+   {
+      route(false);
+   }
+   
+   public final void testRouteTransactionalPersistent() throws Throwable
+   {
+      routeTransactional(true);
+   }
+   
+   public final void testRouteTransactionalNonPersistent() throws Throwable
+   {
+      routeTransactional(false);
+   }
+         
+   public final void testRouteInactive() throws Throwable
+   {
+      PostOffice postOffice = null;
+      
+      try
+      {      
+         postOffice = createNonClusteredPostOffice();
+         
+         Condition condition1 = new SimpleCondition("topic1");
+         
+         MessagingQueue queue1 =  new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue1.activate();
+         
+         postOffice.addBinding(new Binding(condition1, queue1, false), false);
+         
+         MessagingQueue queue2 =  new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue2.activate();
+         
+         postOffice.addBinding(new Binding(condition1, queue2, false), false);
+         
+         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue3.activate();
+         
+         postOffice.addBinding(new Binding(condition1, queue3, false), false);
+         
+         MessagingQueue queue4 = new MessagingQueue(1, "queue4", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue4.activate();
+         
+         Condition condition2 = new SimpleCondition("topic2");
+         
+         
+         postOffice.addBinding(new Binding(condition2, queue4, false), false);
+         
+         MessagingQueue queue5 = new MessagingQueue(1, "queue5", channelIDManager.getID(), ms, pm, false,-1, null, false);
+         queue5.activate();
+         
+         postOffice.addBinding(new Binding(condition2, queue5, false), false);
+         
+         MessagingQueue queue6 = new MessagingQueue(1, "queue6", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue6.activate();
+         
+         postOffice.addBinding(new Binding(condition2, queue6, false), false);
+      
+         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+         queue1.getLocalDistributor().add(receiver1);
+         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+         queue2.getLocalDistributor().add(receiver2);
+         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+         queue3.getLocalDistributor().add(receiver3);
+         SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+         queue4.getLocalDistributor().add(receiver4);
+         SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+         queue5.getLocalDistributor().add(receiver5);
+         SimpleReceiver receiver6 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+         queue6.getLocalDistributor().add(receiver6);
+         
+         queue1.deactivate();
+         queue2.deactivate();
+         queue5.deactivate();
+         queue6.deactivate();
+         
+         assertFalse(queue1.isActive());      
+         assertFalse(queue2.isActive());
+         assertFalse(queue5.isActive());
+         assertFalse(queue6.isActive()); 
+         assertTrue(queue3.isActive());
+         assertTrue(queue4.isActive());      
+         
+         Message msg1 = CoreMessageFactory.createCoreMessage(1);      
+         MessageReference ref1 = ms.reference(msg1);
+         
+         boolean routed = postOffice.route(ref1, condition1, null);      
+         assertTrue(routed);
+         
+         List msgs = receiver1.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver2.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver3.getMessages();
+         assertNotNull(msgs);
+         assertEquals(1, msgs.size());
+         Message msgRec = (Message)msgs.get(0);
+         assertTrue(msg1 == msgRec);
+         receiver3.acknowledge(msgRec, null);
+         msgs = queue3.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());  
+         
+         msgs = receiver4.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver5.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver6.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         receiver3.clear();
+                     
+         Message msg2 = CoreMessageFactory.createCoreMessage(2);      
+         MessageReference ref2 = ms.reference(msg2);
+         
+         routed = postOffice.route(ref2, condition2, null);      
+         assertTrue(routed);
+         
+         msgs = receiver1.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver2.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver3.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());      
+         
+         msgs = receiver4.getMessages();
+         assertNotNull(msgs);
+         assertEquals(1, msgs.size());
+         msgRec = (Message)msgs.get(0);
+         assertTrue(msg2 == msgRec);
+         receiver4.acknowledge(msgRec, null);
+         msgs = queue4.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());  
+         
+         msgs = receiver5.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver6.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         if (checkNoMessageData())
+         {
+            fail("data still in database");
+         }
+      }
+      finally
+      {
+         if (postOffice != null)
+         {
+            postOffice.stop();
+         }
+         
+      }
+   
+   }
+
+   public final void testRouteNoQueue() throws Throwable
+   {
+      PostOffice postOffice = null;
+      
+      try
+      {      
+         postOffice = createNonClusteredPostOffice();
+         
+         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue1.activate();
+         
+         postOffice.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
+              
+         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
+         
+         queue1.getLocalDistributor().add(receiver1);
+   
+         assertTrue(queue1.isActive());
+   
+         Message msg1 = CoreMessageFactory.createCoreMessage(1);      
+         
+         MessageReference ref1 = ms.reference(msg1);
+         
+         boolean routed = postOffice.route(ref1, new SimpleCondition("this won't match anything"), null);
+         
+         assertFalse(routed);
+               
+         List msgs = receiver1.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());  
+         
+         if (checkNoMessageData())
+         {
+            fail("data still in database");
+         }
+         
+      }
+      finally
+      {
+         if (postOffice != null)
+         {
+            postOffice.stop();
+         }
+         
+      }
+   }
+   
+   
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+   
+      
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+   }
+
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+   }
+
+   // Private -------------------------------------------------------
+   
+   private void route(boolean persistentMessage) throws Throwable
+   {
+      PostOffice postOffice = null;
+      
+      try
+      {      
+         postOffice = createNonClusteredPostOffice();
+      
+         Condition condition1 = new SimpleCondition("topic1");
+         
+         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue1.activate();
+         
+         postOffice.addBinding(new Binding(condition1, queue1, false), false);
+         
+         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue2.activate();
+         
+         postOffice.addBinding(new Binding(condition1, queue2, false), false);
+         
+         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue3.activate();
+         
+         postOffice.addBinding(new Binding(condition1, queue3, false), false);
+         
+         MessagingQueue queue4 = new MessagingQueue(1, "queue4", channelIDManager.getID(), ms, pm, true, -1, null, false);
+         queue4.activate();
+         
+         Condition condition2 = new SimpleCondition("topic2");
+         
+         postOffice.addBinding(new Binding(condition2, queue4, false), false);
+         
+         MessagingQueue queue5 = new MessagingQueue(1, "queue5", channelIDManager.getID(), ms, pm, true, -1, null, false);
+         queue5.activate();
+         
+         postOffice.addBinding(new Binding(condition2, queue5, false), false);
+         
+         MessagingQueue queue6 = new MessagingQueue(1, "queue6", channelIDManager.getID(), ms, pm, true, -1, null, false);
+         queue6.activate();
+         
+         postOffice.addBinding(new Binding(condition2, queue6, false), false);
+      
+         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
+         queue1.getLocalDistributor().add(receiver1);
+         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
+         queue2.getLocalDistributor().add(receiver2);
+         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
+         queue3.getLocalDistributor().add(receiver3);
+         SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
+         queue4.getLocalDistributor().add(receiver4);
+         SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
+         queue5.getLocalDistributor().add(receiver5);
+         SimpleReceiver receiver6 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
+         queue6.getLocalDistributor().add(receiver6);
+         
+         assertTrue(queue1.isActive());      
+         assertTrue(queue2.isActive());
+         assertTrue(queue3.isActive());      
+         assertTrue(queue4.isActive());
+         assertTrue(queue5.isActive());      
+         assertTrue(queue6.isActive());
+         
+         Message msg1 = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
+         MessageReference ref1 = ms.reference(msg1);
+         
+         boolean routed = postOffice.route(ref1, condition1, null);      
+         assertTrue(routed);
+         
+         List msgs = receiver1.getMessages();
+         assertNotNull(msgs);
+         assertEquals(1, msgs.size());
+         Message msgRec = (Message)msgs.get(0);
+         assertTrue(msg1 == msgRec);
+         receiver1.acknowledge(msgRec, null);
+         msgs = queue1.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver2.getMessages();
+         assertNotNull(msgs);
+         assertEquals(1, msgs.size());
+         msgRec = (Message)msgs.get(0);
+         assertTrue(msg1 == msgRec);
+         receiver2.acknowledge(msgRec, null);
+         msgs = queue2.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver3.getMessages();
+         assertNotNull(msgs);
+         assertEquals(1, msgs.size());
+         msgRec = (Message)msgs.get(0);
+         assertTrue(msg1 == msgRec);
+         receiver3.acknowledge(msgRec, null);
+         msgs = queue3.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver4.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver5.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver6.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         receiver1.clear();
+         receiver2.clear();
+         receiver3.clear();
+         
+         
+         Message msg2 = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
+         MessageReference ref2 = ms.reference(msg2);
+         
+         routed = postOffice.route(ref2, condition2, null);      
+         assertTrue(routed);
+         
+         msgs = receiver4.getMessages();
+         assertNotNull(msgs);
+         assertEquals(1, msgs.size());
+         msgRec = (Message)msgs.get(0);
+         assertTrue(msg2 == msgRec);
+         receiver4.acknowledge(msgRec, null);
+         msgs = queue4.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver5.getMessages();
+         assertNotNull(msgs);
+         assertEquals(1, msgs.size());
+         msgRec = (Message)msgs.get(0);
+         assertTrue(msg2 == msgRec);
+         receiver5.acknowledge(msgRec, null);
+         msgs = queue5.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver6.getMessages();
+         assertNotNull(msgs);
+         assertEquals(1, msgs.size());
+         msgRec = (Message)msgs.get(0);
+         assertTrue(msg2 == msgRec);
+         receiver6.acknowledge(msgRec, null);
+         msgs = queue6.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());    
+         
+         msgs = receiver1.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver2.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = receiver3.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+      }
+      finally
+      {
+         if (postOffice != null)
+         {
+            postOffice.stop();
+         }
+         
+         if (checkNoMessageData())
+         {
+            fail("data still in database");
+         }
+      }
+   }
+   
+   private void routeTransactional(boolean persistentMessage) throws Throwable
+   {
+      PostOffice postOffice = null;
+      
+      try
+      {      
+         postOffice = createNonClusteredPostOffice();
+         
+         Condition condition1 = new SimpleCondition("topic1");
+      
+         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue1.activate();
+         
+         postOffice.addBinding(new Binding(condition1, queue1, false), false);
+         
+         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, true,-1, null, false);
+         queue2.activate();
+         
+         postOffice.addBinding(new Binding(condition1, queue2, false), false);
+          
+         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
+         queue1.getLocalDistributor().add(receiver1);
+
+         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
+         queue2.getLocalDistributor().add(receiver2);
+   
+         assertTrue(queue1.isActive());
+         assertTrue(queue2.isActive());
+   
+         Message msg1 = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);      
+         MessageReference ref1 = ms.reference(msg1);
+         
+         Message msg2 = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);      
+         MessageReference ref2 = ms.reference(msg2);
+         
+         Transaction tx = tr.createTransaction();
+         
+         boolean routed = postOffice.route(ref1, condition1, tx);            
+         assertTrue(routed);
+         routed = postOffice.route(ref2, condition1, tx);            
+         assertTrue(routed);
+               
+         List msgs = queue1.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         msgs = queue2.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         tx.commit();
+         
+         msgs = receiver1.getMessages();
+         assertNotNull(msgs);
+         assertEquals(2, msgs.size());
+         Message msgRec1 = (Message)msgs.get(0);
+         Message msgRec2 = (Message)msgs.get(1);
+         assertTrue(msgRec1 == msg1);
+         assertTrue(msgRec2 == msg2);
+         
+         msgs = receiver2.getMessages();
+         assertNotNull(msgs);
+         assertEquals(2, msgs.size());
+         msgRec1 = (Message)msgs.get(0);
+         msgRec2 = (Message)msgs.get(1);
+         assertTrue(msgRec1 == msg1);
+         assertTrue(msgRec2 == msg2);
+         
+         //Acknowledge
+         receiver1.acknowledge(msgRec1, null);
+         receiver1.acknowledge(msgRec2, null);
+         
+         receiver2.acknowledge(msgRec1, null);
+         receiver2.acknowledge(msgRec2, null);
+   
+         msgs = queue1.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty()); 
+         
+         receiver1.clear();
+         
+         msgs = queue2.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty()); 
+         
+         receiver2.clear();
+              
+         Message msg3 = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);      
+         MessageReference ref3 = ms.reference(msg3);
+         
+         Message msg4 = CoreMessageFactory.createCoreMessage(4, persistentMessage, null);      
+         MessageReference ref4 = ms.reference(msg4);
+         
+         tx = tr.createTransaction();
+         
+         routed = postOffice.route(ref3, condition1, tx);            
+         assertTrue(routed);
+         routed = postOffice.route(ref4, condition1, tx);            
+         assertTrue(routed);
+               
+         msgs = queue1.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty()); 
+         
+         msgs = queue2.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty()); 
+         
+         tx.rollback();
+         
+         msgs = receiver1.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         receiver1.clear();
+         
+         msgs = receiver2.getMessages();
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+         
+         receiver2.clear();
+         
+         
+         Message msg5 = CoreMessageFactory.createCoreMessage(5, persistentMessage, null);      
+         MessageReference ref5 = ms.reference(msg5);
+         
+         Message msg6 = CoreMessageFactory.createCoreMessage(6, persistentMessage, null);      
+         MessageReference ref6 = ms.reference(msg6);
+               
+         routed = postOffice.route(ref5, new SimpleCondition("topic1"), null);            
+         assertTrue(routed);
+         routed = postOffice.route(ref6, new SimpleCondition("topic1"), null);            
+         assertTrue(routed);
+         
+         msgs = receiver1.getMessages();
+         assertNotNull(msgs);
+         assertEquals(2, msgs.size());
+         msgRec1 = (Message)msgs.get(0);
+         msgRec2 = (Message)msgs.get(1);
+         assertTrue(msgRec1 == msg5);
+         assertTrue(msgRec2 == msg6);
+         
+         msgs = receiver2.getMessages();
+         assertNotNull(msgs);
+         assertEquals(2, msgs.size());
+         msgRec1 = (Message)msgs.get(0);
+         msgRec2 = (Message)msgs.get(1);
+         assertTrue(msgRec1 == msg5);
+         assertTrue(msgRec2 == msg6);
+         
+         //Acknowledge transactionally
+         
+         tx = tr.createTransaction();
+         
+         receiver1.acknowledge(msgRec1, tx);
+         receiver1.acknowledge(msgRec2, tx);
+         
+         receiver2.acknowledge(msgRec1, tx);
+         receiver2.acknowledge(msgRec2, tx);
+         
+         int deliveringCount = queue1.getDeliveringCount();
+         assertEquals(2, deliveringCount);
+         
+         deliveringCount = queue2.getDeliveringCount();
+         assertEquals(2, deliveringCount);
+         
+         tx.commit();
+         
+         msgs = queue1.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+               
+         receiver1.clear();
+         
+         msgs = queue2.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());
+               
+         receiver2.clear();
+         
+         Message msg7 = CoreMessageFactory.createCoreMessage(7, persistentMessage, null);      
+         MessageReference ref7 = ms.reference(msg7);
+         
+         Message msg8 = CoreMessageFactory.createCoreMessage(8, persistentMessage, null);      
+         MessageReference ref8 = ms.reference(msg8);
+               
+         routed = postOffice.route(ref7, new SimpleCondition("topic1"), null);            
+         assertTrue(routed);
+         routed = postOffice.route(ref8, new SimpleCondition("topic1"), null);            
+         assertTrue(routed);
+         
+         msgs = receiver1.getMessages();
+         assertNotNull(msgs);
+         assertEquals(2, msgs.size());
+         msgRec1 = (Message)msgs.get(0);
+         msgRec2 = (Message)msgs.get(1);
+         assertTrue(msgRec1 == msg7);
+         assertTrue(msgRec2 == msg8);
+         
+         msgs = receiver2.getMessages();
+         assertNotNull(msgs);
+         assertEquals(2, msgs.size());
+         msgRec1 = (Message)msgs.get(0);
+         msgRec2 = (Message)msgs.get(1);
+         assertTrue(msgRec1 == msg7);
+         assertTrue(msgRec2 == msg8);
+         
+         //Acknowledge transactionally
+         
+         tx = tr.createTransaction();
+         
+         receiver1.acknowledge(msgRec1, tx);
+         receiver1.acknowledge(msgRec2, tx);
+         
+         receiver2.acknowledge(msgRec1, tx);
+         receiver2.acknowledge(msgRec2, tx);
+         
+         deliveringCount = queue1.getDeliveringCount();
+         assertEquals(2, deliveringCount);
+         
+         deliveringCount = queue2.getDeliveringCount();
+         assertEquals(2, deliveringCount);
+         
+         tx.rollback();
+         
+         deliveringCount = queue1.getDeliveringCount();
+         assertEquals(2, deliveringCount);                  
+         
+         receiver1.acknowledge(msgRec1, null);
+         receiver1.acknowledge(msgRec2, null);
+         
+         deliveringCount = queue2.getDeliveringCount();
+         assertEquals(2, deliveringCount);     
+         
+         
+         receiver2.acknowledge(msgRec1, null);
+         receiver2.acknowledge(msgRec2, null);
+         
+         if (checkNoMessageData())
+         {
+            fail("data still in database");
+         }
+      }
+      finally
+      {
+         if (postOffice != null)
+         {
+            postOffice.stop();
+         }         
+      }
+   }
+   
+   private void routeWithFilter(boolean persistentMessage) throws Throwable
+   {
+      PostOffice postOffice = null;
+      
+      try
+      {      
+         postOffice = createNonClusteredPostOffice();
+         
+         SimpleFilter filter = new SimpleFilter(2);
+         
+         Condition condition1 = new SimpleCondition("topic1");
+      
+         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, filter, false);
+         queue1.activate();
+         
+         postOffice.addBinding(new Binding(condition1, queue1, false), false);
+         
+         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue2.activate();
+         
+         postOffice.addBinding(new Binding(condition1, queue2, false), false);
+         
+         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
+         queue3.activate();
+         
+         postOffice.addBinding(new Binding(condition1, queue3, false), false);
+         
+         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+         queue1.getLocalDistributor().add(receiver1);
+         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+         queue2.getLocalDistributor().add(receiver2);
+         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+         queue3.getLocalDistributor().add(receiver3);
+         
+         Message msg1 = CoreMessageFactory.createCoreMessage(1);      
+         MessageReference ref1 = ms.reference(msg1);         
+         boolean routed = postOffice.route(ref1, condition1, null);      
+         assertTrue(routed);
+         Message msg2 = CoreMessageFactory.createCoreMessage(2);      
+         MessageReference ref2 = ms.reference(msg2);         
+         routed = postOffice.route(ref2, condition1, null);      
+         assertTrue(routed);
+         Message msg3 = CoreMessageFactory.createCoreMessage(3);      
+         MessageReference ref3 = ms.reference(msg3);         
+         routed = postOffice.route(ref3, condition1, null);      
+         assertTrue(routed);
+         
+         List msgs = receiver1.getMessages();
+         assertNotNull(msgs);           
+         assertEquals(1, msgs.size());                  
+         Message msgRec = (Message)msgs.get(0);
+         assertTrue(msg2 == msgRec);
+         receiver1.acknowledge(msgRec, null);
+         msgs = queue1.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());  
+         
+         msgs = receiver2.getMessages();
+         assertNotNull(msgs);
+         assertEquals(3, msgs.size());
+         Message msgRec1 = (Message)msgs.get(0);
+         assertTrue(msg1 == msgRec1);
+         Message msgRec2 = (Message)msgs.get(1);
+         assertTrue(msg2 == msgRec2);
+         Message msgRec3 = (Message)msgs.get(2);
+         assertTrue(msg3 == msgRec3);
+          
+         receiver2.acknowledge(msgRec1, null);
+         receiver2.acknowledge(msgRec2, null);
+         receiver2.acknowledge(msgRec3, null);
+         msgs = queue2.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty());  
+         
+         msgs = receiver3.getMessages();
+         assertNotNull(msgs);
+         assertEquals(3, msgs.size());
+         msgRec1 = (Message)msgs.get(0);
+         assertTrue(msg1 == msgRec1);
+         msgRec2 = (Message)msgs.get(1);
+         assertTrue(msg2 == msgRec2);
+         msgRec3 = (Message)msgs.get(2);
+         assertTrue(msg3 == msgRec3);
+          
+         receiver3.acknowledge(msgRec1, null);
+         receiver3.acknowledge(msgRec2, null);
+         receiver3.acknowledge(msgRec3, null);
+         msgs = queue3.browse(null);
+         assertNotNull(msgs);
+         assertTrue(msgs.isEmpty()); 
+         
+         if (checkNoMessageData())
+         {
+            fail("data still in database");
+         }
+         
+      }
+      finally
+      {
+         if (postOffice != null)
+         {
+            postOffice.stop();
+         }
+        
+      }
+   }
+
+   // Inner classes -------------------------------------------------
+
+}
+

Copied: trunk/tests/src/org/jboss/test/messaging/core/postoffice/SimpleJChannelFactory.java (from rev 2829, trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/SimpleJChannelFactory.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/postoffice/SimpleJChannelFactory.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/core/postoffice/SimpleJChannelFactory.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -0,0 +1,97 @@
+/*
+   * 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.core.postoffice;
+
+import org.jgroups.JChannel;
+import org.jboss.messaging.core.contract.JChannelFactory;
+
+/**
+ * A JChannelFactory that will use String JChannel configurations to create JChannel instances.
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class SimpleJChannelFactory implements JChannelFactory
+{
+   // Constants ------------------------------------------------------------------------------------
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   String asyncConfig;
+   String syncConfig;
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public SimpleJChannelFactory(String syncConfig, String asyncConfig)
+   {
+      this.syncConfig = syncConfig;
+      this.asyncConfig = asyncConfig;
+   }
+
+   // JChannelFactory ------------------------------------------------------------------------------
+
+   public JChannel createControlChannel() throws Exception
+   {
+      return new JChannel(syncConfig);
+   }
+
+   public JChannel createDataChannel() throws Exception
+   {
+      return new JChannel(asyncConfig);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   public String getAsyncConfig()
+   {
+      return asyncConfig;
+   }
+
+   public void setAsyncConfig(String asyncConfig)
+   {
+      this.asyncConfig = asyncConfig;
+   }
+
+   public String getSyncConfig()
+   {
+      return syncConfig;
+   }
+
+   public void setSyncConfig(String syncConfig)
+   {
+      this.syncConfig = syncConfig;
+   }
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}

Copied: trunk/tests/src/org/jboss/test/messaging/jms/JMSTestBase.java (from rev 2829, trunk/tests/src/org/jboss/test/messaging/jms/base/JMSTestBase.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/JMSTestBase.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/jms/JMSTestBase.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -0,0 +1,118 @@
+/*
+  * 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;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.jms.client.JBossConnectionFactory;
+
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.jms.ConnectionFactory;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.naming.InitialContext;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class JMSTestBase extends MessagingTestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Static --------------------------------------------------------
+   
+   // Attributes ----------------------------------------------------
+
+   protected ConnectionFactory connFactory;
+   protected Connection conn;
+   protected Session session;
+   protected MessageProducer queueProd;
+   protected MessageConsumer queueCons;
+
+   protected Queue queue;
+   protected Topic topic;
+
+
+   // Constructors --------------------------------------------------
+
+   public JMSTestBase(String name)
+   {
+      super(name);
+   }
+
+   // Public --------------------------------------------------------
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+
+      ServerManagement.start("all");
+      
+      
+
+      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+      connFactory = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
+
+      conn = connFactory.createConnection();
+      session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      ServerManagement.undeployQueue("Queue");
+      ServerManagement.deployQueue("Queue");
+      queue = (Queue)ic.lookup("/queue/Queue");
+      
+      this.drainDestination(connFactory, queue);
+
+      ServerManagement.undeployTopic("Topic");
+      ServerManagement.deployTopic("Topic");
+      topic = (Topic)ic.lookup("/topic/Topic");
+
+      queueProd = session.createProducer(queue);
+      queueCons = session.createConsumer(queue);
+
+      conn.start();
+
+      ic.close();
+   }
+
+   public void tearDown() throws Exception
+   {
+      conn.close();
+      ServerManagement.undeployQueue("Queue");
+      ServerManagement.undeployTopic("Topic");
+      
+      super.tearDown();
+   }
+
+   // Package protected ---------------------------------------------
+   
+   // Protected -----------------------------------------------------
+   
+   // Private -------------------------------------------------------
+   
+   // Inner classes -------------------------------------------------   
+}

Deleted: trunk/tests/src/org/jboss/test/messaging/jms/base/JMSTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/base/JMSTestBase.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/base/JMSTestBase.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -1,118 +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.base;
-
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.jms.client.JBossConnectionFactory;
-
-import javax.jms.Queue;
-import javax.jms.Topic;
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.MessageProducer;
-import javax.jms.MessageConsumer;
-import javax.naming.InitialContext;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class JMSTestBase extends MessagingTestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Static --------------------------------------------------------
-   
-   // Attributes ----------------------------------------------------
-
-   protected ConnectionFactory connFactory;
-   protected Connection conn;
-   protected Session session;
-   protected MessageProducer queueProd;
-   protected MessageConsumer queueCons;
-
-   protected Queue queue;
-   protected Topic topic;
-
-
-   // Constructors --------------------------------------------------
-
-   public JMSTestBase(String name)
-   {
-      super(name);
-   }
-
-   // Public --------------------------------------------------------
-
-   public void setUp() throws Exception
-   {
-      super.setUp();
-
-      ServerManagement.start("all");
-      
-      
-
-      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-      connFactory = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
-
-      conn = connFactory.createConnection();
-      session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      ServerManagement.undeployQueue("Queue");
-      ServerManagement.deployQueue("Queue");
-      queue = (Queue)ic.lookup("/queue/Queue");
-      
-      this.drainDestination(connFactory, queue);
-
-      ServerManagement.undeployTopic("Topic");
-      ServerManagement.deployTopic("Topic");
-      topic = (Topic)ic.lookup("/topic/Topic");
-
-      queueProd = session.createProducer(queue);
-      queueCons = session.createConsumer(queue);
-
-      conn.start();
-
-      ic.close();
-   }
-
-   public void tearDown() throws Exception
-   {
-      conn.close();
-      ServerManagement.undeployQueue("Queue");
-      ServerManagement.undeployTopic("Topic");
-      
-      super.tearDown();
-   }
-
-   // Package protected ---------------------------------------------
-   
-   // Protected -----------------------------------------------------
-   
-   // Private -------------------------------------------------------
-   
-   // Inner classes -------------------------------------------------   
-}

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -32,7 +32,6 @@
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
 
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 
 /**

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -42,7 +42,6 @@
 import org.jboss.jms.client.state.SessionState;
 import org.jboss.profiler.jvmti.InventoryDataPoint;
 import org.jboss.profiler.jvmti.JVMTIInterface;
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 
 /**

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -22,7 +22,6 @@
 
 package org.jboss.test.messaging.jms.clustering;
 
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.jms.client.JBossConnectionFactory;
 import org.jboss.jms.client.state.ConnectionState;

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -27,7 +27,6 @@
 import org.jboss.jms.client.JBossConnection;
 import org.jboss.jms.client.JBossConnectionFactory;
 import org.jboss.jms.exception.MessagingNetworkFailureException;
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
 

Copied: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java (from rev 2829, trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -0,0 +1,361 @@
+/*
+   * 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.clustering;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.jms.client.FailoverEvent;
+import org.jboss.jms.client.FailoverListener;
+import org.jboss.jms.client.JBossConnection;
+import org.jboss.jms.client.delegate.DelegateSupport;
+import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
+
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.org">Tim Fox</a>
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ * $Id$
+ */
+public class ClusteringTestBase extends MessagingTestCase
+{
+   // Constants ------------------------------------------------------------------------------------
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   protected int nodeCount;
+   protected String config = "all";
+
+   protected Context[] ic;
+   protected Queue queue[];
+   protected Topic topic[];
+   
+   protected ServiceAttributeOverrides overrides;
+
+   // No need to have multiple conncetion factories since a clustered connection factory will create
+   // connections in a round robin fashion on different servers.
+
+   protected ConnectionFactory cf;
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public ClusteringTestBase(String name)
+   {
+      super(name);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      if (nodeCount < 1)
+      {
+         throw new Exception("Node count not defined! Initalize nodeCount in the test's setUp()");
+      }
+
+      ic = new Context[nodeCount];
+      queue = new Queue[nodeCount];
+      topic = new Topic[nodeCount];
+
+      for (int i = 0; i < nodeCount; i++)
+      {
+         // make sure all servers are created and started; make sure that database is zapped
+         // ONLY for the first server, the others rely on values they expect to find in shared
+         // tables; don't clear the database for those.
+         ServerManagement.start(i, config, overrides, i == 0);
+
+         ServerManagement.deployQueue("testDistributedQueue", i);
+         ServerManagement.deployTopic("testDistributedTopic", i);
+
+         ic[i] = new InitialContext(ServerManagement.getJNDIEnvironment(i));
+         queue[i] = (Queue)ic[i].lookup("queue/testDistributedQueue");
+         topic[i] = (Topic)ic[i].lookup("topic/testDistributedTopic");
+      }
+
+      // We only need to lookup one connection factory since it will be clustered so we will
+      // actually create connections on different servers (round robin).
+      cf = (ConnectionFactory)ic[0].lookup("/ClusteredConnectionFactory");
+
+      drainQueues();
+   }
+
+   protected void tearDown() throws Exception
+   {
+   	log.info("tearing down");
+      for(int i = 0; i < nodeCount; i++)
+      {
+         if (ServerManagement.isStarted(i))
+         {
+         	log.info("stopping server " + i);
+            ServerManagement.log(ServerManagement.INFO, "Undeploying Server " + i, i);
+            ServerManagement.undeployQueue("testDistributedQueue", i);
+            ServerManagement.undeployTopic("testDistributedTopic", i);
+            ServerManagement.stop(i);
+         }
+
+         ic[i].close();
+      }
+
+      super.tearDown();
+   }
+
+   protected String getLocatorURL(Connection conn)
+   {
+      return getConnectionState(conn).getRemotingConnection().
+         getRemotingClient().getInvoker().getLocator().getLocatorURI();
+   }
+
+   protected int getServerId(Connection conn)
+   {
+      return getConnectionState(conn).getServerID();
+   }
+
+   protected int getObjectId(Connection conn)
+   {
+      return ((DelegateSupport) ((JBossConnection) conn).
+         getDelegate()).getID();
+   }
+
+   protected ConnectionState getConnectionState(Connection conn)
+   {
+      return (ConnectionState) (((DelegateSupport) ((JBossConnection) conn).
+         getDelegate()).getState());
+   }
+
+   protected Connection createConnectionOnServer(ConnectionFactory factory, int serverId)
+      throws Exception
+   {
+      int count=0;
+
+      while (true)
+      {
+         if (count++>10)
+            return null;
+
+         Connection connection = factory.createConnection();
+
+         if (getServerId(connection) == serverId)
+         {
+            return connection;
+         }
+         else
+         {
+            connection.close();
+         }
+      }
+   }
+
+
+   protected void waitForFailoverComplete(int serverID, Connection conn1)
+      throws Exception
+   {
+
+      assertEquals(serverID, ((JBossConnection)conn1).getServerID());
+
+      // register a failover listener
+      SimpleFailoverListener failoverListener = new SimpleFailoverListener();
+      ((JBossConnection)conn1).registerFailoverListener(failoverListener);
+
+      log.debug("killing node " + serverID + " ....");
+
+      ServerManagement.kill(serverID);
+
+      log.info("########");
+      log.info("######## KILLED NODE " + serverID);
+      log.info("########");
+
+      // wait for the client-side failover to complete
+
+      while (true)
+      {
+      	FailoverEvent event = failoverListener.getEvent(120000);
+      	if (event != null && FailoverEvent.FAILOVER_COMPLETED == event.getType())
+      	{
+      		break;
+      	}
+      	if (event == null)
+      	{
+      		fail("Did not get expected FAILOVER_COMPLETED event");
+      	}
+      }
+
+      // failover complete
+      log.info("failover completed");
+   }
+
+
+
+   /**
+    * Lookup for the connection with the right serverID. I'm using this method to find the proper
+    * serverId so I won't relay on loadBalancing policies on testcases.
+    */
+   protected Connection getConnection(Connection[] conn, int serverId) throws Exception
+   {
+      for(int i = 0; i < conn.length; i++)
+      {
+         ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
+            getDelegate()).getState());
+
+         if (state.getServerID() == serverId)
+         {
+            return conn[i];
+         }
+      }
+
+      return null;
+   }
+
+   protected void checkConnectionsDifferentServers(Connection[] conn) throws Exception
+   {
+      int[] serverID = new int[conn.length];
+      for(int i = 0; i < conn.length; i++)
+      {
+         ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
+            getDelegate()).getState());
+         serverID[i] = state.getServerID();
+      }
+
+      for(int i = 0; i < nodeCount; i++)
+      {
+         for(int j = 0; j < nodeCount; j++)
+         {
+            if (i == j)
+            {
+               continue;
+            }
+
+            if (serverID[i] == serverID[j])
+            {
+               fail("Connections " + i + " and " + j +
+                  " are pointing to the same physical node (" + serverID[i] + ")");
+            }
+         }
+      }
+   }
+
+   // Private --------------------------------------------------------------------------------------
+
+   private void drainQueues() throws Exception
+   {
+      Connection[] conn = new Connection[nodeCount];
+
+      try
+      {
+         // TODO This is a dangerous hack, relying on an arbitrary distribution algorithm
+         // (round-robin in this case). If we want a connection to a specific node, we should be
+         // able to look up something like "/ClusteredConnectionFactory0"
+         
+         for(int i = 0; i < nodeCount; i++)
+         {
+            conn[i] = cf.createConnection();
+         }
+
+         // Safety check, making sure we get connections to distinct nodes
+
+         checkConnectionsDifferentServers(conn);
+
+         for(int i = 0; i < nodeCount; i++)
+         {
+            Session s = conn[i].createSession(false, Session.AUTO_ACKNOWLEDGE);
+            MessageConsumer c = s.createConsumer(queue[i]);
+            conn[i].start();
+
+            Message msg = null;
+            do
+            {
+               msg = c.receive(1000);
+               if (msg != null)
+               {
+                  log.info("Drained message " + msg + " on node " + i);
+               }
+            }
+            while (msg != null);
+         }
+      }
+      finally
+      {
+         for(int i = 0; i < nodeCount; i++)
+         {
+            if (conn[i] != null)
+            {
+               conn[i].close();
+            }
+         }
+      }
+   }
+
+   // Inner classes --------------------------------------------------------------------------------
+   
+   protected class SimpleFailoverListener implements FailoverListener
+   {
+      private LinkedQueue buffer;
+
+      public SimpleFailoverListener()
+      {
+         buffer = new LinkedQueue();
+      }
+
+      public void failoverEventOccured(FailoverEvent event)
+      {
+         try
+         {
+            buffer.put(event);
+         }
+         catch(InterruptedException e)
+         {
+            throw new RuntimeException("Putting thread interrupted while trying to add event " +
+               "to buffer", e);
+         }
+      }
+
+      /**
+       * Blocks until a FailoverEvent is available or timeout occurs, in which case returns null.
+       */
+      public FailoverEvent getEvent(long timeout) throws InterruptedException
+      {
+         return (FailoverEvent)buffer.poll(timeout);
+      }
+   }
+
+}

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -18,7 +18,6 @@
 
 import org.jboss.jms.client.FailoverEvent;
 import org.jboss.jms.client.JBossConnection;
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 
 import EDU.oswego.cs.dl.util.concurrent.Latch;

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -32,7 +32,6 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 
 /**
  * 

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -30,7 +30,6 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 
 /**
  * 

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -26,7 +26,6 @@
 import org.jboss.jms.client.remoting.JMSRemotingConnection;
 import org.jboss.jms.client.state.ConnectionState;
 import org.jboss.jms.exception.MessagingTransactionRolledBackException;
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
 

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -42,7 +42,6 @@
 import org.jboss.jms.client.state.ConsumerState;
 import org.jboss.jms.client.state.SessionState;
 import org.jboss.jms.message.MessageProxy;
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 
 /**

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -6,7 +6,6 @@
  */
 package org.jboss.test.messaging.jms.clustering;
 
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.jms.client.JBossConnection;
 import org.jboss.jms.client.delegate.ClientConnectionDelegate;

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/MergeQueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/MergeQueueTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/MergeQueueTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -18,7 +18,6 @@
 import javax.jms.TextMessage;
 
 import org.jboss.jms.client.JBossConnection;
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 
 /**

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -35,7 +35,6 @@
 import org.jboss.jms.client.JBossConnection;
 import org.jboss.jms.client.delegate.ClientConnectionDelegate;
 import org.jboss.logging.Logger;
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 
 /**

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -34,7 +34,6 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 
 import EDU.oswego.cs.dl.util.concurrent.Latch;

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -22,7 +22,6 @@
 
 package org.jboss.test.messaging.jms.clustering;
 
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.jms.client.JBossConnectionFactory;
 import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
 

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -30,7 +30,6 @@
 import javax.jms.TextMessage;
 import javax.management.ObjectName;
 
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
 
 /**

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/RecoverDeliveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/RecoverDeliveryTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/RecoverDeliveryTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -30,7 +30,6 @@
 import org.jboss.jms.delegate.SessionDelegate;
 import org.jboss.jms.message.MessageProxy;
 import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import javax.jms.Session;
 import javax.jms.MessageProducer;
 import javax.jms.MessageConsumer;

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -29,7 +29,6 @@
 import javax.jms.TextMessage;
 import javax.jms.Topic;
 
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 
 /**
  * A test for temporary destinations in a clustered enviroment.

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -24,7 +24,6 @@
 
 import org.jboss.jms.client.FailoverEvent;
 import org.jboss.jms.client.JBossConnection;
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
 import org.jboss.test.messaging.tools.jmx.ServiceContainer;

Deleted: trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -1,361 +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.clustering.base;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.jboss.jms.client.FailoverEvent;
-import org.jboss.jms.client.FailoverListener;
-import org.jboss.jms.client.JBossConnection;
-import org.jboss.jms.client.delegate.DelegateSupport;
-import org.jboss.jms.client.state.ConnectionState;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
-
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.org">Tim Fox</a>
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- * $Id$
- */
-public class ClusteringTestBase extends MessagingTestCase
-{
-   // Constants ------------------------------------------------------------------------------------
-
-   // Static ---------------------------------------------------------------------------------------
-
-   // Attributes -----------------------------------------------------------------------------------
-
-   protected int nodeCount;
-   protected String config = "all";
-
-   protected Context[] ic;
-   protected Queue queue[];
-   protected Topic topic[];
-   
-   protected ServiceAttributeOverrides overrides;
-
-   // No need to have multiple conncetion factories since a clustered connection factory will create
-   // connections in a round robin fashion on different servers.
-
-   protected ConnectionFactory cf;
-
-   // Constructors ---------------------------------------------------------------------------------
-
-   public ClusteringTestBase(String name)
-   {
-      super(name);
-   }
-
-   // Public ---------------------------------------------------------------------------------------
-
-   // Package protected ----------------------------------------------------------------------------
-
-   // Protected ------------------------------------------------------------------------------------
-
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-
-      if (nodeCount < 1)
-      {
-         throw new Exception("Node count not defined! Initalize nodeCount in the test's setUp()");
-      }
-
-      ic = new Context[nodeCount];
-      queue = new Queue[nodeCount];
-      topic = new Topic[nodeCount];
-
-      for (int i = 0; i < nodeCount; i++)
-      {
-         // make sure all servers are created and started; make sure that database is zapped
-         // ONLY for the first server, the others rely on values they expect to find in shared
-         // tables; don't clear the database for those.
-         ServerManagement.start(i, config, overrides, i == 0);
-
-         ServerManagement.deployQueue("testDistributedQueue", i);
-         ServerManagement.deployTopic("testDistributedTopic", i);
-
-         ic[i] = new InitialContext(ServerManagement.getJNDIEnvironment(i));
-         queue[i] = (Queue)ic[i].lookup("queue/testDistributedQueue");
-         topic[i] = (Topic)ic[i].lookup("topic/testDistributedTopic");
-      }
-
-      // We only need to lookup one connection factory since it will be clustered so we will
-      // actually create connections on different servers (round robin).
-      cf = (ConnectionFactory)ic[0].lookup("/ClusteredConnectionFactory");
-
-      drainQueues();
-   }
-
-   protected void tearDown() throws Exception
-   {
-   	log.info("tearing down");
-      for(int i = 0; i < nodeCount; i++)
-      {
-         if (ServerManagement.isStarted(i))
-         {
-         	log.info("stopping server " + i);
-            ServerManagement.log(ServerManagement.INFO, "Undeploying Server " + i, i);
-            ServerManagement.undeployQueue("testDistributedQueue", i);
-            ServerManagement.undeployTopic("testDistributedTopic", i);
-            ServerManagement.stop(i);
-         }
-
-         ic[i].close();
-      }
-
-      super.tearDown();
-   }
-
-   protected String getLocatorURL(Connection conn)
-   {
-      return getConnectionState(conn).getRemotingConnection().
-         getRemotingClient().getInvoker().getLocator().getLocatorURI();
-   }
-
-   protected int getServerId(Connection conn)
-   {
-      return getConnectionState(conn).getServerID();
-   }
-
-   protected int getObjectId(Connection conn)
-   {
-      return ((DelegateSupport) ((JBossConnection) conn).
-         getDelegate()).getID();
-   }
-
-   protected ConnectionState getConnectionState(Connection conn)
-   {
-      return (ConnectionState) (((DelegateSupport) ((JBossConnection) conn).
-         getDelegate()).getState());
-   }
-
-   protected Connection createConnectionOnServer(ConnectionFactory factory, int serverId)
-      throws Exception
-   {
-      int count=0;
-
-      while (true)
-      {
-         if (count++>10)
-            return null;
-
-         Connection connection = factory.createConnection();
-
-         if (getServerId(connection) == serverId)
-         {
-            return connection;
-         }
-         else
-         {
-            connection.close();
-         }
-      }
-   }
-
-
-   protected void waitForFailoverComplete(int serverID, Connection conn1)
-      throws Exception
-   {
-
-      assertEquals(serverID, ((JBossConnection)conn1).getServerID());
-
-      // register a failover listener
-      SimpleFailoverListener failoverListener = new SimpleFailoverListener();
-      ((JBossConnection)conn1).registerFailoverListener(failoverListener);
-
-      log.debug("killing node " + serverID + " ....");
-
-      ServerManagement.kill(serverID);
-
-      log.info("########");
-      log.info("######## KILLED NODE " + serverID);
-      log.info("########");
-
-      // wait for the client-side failover to complete
-
-      while (true)
-      {
-      	FailoverEvent event = failoverListener.getEvent(120000);
-      	if (event != null && FailoverEvent.FAILOVER_COMPLETED == event.getType())
-      	{
-      		break;
-      	}
-      	if (event == null)
-      	{
-      		fail("Did not get expected FAILOVER_COMPLETED event");
-      	}
-      }
-
-      // failover complete
-      log.info("failover completed");
-   }
-
-
-
-   /**
-    * Lookup for the connection with the right serverID. I'm using this method to find the proper
-    * serverId so I won't relay on loadBalancing policies on testcases.
-    */
-   protected Connection getConnection(Connection[] conn, int serverId) throws Exception
-   {
-      for(int i = 0; i < conn.length; i++)
-      {
-         ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
-            getDelegate()).getState());
-
-         if (state.getServerID() == serverId)
-         {
-            return conn[i];
-         }
-      }
-
-      return null;
-   }
-
-   protected void checkConnectionsDifferentServers(Connection[] conn) throws Exception
-   {
-      int[] serverID = new int[conn.length];
-      for(int i = 0; i < conn.length; i++)
-      {
-         ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
-            getDelegate()).getState());
-         serverID[i] = state.getServerID();
-      }
-
-      for(int i = 0; i < nodeCount; i++)
-      {
-         for(int j = 0; j < nodeCount; j++)
-         {
-            if (i == j)
-            {
-               continue;
-            }
-
-            if (serverID[i] == serverID[j])
-            {
-               fail("Connections " + i + " and " + j +
-                  " are pointing to the same physical node (" + serverID[i] + ")");
-            }
-         }
-      }
-   }
-
-   // Private --------------------------------------------------------------------------------------
-
-   private void drainQueues() throws Exception
-   {
-      Connection[] conn = new Connection[nodeCount];
-
-      try
-      {
-         // TODO This is a dangerous hack, relying on an arbitrary distribution algorithm
-         // (round-robin in this case). If we want a connection to a specific node, we should be
-         // able to look up something like "/ClusteredConnectionFactory0"
-         
-         for(int i = 0; i < nodeCount; i++)
-         {
-            conn[i] = cf.createConnection();
-         }
-
-         // Safety check, making sure we get connections to distinct nodes
-
-         checkConnectionsDifferentServers(conn);
-
-         for(int i = 0; i < nodeCount; i++)
-         {
-            Session s = conn[i].createSession(false, Session.AUTO_ACKNOWLEDGE);
-            MessageConsumer c = s.createConsumer(queue[i]);
-            conn[i].start();
-
-            Message msg = null;
-            do
-            {
-               msg = c.receive(1000);
-               if (msg != null)
-               {
-                  log.info("Drained message " + msg + " on node " + i);
-               }
-            }
-            while (msg != null);
-         }
-      }
-      finally
-      {
-         for(int i = 0; i < nodeCount; i++)
-         {
-            if (conn[i] != null)
-            {
-               conn[i].close();
-            }
-         }
-      }
-   }
-
-   // Inner classes --------------------------------------------------------------------------------
-   
-   protected class SimpleFailoverListener implements FailoverListener
-   {
-      private LinkedQueue buffer;
-
-      public SimpleFailoverListener()
-      {
-         buffer = new LinkedQueue();
-      }
-
-      public void failoverEventOccured(FailoverEvent event)
-      {
-         try
-         {
-            buffer.put(event);
-         }
-         catch(InterruptedException e)
-         {
-            throw new RuntimeException("Putting thread interrupted while trying to add event " +
-               "to buffer", e);
-         }
-      }
-
-      /**
-       * Blocks until a FailoverEvent is available or timeout occurs, in which case returns null.
-       */
-      public FailoverEvent getEvent(long timeout) throws InterruptedException
-      {
-         return (FailoverEvent)buffer.poll(timeout);
-      }
-   }
-
-}

Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/BytesMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/BytesMessageTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/BytesMessageTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -21,7 +21,6 @@
   */
 package org.jboss.test.messaging.jms.message;
 
-import org.jboss.test.messaging.jms.message.base.MessageTestBase;
 
 import javax.jms.BytesMessage;
 import javax.jms.JMSException;

Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/MapMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/MapMessageTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/MapMessageTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -21,7 +21,6 @@
   */
 package org.jboss.test.messaging.jms.message;
 
-import org.jboss.test.messaging.jms.message.base.MessageTestBase;
 
 import javax.jms.MapMessage;
 import javax.jms.JMSException;

Copied: trunk/tests/src/org/jboss/test/messaging/jms/message/MessageTestBase.java (from rev 2829, trunk/tests/src/org/jboss/test/messaging/jms/message/base/MessageTestBase.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/MessageTestBase.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/MessageTestBase.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -0,0 +1,143 @@
+/*
+  * 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.message;
+
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+
+import org.jboss.test.messaging.jms.JMSTestBase;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class MessageTestBase extends JMSTestBase
+{
+   // Constants -----------------------------------------------------
+
+   // Static --------------------------------------------------------
+   
+   // Attributes ----------------------------------------------------
+
+   protected Message message;
+
+   // Constructors --------------------------------------------------
+
+   public MessageTestBase(String name)
+   {
+      super(name);
+   }
+
+   // Public --------------------------------------------------------
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+   }
+
+   public void tearDown() throws Exception
+   {
+      super.tearDown();
+   }
+
+   public void testNonPersistentSend() throws Exception
+   {
+      prepareMessage(message);
+
+      queueProd.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      queueProd.send(message);
+      
+      log.debug("Message sent");
+
+      Message r = queueCons.receive();
+      
+      log.debug("Message received");
+
+      assertEquals(DeliveryMode.NON_PERSISTENT, r.getJMSDeliveryMode());
+
+      assertEquivalent(r, DeliveryMode.NON_PERSISTENT);
+   }
+
+   public void testPersistentSend() throws Exception
+   {
+      prepareMessage(message);
+
+      queueProd.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+      // make sure the message is serialized to and from the database
+      //SoftMessageReference.keepSoftReference = false;
+
+      queueProd.send(message);
+
+      Message r = queueCons.receive();
+
+      assertEquals(DeliveryMode.PERSISTENT, r.getJMSDeliveryMode());
+
+      assertEquivalent(r, DeliveryMode.PERSISTENT);
+   }
+
+   // Package protected ---------------------------------------------
+   
+   // Protected -----------------------------------------------------
+
+   protected void prepareMessage(Message m) throws JMSException
+   {
+      m.setBooleanProperty("booleanProperty", true);
+      m.setByteProperty("byteProperty", (byte)3);
+      m.setDoubleProperty("doubleProperty", 4.0);
+      m.setFloatProperty("floatProperty", 5.0f);
+      m.setIntProperty("intProperty", 6);
+      m.setLongProperty("longProperty", 7);
+      m.setShortProperty("shortProperty", (short)8);
+      m.setStringProperty("stringProperty", "this is a String property");
+
+      m.setJMSCorrelationID("this is the correlation ID");
+      m.setJMSReplyTo(topic);
+      m.setJMSType("someArbitraryType");
+   }
+
+   protected void assertEquivalent(Message m, int mode) throws JMSException
+   {
+      assertEquals(true, m.getBooleanProperty("booleanProperty"));
+      assertEquals((byte)3, m.getByteProperty("byteProperty"));
+      assertEquals(new Double(4.0), new Double(m.getDoubleProperty("doubleProperty")));
+      assertEquals(new Float(5.0f), new Float(m.getFloatProperty("floatProperty")));
+      assertEquals(6, m.getIntProperty("intProperty"));
+      assertEquals(7, m.getLongProperty("longProperty"));
+      assertEquals((short)8, m.getShortProperty("shortProperty"));
+      assertEquals("this is a String property", m.getStringProperty("stringProperty"));
+
+      assertEquals("this is the correlation ID", m.getJMSCorrelationID());
+      assertEquals(topic, m.getJMSReplyTo());
+      assertEquals("someArbitraryType", m.getJMSType());
+      assertEquals(queue, m.getJMSDestination());
+      assertFalse(m.getJMSRedelivered());
+      assertEquals(mode, m.getJMSDeliveryMode());
+   }
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -26,7 +26,6 @@
 import javax.jms.ObjectMessage;
 import javax.jms.DeliveryMode;
 
-import org.jboss.test.messaging.jms.message.base.MessageTestBase;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.io.File;

Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/StreamMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/StreamMessageTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/StreamMessageTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -21,7 +21,6 @@
   */
 package org.jboss.test.messaging.jms.message;
 
-import org.jboss.test.messaging.jms.message.base.MessageTestBase;
 
 import javax.jms.JMSException;
 import javax.jms.Message;

Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/TextMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/TextMessageTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/TextMessageTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -21,7 +21,6 @@
   */
 package org.jboss.test.messaging.jms.message;
 
-import org.jboss.test.messaging.jms.message.base.MessageTestBase;
 
 import javax.jms.TextMessage;
 import javax.jms.JMSException;

Deleted: trunk/tests/src/org/jboss/test/messaging/jms/message/base/MessageTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/base/MessageTestBase.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/base/MessageTestBase.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -1,143 +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.message.base;
-
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-
-import org.jboss.test.messaging.jms.base.JMSTestBase;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class MessageTestBase extends JMSTestBase
-{
-   // Constants -----------------------------------------------------
-
-   // Static --------------------------------------------------------
-   
-   // Attributes ----------------------------------------------------
-
-   protected Message message;
-
-   // Constructors --------------------------------------------------
-
-   public MessageTestBase(String name)
-   {
-      super(name);
-   }
-
-   // Public --------------------------------------------------------
-
-   public void setUp() throws Exception
-   {
-      super.setUp();
-   }
-
-   public void tearDown() throws Exception
-   {
-      super.tearDown();
-   }
-
-   public void testNonPersistentSend() throws Exception
-   {
-      prepareMessage(message);
-
-      queueProd.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      queueProd.send(message);
-      
-      log.debug("Message sent");
-
-      Message r = queueCons.receive();
-      
-      log.debug("Message received");
-
-      assertEquals(DeliveryMode.NON_PERSISTENT, r.getJMSDeliveryMode());
-
-      assertEquivalent(r, DeliveryMode.NON_PERSISTENT);
-   }
-
-   public void testPersistentSend() throws Exception
-   {
-      prepareMessage(message);
-
-      queueProd.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-      // make sure the message is serialized to and from the database
-      //SoftMessageReference.keepSoftReference = false;
-
-      queueProd.send(message);
-
-      Message r = queueCons.receive();
-
-      assertEquals(DeliveryMode.PERSISTENT, r.getJMSDeliveryMode());
-
-      assertEquivalent(r, DeliveryMode.PERSISTENT);
-   }
-
-   // Package protected ---------------------------------------------
-   
-   // Protected -----------------------------------------------------
-
-   protected void prepareMessage(Message m) throws JMSException
-   {
-      m.setBooleanProperty("booleanProperty", true);
-      m.setByteProperty("byteProperty", (byte)3);
-      m.setDoubleProperty("doubleProperty", 4.0);
-      m.setFloatProperty("floatProperty", 5.0f);
-      m.setIntProperty("intProperty", 6);
-      m.setLongProperty("longProperty", 7);
-      m.setShortProperty("shortProperty", (short)8);
-      m.setStringProperty("stringProperty", "this is a String property");
-
-      m.setJMSCorrelationID("this is the correlation ID");
-      m.setJMSReplyTo(topic);
-      m.setJMSType("someArbitraryType");
-   }
-
-   protected void assertEquivalent(Message m, int mode) throws JMSException
-   {
-      assertEquals(true, m.getBooleanProperty("booleanProperty"));
-      assertEquals((byte)3, m.getByteProperty("byteProperty"));
-      assertEquals(new Double(4.0), new Double(m.getDoubleProperty("doubleProperty")));
-      assertEquals(new Float(5.0f), new Float(m.getFloatProperty("floatProperty")));
-      assertEquals(6, m.getIntProperty("intProperty"));
-      assertEquals(7, m.getLongProperty("longProperty"));
-      assertEquals((short)8, m.getShortProperty("shortProperty"));
-      assertEquals("this is a String property", m.getStringProperty("stringProperty"));
-
-      assertEquals("this is the correlation ID", m.getJMSCorrelationID());
-      assertEquals(topic, m.getJMSReplyTo());
-      assertEquals("someArbitraryType", m.getJMSType());
-      assertEquals(queue, m.getJMSDestination());
-      assertFalse(m.getJMSRedelivered());
-      assertEquals(mode, m.getJMSDeliveryMode());
-   }
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/foreign/ForeignMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/foreign/ForeignMessageTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/foreign/ForeignMessageTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -23,8 +23,8 @@
 
 import javax.jms.Message;
 
+import org.jboss.test.messaging.jms.message.MessageTestBase;
 import org.jboss.test.messaging.jms.message.SimpleJMSMessage;
-import org.jboss.test.messaging.jms.message.base.MessageTestBase;
 
 
 /**

Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/ConnectionConsumerStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/ConnectionConsumerStressTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/ConnectionConsumerStressTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -26,7 +26,6 @@
 import javax.jms.MessageProducer;
 import javax.jms.Session;
 
-import org.jboss.test.messaging.jms.stress.base.StressTestBase;
 
 /**
  * 

Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/QueueStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/QueueStressTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/QueueStressTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -29,7 +29,6 @@
 import javax.jms.XAConnection;
 import javax.jms.XASession;
 
-import org.jboss.test.messaging.jms.stress.base.StressTestBase;
 
 /**
  * 

Copied: trunk/tests/src/org/jboss/test/messaging/jms/stress/StressTestBase.java (from rev 2829, trunk/tests/src/org/jboss/test/messaging/jms/stress/base/StressTestBase.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/StressTestBase.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/StressTestBase.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -0,0 +1,151 @@
+/*
+  * 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.stress;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Topic;
+import javax.naming.InitialContext;
+
+import org.jboss.messaging.util.LockMap;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+
+/**
+ * 
+ * Base class for stress tests
+ * 
+ * @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+*/
+public class StressTestBase extends MessagingTestCase
+{
+   protected static final int NUM_PERSISTENT_MESSAGES = 4000;
+   
+   protected static final int NUM_NON_PERSISTENT_MESSAGES = 6000;
+   
+   protected static final int NUM_PERSISTENT_PRESEND = 2000;
+   
+   protected static final int NUM_NON_PERSISTENT_PRESEND = 3000;
+   
+   protected ConnectionFactory cf;
+
+   protected Destination topic;
+
+   protected Destination queue1;
+   protected Destination queue2;
+   protected Destination queue3;
+   protected Destination queue4;
+   
+   protected Topic topic1;
+   protected Topic topic2;
+   protected Topic topic3;
+   protected Topic topic4;
+
+   public StressTestBase(String name)
+   {
+      super(name);
+   }
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      
+      ServerManagement.start("all");            
+      
+      //We test with small values for paging params to really stress it
+      
+      final int fullSize = 1000;
+      
+      final int pageSize = 100;
+      
+      final int downCacheSize = 100;
+      
+      ServerManagement.deployQueue("Queue1", fullSize, pageSize, downCacheSize);
+      ServerManagement.deployQueue("Queue2", fullSize, pageSize, downCacheSize);
+      ServerManagement.deployQueue("Queue3", fullSize, pageSize, downCacheSize);
+      ServerManagement.deployQueue("Queue4", fullSize, pageSize, downCacheSize);
+      
+      ServerManagement.deployTopic("Topic1", fullSize, pageSize, downCacheSize);
+      ServerManagement.deployTopic("Topic2", fullSize, pageSize, downCacheSize);
+      ServerManagement.deployTopic("Topic3", fullSize, pageSize, downCacheSize);
+      ServerManagement.deployTopic("Topic4", fullSize, pageSize, downCacheSize);
+            
+      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+      cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+      
+      queue1 = (Destination)ic.lookup("/queue/Queue1");
+      queue2 = (Destination)ic.lookup("/queue/Queue2");
+      queue3 = (Destination)ic.lookup("/queue/Queue3");
+      queue4 = (Destination)ic.lookup("/queue/Queue4");
+
+      topic1 = (Topic)ic.lookup("/topic/Topic1");
+      topic2 = (Topic)ic.lookup("/topic/Topic2");
+      topic3 = (Topic)ic.lookup("/topic/Topic3");
+      topic4 = (Topic)ic.lookup("/topic/Topic4");            
+   }
+
+   public void tearDown() throws Exception
+   {
+      assertEquals(0, LockMap.instance.getSize());
+            
+      ServerManagement.undeployQueue("Queue1");
+      ServerManagement.undeployQueue("Queue2");
+      ServerManagement.undeployQueue("Queue3");
+      ServerManagement.undeployQueue("Queue4");
+
+      ServerManagement.undeployTopic("Topic1");
+      ServerManagement.undeployTopic("Topic2");
+      ServerManagement.undeployTopic("Topic3");
+      ServerManagement.undeployTopic("Topic4");
+      
+      ServerManagement.stop();
+      
+      super.tearDown();            
+   }
+   
+   protected void runRunners(Runner[] runners) throws Exception
+   {
+      Thread[] threads = new Thread[runners.length];
+      for (int i = 0; i < runners.length; i++)
+      {
+         threads[i] = new Thread(runners[i]);
+         threads[i].start();
+      }
+      
+      for (int i = 0; i < runners.length; i++)
+      {
+         threads[i].join();
+      }
+      
+      for (int i = 0; i < runners.length; i++)
+      {
+         if (runners[i].isFailed())
+         {
+            fail("Runner " + i + " failed");
+            log.error("runner failed");
+         }
+      } 
+   }
+}

Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/TopicStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/TopicStressTest.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/TopicStressTest.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -21,7 +21,6 @@
   */
 package org.jboss.test.messaging.jms.stress;
 
-import org.jboss.test.messaging.jms.stress.base.StressTestBase;
 
 import javax.jms.Connection;
 import javax.jms.DeliveryMode;

Deleted: trunk/tests/src/org/jboss/test/messaging/jms/stress/base/StressTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/base/StressTestBase.java	2007-07-03 17:08:00 UTC (rev 2829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/base/StressTestBase.java	2007-07-03 17:35:17 UTC (rev 2830)
@@ -1,152 +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.stress.base;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.Topic;
-import javax.naming.InitialContext;
-
-import org.jboss.messaging.util.LockMap;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.jms.stress.Runner;
-import org.jboss.test.messaging.tools.ServerManagement;
-
-/**
- * 
- * Base class for stress tests
- * 
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
-*/
-public class StressTestBase extends MessagingTestCase
-{
-   protected static final int NUM_PERSISTENT_MESSAGES = 4000;
-   
-   protected static final int NUM_NON_PERSISTENT_MESSAGES = 6000;
-   
-   protected static final int NUM_PERSISTENT_PRESEND = 2000;
-   
-   protected static final int NUM_NON_PERSISTENT_PRESEND = 3000;
-   
-   protected ConnectionFactory cf;
-
-   protected Destination topic;
-
-   protected Destination queue1;
-   protected Destination queue2;
-   protected Destination queue3;
-   protected Destination queue4;
-   
-   protected Topic topic1;
-   protected Topic topic2;
-   protected Topic topic3;
-   protected Topic topic4;
-
-   public StressTestBase(String name)
-   {
-      super(name);
-   }
-
-   public void setUp() throws Exception
-   {
-      super.setUp();
-      
-      ServerManagement.start("all");            
-      
-      //We test with small values for paging params to really stress it
-      
-      final int fullSize = 1000;
-      
-      final int pageSize = 100;
-      
-      final int downCacheSize = 100;
-      
-      ServerManagement.deployQueue("Queue1", fullSize, pageSize, downCacheSize);
-      ServerManagement.deployQueue("Queue2", fullSize, pageSize, downCacheSize);
-      ServerManagement.deployQueue("Queue3", fullSize, pageSize, downCacheSize);
-      ServerManagement.deployQueue("Queue4", fullSize, pageSize, downCacheSize);
-      
-      ServerManagement.deployTopic("Topic1", fullSize, pageSize, downCacheSize);
-      ServerManagement.deployTopic("Topic2", fullSize, pageSize, downCacheSize);
-      ServerManagement.deployTopic("Topic3", fullSize, pageSize, downCacheSize);
-      ServerManagement.deployTopic("Topic4", fullSize, pageSize, downCacheSize);
-            
-      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-      cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-      
-      queue1 = (Destination)ic.lookup("/queue/Queue1");
-      queue2 = (Destination)ic.lookup("/queue/Queue2");
-      queue3 = (Destination)ic.lookup("/queue/Queue3");
-      queue4 = (Destination)ic.lookup("/queue/Queue4");
-
-      topic1 = (Topic)ic.lookup("/topic/Topic1");
-      topic2 = (Topic)ic.lookup("/topic/Topic2");
-      topic3 = (Topic)ic.lookup("/topic/Topic3");
-      topic4 = (Topic)ic.lookup("/topic/Topic4");            
-   }
-
-   public void tearDown() throws Exception
-   {
-      assertEquals(0, LockMap.instance.getSize());
-            
-      ServerManagement.undeployQueue("Queue1");
-      ServerManagement.undeployQueue("Queue2");
-      ServerManagement.undeployQueue("Queue3");
-      ServerManagement.undeployQueue("Queue4");
-
-      ServerManagement.undeployTopic("Topic1");
-      ServerManagement.undeployTopic("Topic2");
-      ServerManagement.undeployTopic("Topic3");
-      ServerManagement.undeployTopic("Topic4");
-      
-      ServerManagement.stop();
-      
-      super.tearDown();            
-   }
-   
-   protected void runRunners(Runner[] runners) throws Exception
-   {
-      Thread[] threads = new Thread[runners.length];
-      for (int i = 0; i < runners.length; i++)
-      {
-         threads[i] = new Thread(runners[i]);
-         threads[i].start();
-      }
-      
-      for (int i = 0; i < runners.length; i++)
-      {
-         threads[i].join();
-      }
-      
-      for (int i = 0; i < runners.length; i++)
-      {
-         if (runners[i].isFailed())
-         {
-            fail("Runner " + i + " failed");
-            log.error("runner failed");
-         }
-      } 
-   }
-}




More information about the jboss-cvs-commits mailing list