[jboss-cvs] JBoss Messaging SVN: r5647 - in trunk: src/main/org/jboss/messaging/core/client/impl and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 15 10:29:34 EST 2009


Author: jmesnil
Date: 2009-01-15 10:29:32 -0500 (Thu, 15 Jan 2009)
New Revision: 5647

Modified:
   trunk/src/main/org/jboss/messaging/core/client/ClientSession.java
   trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientSessionImplTest.java
Log:
JBMESSAGING-1318: convenient core API methods

added overloaded methods to create queues
added unit tests (the commented tests were out of date...)


Modified: trunk/src/main/org/jboss/messaging/core/client/ClientSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientSession.java	2009-01-15 06:23:14 UTC (rev 5646)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientSession.java	2009-01-15 15:29:32 UTC (rev 5647)
@@ -44,8 +44,30 @@
  */
 public interface ClientSession extends XAResource
 {
+   /**
+    * Queues created by this method are <em>not</em> temporary
+    */
    void createQueue(SimpleString address,
                     SimpleString queueName,
+                    boolean durable) throws MessagingException;
+   /**
+    * Queues created by this method are <em>not</em> temporary
+    */
+   void createQueue(String address,
+                    String queueName,
+                    boolean durable) throws MessagingException;
+
+   void createQueue(SimpleString address,
+                    SimpleString queueName,
+                    boolean durable,
+                    boolean temporary) throws MessagingException;
+   void createQueue(String address,
+                    String queueName,
+                    boolean durable,
+                    boolean temporary) throws MessagingException;
+
+   void createQueue(SimpleString address,
+                    SimpleString queueName,
                     SimpleString filterString,
                     boolean durable,
                     boolean temporary) throws MessagingException;
@@ -110,7 +132,7 @@
 
    /**
     * Create a producer with no default address.
-    * Address must be specified everytime a message is sent
+    * Address must be specified every time a message is sent
     * 
     * @see ClientProducer#send(SimpleString, org.jboss.messaging.core.message.Message)
     */

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java	2009-01-15 06:23:14 UTC (rev 5646)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java	2009-01-15 15:29:32 UTC (rev 5647)
@@ -232,6 +232,36 @@
    // ClientSession implementation
    // -----------------------------------------------------------------
 
+   public void createQueue(final SimpleString address, 
+                           final SimpleString queueName, 
+                           final boolean durable) throws MessagingException
+   {
+      createQueue(address, queueName, durable, false);
+   }
+
+   public void createQueue(final String address,
+                           final String queueName,
+                           final boolean durable) throws MessagingException
+   {
+      createQueue(toSimpleString(address), toSimpleString(queueName), durable);
+   }
+   
+   public void createQueue(final SimpleString address, 
+                           final SimpleString queueName, 
+                           final boolean durable, 
+                           final boolean temporary) throws MessagingException
+   {
+      createQueue(address, queueName, null, durable, temporary);
+   }
+
+   public void createQueue(final String address,
+                           final String queueName,
+                           final boolean durable,
+                           final boolean temporary) throws MessagingException
+   {
+      createQueue(toSimpleString(address), toSimpleString(queueName), durable, temporary);
+   }
+
    public void createQueue(final SimpleString address,
                            final SimpleString queueName,
                            final SimpleString filterString,

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientSessionImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientSessionImplTest.java	2009-01-15 06:23:14 UTC (rev 5646)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientSessionImplTest.java	2009-01-15 15:29:32 UTC (rev 5647)
@@ -18,2495 +18,1566 @@
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
+ */
 
 package org.jboss.messaging.tests.unit.core.client.impl;
 
+import static org.easymock.EasyMock.anyInt;
+import static org.easymock.EasyMock.anyLong;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.core.exception.MessagingException.OBJECT_CLOSED;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomPositiveInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomPositiveLong;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+import static org.jboss.messaging.tests.util.RandomUtil.randomXid;
+
+import java.io.File;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.easymock.EasyMock;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.impl.ClientConsumerInternal;
+import org.jboss.messaging.core.client.impl.ClientProducerInternal;
+import org.jboss.messaging.core.client.impl.ClientSessionImpl;
+import org.jboss.messaging.core.client.impl.ConnectionManager;
+import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.RemotingConnection;
+import org.jboss.messaging.core.remoting.impl.wireformat.NullResponseMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionAcknowledgeMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddDestinationMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryResponseMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionCloseMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionConsumerFlowCreditMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateConsumerMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateQueueMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionDeleteQueueMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAResponseMessage;
 import org.jboss.messaging.tests.util.UnitTestCase;
+import org.jboss.messaging.util.SimpleString;
 
 /**
  * 
  * A ClientSessionImplTest
  * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
  *
  */
 public class ClientSessionImplTest extends UnitTestCase
 {
+
    private static final Logger log = Logger.getLogger(ClientSessionImplTest.class);
 
+   private ConnectionManager cm;
+
+   private RemotingConnection rc;
+
+   private Channel channel;
+
+   private ClientSessionImpl session;
+
+   private boolean autoCommitSends;
+
+   private int consumerWindowSize;
+
+   private int consumerMaxRate;
+
    // Public -----------------------------------------------------------------------------------------------------------
 
-   public void testDummy()
-   {      
+   public void testCreateQueue() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      SimpleString queueName = randomSimpleString();
+      SimpleString filterString = randomSimpleString();
+      boolean durable = randomBoolean();
+      boolean temporary = randomBoolean();
+
+      SessionCreateQueueMessage request = new SessionCreateQueueMessage(address, queueName, null, durable, false);
+
+      // SimpleString version
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      replayMocks();
+
+      session.createQueue(address, queueName, durable);
+
+      verifyMocks();
+
+      // String versions
+      resetMocks();
+
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      replayMocks();
+
+      session.createQueue(address.toString(), queueName.toString(), durable);
+
+      verifyMocks();
+
+      // with temporary
+      request = new SessionCreateQueueMessage(address, queueName, null, durable, temporary);
+
+      resetMocks();
+
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      replayMocks();
+
+      session.createQueue(address.toString(), queueName.toString(), durable, temporary);
+
+      verifyMocks();
+
+      // full methods
+      resetMocks();
+
+      request = new SessionCreateQueueMessage(address, queueName, filterString, durable, temporary);
+
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      replayMocks();
+
+      session.createQueue(address, queueName, filterString, durable, temporary);
+
+      verifyMocks();
+
+      // full methods with String
+      resetMocks();
+
+      request = new SessionCreateQueueMessage(address, queueName, filterString, durable, temporary);
+
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      replayMocks();
+
+      session.createQueue(address.toString(), queueName.toString(), filterString.toString(), durable, temporary);
+
+      verifyMocks();
    }
+
+   public void testDeleteQueue() throws Exception
+   {
+      SimpleString queueName = randomSimpleString();
+
+      SessionDeleteQueueMessage request = new SessionDeleteQueueMessage(queueName);
+
+      // SimpleString version
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      replayMocks();
+
+      session.deleteQueue(queueName);
+
+      verifyMocks();
+
+      // String version
+      resetMocks();
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      replayMocks();
+
+      session.deleteQueue(queueName.toString());
+
+      verifyMocks();
+   }
+
+   public void testQueueQuery() throws Exception
+   {
+      SimpleString queueName = randomSimpleString();
+
+      SessionQueueQueryMessage request = new SessionQueueQueryMessage(queueName);
+      SessionQueueQueryResponseMessage resp = new SessionQueueQueryResponseMessage();
+
+      expect(channel.sendBlocking(request)).andReturn(resp);
+      replayMocks();
+
+      SessionQueueQueryResponseMessage resp2 = session.queueQuery(queueName);
+      assertTrue(resp == resp2);
+
+      verifyMocks();
+   }
+
+   public void testBindingQuery() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+
+      SessionBindingQueryMessage request = new SessionBindingQueryMessage(address);
+      SessionBindingQueryResponseMessage resp = new SessionBindingQueryResponseMessage();
+
+      expect(channel.sendBlocking(request)).andReturn(resp);
+      replayMocks();
+
+      SessionBindingQueryResponseMessage resp2 = session.bindingQuery(request.getAddress());
+      assertTrue(resp == resp2);
+
+      verifyMocks();
+   }
+
+   public void testAddDestination() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      boolean durable = randomBoolean();
+      boolean temporary = randomBoolean();
+
+      SessionAddDestinationMessage request = new SessionAddDestinationMessage(address, durable, temporary);
+
+      // SimpleString verion
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+
+      replayMocks();
+
+      session.addDestination(address, durable, temporary);
+
+      verifyMocks();
+
+      // String verion
+      resetMocks();
+
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+
+      replayMocks();
+
+      session.addDestination(address.toString(), durable, temporary);
+
+      verifyMocks();
+   }
+
+   public void testRemoveDestination() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      boolean durable = randomBoolean();
+
+      SessionRemoveDestinationMessage request = new SessionRemoveDestinationMessage(address, durable);
+
+      // SimpleString version
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      replayMocks();
+
+      session.removeDestination(address, durable);
+
+      verifyMocks();
+
+      // String version
+      resetMocks();
+
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      replayMocks();
+
+      session.removeDestination(address.toString(), durable);
+
+      verifyMocks();
+   }
+
+   public void testCreateConsumer() throws Exception
+   {
+      SimpleString queueName = randomSimpleString();
+      SimpleString filterString = randomSimpleString();
+
+      SessionCreateConsumerMessage request = new SessionCreateConsumerMessage(queueName, null, false);
+
+      // SimpleString version
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      SessionConsumerFlowCreditMessage flowMessage = new SessionConsumerFlowCreditMessage(randomPositiveLong(),
+                                                                                          anyInt());
+      channel.send(flowMessage);
+      replayMocks();
+
+      session.createConsumer(queueName);
+
+      verifyMocks();
+
+      // String version
+      resetMocks();
+
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      flowMessage = new SessionConsumerFlowCreditMessage(randomPositiveLong(), anyInt());
+      channel.send(flowMessage);
+      replayMocks();
+
+      session.createConsumer(queueName.toString());
+
+      verifyMocks();
+
+      // with a filter
+      resetMocks();
+
+      request = new SessionCreateConsumerMessage(queueName, filterString, false);
+
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      flowMessage = new SessionConsumerFlowCreditMessage(randomPositiveLong(), anyInt());
+      channel.send(flowMessage);
+      replayMocks();
+
+      session.createConsumer(queueName, filterString);
+
+      verifyMocks();
+
+      // with a filter String
+      resetMocks();
+
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      flowMessage = new SessionConsumerFlowCreditMessage(randomPositiveLong(), anyInt());
+      channel.send(flowMessage);
+      replayMocks();
+
+      session.createConsumer(queueName.toString(), filterString.toString());
+
+      verifyMocks();
+
+      // for browsing
+      resetMocks();
+
+      boolean browseOnly = randomBoolean();
+      request = new SessionCreateConsumerMessage(queueName, filterString, browseOnly);
+
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      flowMessage = new SessionConsumerFlowCreditMessage(randomPositiveLong(), anyInt());
+      channel.send(flowMessage);
+      replayMocks();
+
+      session.createConsumer(queueName, filterString, browseOnly);
+
+      verifyMocks();
+
+      // for browsing with String
+      resetMocks();
+
+      request = new SessionCreateConsumerMessage(queueName, filterString, browseOnly);
+
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      flowMessage = new SessionConsumerFlowCreditMessage(randomPositiveLong(), anyInt());
+      channel.send(flowMessage);
+      replayMocks();
+
+      session.createConsumer(queueName.toString(), filterString.toString(), browseOnly);
+
+      verifyMocks();
+
+      // full version
+      resetMocks();
+
+      request = new SessionCreateConsumerMessage(queueName, filterString, browseOnly);
+
+      int maxRate = randomPositiveInt();
+      int windowSize = randomPositiveInt();
+      expect(channel.sendBlocking(request)).andReturn(new NullResponseMessage());
+      flowMessage = new SessionConsumerFlowCreditMessage(anyLong(), windowSize);
+      channel.send(flowMessage);
+      replayMocks();
+
+      session.createConsumer(queueName, filterString, windowSize, maxRate, browseOnly);
+
+      verifyMocks();
+
+   }
+
+   public void testCreateProducer() throws Exception
+   {
+      ClientProducer producer = session.createProducer();
+      assertNull(producer.getAddress());
+
+      SimpleString address = randomSimpleString();
+      producer = session.createProducer(address);
+      assertEquals(address, producer.getAddress());
+
+      producer = session.createProducer(address.toString());
+      assertEquals(address, producer.getAddress());
+
+      int maxRate = randomPositiveInt();
+      producer = session.createProducer(address, maxRate);
+      assertEquals(address, producer.getAddress());
+      assertEquals(maxRate, producer.getMaxRate());
+
+      producer = session.createProducer(address.toString(), maxRate);
+      assertEquals(address, producer.getAddress());
+      assertEquals(maxRate, producer.getMaxRate());
+
+      boolean blockOnNonPersistentSend = randomBoolean();
+      boolean blockOnPersistentSend = randomBoolean();
+      producer = session.createProducer(address, maxRate, blockOnNonPersistentSend, blockOnPersistentSend);
+      assertEquals(address, producer.getAddress());
+      assertEquals(maxRate, producer.getMaxRate());
+      assertEquals(autoCommitSends && blockOnNonPersistentSend, producer.isBlockOnNonPersistentSend());
+      assertEquals(autoCommitSends && blockOnPersistentSend, producer.isBlockOnPersistentSend());
+
+      producer = session.createProducer(address.toString(), maxRate, blockOnNonPersistentSend, blockOnPersistentSend);
+      assertEquals(address, producer.getAddress());
+      assertEquals(maxRate, producer.getMaxRate());
+      assertEquals(autoCommitSends && blockOnNonPersistentSend, producer.isBlockOnNonPersistentSend());
+      assertEquals(autoCommitSends && blockOnPersistentSend, producer.isBlockOnPersistentSend());
+   }
+
+   public void testGetXAResource() throws Exception
+   {
+      XAResource res = session.getXAResource();
+
+      assertTrue(res == session);
+   }
+
+   public void testAcknowledge() throws Exception
+   {
+      testAcknowledge(true);
+      testAcknowledge(false);
+   }
    
-//   public void testConstructor() throws Exception
-//   {            
-//      testConstructor(132, true, 10, true, true, true, true, 100);
-//      testConstructor(132, false, 10, false, false, false, false, 12);
-//   }
-//
-//   public void testConstructorInvalidArgs() throws Exception
-//   {  
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      Executor executor = EasyMock.createStrictMock(Executor.class);
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class); 
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      try
-//      {
-//         new ClientSessionImpl("blah", 1, false, -2, false, false, false, false, rc, cf, pd, 100, cm);
-//         fail("Should throw exception");
-//      }
-//      catch (IllegalArgumentException e)
-//      {
-//         //Ok
-//      }
-//
-//      try
-//      {
-//         new ClientSessionImpl("blah", 1, false, -10, false, false, false, false, rc, cf, pd, 100, cm);
-//         fail("Should throw exception");
-//      }
-//      catch (IllegalArgumentException e)
-//      {
-//         //Ok
-//      }
-//
-//      try
-//      {
-//         new ClientSessionImpl("blah", 1, false, 0, false, false, false, false, rc, cf, pd, 100, cm);
-//         fail("Should throw exception");
-//      }
-//      catch (IllegalArgumentException e)
-//      {
-//         //Ok
-//      }
-//   }
-//
-//   public void testCreateQueue() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//  
-//      SessionCreateQueueMessage request = new SessionCreateQueueMessage(new SimpleString("blah"), new SimpleString("hagshg"),
-//            new SimpleString("jhjhs"), false, false);
-//      
-//      final int targetID = 121;
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(targetID, request)).andReturn(null);
-//      
-//      EasyMock.replay(rc, cf, pd);
-//
-//      ClientSession session =
-//         new ClientSessionImpl("blah", targetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//                  
-//      session.createQueue(request.getAddress(), request.getQueueName(), request.getFilterString(), request.isDurable(), request.isDurable());
-//      
-//      EasyMock.verify(rc, cf, pd);     
-//   }
-//   
-//   public void testDeleteQueue() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      SessionDeleteQueueMessage request = new SessionDeleteQueueMessage(new SimpleString("blah"));
-//      
-//      final int targetID = 121;
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(targetID, request)).andReturn(null);
-//      
-//      EasyMock.replay(rc, cf, pd, cm);
-//                  
-//      ClientSession session = new ClientSessionImpl("blah", targetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//                  
-//      session.deleteQueue(request.getQueueName());
-//      
-//      EasyMock.verify(rc, cf, pd, cm);     
-//   }
-//   
-//   public void testQueueQuery() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);    
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      SessionQueueQueryMessage request = new SessionQueueQueryMessage(new SimpleString("blah"));
-//      
-//      SessionQueueQueryResponseMessage resp = new SessionQueueQueryResponseMessage();
-//      
-//      final int targetID = 121;
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(targetID, request)).andReturn(resp);
-//      
-//      EasyMock.replay(rc, cf, pd, cm);
-//                  
-//      ClientSession session = new ClientSessionImpl("blah", targetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//                  
-//      SessionQueueQueryResponseMessage resp2 = session.queueQuery(request.getQueueName());
-//      
-//      EasyMock.verify(rc, rc, cf, pd, cm);
-//      
-//      assertTrue(resp == resp2);
-//   }
-//   
-//   public void testBindingQuery() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//
-//      SessionBindingQueryMessage request = new SessionBindingQueryMessage(new SimpleString("blah"));
-//      
-//      SessionBindingQueryResponseMessage resp = new SessionBindingQueryResponseMessage();
-//      
-//      final int targetID = 121;
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(targetID, request)).andReturn(resp);
-//      
-//      EasyMock.replay(rc, cf, pd, cm);
-//                  
-//      ClientSession session = new ClientSessionImpl("blah", targetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//                  
-//      SessionBindingQueryResponseMessage resp2 = session.bindingQuery(request.getAddress());
-//      
-//      EasyMock.verify(rc, cf, pd, cm); 
-//      
-//      assertTrue(resp == resp2);
-//   }
-//   
-//   public void testAddDestination() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      SessionAddDestinationMessage request = new SessionAddDestinationMessage(new SimpleString("blah"), true, true);
-//      
-//      final int targetID = 121;
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(targetID,  request)).andReturn(null);
-//      
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSession session = new ClientSessionImpl("blah", targetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//                  
-//      session.addDestination(request.getAddress(), request.isDurable(), request.isTemporary());
-//      
-//      EasyMock.verify(rc, cf, pd, cm); 
-//   }
-//   
-//   public void testRemoveDestination() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      SessionRemoveDestinationMessage request = new SessionRemoveDestinationMessage(new SimpleString("blah"), true);
-//      
-//      final int targetID = 121;
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(targetID, request)).andReturn(null);
-//      
-//      EasyMock.replay(rc, cf, pd, cm);
-//                  
-//      ClientSession session = new ClientSessionImpl("blah", targetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//                  
-//      session.removeDestination(request.getAddress(), true);
-//      
-//      EasyMock.verify(rc, cf, pd, cm); 
-//   }
-//   
-//   public void testCreateConsumer() throws Exception
-//   {
-//      //First test with the wide createConsumer method
-//      
-//      testCreateConsumerWideMethod(new SimpleString("usahduiahs"), new SimpleString("ygyggyg"),
-//            false, false, false, 121455, 76556, 121455);
-//      testCreateConsumerWideMethod(new SimpleString("usahduiahs"), null,
-//            false, false, false, 121455, 76556, 121455);
-//      
-//      //test where server window size overrides client window size
-//      testCreateConsumerWideMethod(new SimpleString("usahduiahs"), null,
-//            false, false, false, 121455, 76556, 675675765);
-//      testCreateConsumerWideMethod(new SimpleString("usahduiahs"), null,
-//            false, false, false, 121455, 76556, 1);
-//      testCreateConsumerWideMethod(new SimpleString("usahduiahs"), null,
-//            false, false, false, 121455, 76556, -1);
-//      
-//      //And with the method that takes defaults from the cf
-//      
-//      testCreateConsumerDefaultsMethod(new SimpleString("usahduiahs"), new SimpleString("ygyggyg"),
-//            false, false, false, 121455, 76556, 121455);
-//      testCreateConsumerDefaultsMethod(new SimpleString("usahduiahs"), null,
-//            false, false, false, 121455, 76556, 121455);
-//      
-//      //test where server window size overrides client window size
-//      testCreateConsumerDefaultsMethod(new SimpleString("usahduiahs"), null,
-//            false, false, false, 121455, 76556, 675675765);
-//      testCreateConsumerDefaultsMethod(new SimpleString("usahduiahs"), null,
-//            false, false, false, 121455, 76556, 1);
-//      testCreateConsumerDefaultsMethod(new SimpleString("usahduiahs"), null,
-//            false, false, false, 121455, 76556, -1);
-//      
-//      // And with the basic createConsumer method:
-//      
-//      testCreateConsumerBasicMethod(new SimpleString("usahduiahs"), 121455, 76556, 121455);
-//      testCreateConsumerBasicMethod(new SimpleString("usahduiahs"), 121455, 76556, 121455);
-//      
-//      //test where server window size overrides client window size
-//      testCreateConsumerBasicMethod(new SimpleString("usahduiahs"), 121455, 76556, 675675765);
-//      testCreateConsumerBasicMethod(new SimpleString("usahduiahs"), 121455, 76556, 1);
-//      testCreateConsumerBasicMethod(new SimpleString("usahduiahs"), 121455, 76556, -1);
-//   }
-//   
-//   public void testCreateProducer() throws Exception
-//   {
-//      //test with the wide method
-//      
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, false, false, false);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, false, false, true);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, false, true, false);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, false, true, true);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, true, false, false);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, true, false, true);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, true, true, false);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, true, true, true);
-//      
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, false, false, false);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, false, false, true);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, false, true, false);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, false, true, true);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, true, false, false);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, true, false, true);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, true, true, false);
-//      testCreateProducerWideMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, true, true, true);
-//      
-//      //Test with the basic method
-//      
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, false, false, false);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, false, false, true);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, false, true, false);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, false, true, true);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, true, false, false);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, true, false, true);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, true, true, false);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 545454, 5454, true, true, true);
-//      
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, false, false, false);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, false, false, true);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, false, true, false);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, false, true, true);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, true, false, false);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, true, false, true);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, true, true, false);
-//      testCreateProducerBasicMethod(new SimpleString("yugygugy"), 545454, 5454, 675765, 3232, true, true, true);
-//
-//      //Test with the rate limited method
-//      
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, -1, 5454, false, false, false);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, -1, 5454, false, false, true);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, -1, 5454, false, true, false);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, -1, 5454, false, true, true);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, -1, 5454, true, false, false);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, -1, 5454, true, false, true);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, -1, 5454, true, true, false);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, -1, 5454, true, true, true);
-//      
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, false, false, false);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, false, false, true);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, false, true, false);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, false, true, true);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, true, false, false);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, true, false, true);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, true, true, false);
-//      testCreateProducerRateLimitedMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, true, true, true);
-//      
-//      //Test with the create producer with window size method
-//      
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 545454, -1, false, false, false);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 545454, -1, false, false, true);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 545454, -1, false, true, false);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 545454, -1, false, true, true);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 545454, -1, true, false, false);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 545454, -1, true, false, true);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 545454, -1, true, true, false);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 545454, -1, true, true, true);
-//      
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, false, false, false);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, false, false, true);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, false, true, false);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, false, true, true);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, true, false, false);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, true, false, true);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, true, true, false);
-//      testCreateProducerWithWindowSizeMethod(new SimpleString("yugygugy"), 5454, 675765, 3232, true, true, true);      
-//   }
-//   
-//   public void testProducerCaching() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//        
-//      final long sessionTargetID = 9121892;
-//      
-//      final SimpleString address1 = new SimpleString("gyugg");
-//      final SimpleString address2 = new SimpleString("g237429834");
-//      final int windowSize = 72887827;
-//      final int maxRate = -1;
-//      
-//      //In create producer method
-//            
-//      {
-//         final long clientTargetID = 7676876;
-//         
-//         EasyMock.expect(pd.generateID()).andReturn(clientTargetID);
-//                  
-//         SessionCreateProducerMessage request =
-//            new SessionCreateProducerMessage(clientTargetID, address1, windowSize, maxRate);             
-//         
-//         SessionCreateProducerResponseMessage resp = 
-//            new SessionCreateProducerResponseMessage(67765765, windowSize, maxRate);
-//         
-//         EasyMock.expect(cm.sendCommandBlocking(sessionTargetID,  request)).andReturn(resp);
-//               
-//         pd.register(new ClientSessionPacketHandler(null, clientTargetID, null));
-//      }
-//      
-//      {  
-//         final long clientTargetID = 54654654;
-//         
-//         EasyMock.expect(pd.generateID()).andReturn(clientTargetID);
-//         
-//         SessionCreateProducerMessage request =
-//            new SessionCreateProducerMessage(clientTargetID, address2, windowSize, maxRate);             
-//         
-//         SessionCreateProducerResponseMessage resp = 
-//            new SessionCreateProducerResponseMessage(7676876, windowSize, maxRate);
-//         
-//         EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, request)).andReturn(resp);
-//         
-//         pd.register(new ClientSessionPacketHandler(null, clientTargetID, null));
-//      }
-//      
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      //Create three with address1 - only one should be actually created
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, false, -1, true, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      assertEquals(0, session.getProducerCache().size());
-//      
-//      ClientProducerInternal producer1 = (ClientProducerInternal)session.createProducer(address1, windowSize, maxRate,
-//                                                                                        false, false);
-//      
-//      assertEquals(0, session.getProducerCache().size());
-//      
-//      session.removeProducer(producer1);  
-//      
-//      assertEquals(1, session.getProducerCache().size());
-//      
-//      ClientProducerInternal producer2 = (ClientProducerInternal)session.createProducer(address1, windowSize, maxRate,
-//                                                                                       false, false);      
-//      
-//      assertEquals(0, session.getProducerCache().size());
-//      
-//      session.removeProducer(producer2);
-//      
-//      assertEquals(1, session.getProducerCache().size());
-//      
-//      ClientProducerInternal producer3 = (ClientProducerInternal)session.createProducer(address1, windowSize, maxRate,
-//                                                                                        false, false);
-//      
-//      assertEquals(0, session.getProducerCache().size());
-//      
-//      session.removeProducer(producer3);
-//      
-//      assertEquals(1, session.getProducerCache().size());
-//      
-//      //Create another with a different address
-//      
-//      ClientProducerInternal producer4 = (ClientProducerInternal)session.createProducer(address2, windowSize, maxRate,
-//                                                                                        false, false);
-//      
-//      assertEquals(1, session.getProducerCache().size());
-//      
-//      session.removeProducer(producer4); 
-//      
-//      assertEquals(2, session.getProducerCache().size());
-//            
-//      EasyMock.verify(rc, cf, pd, cm);
-//      
-//      assertTrue(producer1 == producer2);
-//      assertTrue(producer2 == producer3);
-//      assertFalse(producer1 == producer4);
-//      assertFalse(producer2 == producer4);
-//      assertFalse(producer3 == producer4);      
-//   }
-//   
-//   public void testProducerNoCaching() throws Exception
-//   {       
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);     
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//          
-//      final long sessionTargetID = 7617622;      
-//      final SimpleString address = new SimpleString("gyugg");
-//      final int windowSize = 72887827;
-//      final int maxRate = -1;
-//
-//      for (int i = 0; i < 3; i++)
-//      {
-//         //In create producer method
-//          
-//         final long clientTargetID = i + 65655;
-//         
-//         EasyMock.expect(pd.generateID()).andReturn(clientTargetID);         
-//         
-//         SessionCreateProducerMessage request =
-//            new SessionCreateProducerMessage(clientTargetID, address, windowSize, maxRate);             
-//         
-//         SessionCreateProducerResponseMessage resp = 
-//            new SessionCreateProducerResponseMessage(i + 273263, windowSize, maxRate);
-//         
-//         EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, request)).andReturn(resp);
-//                    
-//         pd.register(new ClientSessionPacketHandler(null, clientTargetID, null));      
-//      }
-//
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      ClientProducerInternal producer1 = (ClientProducerInternal)session.createProducer(address, windowSize, maxRate,
-//                                                                                        false, false);
-//      session.removeProducer(producer1);  
-//      
-//      ClientProducerInternal producer2 = (ClientProducerInternal)session.createProducer(address, windowSize, maxRate,
-//                                                                                       false, false);      
-//      session.removeProducer(producer2);
-//      
-//      ClientProducerInternal producer3 = (ClientProducerInternal)session.createProducer(address, windowSize, maxRate,
-//                                                                                        false, false);
-//      session.removeProducer(producer3);
-//      
-//      EasyMock.verify(rc, cf, pd, cm);
-//      
-//      assertFalse(producer1 == producer2);
-//      assertFalse(producer2 == producer3);
-//      assertFalse(producer1 == producer3);
-//   }
-//   
-//   public void testCreateBrowser() throws Exception
-//   {
-//      testCreateBrowser(true);
-//      testCreateBrowser(false);
-//   }
-//         
-//   public void testGetXAResource() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      ClientSession session = new ClientSessionImpl("blah", 5465, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      XAResource res = session.getXAResource();
-//      
-//      assertTrue(res == session);
-//   }
-//   
-//   public void testTransactedSessionAcknowledgeNotBroken() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//   
-//      final int numMessages = 100;
-//      
-//      final int sessionTargetID = 71267162;
-//            
-//      SessionAcknowledgeMessageBlah message = new SessionAcknowledgeMessageBlah(numMessages - 1, true);
-//            
-//      cm.sendCommandOneway(sessionTargetID, message);
-//
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, new PacketImpl(PacketImpl.SESS_COMMIT))).andReturn(null);
-//      
-//      //Create some consumers
-//      
-//      ClientConsumerInternal cons1 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      ClientConsumerInternal cons2 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      
-//      cons1.recover(numMessages);
-//      cons2.recover(numMessages);
-//            
-//      SessionAcknowledgeMessageBlah message2 = new SessionAcknowledgeMessageBlah(numMessages * 2 - 1, true);
-//      
-//      cm.sendCommandOneway(sessionTargetID, message2);
-//
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, new PacketImpl(PacketImpl.SESS_ROLLBACK))).andReturn(null);
-//                  
-//      EasyMock.replay(rc, cf, pd, cons1, cons2, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      session.addConsumer(cons1);
-//      session.addConsumer(cons2);
-//      
-//      //Simulate some messages being delivered in a non broken sequence (i.e. what would happen with a single consumer
-//      //on the session)
-//            
-//      for (int i = 0; i < numMessages; i++)
-//      {
-//         session.delivered(i, false);
-//         
-//         session.acknowledge();
-//      }
-//      
-//      //Then commit
-//      session.commit();
-//      
-//      for (int i = numMessages; i < numMessages * 2; i++)
-//      {
-//         session.delivered(i, false);
-//         
-//         session.acknowledge();
-//      }
-//      
-//      session.rollback();
-//      
-//      EasyMock.verify(rc, cf, pd, cons1, cons2, cm);
-//   }
-//   
-//   public void testAutoCommitSessionAcknowledge() throws Exception
-//   {
-//      testAutoCommitSessionAcknowledge(true);
-//      testAutoCommitSessionAcknowledge(false);
-//   }
-//            
-//   public void testTransactedSessionAcknowledgeBroken() throws Exception
-//   {
-//      testTransactedSessionAcknowledgeBroken(true);
-//      testTransactedSessionAcknowledgeBroken(false);
-//   }
-//         
-//   public void testTransactedSessionAcknowledgeNotBrokenExpired() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      final int[] messages = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
-//      
-//      final int sessionTargetID = 71267162;
-//         
-//      for (int i = 0; i < messages.length; i++)
-//      {
-//         SessionCancelMessage message = new SessionCancelMessage(messages[i], true);
-//         
-//         cm.sendCommandOneway(sessionTargetID, message);
-//      }
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, new PacketImpl(PacketImpl.SESS_COMMIT))).andReturn(null);
-//                  
-//      EasyMock.replay(rc, cf, pd, cm);
-//
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      //Simulate some messages being delivered in a non broken sequence (i.e. what would happen with a single consumer
-//      //on the session)
-//            
-//      for (int i = 0; i < messages.length; i++)
-//      {
-//         session.delivered(messages[i], true);
-//         
-//         session.acknowledge();
-//      }
-//      
-//      //Then commit
-//      session.commit();
-//      
-//      EasyMock.verify(rc, cf, pd, cm);
-//   }
-//   
-//   public void testTransactedSessionAcknowledgeBrokenExpired() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      final int[] messages = new int[] { 1, 3, 5, 7, 9, 2, 4, 10, 20, 21, 22, 23, 19, 18, 15, 30, 31, 32, 40, 35 };
-//      
-//      final int sessionTargetID = 71267162;
-//         
-//      for (int i = 0; i < messages.length; i++)
-//      {
-//         SessionCancelMessage message = new SessionCancelMessage(messages[i], true);
-//         
-//         cm.sendCommandOneway(sessionTargetID, message);
-//      }
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, new PacketImpl(PacketImpl.SESS_COMMIT))).andReturn(null);
-//                  
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      //Simulate some messages being delivered in a broken sequence (i.e. what would happen with a single consumer
-//      //on the session)
-//            
-//      for (int i = 0; i < messages.length; i++)
-//      {
-//         session.delivered(messages[i], true);
-//         
-//         session.acknowledge();
-//      }
-//      
-//      //Then commit
-//      session.commit();
-//      
-//      EasyMock.verify(rc, cf, pd, cm);; 
-//   }
-//
-//   public void testCleanUp2() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      ConnectionRegistry reg = EasyMock.createStrictMock(ConnectionRegistry.class);
-//        
-//      final long sessionTargetID = 9121892;
-//                  
-//      EasyMock.replay(rc, cf, pd, cm, reg);
-//      
-//      ClientSessionImpl session =
-//         new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      session.setConnectionRegistry(reg);
-//      
-//      EasyMock.verify(rc, cf, pd, cm, reg);
-//      
-//      EasyMock.reset(rc, cf, pd, cm, reg);
-//      
-//      ClientProducerInternal prod1 = EasyMock.createStrictMock(ClientProducerInternal.class);
-//      ClientProducerInternal prod2 = EasyMock.createStrictMock(ClientProducerInternal.class);
-//      
-//      ClientConsumerInternal cons1 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      ClientConsumerInternal cons2 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      
-//      ClientBrowser browser1 = EasyMock.createStrictMock(ClientBrowser.class);
-//      ClientBrowser browser2 = EasyMock.createStrictMock(ClientBrowser.class);
-//                    
-//      prod1.cleanUp();
-//      prod2.cleanUp();
-//      cons1.cleanUp();
-//      cons2.cleanUp();
-//      browser1.cleanUp();
-//      browser2.cleanUp();
-//      
-//      cm.close();
-//      final String connectionID = "uahsjash";
-//      EasyMock.expect(rc.getID()).andStubReturn(connectionID);
-//      reg.returnConnection(connectionID);
-//        
-//      EasyMock.replay(cf, pd, prod1, prod2, cons1, cons2, browser1, browser2, cm, reg, rc);
-//                 
-//      session.addProducer(prod1);
-//      session.addProducer(prod2);
-//      
-//      session.addConsumer(cons1);
-//      session.addConsumer(cons2);
-//      
-//      session.addBrowser(browser1);
-//      session.addBrowser(browser2);
-//      
-//      assertFalse(session.isClosed());
-//      
-//      session.cleanUp();
-//
-//      assertTrue(session.isClosed());
-//      
-//      EasyMock.verify(rc, cf, pd, prod1, prod2, cons1, cons2, browser1, browser2, cm, reg, rc);      
-//   }
-//         
-//   public void testClose() throws Exception   
-//   {
-//      testClose(true);
-//      testClose(false);
-//   }
-//         
-//   public void testAddRemoveConsumer() throws Exception
-//   {
-//      testAddRemoveConsumer(true);
-//      testAddRemoveConsumer(false);
-//   }
-//   
-//   public void testAddRemoveProducer() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//        
-//      final long sessionTargetID = 9121892;
-//                  
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      EasyMock.verify(rc, cf, pd, cm);
-//      
-//      EasyMock.reset(rc, cf, pd, cm);
-//                                      
-//      ClientProducerInternal prod1 = EasyMock.createStrictMock(ClientProducerInternal.class);
-//      ClientProducerInternal prod2 = EasyMock.createStrictMock(ClientProducerInternal.class);
-//      
-//      session.addProducer(prod1);
-//      session.addProducer(prod2);
-//      
-//      assertEquals(2, session.getProducers().size());
-//      assertTrue(session.getProducers().contains(prod1));
-//      assertTrue(session.getProducers().contains(prod2));
-//       
-//      session.removeProducer(prod1);
-//      
-//      assertEquals(1, session.getProducers().size());
-//      assertTrue(session.getProducers().contains(prod2));   
-//      
-//      session.removeProducer(prod2);
-//      
-//      assertEquals(0, session.getProducers().size()); 
-//   }
-//   
-//   public void testAddRemoveBrowser() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//        
-//      final long sessionTargetID = 9121892;
-//                  
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      EasyMock.verify(rc, cf, pd, cm);
-//      
-//      EasyMock.reset(rc, cf, pd, cm);
-//                                      
-//      ClientBrowser browser1 = EasyMock.createStrictMock(ClientBrowser.class);
-//      ClientBrowser browser2 = EasyMock.createStrictMock(ClientBrowser.class);
-//      
-//      session.addBrowser(browser1);
-//      session.addBrowser(browser2);
-//      
-//      assertEquals(2, session.getBrowsers().size());
-//      assertTrue(session.getBrowsers().contains(browser1));
-//      assertTrue(session.getBrowsers().contains(browser2));
-//       
-//      session.removeBrowser(browser1);
-//      
-//      assertEquals(1, session.getBrowsers().size());
-//      assertTrue(session.getBrowsers().contains(browser2));   
-//      
-//      session.removeBrowser(browser2);
-//      
-//      assertEquals(0, session.getBrowsers().size()); 
-//   }
-//   
-//   public void testXACommit() throws Exception
-//   {
-//      testXACommit(false, false);
-//      testXACommit(false, true);
-//      testXACommit(true, false);
-//      testXACommit(true, true);
-//   }
-//   
-//   public void testXAEnd() throws Exception
-//   {
-//      testXAEnd(XAResource.TMSUSPEND, false);
-//      testXAEnd(XAResource.TMSUSPEND, true);
-//      testXAEnd(XAResource.TMSUCCESS, false);
-//      testXAEnd(XAResource.TMSUCCESS, true);
-//      testXAEnd(XAResource.TMFAIL, false);
-//      testXAEnd(XAResource.TMFAIL, true);
-//   }
-//   
-//   public void testXAForget() throws Exception
-//   {
-//      testXAForget(false);
-//      testXAForget(true);
-//   }
-//   
-//   public void testGetTransactionTimeout() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//        
-//      final long sessionTargetID = 9121892;
-//      
-//      Packet packet = new PacketImpl(PacketImpl.SESS_XA_GET_TIMEOUT);
-//
-//      final int timeout = 1098289;
-//      
-//      SessionXAGetTimeoutResponseMessage resp = new SessionXAGetTimeoutResponseMessage(timeout);
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
-//                       
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      int timeout2 = session.getTransactionTimeout();
-//            
-//      EasyMock.verify(rc, cf, pd, cm);  
-//      
-//      assertEquals(timeout, timeout2);
-//   }
-//   
-//   public void testIsSameRM() throws Exception
-//   {      
-//      RemotingConnection rc1 = EasyMock.createStrictMock(RemotingConnection.class);
-//      RemotingConnection rc2 = EasyMock.createStrictMock(RemotingConnection.class);
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//                               
-//      EasyMock.replay(rc1, rc2, cf, pd, cm);
-//      
-//      ClientSessionInternal session1 =
-//         new ClientSessionImpl("blah", 4343, true, -1, false, false, false, false, rc1, cf, pd, 100, cm);
-//      
-//      ClientSessionInternal session2 =
-//         new ClientSessionImpl("blah2", 4343, true, -1, false, false, false, false, rc2, cf, pd, 100, cm);
-//      
-//      ClientSessionInternal session3 =
-//         new ClientSessionImpl("blah3", 4343, true, -1, false, false, false, false, rc2, cf, pd, 100, cm);
-//      
-//      assertFalse(session1.isSameRM(session2));
-//      assertFalse(session2.isSameRM(session1));
-//      
-//      assertTrue(session2.isSameRM(session3));
-//      assertTrue(session3.isSameRM(session2));
-//      
-//      assertFalse(session1.isSameRM(session3));
-//      assertFalse(session3.isSameRM(session1));
-//      
-//      assertTrue(session1.isSameRM(session1));
-//      assertTrue(session2.isSameRM(session2));
-//      assertTrue(session3.isSameRM(session3));
-//      
-//      EasyMock.verify(rc1, rc2, cf, pd, cm);
-//   }
-//   
-//   public void testXAPrepare() throws Exception
-//   {
-//      testXAPrepare(false, false);
-//      testXAPrepare(false, true);
-//      testXAPrepare(true, false);
-//      testXAPrepare(true, true);
-//   }
-//   
-//   public void testXARecover() throws Exception
-//   {
-//      testXARecover(XAResource.TMNOFLAGS);
-//      testXARecover(XAResource.TMSTARTRSCAN);
-//      testXARecover(XAResource.TMENDRSCAN);
-//      testXARecover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN);
-//   }
-//   
-//   public void testXARollback() throws Exception
-//   {
-//      testXARollback(true);
-//      testXARollback(false);
-//   }
-//   
-//   public void testXASetTransactionTimeout() throws Exception
-//   {
-//      testXASetTransactionTimeout(false);
-//      testXASetTransactionTimeout(true);
-//   }
-//   
-//   public void testXAStart() throws Exception
-//   {
-//      testXAStart(XAResource.TMJOIN, false);
-//      testXAStart(XAResource.TMRESUME, false);
-//      testXAStart(XAResource.TMNOFLAGS, false);
-//      testXAStart(XAResource.TMJOIN, true);
-//      testXAStart(XAResource.TMRESUME, true);
-//      testXAStart(XAResource.TMNOFLAGS, true);
-//   }
-//
-//   public void testCleanUp1() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      ConnectionRegistry reg = EasyMock.createStrictMock(ConnectionRegistry.class);
-//
-//      SessionCreateQueueMessage request = new SessionCreateQueueMessage(new SimpleString("blah"), new SimpleString("hagshg"),
-//            new SimpleString("jhjhs"), false, false);
-//
-//      final int targetID = 121;
-//
-//      EasyMock.expect(cm.sendCommandBlocking(targetID, request)).andReturn(null);
-//
-//      EasyMock.replay(rc, cf, pd, cm);
-//
-//      ClientSessionImpl session = new ClientSessionImpl("blah", targetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      session.setConnectionRegistry(reg);
-//
-//      session.createQueue(request.getAddress(), request.getQueueName(), request.getFilterString(), request.isDurable(), request.isDurable());
-//
-//      EasyMock.verify(rc, cf, pd, cm);
-//
-//      EasyMock.reset(rc, cf, pd, cm);   
-//      cm.close();
-//      final String connectionID = "uahsjash";
-//      EasyMock.expect(rc.getID()).andStubReturn(connectionID);
-//      reg.returnConnection(connectionID);
-//      EasyMock.replay(rc, cf, pd, cm);
-//      session.cleanUp();
-//      EasyMock.verify(rc, cf, pd, cm);
-//   }
-//
-//   public void notXA() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//              
-//      final long sessionTargetID = 9121892;
-//                  
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session = new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      EasyMock.verify(rc, cf, pd, cm);
-//      
-//      EasyMock.reset(rc, cf, pd, cm);      
-//      try
-//      {
-//         session.commit(randomXid(), false);
-//         fail("Should throw exception");
-//      }
-//      catch (XAException e)
-//      {
-//         assertEquals(XAException.XAER_RMERR, e.errorCode);
-//      }
-//      
-//      try
-//      {
-//         session.end(randomXid(), 8778);
-//         fail("Should throw exception");
-//      }
-//      catch (XAException e)
-//      {
-//         assertEquals(XAException.XAER_RMERR, e.errorCode);
-//      }
-//      
-//      try
-//      {
-//         session.forget(randomXid());
-//         fail("Should throw exception");
-//      }
-//      catch (XAException e)
-//      {
-//         assertEquals(XAException.XAER_RMERR, e.errorCode);
-//      }
-//      
-//      try
-//      {
-//         session.getTransactionTimeout();
-//         fail("Should throw exception");
-//      }
-//      catch (XAException e)
-//      {
-//         assertEquals(XAException.XAER_RMERR, e.errorCode);
-//      }
-//      
-//      try
-//      {
-//         session.isSameRM(session);
-//         fail("Should throw exception");
-//      }
-//      catch (XAException e)
-//      {
-//         assertEquals(XAException.XAER_RMERR, e.errorCode);
-//      }
-//      
-//      try
-//      {
-//         session.prepare(randomXid());
-//         fail("Should throw exception");
-//      }
-//      catch (XAException e)
-//      {
-//         assertEquals(XAException.XAER_RMERR, e.errorCode);
-//      }
-//      
-//      try
-//      {
-//         session.recover(89787);
-//         fail("Should throw exception");
-//      }
-//      catch (XAException e)
-//      {
-//         assertEquals(XAException.XAER_RMERR, e.errorCode);
-//      }
-//      
-//      try
-//      {
-//         session.rollback(randomXid());
-//         fail("Should throw exception");
-//      }
-//      catch (XAException e)
-//      {
-//         assertEquals(XAException.XAER_RMERR, e.errorCode);
-//      }
-//      
-//      try
-//      {
-//         session.setTransactionTimeout(767);
-//         fail("Should throw exception");
-//      }
-//      catch (XAException e)
-//      {
-//         assertEquals(XAException.XAER_RMERR, e.errorCode);
-//      }
-//      
-//      try
-//      {
-//         session.start(randomXid(), 8768);
-//         fail("Should throw exception");
-//      }
-//      catch (XAException e)
-//      {
-//         assertEquals(XAException.XAER_RMERR, e.errorCode);
-//      }
-//   }
-//   
-//   public void testCreateMessage() throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      MessagingBuffer buff = EasyMock.createMock(MessagingBuffer.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      EasyMock.expect(rc.createBuffer(ClientSessionImpl.INITIAL_MESSAGE_BODY_SIZE)).andStubReturn(buff);      
-//      EasyMock.replay(rc);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", 453543, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      ClientMessage msg = session.createClientMessage(false);
-//      assertFalse(msg.isDurable());
-//      
-//      msg = session.createClientMessage(true);
-//      assertTrue(msg.isDurable());
-//      
-//      final byte type = 123;
-//      
-//      msg = session.createClientMessage(type, false);
-//      assertFalse(msg.isDurable());
-//      assertEquals(type, msg.getType());
-//      
-//      msg = session.createClientMessage(type, true);
-//      assertTrue(msg.isDurable());
-//      assertEquals(type, msg.getType());
-//            
-//      final long expiration = 120912902;
-//      final long timestamp = 1029128;
-//      final byte priority = 12;
-//            
-//      msg = session.createClientMessage(type, false, expiration, timestamp, priority);
-//      assertFalse(msg.isDurable());
-//      assertEquals(type, msg.getType());
-//      assertEquals(expiration, msg.getExpiration());
-//      assertEquals(timestamp, msg.getTimestamp());
-//      assertEquals(priority, msg.getPriority());
-//
-//      msg = session.createClientMessage(type, true, expiration, timestamp, priority);
-//      assertTrue(msg.isDurable());
-//      assertEquals(type, msg.getType());
-//      assertEquals(expiration, msg.getExpiration());
-//      assertEquals(timestamp, msg.getTimestamp());
-//      assertEquals(priority, msg.getPriority());
-//   }
-//   
-//   // Private -------------------------------------------------------------------------------------------
-//
-//   private void testClose(boolean delivered) throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      ConnectionRegistry reg = EasyMock.createStrictMock(ConnectionRegistry.class);
-//        
-//      final long sessionTargetID = 9121892;
-//                  
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionImpl session =
-//         new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      session.setConnectionRegistry(reg);
-//      
-//      EasyMock.verify(rc, cf, pd, cm);
-//      
-//      EasyMock.reset(rc, cf, pd, cm);
-//      
-//      ClientProducerInternal prod1 = EasyMock.createStrictMock(ClientProducerInternal.class);
-//      ClientProducerInternal prod2 = EasyMock.createStrictMock(ClientProducerInternal.class);
-//      
-//      ClientConsumerInternal cons1 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      ClientConsumerInternal cons2 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      
-//      ClientBrowser browser1 = EasyMock.createStrictMock(ClientBrowser.class);
-//      ClientBrowser browser2 = EasyMock.createStrictMock(ClientBrowser.class);
-//                    
-//      prod1.close();
-//      prod2.close();
-//      cons1.close();
-//      cons2.close();
-//      browser1.close();
-//      browser2.close();
-//      
-//      final int numDeliveries = 10;
-//      
-//      if (delivered)
-//      {
-//         SessionAcknowledgeMessageBlah message = new SessionAcknowledgeMessageBlah(numDeliveries - 1, true);
-//         
-//         cm.sendCommandOneway(sessionTargetID, message);
-//      }
-//            
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, new PacketImpl(PacketImpl.CLOSE))).andReturn(null);
-//      
-//      cm.close();
-//                 
-//      final String connectionID = "uahsjash";
-//      EasyMock.expect(rc.getID()).andStubReturn(connectionID);
-//      reg.returnConnection(connectionID);
-//             
-//      EasyMock.replay(rc, cf, pd, prod1, prod2, cons1, cons2, browser1, browser2, cm);
-//                 
-//      session.addProducer(prod1);
-//      session.addProducer(prod2);
-//      
-//      session.addConsumer(cons1);
-//      session.addConsumer(cons2);
-//      
-//      session.addBrowser(browser1);
-//      session.addBrowser(browser2);
-//      
-//      assertFalse(session.isClosed());
-//      
-//      if (delivered)
-//      {
-//         //Simulate there being some undelivered messages
-//         for (int i = 0; i < numDeliveries; i++)
-//         {
-//            session.delivered(i, false);
-//            session.acknowledge();
-//         }
-//      }
-//            
-//      session.close();      
-//      
-//      EasyMock.verify(rc, cf, pd, prod1, prod2, cons1, cons2, browser1, browser2, cm);
-//      
-//      assertTrue(session.isClosed());  
-//      
-//      EasyMock.reset(rc, cf, pd, prod1, prod2, cons1, cons2, browser1, browser2, cm);
-//      
-//      EasyMock.replay(rc, cf, pd, prod1, prod2, cons1, cons2, browser1, browser2, cm);
-//      
-//      //Close again should do nothing
-//      
-//      session.close();
-//      
-//      EasyMock.verify(rc, cf, pd, prod1, prod2, cons1, cons2, browser1, browser2, cm);
-//      
-//      try
-//      {
-//         session.createQueue(new SimpleString("trtr"), new SimpleString("iuasij"), null, false, false);
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.deleteQueue(new SimpleString("trtr"));
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.addDestination(new SimpleString("trtr"), false, false);
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.removeDestination(new SimpleString("trtr"), false);
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.queueQuery(new SimpleString("trtr"));
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.bindingQuery(new SimpleString("trtr"));
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.createConsumer(new SimpleString("trtr"));
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.createConsumer(new SimpleString("iasjq"), new SimpleString("iuahsdiaj"), false);
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.createConsumer(new SimpleString("iasjq"), new SimpleString("iuahsdiaj"), false, 123412, 7162761);
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.createBrowser(new SimpleString("husuhsuh"));
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.createBrowser(new SimpleString("husuhsuh"), null);
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.createProducer(new SimpleString("husuhsuh"));
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.createProducer(new SimpleString("iashi"), 878778, 8778, false, false);
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.createRateLimitedProducer(new SimpleString("uhsuhs"), 78676);
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.createProducerWithWindowSize(new SimpleString("uhsuhs"), 78676);
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.commit();
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.rollback();
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//      try
-//      {
-//         session.acknowledge();
-//         fail("Should throw exception");
-//      }
-//      catch (MessagingException e)
-//      {
-//         assertEquals(MessagingException.OBJECT_CLOSED, e.getCode());
-//      }
-//      
-//   }
-//   
-//   private void testXAStart(int flags, boolean error) throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//        
-//      final long sessionTargetID = 9121892;
-//      
-//      Xid xid = randomXid();
-//      
-//      Packet packet = null;
-//      if (flags == XAResource.TMJOIN)
-//      {
-//         packet = new SessionXAJoinMessage(xid);           
-//      }
-//      else if (flags == XAResource.TMRESUME)
-//      {
-//         packet = new SessionXAResumeMessage(xid);
-//      }
-//      else if (flags == XAResource.TMNOFLAGS)
-//      {
-//         packet = new SessionXAStartMessage(xid);
-//      }
-//
-//      final int numMessages = 10;
-//      
-//      if (flags != XAResource.TMNOFLAGS)
-//      {      
-//         SessionAcknowledgeMessageBlah msg = new SessionAcknowledgeMessageBlah(numMessages - 1, true);
-//         
-//         cm.sendCommandOneway(sessionTargetID, msg);
-//      }
-//      
-//      SessionXAResponseMessage resp = new SessionXAResponseMessage(error, XAException.XAER_RMERR, "blah");
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
-//                       
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session = new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      //Simulate some unflushed messages
-//      
-//      for (int i = 0; i < numMessages; i++)
-//      {
-//         session.delivered(i, false);
-//         session.acknowledge();
-//      }
-//      
-//      if (error)
-//      {
-//         try
-//         {
-//            session.start(xid, flags);
-//            fail("Should throw exception");
-//         }
-//         catch (XAException e)
-//         {
-//            assertEquals(XAException.XAER_RMERR, e.errorCode);
-//         }
-//      }
-//      else
-//      {
-//         session.start(xid, flags);
-//      }
-//      
-//      EasyMock.verify(rc, cf, pd, cm);          
-//   }
-//   
-//   private void testXASetTransactionTimeout(boolean error) throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);      
-//        
-//      final long sessionTargetID = 9121892;
-//      
-//      final int timeout = 1897217;
-//      
-//      SessionXASetTimeoutMessage packet = new SessionXASetTimeoutMessage(timeout);
-//      
-//      SessionXASetTimeoutResponseMessage resp = new SessionXASetTimeoutResponseMessage(!error);
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
-//                       
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      boolean ok = session.setTransactionTimeout(timeout);
-//      
-//      assertTrue(ok == !error);
-//      
-//      EasyMock.verify(rc, cf, pd, cm);  
-//   }
-//   
-//   private void testXARollback(boolean error) throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//           
-//      final long sessionTargetID = 9121892;
-//      
-//      Xid xid = randomXid();
-//      
-//      SessionXARollbackMessage packet = new SessionXARollbackMessage(xid);
-//      
-//      SessionXAResponseMessage resp = new SessionXAResponseMessage(error, XAException.XAER_RMERR, "blah");
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
-//                       
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      if (error)
-//      {
-//         try
-//         {
-//            session.rollback(xid);
-//            fail("Should throw exception");
-//         }
-//         catch (XAException e)
-//         {
-//            assertEquals(XAException.XAER_RMERR, e.errorCode);
-//         }
-//      }
-//      else
-//      {
-//         session.rollback(xid);
-//      }
-//      
-//      EasyMock.verify(rc, cf, pd, cm);  
-//   }
-//   
-//   private void testXARecover(final int flags) throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      final long sessionTargetID = 9121892;
-//      
-//      final Xid[] xids = new Xid[] { randomXid(), randomXid(), randomXid() } ;
-//                  
-//      if ((flags & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN)
-//      {
-//         PacketImpl packet = new PacketImpl(PacketImpl.SESS_XA_INDOUBT_XIDS);
-//         
-//         SessionXAGetInDoubtXidsResponseMessage resp = new SessionXAGetInDoubtXidsResponseMessage(Arrays.asList(xids));
-//         
-//         EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
-//      }
-//                       
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      Xid[] xids2 = session.recover(flags);
-//      
-//      if ((flags & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN)
-//      {
-//         assertEquals(xids.length, xids2.length);
-//         
-//         for (int i = 0; i < xids.length; i++)
-//         {
-//            assertEquals(xids[i], xids2[i]);
-//         }
-//      }
-//      else
-//      {
-//         assertTrue(xids2.length == 0);
-//      }
-//      
-//      EasyMock.verify(rc, cf, pd, cm);  
-//   }
-//   
-//   private void testXAPrepare(boolean error, boolean readOnly) throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//        
-//      final long sessionTargetID = 9121892;
-//      
-//      Xid xid = randomXid();
-//      
-//      SessionXAPrepareMessage packet = new SessionXAPrepareMessage(xid);
-//      
-//      SessionXAResponseMessage resp = new SessionXAResponseMessage(error, error ? XAException.XAER_RMERR : readOnly ? XAResource.XA_RDONLY : XAResource.XA_OK, "blah");
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
-//                       
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      if (error)
-//      {
-//         try
-//         {
-//            session.prepare(xid);
-//            fail("Should throw exception");
-//         }
-//         catch (XAException e)
-//         {
-//            assertEquals(XAException.XAER_RMERR, e.errorCode);
-//         }
-//      }
-//      else
-//      {
-//         int res = session.prepare(xid);
-//         
-//         if (readOnly)
-//         {
-//            assertEquals(XAResource.XA_RDONLY, res);
-//         }
-//         else
-//         {
-//            assertEquals(XAResource.XA_OK, res);
-//         }
-//      }
-//      
-//      EasyMock.verify(rc, cf, pd, cm);  
-//   }
-//   
-//   private void testXAForget(final boolean error) throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//        
-//      final long sessionTargetID = 9121892;
-//      
-//      Xid xid = randomXid();
-//      
-//      Packet packet = new SessionXAForgetMessage(xid);
-//
-//      final int numMessages = 10;
-//      
-//      SessionAcknowledgeMessageBlah msg = new SessionAcknowledgeMessageBlah(numMessages - 1, true);
-//      
-//      cm.sendCommandOneway(sessionTargetID, msg);
-//      
-//      SessionXAResponseMessage resp = new SessionXAResponseMessage(error, XAException.XAER_RMERR, "blah");
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
-//                       
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
-//      
-//      //Simulate some unflushed messages
-//      
-//      for (int i = 0; i < numMessages; i++)
-//      {
-//         session.delivered(i, false);
-//         session.acknowledge();
-//      }
-//      
-//      if (error)
-//      {
-//         try
-//         {
-//            session.forget(xid);
-//            fail("Should throw exception");
-//         }
-//         catch (XAException e)
-//         {
-//            assertEquals(XAException.XAER_RMERR, e.errorCode);
-//         }
-//      }
-//      else
-//      {
-//         session.forget(xid);
-//      }
-//      
-//      EasyMock.verify(rc, cf, pd, cm);           
-//   }
-//   
-//   private void testXAEnd(int flags, boolean error) throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//        
-//      final long sessionTargetID = 9121892;
-//      
-//      Xid xid = randomXid();
-//      
-//      Packet packet = null;
-//      if (flags == XAResource.TMSUSPEND)
-//      {
-//         packet = new PacketImpl(PacketImpl.SESS_XA_SUSPEND);                  
-//      }
-//      else if (flags == XAResource.TMSUCCESS)
-//      {
-//         packet = new SessionXAEndMessage(xid, false);
-//      }
-//      else if (flags == XAResource.TMFAIL)
-//      {
-//         packet = new SessionXAEndMessage(xid, true);
-//      }
-//
-//      final int numMessages = 10;
-//      
-//      SessionAcknowledgeMessageBlah msg = new SessionAcknowledgeMessageBlah(numMessages - 1, true);
-//      
-//      cm.sendCommandOneway(sessionTargetID, msg);
-//      
-//      SessionXAResponseMessage resp = new SessionXAResponseMessage(error, XAException.XAER_RMERR, "blah");
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
-//                       
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session = new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false,rc, cf, pd, 100, cm);
-//      
-//      //Simulate some unflushed messages
-//      
-//      for (int i = 0; i < numMessages; i++)
-//      {
-//         session.delivered(i, false);
-//         session.acknowledge();
-//      }
-//      
-//      if (error)
-//      {
-//         try
-//         {
-//            session.end(xid, flags);
-//            fail("Should throw exception");
-//         }
-//         catch (XAException e)
-//         {
-//            assertEquals(XAException.XAER_RMERR, e.errorCode);
-//         }
-//      }
-//      else
-//      {
-//         session.end(xid, flags);
-//      }
-//      
-//      EasyMock.verify(rc, cf, pd, cm);          
-//   }
-//   
-//   private void testXACommit(boolean onePhase, boolean error) throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//        
-//      final long sessionTargetID = 9121892;
-//      
-//      Xid xid = randomXid();
-//      
-//      SessionXACommitMessage packet = new SessionXACommitMessage(xid, onePhase);
-//      
-//      SessionXAResponseMessage resp = new SessionXAResponseMessage(error, XAException.XAER_RMERR, "blah");
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
-//                       
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session = new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false,rc, cf, pd, 100, cm);
-//      
-//      if (error)
-//      {
-//         try
-//         {
-//            session.commit(xid, onePhase);
-//            fail("Should throw exception");
-//         }
-//         catch (XAException e)
-//         {
-//            assertEquals(XAException.XAER_RMERR, e.errorCode);
-//         }
-//      }
-//      else
-//      {
-//         session.commit(xid, onePhase);
-//      }
-//      
-//      EasyMock.verify(rc, cf, pd, cm);  
-//   }
-//   
-//   private void testAddRemoveConsumer(boolean delivered) throws Exception
-//   {
-//      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//        
-//      final long sessionTargetID = 9121892;
-//                  
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session = new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false,rc, cf, pd, 100, cm);
-//      
-//      EasyMock.verify(rc, cf, pd, cm);
-//      
-//      EasyMock.reset(rc, cf, pd, cm);
-//         
-//      final int numDeliveries = 10;
-//      
-//      if (delivered)
-//      {
-//         SessionAcknowledgeMessageBlah message = new SessionAcknowledgeMessageBlah(numDeliveries - 1, true);
-//         
-//         cm.sendCommandOneway(sessionTargetID, message);
-//      }
-//            
-//      cm.sendCommandOneway(sessionTargetID, new SessionCancelMessage(-1, false));
-//      
-//      cm.sendCommandOneway(sessionTargetID, new SessionCancelMessage(-1, false));
-//                       
-//      EasyMock.replay(rc, cf, pd, cm);
-//                       
-//      ClientConsumerInternal cons1 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      ClientConsumerInternal cons2 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      
-//      session.addConsumer(cons1);
-//      session.addConsumer(cons2);
-//      
-//      assertEquals(2, session.getConsumers().size());
-//      assertTrue(session.getConsumers().contains(cons1));
-//      assertTrue(session.getConsumers().contains(cons2));
-//      
-//      if (delivered)
-//      {
-//         //Simulate there being some undelivered messages
-//         for (int i = 0; i < numDeliveries; i++)
-//         {
-//            session.delivered(i, false);
-//            session.acknowledge();
-//         }
-//      }
-//            
-//      session.removeConsumer(cons1);
-//      
-//      assertEquals(1, session.getConsumers().size());
-//      assertTrue(session.getConsumers().contains(cons2));  
-//      
-//      session.removeConsumer(cons2);
-//      assertEquals(0, session.getConsumers().size());
-//      
-//      EasyMock.verify(rc, cf, pd, cm);          
-//   }
-//   
-//   private void testAutoCommitSessionAcknowledge(boolean blockOnAcknowledge) throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      final int numMessages = 100;
-//      
-//      final int batchSize = 10;
-//            
-//      final int sessionTargetID = 71267162;
-//            
-//      for (int i = 0; i < numMessages / batchSize; i++)
-//      {
-//         SessionAcknowledgeMessageBlah message = new SessionAcknowledgeMessageBlah((i + 1) * batchSize - 1, true);
-//               
-//         if (blockOnAcknowledge)
-//         {
-//            EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, message)).andReturn(null);
-//         }
-//         else
-//         {
-//            cm.sendCommandOneway(sessionTargetID, message);
-//         }
-//      }
-//
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, new PacketImpl(PacketImpl.SESS_COMMIT))).andReturn(null);
-//      
-//      ClientConsumerInternal cons1 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      ClientConsumerInternal cons2 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      
-//      for (int i = 0; i < numMessages / batchSize; i++)
-//      {
-//         SessionAcknowledgeMessageBlah message = new SessionAcknowledgeMessageBlah(numMessages + (i + 1) * batchSize - 1, true);
-//                   
-//         if (blockOnAcknowledge)
-//         {
-//            EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, message)).andReturn(null);
-//         }
-//         else
-//         {
-//            cm.sendCommandOneway(sessionTargetID, message);
-//         }
-//      }
-//      
-//      cons1.recover(numMessages * 2);
-//      cons2.recover(numMessages * 2);
-//            
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, new PacketImpl(PacketImpl.SESS_ROLLBACK))).andReturn(null);
-//                                     
-//      EasyMock.replay(rc, cf, pd, cons1, cons2, cm);
-//            
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, false, batchSize, false, false, true, blockOnAcknowledge,rc, cf, pd, 100, cm);
-//      
-//      session.addConsumer(cons1);
-//      
-//      session.addConsumer(cons2);
-//      
-//      //Simulate some messages being delivered in a non broken sequence (i.e. what would happen with a single consumer
-//      //on the session)
-//            
-//      for (int i = 0; i < numMessages; i++)
-//      {
-//         session.delivered(i, false);
-//         
-//         session.acknowledge();
-//      }
-//      
-//      //Then commit
-//      session.commit();
-//      
-//      for (int i = numMessages; i < numMessages * 2; i++)
-//      {
-//         session.delivered(i, false);
-//         
-//         session.acknowledge();
-//      }
-//      
-//      session.rollback();
-//      
-//      EasyMock.verify(rc, cf, pd, cons1, cons2, cm);
-//   }
-//   
-//   private void testTransactedSessionAcknowledgeBroken(boolean blockOnAcknowledge) throws Exception
-//   {
-//      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      final int[] messages = new int[] { 1, 3, 5, 7, 9, 2, 4, 10, 20, 21, 22, 23, 19, 18, 15, 30, 31, 32, 40, 35 };
-//      
-//      final int sessionTargetID = 71267162;
-//         
-//      for (int i = 0; i < messages.length; i++)
-//      {
-//         SessionAcknowledgeMessageBlah message = new SessionAcknowledgeMessageBlah(messages[i], false);
-//         
-//         if (blockOnAcknowledge)
-//         {
-//            EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, message)).andReturn(null);
-//         }
-//         else
-//         {
-//            cm.sendCommandOneway(sessionTargetID, message);
-//         }
-//      }
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, new PacketImpl(PacketImpl.SESS_COMMIT))).andReturn(null);
-//      
-//      final int[] messages2 = new int[] { 43, 44, 50, 47, 48, 60, 45, 61, 62, 64 };
-//      
-//      ClientConsumerInternal cons1 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      ClientConsumerInternal cons2 = EasyMock.createStrictMock(ClientConsumerInternal.class);
-//      
-//      for (int i = 0; i < messages2.length; i++)
-//      {
-//         SessionAcknowledgeMessageBlah message = new SessionAcknowledgeMessageBlah(messages2[i], false);
-//         
-//         if (blockOnAcknowledge)
-//         {
-//            EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, message)).andReturn(null);
-//         }
-//         else
-//         {
-//            cm.sendCommandOneway(sessionTargetID, message);
-//         }
-//      }
-//      
-//      //Recover back to the last committed
-//      cons1.recover(36);
-//      cons2.recover(36);
-//            
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, new PacketImpl(PacketImpl.SESS_ROLLBACK))).andReturn(null);
-//                        
-//      EasyMock.replay(rc, cf, pd, cons1, cons2, cm);
-//      
-//      ClientSessionInternal session =
-//         new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, blockOnAcknowledge,rc, cf, pd, 100, cm);
-//      
-//      session.addConsumer(cons1);
-//      session.addConsumer(cons2);
-//      
-//      //Simulate some messages being delivered in a broken sequence (i.e. what would happen with a single consumer
-//      //on the session)
-//            
-//      for (int i = 0; i < messages.length; i++)
-//      {
-//         session.delivered(messages[i], false);
-//         
-//         session.acknowledge();
-//      }
-//      
-//      //Then commit
-//      session.commit();
-//      
-//      for (int i = 0; i < messages2.length; i++)
-//      {
-//         session.delivered(messages2[i], false);
-//         
-//         session.acknowledge();
-//      }
-//      
-//      session.rollback();
-//      
-//      EasyMock.verify(rc, cf, pd, cons1, cons2, cm); 
-//   }
-//   
-//   private void testCreateBrowser(boolean filter) throws Exception
-//   {
-//      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//          
-//      final long sessionTargetID = 7617622;      
-//      final SimpleString queueName = new SimpleString("gyugg");
-//      final SimpleString sfilter = filter ? new SimpleString("ygyg") : null;
-//      
-//      SessionCreateBrowserMessage request =
-//         new SessionCreateBrowserMessage(queueName, sfilter);             
-//      
-//      SessionCreateBrowserResponseMessage resp = 
-//         new SessionCreateBrowserResponseMessage(76675765);
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, request)).andReturn(resp);
-//      
-//      EasyMock.replay(rc, cf, pd, cm);
-//      
-//      ClientSessionInternal session = new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false,rc, cf, pd, 100, cm);
-//      
-//      if (filter)
-//      {
-//         ClientBrowser browser = session.createBrowser(queueName, sfilter);
-//      }
-//      else
-//      {
-//         ClientBrowser browser = session.createBrowser(queueName);
-//      }
-//      
-//      EasyMock.verify(rc, cf, pd, cm);
-//   }
-//   
-//   private void testCreateProducerWithWindowSizeMethod(final SimpleString address,
-//         final int windowSize, final int initialCredits,
-//         final int serverMaxRate,
-//         final boolean blockOnNPSend,
-//         final boolean blockOnPSend,
-//         final boolean autoCommitSends) throws Exception
-//   {
-//      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//
-//      // Defaults from cf
-//
-//      EasyMock.expect(cf.isBlockOnNonPersistentSend()).andReturn(blockOnNPSend);
-//
-//      EasyMock.expect(cf.isBlockOnPersistentSend()).andReturn(blockOnPSend);   
-//
-//      final long clientTargetID = 7676876;
-//
-//      EasyMock.expect(pd.generateID()).andReturn(clientTargetID);
-//
-//      final long sessionTargetID = 9121892;
-//
-//      SessionCreateProducerMessage request =
-//         new SessionCreateProducerMessage(clientTargetID, address, windowSize, -1);             
-//
-//      SessionCreateProducerResponseMessage resp = 
-//         new SessionCreateProducerResponseMessage(67765765, initialCredits, serverMaxRate);
-//
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, request)).andReturn(resp);
-//
-//
-//      pd.register(new ClientSessionPacketHandler(null, clientTargetID, null));
-//
-//      EasyMock.replay(cf, rc, pd, cm);
-//
-//      ClientSession session = new ClientSessionImpl("blah", sessionTargetID, false, -1, false, autoCommitSends, false, false,rc, cf, pd, 100, cm);
-//
-//      ClientProducerInternal producer = (ClientProducerInternal)session.createProducerWithWindowSize(address, windowSize);
-//
-//      EasyMock.verify(cf, rc, pd, cm);   
-//
-//      assertEquals(address, producer.getAddress());
-//      assertEquals(autoCommitSends && blockOnNPSend, producer.isBlockOnNonPersistentSend());
-//      assertEquals(autoCommitSends && blockOnPSend, producer.isBlockOnPersistentSend());
-//      assertEquals(initialCredits, producer.getInitialWindowSize());
-//      assertEquals(serverMaxRate, producer.getMaxRate());
-//   }
-//   
-//   private void testCreateProducerRateLimitedMethod(final SimpleString address,
-//                                                    final int maxRate, final int initialCredits,
-//                                                    final int serverMaxRate,
-//                                                    final boolean blockOnNPSend,
-//                                                    final boolean blockOnPSend,
-//                                                    final boolean autoCommitSends) throws Exception
-//   {
-//      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      // Defaults from cf
-//        
-//      EasyMock.expect(cf.isBlockOnNonPersistentSend()).andReturn(blockOnNPSend);
-//      
-//      EasyMock.expect(cf.isBlockOnPersistentSend()).andReturn(blockOnPSend);   
-//
-//      final long clientTargetID = 7676876;
-//
-//      EasyMock.expect(pd.generateID()).andReturn(clientTargetID);
-//
-//      final long sessionTargetID = 9121892;
-//
-//      SessionCreateProducerMessage request =
-//         new SessionCreateProducerMessage(clientTargetID, address, -1, maxRate);             
-//
-//      SessionCreateProducerResponseMessage resp = 
-//         new SessionCreateProducerResponseMessage(67765765, initialCredits, serverMaxRate);
-//
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, request)).andReturn(resp);
-//        
-//      pd.register(new ClientSessionPacketHandler(null, clientTargetID, null));
-//
-//      EasyMock.replay(cf, rc, pd, cm);
-//
-//      ClientSession session = new ClientSessionImpl("blah", sessionTargetID, false, -1, false, autoCommitSends, false, false,rc, cf, pd, 100, cm);
-//
-//      ClientProducerInternal producer = (ClientProducerInternal)session.createRateLimitedProducer(address, maxRate);
-//
-//      EasyMock.verify(cf, rc, pd, cm);
-//
-//      assertEquals(address, producer.getAddress());
-//      assertEquals(autoCommitSends && blockOnNPSend, producer.isBlockOnNonPersistentSend());
-//      assertEquals(autoCommitSends && blockOnPSend, producer.isBlockOnPersistentSend());
-//      assertEquals(initialCredits, producer.getInitialWindowSize());
-//      assertEquals(serverMaxRate, producer.getMaxRate());
-//   }
-//   
-//   private void testCreateProducerBasicMethod(final SimpleString address, final int windowSize,
-//         final int maxRate, final int initialCredits,
-//         final int serverMaxRate,
-//         final boolean blockOnNPSend,
-//         final boolean blockOnPSend,
-//         final boolean autoCommitSends) throws Exception
-//   {
-//      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      // Defaults from cf
-//      
-//      EasyMock.expect(cf.getProducerWindowSize()).andReturn(windowSize);
-//      
-//      EasyMock.expect(cf.getProducerMaxRate()).andReturn(maxRate);   
-//      
-//      EasyMock.expect(cf.isBlockOnNonPersistentSend()).andReturn(blockOnNPSend);
-//        
-//      EasyMock.expect(cf.isBlockOnPersistentSend()).andReturn(blockOnPSend);   
-//
-//      final long clientTargetID = 7676876;
-//
-//      EasyMock.expect(pd.generateID()).andReturn(clientTargetID);
-//
-//      final long sessionTargetID = 9121892;
-//
-//      SessionCreateProducerMessage request =
-//         new SessionCreateProducerMessage(clientTargetID, address, windowSize, maxRate);             
-//
-//      SessionCreateProducerResponseMessage resp = 
-//         new SessionCreateProducerResponseMessage(67765765, initialCredits, serverMaxRate);
-//
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, request)).andReturn(resp);
-//  
-//      pd.register(new ClientSessionPacketHandler(null, clientTargetID, null));
-//
-//      EasyMock.replay(cf, rc, pd, cm);
-//
-//      ClientSession session = new ClientSessionImpl("blah", sessionTargetID, false, -1, false, autoCommitSends, false, false,rc, cf, pd, 100, cm);
-//
-//      ClientProducerInternal producer = (ClientProducerInternal)session.createProducer(address);
-//
-//      EasyMock.verify(cf, rc, pd, cm);
-//
-//      assertEquals(address, producer.getAddress());
-//      assertEquals(autoCommitSends && blockOnNPSend, producer.isBlockOnNonPersistentSend());
-//      assertEquals(autoCommitSends && blockOnPSend, producer.isBlockOnPersistentSend());
-//      assertEquals(initialCredits, producer.getInitialWindowSize());
-//      assertEquals(serverMaxRate, producer.getMaxRate());
-//   }
-//   
-//   private void testCreateProducerWideMethod(final SimpleString address, final int windowSize,
-//                                             final int maxRate, final int initialCredits,
-//                                             final int serverMaxRate,
-//                                             final boolean blockOnNPSend,
-//                                             final boolean blockOnPSend,
-//                                             final boolean autoCommitSends) throws Exception
-//   {
-//      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//                        
-//      final long clientTargetID = 7676876;
-//      
-//      EasyMock.expect(pd.generateID()).andReturn(clientTargetID);
-//      
-//      final long sessionTargetID = 9121892;
-//      
-//      SessionCreateProducerMessage request =
-//         new SessionCreateProducerMessage(clientTargetID, address, windowSize, maxRate);             
-//      
-//      SessionCreateProducerResponseMessage resp = 
-//         new SessionCreateProducerResponseMessage(67765765, initialCredits, serverMaxRate);
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, request)).andReturn(resp);
-//      
-//      pd.register(new ClientSessionPacketHandler(null, clientTargetID, null));
-//      
-//      EasyMock.replay(cf, rc, pd, cm);
-//      
-//      ClientSession session = new ClientSessionImpl("blah", sessionTargetID, false, -1, false, autoCommitSends, false, false,rc, cf, pd, 100, cm);
-//
-//      ClientProducerInternal producer = (ClientProducerInternal)session.createProducer(address, windowSize, maxRate, blockOnNPSend, blockOnPSend);
-//      
-//      EasyMock.verify(cf, rc, pd, cm);
-//      
-//      assertEquals(address, producer.getAddress());
-//      assertEquals(autoCommitSends && blockOnNPSend, producer.isBlockOnNonPersistentSend());
-//      assertEquals(autoCommitSends && blockOnPSend, producer.isBlockOnPersistentSend());
-//      assertEquals(initialCredits, producer.getInitialWindowSize());
-//      assertEquals(serverMaxRate, producer.getMaxRate());
-//   }
-//   
-//   private void testCreateConsumerDefaultsMethod(final SimpleString queueName, final SimpleString filterString, final boolean noLocal,
-//         final boolean autoDeleteQueue, final boolean direct,
-//         final int windowSize, final int maxRate, final int serverWindowSize) throws Exception
-//   {
-//      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//         
-//      EasyMock.expect(cf.getConsumerWindowSize()).andReturn(windowSize);
-//      
-//      EasyMock.expect(cf.getConsumerMaxRate()).andReturn(maxRate);      
-//                  
-//      final long clientTargetID = 87126716;
-//      
-//      EasyMock.expect(pd.generateID()).andReturn(clientTargetID);
-//      
-//      final long sessionTargetID = 9121892;
-//      
-//      SessionCreateConsumerMessage request =
-//         new SessionCreateConsumerMessage(clientTargetID, queueName, filterString, 
-//                                          windowSize, maxRate);             
-//      
-//      SessionCreateConsumerResponseMessage resp = 
-//         new SessionCreateConsumerResponseMessage(656652, serverWindowSize);
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, request)).andReturn(resp);
-//      
-//      pd.register(new ClientConsumerPacketHandler(null, clientTargetID, null));
-//      
-//      cm.sendCommandOneway(resp.getConsumerTargetID(), 
-//                    new SessionConsumerFlowCreditMessage(resp.getWindowSize()));
-//      
-//      EasyMock.replay(cf, rc, pd, cm);
-//      ClientSession session = new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false,rc, cf, pd, 100, cm);
-//      
-//      ClientConsumerInternal consumer =
-//         (ClientConsumerInternal)session.createConsumer(queueName, filterString,
-//                                                                   direct);              
-//      EasyMock.verify(cf, rc, pd, cm);
-//      
-//      assertEquals(clientTargetID, consumer.getClientTargetID());
-//      
-//      if (serverWindowSize == -1)
-//      {
-//         assertEquals(0, consumer.getClientWindowSize());
-//      }
-//      else if (serverWindowSize == 1)
-//      {
-//         assertEquals(1, consumer.getClientWindowSize());
-//      }
-//      else if (serverWindowSize > 1)
-//      {
-//         assertEquals(serverWindowSize >> 1, consumer.getClientWindowSize());
-//      }
-//   }
-//   
-//   private void testCreateConsumerWideMethod(final SimpleString queueName, final SimpleString filterString, final boolean noLocal,
-//         final boolean autoDeleteQueue, final boolean direct,
-//         final int windowSize, final int maxRate, final int serverWindowSize) throws Exception
-//   {
-//      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      final long clientTargetID = 87126716;
-//      
-//      EasyMock.expect(pd.generateID()).andReturn(clientTargetID);
-//      
-//      final long sessionTargetID = 9121892;
-//      
-//      SessionCreateConsumerMessage request =
-//         new SessionCreateConsumerMessage(clientTargetID, queueName, filterString,
-//                                          windowSize, maxRate);             
-//      
-//      SessionCreateConsumerResponseMessage resp = 
-//         new SessionCreateConsumerResponseMessage(656652, serverWindowSize);
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, request)).andReturn(resp);
-//          
-//      pd.register(new ClientConsumerPacketHandler(null, clientTargetID, null));
-//      
-//      cm.sendCommandOneway(resp.getConsumerTargetID(), 
-//                    new SessionConsumerFlowCreditMessage(resp.getWindowSize()));
-//      
-//      EasyMock.replay(cf, rc, pd, cm);
-//      
-//      ClientSession session = new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false,rc, cf, pd, 100, cm);
-//      
-//      ClientConsumerInternal consumer = (ClientConsumerInternal)session.createConsumer(queueName, filterString,
-//                                                                   direct, windowSize, maxRate);    
-//      EasyMock.verify(cf, rc, pd, cm); 
-//      
-//      assertEquals(clientTargetID, consumer.getClientTargetID());
-//      
-//      if (serverWindowSize == -1)
-//      {
-//         assertEquals(0, consumer.getClientWindowSize());
-//      }
-//      else if (serverWindowSize == 1)
-//      {
-//         assertEquals(1, consumer.getClientWindowSize());
-//      }
-//      else if (serverWindowSize > 1)
-//      {
-//         assertEquals(serverWindowSize >> 1, consumer.getClientWindowSize());
-//      }
-//   }
-//   
-//   private void testCreateConsumerBasicMethod(final SimpleString queueName, final int windowSize,
-//         final int maxRate, final int serverWindowSize) throws Exception
-//   {
-//      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      EasyMock.expect(cf.getConsumerWindowSize()).andReturn(windowSize);
-//      
-//      EasyMock.expect(cf.getConsumerMaxRate()).andReturn(maxRate);   
-//       
-//      final long clientTargetID = 87126716;
-//      
-//      EasyMock.expect(pd.generateID()).andReturn(clientTargetID);
-//      
-//      final long sessionTargetID = 9121892;
-//      
-//      SessionCreateConsumerMessage request =
-//         new SessionCreateConsumerMessage(clientTargetID, queueName, null,
-//                                          windowSize, maxRate);             
-//      
-//      SessionCreateConsumerResponseMessage resp = 
-//         new SessionCreateConsumerResponseMessage(656652, serverWindowSize);
-//      
-//      EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, request)).andReturn(resp);
-//      
-//      pd.register(new ClientConsumerPacketHandler(null, clientTargetID, null));
-//      
-//      cm.sendCommandOneway(resp.getConsumerTargetID(), 
-//                    new SessionConsumerFlowCreditMessage(resp.getWindowSize()));
-//      
-//      EasyMock.replay(cf, rc, pd, cm);
-//      
-//      ClientSession session = new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false,rc, cf, pd, 100, cm);
-//      
-//      ClientConsumerInternal consumer = (ClientConsumerInternal)session.createConsumer(queueName);    
-//      EasyMock.verify(cf, rc, pd, cm);
-//      
-//      assertEquals(clientTargetID, consumer.getClientTargetID());
-//      
-//      if (serverWindowSize == -1)
-//      {
-//         assertEquals(0, consumer.getClientWindowSize());
-//      }
-//      else if (serverWindowSize == 1)
-//      {
-//         assertEquals(1, consumer.getClientWindowSize());
-//      }
-//      else if (serverWindowSize > 1)
-//      {
-//         assertEquals(serverWindowSize >> 1, consumer.getClientWindowSize());
-//      }
-//   }
-//   
-//   private void testConstructor(final long serverTargetID,
-//         final boolean xa,
-//         final int lazyAckBatchSize, final boolean cacheProducers,                            
-//         final boolean autoCommitSends, final boolean autoCommitAcks,
-//         final boolean blockOnAcknowledge,
-//         final int version) throws Exception
-//   {      
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);      
-//      ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
-//      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//      CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//      
-//      EasyMock.replay(rc, cf, pd, cm);
-//
-//      ClientSessionInternal session = new ClientSessionImpl("blah", serverTargetID, xa,
-//            lazyAckBatchSize, cacheProducers, autoCommitSends, autoCommitAcks, blockOnAcknowledge,
-//            rc, cf, pd, version, cm);
-//
-//      EasyMock.verify(rc, cf, pd, cm);
-//     
-//      assertEquals(xa, session.isXA());
-//      assertEquals(lazyAckBatchSize, session.getLazyAckBatchSize());
-//      assertEquals(cacheProducers, session.isCacheProducers());
-//      assertEquals(autoCommitSends, session.isAutoCommitSends());
-//      assertEquals(autoCommitAcks, session.isAutoCommitAcks());
-//      assertEquals(blockOnAcknowledge, session.isBlockOnAcknowledge());
-//      assertEquals(version, session.getVersion());
-//   }
-}
+   public void testCommit() throws Exception
+   {
+      expect(channel.sendBlocking(new PacketImpl(PacketImpl.SESS_COMMIT))).andReturn(new NullResponseMessage());
 
+      replayMocks();
+
+      session.commit();
+
+      verifyMocks();
+
+      // if there are consumers
+      resetMocks();
+
+      ClientConsumerInternal cons = createMock(ClientConsumerInternal.class);
+      expect(cons.getID()).andStubReturn(randomPositiveLong());
+      cons.flushAcks();
+      expect(channel.sendBlocking(new PacketImpl(PacketImpl.SESS_COMMIT))).andReturn(new NullResponseMessage());
+
+      replayMocks(cons);
+
+      session.addConsumer(cons);
+      session.commit();
+
+      verifyMocks(cons);
+   }
+
+   public void testXACommit() throws Exception
+   {
+      testXACommit(false, false);
+      testXACommit(false, true);
+      testXACommit(true, false);
+      testXACommit(true, true);
+   }
+
+   // public void testCleanUp2() throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   // ConnectionRegistry reg = EasyMock.createStrictMock(ConnectionRegistry.class);
+   //        
+   // final long sessionTargetID = 9121892;
+   //                  
+   // EasyMock.replay(rc, cf, pd, cm, reg);
+   //      
+   // ClientSessionImpl session =
+   // new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
+   // session.setConnectionRegistry(reg);
+   //      
+   // EasyMock.verify(rc, cf, pd, cm, reg);
+   //      
+   // EasyMock.reset(rc, cf, pd, cm, reg);
+   //      
+   // ClientProducerInternal prod1 = EasyMock.createStrictMock(ClientProducerInternal.class);
+   // ClientProducerInternal prod2 = EasyMock.createStrictMock(ClientProducerInternal.class);
+   //      
+   // ClientConsumerInternal cons1 = EasyMock.createStrictMock(ClientConsumerInternal.class);
+   // ClientConsumerInternal cons2 = EasyMock.createStrictMock(ClientConsumerInternal.class);
+   //      
+   // ClientBrowser browser1 = EasyMock.createStrictMock(ClientBrowser.class);
+   // ClientBrowser browser2 = EasyMock.createStrictMock(ClientBrowser.class);
+   //                    
+   // prod1.cleanUp();
+   // prod2.cleanUp();
+   // cons1.cleanUp();
+   // cons2.cleanUp();
+   // browser1.cleanUp();
+   // browser2.cleanUp();
+   //      
+   // cm.close();
+   // final String connectionID = "uahsjash";
+   // EasyMock.expect(rc.getID()).andStubReturn(connectionID);
+   // reg.returnConnection(connectionID);
+   //        
+   // EasyMock.replay(cf, pd, prod1, prod2, cons1, cons2, browser1, browser2, cm, reg, rc);
+   //                 
+   // session.addProducer(prod1);
+   // session.addProducer(prod2);
+   //      
+   // session.addConsumer(cons1);
+   // session.addConsumer(cons2);
+   //      
+   // session.addBrowser(browser1);
+   // session.addBrowser(browser2);
+   //      
+   // assertFalse(session.isClosed());
+   //      
+   // session.cleanUp();
+   //
+   // assertTrue(session.isClosed());
+   //      
+   // EasyMock.verify(rc, cf, pd, prod1, prod2, cons1, cons2, browser1, browser2, cm, reg, rc);
+   // }
+   //         
+
+   //   
+   // public void testXAEnd() throws Exception
+   // {
+   // testXAEnd(XAResource.TMSUSPEND, false);
+   // testXAEnd(XAResource.TMSUSPEND, true);
+   // testXAEnd(XAResource.TMSUCCESS, false);
+   // testXAEnd(XAResource.TMSUCCESS, true);
+   // testXAEnd(XAResource.TMFAIL, false);
+   // testXAEnd(XAResource.TMFAIL, true);
+   // }
+   //   
+   // public void testXAForget() throws Exception
+   // {
+   // testXAForget(false);
+   // testXAForget(true);
+   // }
+   //   
+   // public void testGetTransactionTimeout() throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   //        
+   // final long sessionTargetID = 9121892;
+   //      
+   // Packet packet = new PacketImpl(PacketImpl.SESS_XA_GET_TIMEOUT);
+   //
+   // final int timeout = 1098289;
+   //      
+   // SessionXAGetTimeoutResponseMessage resp = new SessionXAGetTimeoutResponseMessage(timeout);
+   //      
+   // EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
+   //                       
+   // EasyMock.replay(rc, cf, pd, cm);
+   //      
+   // ClientSessionInternal session =
+   // new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
+   //      
+   // int timeout2 = session.getTransactionTimeout();
+   //            
+   // EasyMock.verify(rc, cf, pd, cm);
+   //      
+   // assertEquals(timeout, timeout2);
+   // }
+   //   
+   // public void testIsSameRM() throws Exception
+   // {
+   // RemotingConnection rc1 = EasyMock.createStrictMock(RemotingConnection.class);
+   // RemotingConnection rc2 = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   //                               
+   // EasyMock.replay(rc1, rc2, cf, pd, cm);
+   //      
+   // ClientSessionInternal session1 =
+   // new ClientSessionImpl("blah", 4343, true, -1, false, false, false, false, rc1, cf, pd, 100, cm);
+   //      
+   // ClientSessionInternal session2 =
+   // new ClientSessionImpl("blah2", 4343, true, -1, false, false, false, false, rc2, cf, pd, 100, cm);
+   //      
+   // ClientSessionInternal session3 =
+   // new ClientSessionImpl("blah3", 4343, true, -1, false, false, false, false, rc2, cf, pd, 100, cm);
+   //      
+   // assertFalse(session1.isSameRM(session2));
+   // assertFalse(session2.isSameRM(session1));
+   //      
+   // assertTrue(session2.isSameRM(session3));
+   // assertTrue(session3.isSameRM(session2));
+   //      
+   // assertFalse(session1.isSameRM(session3));
+   // assertFalse(session3.isSameRM(session1));
+   //      
+   // assertTrue(session1.isSameRM(session1));
+   // assertTrue(session2.isSameRM(session2));
+   // assertTrue(session3.isSameRM(session3));
+   //      
+   // EasyMock.verify(rc1, rc2, cf, pd, cm);
+   // }
+   //   
+   // public void testXAPrepare() throws Exception
+   // {
+   // testXAPrepare(false, false);
+   // testXAPrepare(false, true);
+   // testXAPrepare(true, false);
+   // testXAPrepare(true, true);
+   // }
+   //   
+   // public void testXARecover() throws Exception
+   // {
+   // testXARecover(XAResource.TMNOFLAGS);
+   // testXARecover(XAResource.TMSTARTRSCAN);
+   // testXARecover(XAResource.TMENDRSCAN);
+   // testXARecover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN);
+   // }
+   //   
+   // public void testXARollback() throws Exception
+   // {
+   // testXARollback(true);
+   // testXARollback(false);
+   // }
+   //   
+   // public void testXASetTransactionTimeout() throws Exception
+   // {
+   // testXASetTransactionTimeout(false);
+   // testXASetTransactionTimeout(true);
+   // }
+   //   
+   // public void testXAStart() throws Exception
+   // {
+   // testXAStart(XAResource.TMJOIN, false);
+   // testXAStart(XAResource.TMRESUME, false);
+   // testXAStart(XAResource.TMNOFLAGS, false);
+   // testXAStart(XAResource.TMJOIN, true);
+   // testXAStart(XAResource.TMRESUME, true);
+   // testXAStart(XAResource.TMNOFLAGS, true);
+   // }
+   //
+   // public void testCleanUp1() throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   // ConnectionRegistry reg = EasyMock.createStrictMock(ConnectionRegistry.class);
+   //
+   // SessionCreateQueueMessage request = new SessionCreateQueueMessage(new SimpleString("blah"), new
+   // SimpleString("hagshg"),
+   // new SimpleString("jhjhs"), false, false);
+   //
+   // final int targetID = 121;
+   //
+   // EasyMock.expect(cm.sendCommandBlocking(targetID, request)).andReturn(null);
+   //
+   // EasyMock.replay(rc, cf, pd, cm);
+   //
+   // ClientSessionImpl session = new ClientSessionImpl("blah", targetID, false, -1, false, false, false, false, rc, cf,
+   // pd, 100, cm);
+   // session.setConnectionRegistry(reg);
+   //
+   // session.createQueue(request.getAddress(), request.getQueueName(), request.getFilterString(), request.isDurable(),
+   // request.isDurable());
+   //
+   // EasyMock.verify(rc, cf, pd, cm);
+   //
+   // EasyMock.reset(rc, cf, pd, cm);
+   // cm.close();
+   // final String connectionID = "uahsjash";
+   // EasyMock.expect(rc.getID()).andStubReturn(connectionID);
+   // reg.returnConnection(connectionID);
+   // EasyMock.replay(rc, cf, pd, cm);
+   // session.cleanUp();
+   // EasyMock.verify(rc, cf, pd, cm);
+   // }
+   //
+   // public void notXA() throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   //              
+   // final long sessionTargetID = 9121892;
+   //                  
+   // EasyMock.replay(rc, cf, pd, cm);
+   //      
+   // ClientSessionInternal session = new ClientSessionImpl("blah", sessionTargetID, false, -1, false, false, false,
+   // false, rc, cf, pd, 100, cm);
+   //      
+   // EasyMock.verify(rc, cf, pd, cm);
+   //      
+   // EasyMock.reset(rc, cf, pd, cm);
+   // try
+   // {
+   // session.commit(randomXid(), false);
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   //      
+   // try
+   // {
+   // session.end(randomXid(), 8778);
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   //      
+   // try
+   // {
+   // session.forget(randomXid());
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   //      
+   // try
+   // {
+   // session.getTransactionTimeout();
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   //      
+   // try
+   // {
+   // session.isSameRM(session);
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   //      
+   // try
+   // {
+   // session.prepare(randomXid());
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   //      
+   // try
+   // {
+   // session.recover(89787);
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   //      
+   // try
+   // {
+   // session.rollback(randomXid());
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   //      
+   // try
+   // {
+   // session.setTransactionTimeout(767);
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   //      
+   // try
+   // {
+   // session.start(randomXid(), 8768);
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   // }
+   //   
+   // public void testCreateMessage() throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // MessagingBuffer buff = EasyMock.createMock(MessagingBuffer.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   // EasyMock.expect(rc.createBuffer(ClientSessionImpl.INITIAL_MESSAGE_BODY_SIZE)).andStubReturn(buff);
+   // EasyMock.replay(rc);
+   //      
+   // ClientSessionInternal session =
+   // new ClientSessionImpl("blah", 453543, false, -1, false, false, false, false, rc, cf, pd, 100, cm);
+   //      
+   // ClientMessage msg = session.createClientMessage(false);
+   // assertFalse(msg.isDurable());
+   //      
+   // msg = session.createClientMessage(true);
+   // assertTrue(msg.isDurable());
+   //      
+   // final byte type = 123;
+   //      
+   // msg = session.createClientMessage(type, false);
+   // assertFalse(msg.isDurable());
+   // assertEquals(type, msg.getType());
+   //      
+   // msg = session.createClientMessage(type, true);
+   // assertTrue(msg.isDurable());
+   // assertEquals(type, msg.getType());
+   //            
+   // final long expiration = 120912902;
+   // final long timestamp = 1029128;
+   // final byte priority = 12;
+   //            
+   // msg = session.createClientMessage(type, false, expiration, timestamp, priority);
+   // assertFalse(msg.isDurable());
+   // assertEquals(type, msg.getType());
+   // assertEquals(expiration, msg.getExpiration());
+   // assertEquals(timestamp, msg.getTimestamp());
+   // assertEquals(priority, msg.getPriority());
+   //
+   // msg = session.createClientMessage(type, true, expiration, timestamp, priority);
+   // assertTrue(msg.isDurable());
+   // assertEquals(type, msg.getType());
+   // assertEquals(expiration, msg.getExpiration());
+   // assertEquals(timestamp, msg.getTimestamp());
+   // assertEquals(priority, msg.getPriority());
+   // }
+   //   
+   // // Private -------------------------------------------------------------------------------------------
+   //
+   public void testClose() throws Exception
+   {
+      ClientProducerInternal prod1 = EasyMock.createStrictMock(ClientProducerInternal.class);
+      ClientProducerInternal prod2 = EasyMock.createStrictMock(ClientProducerInternal.class);
+
+      ClientConsumerInternal cons1 = EasyMock.createStrictMock(ClientConsumerInternal.class);
+      ClientConsumerInternal cons2 = EasyMock.createStrictMock(ClientConsumerInternal.class);
+
+      prod1.close();
+      prod2.close();
+      expect(cons1.getID()).andStubReturn(randomPositiveLong());
+      cons1.close();
+      expect(cons2.getID()).andStubReturn(randomPositiveLong());
+      cons2.close();
+
+      expect(channel.sendBlocking(new SessionCloseMessage())).andReturn(new NullResponseMessage());
+
+      channel.close();
+      expect(rc.removeFailureListener(session)).andReturn(true);
+      cm.removeSession(session);
+
+      replayMocks(prod1, prod2, cons1, cons2);
+
+      session.addProducer(prod1);
+      session.addProducer(prod2);
+
+      session.addConsumer(cons1);
+      session.addConsumer(cons2);
+
+      assertFalse(session.isClosed());
+
+      session.close();
+
+      assertTrue(session.isClosed());
+
+      verifyMocks(prod1, prod2, cons1, cons2);
+
+   }
+
+   public void testCloseAClosedSession() throws Exception
+   {
+      expect(channel.sendBlocking(new SessionCloseMessage())).andReturn(new NullResponseMessage());
+
+      channel.close();
+      expect(rc.removeFailureListener(session)).andReturn(true);
+      cm.removeSession(session);
+
+      replayMocks();
+
+      assertFalse(session.isClosed());
+
+      session.close();
+
+      assertTrue(session.isClosed());
+
+      session.close(); // DO NOTHING
+
+      verifyMocks();
+   }
+
+   public void testForbiddenCallsOnClosedSession() throws Exception
+   {
+      expect(channel.sendBlocking(new SessionCloseMessage())).andReturn(new NullResponseMessage());
+
+      channel.close();
+      expect(rc.removeFailureListener(session)).andReturn(true);
+      cm.removeSession(session);
+
+      replayMocks();
+
+      assertFalse(session.isClosed());
+
+      session.close();
+
+      assertTrue(session.isClosed());
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.start();
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.stop();
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.createQueue(randomSimpleString(), randomSimpleString(), randomBoolean());
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.deleteQueue(randomSimpleString());
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.addDestination(randomSimpleString(), randomBoolean(), randomBoolean());
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.removeDestination(randomSimpleString(), randomBoolean());
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.queueQuery(randomSimpleString());
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.bindingQuery(randomSimpleString());
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.createConsumer(randomSimpleString());
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.createFileConsumer(new File("blah"), randomSimpleString());
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.createProducer();
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.commit();
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.rollback();
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.acknowledge(randomPositiveLong(), randomPositiveLong());
+         }
+      });
+
+      assertMessagingException(OBJECT_CLOSED, new SessionCaller()
+      {
+         public void call(ClientSessionImpl session) throws MessagingException
+         {
+            session.expire(randomPositiveLong(), randomPositiveLong());
+         }
+      });
+      verifyMocks();
+   }
+
+   //   
+   // private void testXAStart(int flags, boolean error) throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   //        
+   // final long sessionTargetID = 9121892;
+   //      
+   // Xid xid = randomXid();
+   //      
+   // Packet packet = null;
+   // if (flags == XAResource.TMJOIN)
+   // {
+   // packet = new SessionXAJoinMessage(xid);
+   // }
+   // else if (flags == XAResource.TMRESUME)
+   // {
+   // packet = new SessionXAResumeMessage(xid);
+   // }
+   // else if (flags == XAResource.TMNOFLAGS)
+   // {
+   // packet = new SessionXAStartMessage(xid);
+   // }
+   //
+   // final int numMessages = 10;
+   //      
+   // if (flags != XAResource.TMNOFLAGS)
+   // {
+   // SessionAcknowledgeMessageBlah msg = new SessionAcknowledgeMessageBlah(numMessages - 1, true);
+   //         
+   // cm.sendCommandOneway(sessionTargetID, msg);
+   // }
+   //      
+   // SessionXAResponseMessage resp = new SessionXAResponseMessage(error, XAException.XAER_RMERR, "blah");
+   //      
+   // EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
+   //                       
+   // EasyMock.replay(rc, cf, pd, cm);
+   //      
+   // ClientSessionInternal session = new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false,
+   // false, rc, cf, pd, 100, cm);
+   //      
+   // //Simulate some unflushed messages
+   //      
+   // for (int i = 0; i < numMessages; i++)
+   // {
+   // session.delivered(i, false);
+   // session.acknowledge();
+   // }
+   //      
+   // if (error)
+   // {
+   // try
+   // {
+   // session.start(xid, flags);
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   // }
+   // else
+   // {
+   // session.start(xid, flags);
+   // }
+   //      
+   // EasyMock.verify(rc, cf, pd, cm);
+   // }
+   //   
+   // private void testXASetTransactionTimeout(boolean error) throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   //        
+   // final long sessionTargetID = 9121892;
+   //      
+   // final int timeout = 1897217;
+   //      
+   // SessionXASetTimeoutMessage packet = new SessionXASetTimeoutMessage(timeout);
+   //      
+   // SessionXASetTimeoutResponseMessage resp = new SessionXASetTimeoutResponseMessage(!error);
+   //      
+   // EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
+   //                       
+   // EasyMock.replay(rc, cf, pd, cm);
+   //      
+   // ClientSessionInternal session =
+   // new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
+   //      
+   // boolean ok = session.setTransactionTimeout(timeout);
+   //      
+   // assertTrue(ok == !error);
+   //      
+   // EasyMock.verify(rc, cf, pd, cm);
+   // }
+   //   
+   // private void testXARollback(boolean error) throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   //           
+   // final long sessionTargetID = 9121892;
+   //      
+   // Xid xid = randomXid();
+   //      
+   // SessionXARollbackMessage packet = new SessionXARollbackMessage(xid);
+   //      
+   // SessionXAResponseMessage resp = new SessionXAResponseMessage(error, XAException.XAER_RMERR, "blah");
+   //      
+   // EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
+   //                       
+   // EasyMock.replay(rc, cf, pd, cm);
+   //      
+   // ClientSessionInternal session =
+   // new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
+   //      
+   // if (error)
+   // {
+   // try
+   // {
+   // session.rollback(xid);
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   // }
+   // else
+   // {
+   // session.rollback(xid);
+   // }
+   //      
+   // EasyMock.verify(rc, cf, pd, cm);
+   // }
+   //   
+   // private void testXARecover(final int flags) throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   //      
+   // final long sessionTargetID = 9121892;
+   //      
+   // final Xid[] xids = new Xid[] { randomXid(), randomXid(), randomXid() } ;
+   //                  
+   // if ((flags & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN)
+   // {
+   // PacketImpl packet = new PacketImpl(PacketImpl.SESS_XA_INDOUBT_XIDS);
+   //         
+   // SessionXAGetInDoubtXidsResponseMessage resp = new SessionXAGetInDoubtXidsResponseMessage(Arrays.asList(xids));
+   //         
+   // EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
+   // }
+   //                       
+   // EasyMock.replay(rc, cf, pd, cm);
+   //      
+   // ClientSessionInternal session =
+   // new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
+   //      
+   // Xid[] xids2 = session.recover(flags);
+   //      
+   // if ((flags & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN)
+   // {
+   // assertEquals(xids.length, xids2.length);
+   //         
+   // for (int i = 0; i < xids.length; i++)
+   // {
+   // assertEquals(xids[i], xids2[i]);
+   // }
+   // }
+   // else
+   // {
+   // assertTrue(xids2.length == 0);
+   // }
+   //      
+   // EasyMock.verify(rc, cf, pd, cm);
+   // }
+   //   
+   // private void testXAPrepare(boolean error, boolean readOnly) throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   //        
+   // final long sessionTargetID = 9121892;
+   //      
+   // Xid xid = randomXid();
+   //      
+   // SessionXAPrepareMessage packet = new SessionXAPrepareMessage(xid);
+   //      
+   // SessionXAResponseMessage resp = new SessionXAResponseMessage(error, error ? XAException.XAER_RMERR : readOnly ?
+   // XAResource.XA_RDONLY : XAResource.XA_OK, "blah");
+   //      
+   // EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
+   //                       
+   // EasyMock.replay(rc, cf, pd, cm);
+   //      
+   // ClientSessionInternal session =
+   // new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
+   //      
+   // if (error)
+   // {
+   // try
+   // {
+   // session.prepare(xid);
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   // }
+   // else
+   // {
+   // int res = session.prepare(xid);
+   //         
+   // if (readOnly)
+   // {
+   // assertEquals(XAResource.XA_RDONLY, res);
+   // }
+   // else
+   // {
+   // assertEquals(XAResource.XA_OK, res);
+   // }
+   // }
+   //      
+   // EasyMock.verify(rc, cf, pd, cm);
+   // }
+   //   
+   // private void testXAForget(final boolean error) throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   //        
+   // final long sessionTargetID = 9121892;
+   //      
+   // Xid xid = randomXid();
+   //      
+   // Packet packet = new SessionXAForgetMessage(xid);
+   //
+   // final int numMessages = 10;
+   //      
+   // SessionAcknowledgeMessageBlah msg = new SessionAcknowledgeMessageBlah(numMessages - 1, true);
+   //      
+   // cm.sendCommandOneway(sessionTargetID, msg);
+   //      
+   // SessionXAResponseMessage resp = new SessionXAResponseMessage(error, XAException.XAER_RMERR, "blah");
+   //      
+   // EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
+   //                       
+   // EasyMock.replay(rc, cf, pd, cm);
+   //      
+   // ClientSessionInternal session =
+   // new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false, false, rc, cf, pd, 100, cm);
+   //      
+   // //Simulate some unflushed messages
+   //      
+   // for (int i = 0; i < numMessages; i++)
+   // {
+   // session.delivered(i, false);
+   // session.acknowledge();
+   // }
+   //      
+   // if (error)
+   // {
+   // try
+   // {
+   // session.forget(xid);
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   // }
+   // else
+   // {
+   // session.forget(xid);
+   // }
+   //      
+   // EasyMock.verify(rc, cf, pd, cm);
+   // }
+   //   
+   // private void testXAEnd(int flags, boolean error) throws Exception
+   // {
+   // RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+   // ClientSessionFactory cf = EasyMock.createStrictMock(ClientSessionFactory.class);
+   // PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
+   // CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
+   //        
+   // final long sessionTargetID = 9121892;
+   //      
+   // Xid xid = randomXid();
+   //      
+   // Packet packet = null;
+   // if (flags == XAResource.TMSUSPEND)
+   // {
+   // packet = new PacketImpl(PacketImpl.SESS_XA_SUSPEND);
+   // }
+   // else if (flags == XAResource.TMSUCCESS)
+   // {
+   // packet = new SessionXAEndMessage(xid, false);
+   // }
+   // else if (flags == XAResource.TMFAIL)
+   // {
+   // packet = new SessionXAEndMessage(xid, true);
+   // }
+   //
+   // final int numMessages = 10;
+   //      
+   // SessionAcknowledgeMessageBlah msg = new SessionAcknowledgeMessageBlah(numMessages - 1, true);
+   //      
+   // cm.sendCommandOneway(sessionTargetID, msg);
+   //      
+   // SessionXAResponseMessage resp = new SessionXAResponseMessage(error, XAException.XAER_RMERR, "blah");
+   //      
+   // EasyMock.expect(cm.sendCommandBlocking(sessionTargetID, packet)).andReturn(resp);
+   //                       
+   // EasyMock.replay(rc, cf, pd, cm);
+   //      
+   // ClientSessionInternal session = new ClientSessionImpl("blah", sessionTargetID, true, -1, false, false, false,
+   // false,rc, cf, pd, 100, cm);
+   //      
+   // //Simulate some unflushed messages
+   //      
+   // for (int i = 0; i < numMessages; i++)
+   // {
+   // session.delivered(i, false);
+   // session.acknowledge();
+   // }
+   //      
+   // if (error)
+   // {
+   // try
+   // {
+   // session.end(xid, flags);
+   // fail("Should throw exception");
+   // }
+   // catch (XAException e)
+   // {
+   // assertEquals(XAException.XAER_RMERR, e.errorCode);
+   // }
+   // }
+   // else
+   // {
+   // session.end(xid, flags);
+   // }
+   //      
+   // EasyMock.verify(rc, cf, pd, cm);
+   // }
+   //   
+   private void testXACommit(final boolean onePhase, boolean error) throws Exception
+   {
+      resetMocks();
+
+      final Xid xid = randomXid();
+
+      SessionXACommitMessage packet = new SessionXACommitMessage(xid, onePhase);
+      SessionXAResponseMessage resp = new SessionXAResponseMessage(error, XAException.XAER_RMERR, randomString());
+
+      expect(channel.sendBlocking(packet)).andReturn(resp);
+      replayMocks();
+
+      if (error)
+      {
+         assertXAException(XAException.XAER_RMERR, new SessionCaller()
+         {
+            public void call(ClientSessionImpl session) throws Exception
+            {
+               session.commit(xid, onePhase);
+            }
+         });
+      }
+      else
+      {
+         session.commit(xid, onePhase);
+      }
+
+      verifyMocks();
+   }
+
+   // Protected -----------------------------------------------------
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      cm = EasyMock.createMock(ConnectionManager.class);
+      rc = createMock(RemotingConnection.class);
+      channel = createMock(Channel.class);
+
+      autoCommitSends = randomBoolean();
+      consumerWindowSize = randomPositiveInt();
+      consumerMaxRate = randomPositiveInt();
+      session = new ClientSessionImpl(cm,
+                                      randomString(),
+                                      true,
+                                      autoCommitSends,
+                                      true,
+                                      false,
+                                      true,
+                                      true,
+                                      1,
+                                      consumerWindowSize,
+                                      consumerMaxRate,
+                                      1,
+                                      true,
+                                      true,
+                                      1,
+                                      rc,
+                                      1,
+                                      channel);
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      cm = null;
+      rc = null;
+      channel = null;
+      session = null;
+
+      super.tearDown();
+   }
+   
+   // Private -----------------------------------------------------
+
+   private void testAcknowledge(boolean blockOnAck) throws Exception
+   {
+      resetMocks();
+      
+      long messageID = randomPositiveLong();
+      long consumerID = randomPositiveLong();
+      
+      boolean preack = false;
+      session = new ClientSessionImpl(cm,
+                                      randomString(),
+                                      true,
+                                      autoCommitSends,
+                                      true,
+                                      preack,
+                                      blockOnAck,
+                                      true,
+                                      1,
+                                      consumerWindowSize,
+                                      consumerMaxRate,
+                                      1,
+                                      true,
+                                      true,
+                                      1,
+                                      rc,
+                                      1,
+                                      channel);
+      
+      if (blockOnAck)
+      {
+         expect(channel.sendBlocking(new SessionAcknowledgeMessage(consumerID, messageID, true))).andReturn(new NullResponseMessage());
+      } else
+      {
+         channel.send(new SessionAcknowledgeMessage(consumerID, messageID, false));
+      }
+
+      replayMocks();
+      
+      session.acknowledge(consumerID, messageID);
+      
+      verifyMocks();
+   }
+   
+   private void replayMocks(Object... additionalMocks)
+   {
+      replay(cm, rc, channel);
+      replay(additionalMocks);
+   }
+
+   private void resetMocks(Object... additionalMocks)
+   {
+      reset(cm, rc, channel);
+      reset(additionalMocks);
+   }
+
+   private void verifyMocks(Object... additionalMocks)
+   {
+      verify(cm, rc, channel);
+      verify(additionalMocks);
+   }
+
+   private void assertMessagingException(int errorCode, SessionCaller caller) throws Exception
+   {
+      try
+      {
+         caller.call(session);
+         fail("Should throw a MessagingException");
+      }
+      catch (MessagingException e)
+      {
+         assertEquals(errorCode, e.getCode());
+      }
+   }
+
+   private void assertXAException(int errorCode, SessionCaller caller) throws Exception
+   {
+      try
+      {
+         caller.call(session);
+         fail("Should throw a XAException");
+      }
+      catch (XAException e)
+      {
+         assertEquals(errorCode, e.errorCode);
+      }
+   }
+
+   // Inner classes -------------------------------------------------
+   
+   public interface SessionCaller
+   {
+      void call(ClientSessionImpl session) throws Exception;
+   }
+
+}




More information about the jboss-cvs-commits mailing list