You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2012/12/11 09:44:45 UTC

svn commit: r1420034 - /qpid/proton/trunk/proton-j/proton/src/test/java/org/apache/qpid/proton/engine/impl/ssl/ByteHolderTest.java

Author: kwall
Date: Tue Dec 11 08:44:44 2012
New Revision: 1420034

URL: http://svn.apache.org/viewvc?rev=1420034&view=rev
Log:
PROTON-172 improved unit test to check return value from methods.

Applied patch from Philip Harvey<ph...@philharveyonline.com>.

Modified:
    qpid/proton/trunk/proton-j/proton/src/test/java/org/apache/qpid/proton/engine/impl/ssl/ByteHolderTest.java

Modified: qpid/proton/trunk/proton-j/proton/src/test/java/org/apache/qpid/proton/engine/impl/ssl/ByteHolderTest.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/test/java/org/apache/qpid/proton/engine/impl/ssl/ByteHolderTest.java?rev=1420034&r1=1420033&r2=1420034&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/test/java/org/apache/qpid/proton/engine/impl/ssl/ByteHolderTest.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/test/java/org/apache/qpid/proton/engine/impl/ssl/ByteHolderTest.java Tue Dec 11 08:44:44 2012
@@ -32,12 +32,15 @@ import org.junit.Test;
 
 public class ByteHolderTest
 {
-    private ByteHolder _byteHolder = new ByteHolder(10);
+    private static final int CAPACITY = 10;
+    private ByteHolder _byteHolder = new ByteHolder(CAPACITY);
 
     @Test
     public void testEmptyOutput()
     {
-        _byteHolder.writeOutputFrom(new CannedTransportOutput(""));
+        int bytesContained = _byteHolder.writeOutputFrom(new CannedTransportOutput(""));
+
+        assertEquals(0, bytesContained);
         assertByteBufferContents(_byteHolder.prepareToRead(), "");
     }
 
@@ -47,8 +50,9 @@ public class ByteHolderTest
         String smallOutput = "1234";
         assertTrue(smallOutput.length() < _byteHolder.getCapacity());
 
-        _byteHolder.writeOutputFrom(new CannedTransportOutput(smallOutput));
+        int bytesContained = _byteHolder.writeOutputFrom(new CannedTransportOutput(smallOutput));
 
+        assertEquals(smallOutput.length(), bytesContained);
         assertTrue(_byteHolder.hasSpace());
         assertByteBufferContents(_byteHolder.prepareToRead(), smallOutput);
     }
@@ -59,7 +63,9 @@ public class ByteHolderTest
         String bigOutput = "1234567890xxxxx";
         assertTrue(bigOutput.length() > _byteHolder.getCapacity());
 
-        _byteHolder.writeOutputFrom(new CannedTransportOutput(bigOutput));
+        int bytesContained = _byteHolder.writeOutputFrom(new CannedTransportOutput(bigOutput));
+
+        assertEquals(CAPACITY, bytesContained);
         assertFalse(_byteHolder.hasSpace());
         assertByteBufferContents(_byteHolder.prepareToRead(), "1234567890");
     }
@@ -70,7 +76,9 @@ public class ByteHolderTest
         String bigOutput = "1234567890";
         assertTrue("Neither too big nor too small - the Goldilocks case", bigOutput.length() == _byteHolder.getCapacity());
 
-        _byteHolder.writeOutputFrom(new CannedTransportOutput(bigOutput));
+        int bytesContained = _byteHolder.writeOutputFrom(new CannedTransportOutput(bigOutput));
+
+        assertEquals(bigOutput.length(), bytesContained);
         assertFalse(_byteHolder.hasSpace());
         assertByteBufferContents(_byteHolder.prepareToRead(), "1234567890");
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org