You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2008/11/05 19:35:03 UTC

svn commit: r711650 - /jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/tcp/sampler/TCPClientDecoratorTest.java

Author: sebb
Date: Wed Nov  5 10:35:03 2008
New Revision: 711650

URL: http://svn.apache.org/viewvc?rev=711650&view=rev
Log:
Add error tests

Modified:
    jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/tcp/sampler/TCPClientDecoratorTest.java

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/tcp/sampler/TCPClientDecoratorTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/tcp/sampler/TCPClientDecoratorTest.java?rev=711650&r1=711649&r2=711650&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/tcp/sampler/TCPClientDecoratorTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/tcp/sampler/TCPClientDecoratorTest.java Wed Nov  5 10:35:03 2008
@@ -141,6 +141,29 @@
         assertEquals(-1, ba[2]);
         assertEquals(-1, ba[3]);
 
+        // Check illegal array lengths
+        try {
+            ba = TCPClientDecorator.intToByteArray(0, 0);
+            fail();
+        } catch (IllegalArgumentException iae) {
+        }
+
+        try {
+            ba = TCPClientDecorator.intToByteArray(0, 1);
+            fail();
+        } catch (IllegalArgumentException iae) {
+        }
+
+        try {
+            ba = TCPClientDecorator.intToByteArray(0, 3);
+            fail();
+        } catch (IllegalArgumentException iae) {
+        }
+        try {
+            ba = TCPClientDecorator.intToByteArray(0, 5);
+            fail();
+        } catch (IllegalArgumentException iae) {
+        }
     }
 
     public void testByteArrayToInt() throws Exception {
@@ -175,6 +198,43 @@
 
         ba = new byte[] { 127, -1, -1, -1 };
         assertEquals(Integer.MAX_VALUE, TCPClientDecorator.byteArrayToInt(ba));
+
+        // test invalid byte arrays
+        try {
+            TCPClientDecorator.byteArrayToInt(null);
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException expected){
+            // ignored
+        }
+
+        try {
+            TCPClientDecorator.byteArrayToInt(new byte[]{});
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException expected){
+            // ignored
+        }
+
+        try {
+            TCPClientDecorator.byteArrayToInt(new byte[]{0});
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException expected){
+            // ignored
+        }
+
+        try {
+            TCPClientDecorator.byteArrayToInt(new byte[]{0,0,0});
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException expected){
+            // ignored
+        }
+
+        try {
+            TCPClientDecorator.byteArrayToInt(new byte[]{0,0,0});
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException expected){
+            // ignored
+        }
+
     }
 
     
@@ -184,5 +244,4 @@
         assertEquals(Integer.MIN_VALUE, TCPClientDecorator.byteArrayToInt(TCPClientDecorator.intToByteArray(Integer.MIN_VALUE, 4)));      
         assertEquals(Integer.MAX_VALUE, TCPClientDecorator.byteArrayToInt(TCPClientDecorator.intToByteArray(Integer.MAX_VALUE, 4)));      
     }
-
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org