LocalClusteredQueue queue5 = new LocalClusteredQueue(office3, "node3", "sub5", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
LocalClusteredQueue queue5 = new LocalClusteredQueue(office3, 3, "sub5", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
   public final void testClusteredBindUnbind() throws Throwable   {      ClusteredPostOffice office1 = null;            ClusteredPostOffice office2 = null;            ClusteredPostOffice office3 = null;            try      {                  //Start one office                  office1 = createClusteredPostOffice("node1", "testgroup");                  //Add a couple of bindings                  LocalClusteredQueue queue1 = new LocalClusteredQueue(office1, "node1", "sub1", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);                  Binding binding1 =            office1.bindClusteredQueue("topic1", queue1);         LocalClusteredQueue queue2 = new LocalClusteredQueue(office1, "node1", "sub2", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);         Binding binding2 =            office1.bindClusteredQueue("topic1", queue2);                  //Start another office - make sure it picks up the bindings from the first node                  office2 = createClusteredPostOffice("node2", "testgroup");                  Collection bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  Iterator iter = bindings.iterator();         assertEquivalent(binding1, (Binding)iter.next());         assertEquivalent(binding2, (Binding)iter.next());                           //Add another binding on node 2                  LocalClusteredQueue queue3 = new LocalClusteredQueue(office2, "node2", "sub3", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);         Binding binding3 =            office2.bindClusteredQueue("topic1", queue3);           //Make sure both nodes pick it up                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(3, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding1, (Binding)iter.next());         assertEquivalent(binding2, (Binding)iter.next());         assertEquivalent(binding3, (Binding)iter.next());         bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(3, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding1, (Binding)iter.next());         assertEquivalent(binding2, (Binding)iter.next());         assertEquivalent(binding3, (Binding)iter.next());         //Add another binding on node 1                  LocalClusteredQueue queue4 = new LocalClusteredQueue(office2, "node2", "sub4", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);         Binding binding4 =            office2.bindClusteredQueue("topic1", queue4);                  // Make sure both nodes pick it up                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(4, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding1, (Binding)iter.next());         assertEquivalent(binding2, (Binding)iter.next());         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());                  bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(4, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding1, (Binding)iter.next());         assertEquivalent(binding2, (Binding)iter.next());         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());                  //Unbind binding 1 and binding 2         office1.unbindClusteredQueue("sub1");         office1.unbindClusteredQueue("sub2");                  //Make sure bindings are not longer available on either node                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());            bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());                  //Add a third office                           office3 = createClusteredPostOffice("node3", "testgroup");                  //Maks sure it picks up the bindings                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());                  //Add another binding on node 3                           LocalClusteredQueue queue5 = new LocalClusteredQueue(office3, "node3", "sub5", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);                  Binding binding5 =            office3.bindClusteredQueue("topic1", queue5);                  // Make sure all nodes pick it up                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(3, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());         assertEquivalent(binding5, (Binding)iter.next());                  bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(3, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());         assertEquivalent(binding5, (Binding)iter.next());                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(3, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());         assertEquivalent(binding5, (Binding)iter.next());                  //Add a durable and a non durable binding on node 1                  LocalClusteredQueue queue6 = new LocalClusteredQueue(office1, "node1", "sub6", im.getId(), ms, pm, true, true, (QueuedExecutor)pool.get(), null, tr);                           Binding binding6 =            office1.bindClusteredQueue("topic1", queue6);                  LocalClusteredQueue queue7 = new LocalClusteredQueue(office1, "node1", "sub7", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);                           Binding binding7 =            office1.bindClusteredQueue("topic1", queue7);                  // Make sure all nodes pick them up                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(5, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());         assertEquivalent(binding5, (Binding)iter.next());         assertEquivalent(binding6, (Binding)iter.next());         assertEquivalent(binding7, (Binding)iter.next());                  bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(5, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());         assertEquivalent(binding5, (Binding)iter.next());         assertEquivalent(binding6, (Binding)iter.next());         assertEquivalent(binding7, (Binding)iter.next());                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(5, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());         assertEquivalent(binding5, (Binding)iter.next());         assertEquivalent(binding6, (Binding)iter.next());         assertEquivalent(binding7, (Binding)iter.next());                        //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 non durable bindings should be removed from the other nodes         //Durable bindings should remain                  bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(4, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());         assertEquivalent(binding5, (Binding)iter.next());         assertEquivalent(binding6, (Binding)iter.next());                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(4, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding3, (Binding)iter.next());         assertEquivalent(binding4, (Binding)iter.next());         assertEquivalent(binding5, (Binding)iter.next());         assertEquivalent(binding6, (Binding)iter.next());                  //Stop office 2         office2.stop();                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding5, (Binding)iter.next());         assertEquivalent(binding6, (Binding)iter.next());                  //Restart office 1 and office 2         office1 = createClusteredPostOffice("node1", "testgroup");                  office2 = createClusteredPostOffice("node2", "testgroup");                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding5, (Binding)iter.next());         assertEquivalent(binding6, (Binding)iter.next());                  bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding5, (Binding)iter.next());         assertEquivalent(binding6, (Binding)iter.next());                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding5, (Binding)iter.next());         assertEquivalent(binding6, (Binding)iter.next());                  //Stop all offices                  office1.stop();         office2.stop();         office3.stop();                  //Start them all         office1 = createClusteredPostOffice("node1", "testgroup");         office2 = createClusteredPostOffice("node2", "testgroup");         office3 = createClusteredPostOffice("node3", "testgroup");                  //Only the durable queue should survive                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(1, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding6, (Binding)iter.next());                  bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(1, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding6, (Binding)iter.next());                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(1, bindings.size());                  iter = bindings.iterator();         assertEquivalent(binding6, (Binding)iter.next());                        }      finally      {         if (office1 != null)         {            try            {               office1.unbindClusteredQueue("sub6");            }            catch (Exception ignore)            {                           }            office1.stop();         }                  if (office2 != null)         {            office2.stop();         }                  if (office3 != null)         {            office2.stop();         }                  checkNoBindingData();      }         }