[jboss-cvs] JBoss Messaging SVN: r4564 - in trunk/tests/src/org/jboss/messaging/tests: unit/core/util and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 23 12:44:55 EDT 2008


Author: clebert.suconic at jboss.com
Date: 2008-06-23 12:44:54 -0400 (Mon, 23 Jun 2008)
New Revision: 4564

Added:
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/IoBufferWrapper2Test.java
Modified:
   trunk/tests/src/org/jboss/messaging/tests/unit/core/util/MessagingBufferTestBase.java
Log:
Adding tests to complete coverage

Added: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/IoBufferWrapper2Test.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/IoBufferWrapper2Test.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/IoBufferWrapper2Test.java	2008-06-23 16:44:54 UTC (rev 4564)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * 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.integration.core.remoting.mina;
+
+import org.jboss.messaging.core.remoting.impl.mina.IoBufferWrapper;
+import org.jboss.messaging.tests.unit.core.util.MessagingBufferTestBase;
+import org.jboss.messaging.util.MessagingBuffer;
+
+/**
+ * Same as IoBufferWrapperTest, but using a different constructor
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * @author <a href="mailto:csuconic at redhat.com">Clebert Suconic</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class IoBufferWrapper2Test extends MessagingBufferTestBase
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   // BufferWrapperBase overrides -----------------------------------
+   
+   @Override
+   protected MessagingBuffer createBuffer()
+   {
+      return new IoBufferWrapper(512);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/util/MessagingBufferTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/util/MessagingBufferTestBase.java	2008-06-23 16:31:32 UTC (rev 4563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/util/MessagingBufferTestBase.java	2008-06-23 16:44:54 UTC (rev 4564)
@@ -125,6 +125,27 @@
       assertEquals(b, wrapper.getByte());
    }
    
+   public void testUnsignedByte() throws Exception
+   {
+      byte b = (byte) 0xff;
+      wrapper.putByte(b);
+      
+      wrapper.flip();
+      
+      assertEquals(255, wrapper.getUnsignedByte());
+
+      wrapper.rewind();
+      
+      b = (byte) 0xf;
+      wrapper.putByte(b);
+      
+      wrapper.flip();
+      
+      assertEquals(b, wrapper.getUnsignedByte());
+   }
+   
+   
+   
    public void testBytes() throws Exception
    {
       byte[] bytes = randomBytes();
@@ -213,6 +234,45 @@
       assertEquals(l, wrapper.getLong());
    }
    
+   public void testUnsignedShort() throws Exception
+   {
+      short s1 = Short.MAX_VALUE;
+      
+      wrapper.putShort(s1);
+      
+      wrapper.flip();
+      
+      int s2 = wrapper.getUnsignedShort();
+      
+      assertEquals((int) s1, s2);
+      
+      wrapper.rewind();
+      
+      s1 = Short.MIN_VALUE;
+      
+      wrapper.putShort(s1);
+      
+      wrapper.flip();
+      
+      s2 = wrapper.getUnsignedShort();
+      
+      assertEquals(((int) s1) * -1, s2);
+      
+      wrapper.rewind();
+      
+      s1 = -1;
+      
+      wrapper.putShort(s1);
+      
+      wrapper.flip();
+      
+      s2 = wrapper.getUnsignedShort();
+      
+      // / The max of an unsigned short
+      // (http://en.wikipedia.org/wiki/Unsigned_short)
+      assertEquals(s2, 65535);
+   }
+   
    public void testShort() throws Exception
    {
       wrapper.putShort((short) 1);




More information about the jboss-cvs-commits mailing list