[jboss-cvs] JBoss Messaging SVN: r4467 - trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jun 13 16:01:55 EDT 2008


Author: timfox
Date: 2008-06-13 16:01:54 -0400 (Fri, 13 Jun 2008)
New Revision: 4467

Added:
   trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientProducerPacketHandlerTest.java
Log:
Added file


Added: trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientProducerPacketHandlerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientProducerPacketHandlerTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientProducerPacketHandlerTest.java	2008-06-13 20:01:54 UTC (rev 4467)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.tests.unit.core.client.impl;
+
+import org.easymock.EasyMock;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.impl.ClientProducerInternal;
+import org.jboss.messaging.core.client.impl.ClientProducerPacketHandler;
+import org.jboss.messaging.core.remoting.PacketReturner;
+import org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket;
+import org.jboss.messaging.core.remoting.impl.wireformat.ProducerFlowCreditMessage;
+import org.jboss.messaging.tests.util.UnitTestCase;
+
+/**
+ * 
+ * A ClientProducerPacketHandlerTest
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class ClientProducerPacketHandlerTest extends UnitTestCase
+{
+   public void testHandle() throws Exception
+   {
+      ClientProducerInternal producer = EasyMock.createStrictMock(ClientProducerInternal.class);
+      
+      final int id = 716276;
+      
+      ClientProducerPacketHandler handler = new ClientProducerPacketHandler(producer, id);
+         
+      final int credits = 918298;
+      
+      ProducerFlowCreditMessage msg = new ProducerFlowCreditMessage(credits);
+                 
+      assertEquals(id, handler.getID());
+      
+      producer.receiveCredits(credits);
+      
+      EasyMock.replay(producer);
+      
+      handler.handle(msg, EasyMock.createStrictMock(PacketReturner.class));
+      
+      EasyMock.verify(producer);
+      
+      try
+      {
+         handler.handle(new EmptyPacket(EmptyPacket.CONN_START), EasyMock.createStrictMock(PacketReturner.class));
+         fail("Should throw Exception");
+      }
+      catch (IllegalStateException e)
+      {
+         //Ok
+      }
+   }
+   
+   // Private -----------------------------------------------------------------------------------------------------------
+
+}




More information about the jboss-cvs-commits mailing list