office2.bindClusteredQueue("sub3", "topic1", queue3);
office2.bindClusteredQueue("sub3", "topic1", null, queue3);
   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                  ClusteredQueue queue1 = new ClusteredQueue(im.getId(), ms, pm, true, false, 2000, 100, 100, (QueuedExecutor)pool.get(), null);                  Binding binding1 =            office1.bindClusteredQueue("sub1", "topic1", queue1);         ClusteredQueue queue2 = new ClusteredQueue(im.getId(), ms, pm, true, false, 2000, 100, 100, (QueuedExecutor)pool.get(), null);                  Binding binding2 =            office1.bindClusteredQueue("sub2", "topic1", queue2);                  //Start another office - make sure it picks up the bindings from the first node                  office2 = createClusteredPostOffice("node2", "testgroup");                  List bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  assertEquivalent(binding1, (Binding)bindings.get(0));         assertEquivalent(binding2, (Binding)bindings.get(1));                           //Add another binding on node 2                  ClusteredQueue queue3 = new ClusteredQueue(im.getId(), ms, pm, true, false, 2000, 100, 100, (QueuedExecutor)pool.get(), null);                  Binding binding3 =            office2.bindClusteredQueue("sub3", "topic1", queue3);           //Make sure both nodes pick it up                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(3, bindings.size());                  assertEquivalent(binding1, (Binding)bindings.get(0));         assertEquivalent(binding2, (Binding)bindings.get(1));         assertEquivalent(binding3, (Binding)bindings.get(2));         bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(3, bindings.size());                  assertEquivalent(binding1, (Binding)bindings.get(0));         assertEquivalent(binding2, (Binding)bindings.get(1));         assertEquivalent(binding3, (Binding)bindings.get(2));         //Add another binding on node 1                  ClusteredQueue queue4 = new ClusteredQueue(im.getId(), ms, pm, true, false, 2000, 100, 100, (QueuedExecutor)pool.get(), null);                  Binding binding4 =            office2.bindClusteredQueue("sub4", "topic1", queue4);                  // Make sure both nodes pick it up                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(4, bindings.size());                  assertEquivalent(binding1, (Binding)bindings.get(0));         assertEquivalent(binding2, (Binding)bindings.get(1));         assertEquivalent(binding3, (Binding)bindings.get(2));         assertEquivalent(binding4, (Binding)bindings.get(3));                  bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(4, bindings.size());                  assertEquivalent(binding1, (Binding)bindings.get(0));         assertEquivalent(binding2, (Binding)bindings.get(1));         assertEquivalent(binding3, (Binding)bindings.get(2));         assertEquivalent(binding4, (Binding)bindings.get(3));                  //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());                  assertEquivalent(binding3, (Binding)bindings.get(0));         assertEquivalent(binding4, (Binding)bindings.get(1));            bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  assertEquivalent(binding3, (Binding)bindings.get(0));         assertEquivalent(binding4, (Binding)bindings.get(1));                  //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());                  assertEquivalent(binding3, (Binding)bindings.get(0));         assertEquivalent(binding4, (Binding)bindings.get(1));                  //Add another binding on node 3                           ClusteredQueue queue5 = new ClusteredQueue(im.getId(), ms, pm, true, false, 2000, 100, 100, (QueuedExecutor)pool.get(), null);                  Binding binding5 =            office3.bindClusteredQueue("sub5", "topic1", queue5);                  // Make sure all nodes pick it up                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(3, bindings.size());                  assertEquivalent(binding3, (Binding)bindings.get(0));         assertEquivalent(binding4, (Binding)bindings.get(1));         assertEquivalent(binding5, (Binding)bindings.get(2));                  bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(3, bindings.size());                  assertEquivalent(binding3, (Binding)bindings.get(0));         assertEquivalent(binding4, (Binding)bindings.get(1));         assertEquivalent(binding5, (Binding)bindings.get(2));                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(3, bindings.size());                  assertEquivalent(binding3, (Binding)bindings.get(0));         assertEquivalent(binding4, (Binding)bindings.get(1));         assertEquivalent(binding5, (Binding)bindings.get(2));                  //Add a durable and a non durable binding on node 1                  ClusteredQueue queue6 = new ClusteredQueue(im.getId(), ms, pm, true, true, 2000, 100, 100, (QueuedExecutor)pool.get(), null);                  Binding binding6 =            office1.bindClusteredQueue("sub6", "topic1", queue6);                  ClusteredQueue queue7 = new ClusteredQueue(im.getId(), ms, pm, true, false, 2000, 100, 100, (QueuedExecutor)pool.get(), null);                  Binding binding7 =            office1.bindClusteredQueue("sub7", "topic1", queue7);                  // Make sure all nodes pick them up                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(5, bindings.size());                  assertEquivalent(binding3, (Binding)bindings.get(0));         assertEquivalent(binding4, (Binding)bindings.get(1));         assertEquivalent(binding5, (Binding)bindings.get(2));         assertEquivalent(binding6, (Binding)bindings.get(3));         assertEquivalent(binding7, (Binding)bindings.get(4));                  bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(5, bindings.size());                  assertEquivalent(binding3, (Binding)bindings.get(0));         assertEquivalent(binding4, (Binding)bindings.get(1));         assertEquivalent(binding5, (Binding)bindings.get(2));         assertEquivalent(binding6, (Binding)bindings.get(3));         assertEquivalent(binding7, (Binding)bindings.get(4));                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(5, bindings.size());                  assertEquivalent(binding3, (Binding)bindings.get(0));         assertEquivalent(binding4, (Binding)bindings.get(1));         assertEquivalent(binding5, (Binding)bindings.get(2));         assertEquivalent(binding6, (Binding)bindings.get(3));         assertEquivalent(binding7, (Binding)bindings.get(4));                        //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());                  assertEquivalent(binding3, (Binding)bindings.get(0));         assertEquivalent(binding4, (Binding)bindings.get(1));         assertEquivalent(binding5, (Binding)bindings.get(2));         assertEquivalent(binding6, (Binding)bindings.get(3));                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(4, bindings.size());                  assertEquivalent(binding3, (Binding)bindings.get(0));         assertEquivalent(binding4, (Binding)bindings.get(1));         assertEquivalent(binding5, (Binding)bindings.get(2));         assertEquivalent(binding6, (Binding)bindings.get(3));                  //Stop office 2         office2.stop();                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  assertEquivalent(binding5, (Binding)bindings.get(0));         assertEquivalent(binding6, (Binding)bindings.get(1));                  //Restart office 1 and office 2         office1 = createClusteredPostOffice("node1", "testgroup");                  office2 = createClusteredPostOffice("node2", "testgroup");                  bindings = office1.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  assertEquivalent(binding5, (Binding)bindings.get(0));         assertEquivalent(binding6, (Binding)bindings.get(1));                  bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  assertEquivalent(binding5, (Binding)bindings.get(0));         assertEquivalent(binding6, (Binding)bindings.get(1));                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(2, bindings.size());                  assertEquivalent(binding5, (Binding)bindings.get(0));         assertEquivalent(binding6, (Binding)bindings.get(1));                  //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());                  assertEquivalent(binding6, (Binding)bindings.get(0));                  bindings = office2.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(1, bindings.size());                  assertEquivalent(binding6, (Binding)bindings.get(0));                  bindings = office3.listBindingsForCondition("topic1");         assertNotNull(bindings);         assertEquals(1, bindings.size());                  assertEquivalent(binding6, (Binding)bindings.get(0));                        }      finally      {         if (office1 != null)         {            office1.unbindClusteredQueue("sub6");            office1.stop();         }                  if (office2 != null)         {            office2.stop();         }                  if (office3 != null)         {            office2.stop();         }      }         }