commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1573038 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/bzip2/PythonTruncatedBzip2Test.java
Date Fri, 28 Feb 2014 19:29:12 GMT
Author: sebb
Date: Fri Feb 28 19:29:12 2014
New Revision: 1573038

URL: http://svn.apache.org/r1573038
Log:
Arrays#copyOfRange is Java 1.6+; replace with basic local implementation

Modified:
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/bzip2/PythonTruncatedBzip2Test.java

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/bzip2/PythonTruncatedBzip2Test.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/bzip2/PythonTruncatedBzip2Test.java?rev=1573038&r1=1573037&r2=1573038&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/bzip2/PythonTruncatedBzip2Test.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/bzip2/PythonTruncatedBzip2Test.java
Fri Feb 28 19:29:12 2014
@@ -57,7 +57,7 @@ public class PythonTruncatedBzip2Test {
         DATA = out.toByteArray();
 
         // Drop the eos_magic field (6 bytes) and CRC (4 bytes).
-        TRUNCATED_DATA = Arrays.copyOfRange(DATA, 0, DATA.length - 10);
+        TRUNCATED_DATA = copyOfRange(DATA, 0, DATA.length - 10);
     }
 
     @Before
@@ -91,7 +91,7 @@ public class PythonTruncatedBzip2Test {
         ByteBuffer buffer = ByteBuffer.allocate(length);
         bz2Channel.read(buffer);
 
-        assertArrayEquals(Arrays.copyOfRange(TEXT.getBytes(), 0, length),
+        assertArrayEquals(copyOfRange(TEXT.getBytes(), 0, length),
                 buffer.array());
 
         // subsequent read should throw
@@ -110,4 +110,13 @@ public class PythonTruncatedBzip2Test {
 
         return Channels.newChannel(bZin);
     }
+
+    // Helper method since Arrays#copyOfRange is Java 1.6+
+    // Does not check parameters, so may fail if they are incompatible
+    private static byte[] copyOfRange(byte[] original, int from, int to) {
+        int length = to - from;
+        byte buff[] = new byte[length];
+        System.arraycopy(original, from, buff, 0, length);
+        return buff;
+    }
 }



Mime
View raw message