-import static org.junit.Assert.fail;\r
-\r
-import java.io.BufferedInputStream;\r
-import java.io.BufferedOutputStream;\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.FileOutputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.OutputStream;\r
-import java.util.Arrays;\r
-\r
-import junit.framework.Assert;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-@SuppressWarnings("deprecation")\r
-public class FastLZBasicTests {\r
-\r
- static File testData1;\r
- static File testData2;\r
- static File testDataPrime;\r
-\r
- @BeforeClass\r
- public static void initialize() throws IOException {\r
- FastLZ.initialize(null);\r
-\r
- testData1 = new File("uncompressed.data");\r
- writeTestData(testData1, 10000000);\r
- testData2 = new File("uncompressed-small.data");\r
- writeTestData(testData2, 100000);\r
- testDataPrime = new File("uncompressed-prime.data");\r
- writeTestData(testDataPrime, 1000);\r
-\r
- System.out.println("test data directory: " + testData1.getAbsolutePath());\r
-\r
-// File javaFlz = new File("compressed-prime.data.native.flz");\r
-// for (int i = 0; i < 100; ++i) {\r
-// compressFlzJava(testDataPrime, javaFlz);\r
-// }\r
- }\r
-\r
- @Test\r
- public void validateCompress() throws IOException {\r
- validateCompress(testData1);\r
- }\r
-\r
- private void validateCompress(File testData) throws IOException {\r
- System.out.println("==== validateCompress(" + testData.getName() + ") ====");\r
-\r
- File nativeFlz = new File("compressed.data.native.flz");\r
- long nativeCompressedSize = compressFlzNative(testData, nativeFlz);\r
- System.out.println("native compressed size: " + nativeCompressedSize);\r
-\r
- // Need to prime JVM JIT by performing multiple passes\r
- File javaFlz = new File("compressed.data.java.flz");\r
- long javaCompressedSize = compressFlzJava(testData, javaFlz);\r
- System.out.println("java compressed size: " + javaCompressedSize);\r
-\r
- Assert.assertEquals(nativeCompressedSize, javaCompressedSize);\r
-\r
- System.out.println("Comparing compressed outputs...");\r
- compareFiles(nativeFlz, javaFlz);\r
- System.out.println("Compressed outputs match.");\r
-\r
- File decompressedNativeFlz = new File("decompressed.data.native.flz");\r
- File decompressedJavaFlz = new File("decompressed.data.java.flz");\r
- decompressFlzNative(nativeFlz, decompressedNativeFlz);\r
- decompressFlzNative(javaFlz, decompressedJavaFlz);\r
- compareFiles(decompressedJavaFlz, decompressedNativeFlz);\r
- compareFiles(decompressedNativeFlz, testData);\r
- }\r
-\r
-// @Test\r
-// public void validateCompressSmall() throws IOException {\r
-// File nativeFlz = new File("compressed-small.data.native.flz");\r
-// long nativeCompressedSize = compressFlzNative(testData2, nativeFlz);\r
-// System.out.println("native compressed size: " + nativeCompressedSize);\r
-//\r
-// // Need to prime JVM JIT by performing multiple passes\r
-// File javaFlz = new File("compressed-small.data.java.flz");\r
-// long javaCompressedSize = compressFlzJava(testData2, javaFlz);\r
-// System.out.println("java compressed size: " + javaCompressedSize);\r
-//\r
-// Assert.assertEquals(nativeCompressedSize, javaCompressedSize);\r
-//\r
-// System.out.println("Comparing compressed outputs...");\r
-// compareFiles(nativeFlz, javaFlz);\r
-// System.out.println("Compressed outputs match.");\r
-// }\r
-\r
-// @Test\r
-// public void testNativeCompressPerformance() throws IOException {\r
-// File javaFlz = new File("compressed.data.native.flz");\r
-// for (int i = 0; i < 5; ++i) {\r
-// compressFlzNative(testData1, javaFlz);\r
-// }\r
-// }\r
-//\r
-// @Test\r
-// public void testJavaCompressPerformance() throws IOException {\r
-// // Need to prime JVM JIT by performing multiple passes\r
-// File javaFlz = new File("compressed.data.java.flz");\r
-// for (int i = 0; i < 5; ++i) {\r
-// compressFlzJava(testData1, javaFlz);\r
-// }\r
-// }\r
-\r
-// @Test\r
-// public void testCompressNative() throws IOException {\r
-// File flz = new File("compressed.data.native.flz");\r
-// for (int i = 0; i < 5; ++i) {\r
-// long compressedSize = compressFlzNative(testData1, flz);\r
-// System.out.println("native compressed size: " + compressedSize);\r
-// }\r
-// }\r
-//\r
-// @Test\r
-// public void testCompressionJava() throws IOException {\r
-// // Need to prime JVM JIT by performing multiple passes\r
-// File flz = new File("compressed.data.java.flz");\r
-// for (int i = 0; i < 5; ++i) {\r
-// long compressedSize = compressFlzJava(testData1, flz);\r
-// System.out.println("java compressed size: " + compressedSize);\r
-// }\r
-// }\r
-\r
- @SuppressWarnings("unused")\r
- @Test\r
- public void testDecompress() throws IOException {\r
- File nativeFlz = new File("compressed.data.native.flz");\r
- long nativeCompressedSize = compressFlzNative(testData1, nativeFlz);\r
- System.out.println("native compressed size: " + nativeCompressedSize);\r
-\r
- // Need to prime JVM JIT by performing multiple passes\r
- File javaFlz = new File("compressed.data.java.flz");\r
- long javaCompressedSize = compressFlzJava(testData1, javaFlz);\r
- System.out.println("java compressed size: " + javaCompressedSize);\r
-\r
- Assert.assertEquals(nativeCompressedSize, javaCompressedSize);\r
-\r
- System.out.println("Comparing compressed outputs...");\r
- compareFiles(nativeFlz, javaFlz);\r
- System.out.println("Compressed outputs match.");\r
-\r
- File java1 = new File("java-compressed.data.decompressed-with-native");\r
- long nativeDecompressedSize = decompressFlzNative(javaFlz, java1);\r
- System.out.println("Comparing native-decompressed output...");\r
- compareFiles(testData1, java1);\r
- System.out.println("Native-decompressed output matches original.");\r
-\r
- File java2 = new File("java-compressed.data.decompressed-with-java");\r
- long javaDecompressedSize = decompressFlzJava(javaFlz, java2);\r
- System.out.println("Comparing java-decompressed output...");\r
- compareFiles(testData1, java2);\r
- System.out.println("Java-decompressed output matches original.");\r
-\r
- for (int i = 0; i < 5; ++i)\r
- decompressFlz(javaFlz, FastLZ.read(javaFlz), java1, NullOutputStream.INSTANCE);\r
- for (int i = 0; i < 5; ++i)\r
- decompressFlz(javaFlz, FastLZJava.read(javaFlz), java2, NullOutputStream.INSTANCE);\r
- }\r
-\r
+import static org.junit.Assert.fail;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+
+import junit.framework.Assert;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+@SuppressWarnings("deprecation")
+public class FastLZBasicTests {
+
+ static File testData1;
+ static File testData2;
+ static File testDataPrime;
+
+ @BeforeClass
+ public static void initialize() throws IOException {
+ FastLZ.initialize(null);
+
+ testData1 = new File("uncompressed.data");
+ writeTestData(testData1, 10000000);
+ testData2 = new File("uncompressed-small.data");
+ writeTestData(testData2, 100000);
+ testDataPrime = new File("uncompressed-prime.data");
+ writeTestData(testDataPrime, 1000);
+
+ System.out.println("test data directory: " + testData1.getAbsolutePath());
+
+// File javaFlz = new File("compressed-prime.data.native.flz");
+// for (int i = 0; i < 100; ++i) {
+// compressFlzJava(testDataPrime, javaFlz);
+// }
+ }
+
+ @Test
+ public void validateCompress() throws IOException {
+ validateCompress(testData1);
+ }
+
+ private void validateCompress(File testData) throws IOException {
+ System.out.println("==== validateCompress(" + testData.getName() + ") ====");
+
+ File nativeFlz = new File("compressed.data.native.flz");
+ long nativeCompressedSize = compressFlzNative(testData, nativeFlz);
+ System.out.println("native compressed size: " + nativeCompressedSize);
+
+ // Need to prime JVM JIT by performing multiple passes
+ File javaFlz = new File("compressed.data.java.flz");
+ long javaCompressedSize = compressFlzJava(testData, javaFlz);
+ System.out.println("java compressed size: " + javaCompressedSize);
+
+ Assert.assertEquals(nativeCompressedSize, javaCompressedSize);
+
+ System.out.println("Comparing compressed outputs...");
+ compareFiles(nativeFlz, javaFlz);
+ System.out.println("Compressed outputs match.");
+
+ File decompressedNativeFlz = new File("decompressed.data.native.flz");
+ File decompressedJavaFlz = new File("decompressed.data.java.flz");
+ decompressFlzNative(nativeFlz, decompressedNativeFlz);
+ decompressFlzNative(javaFlz, decompressedJavaFlz);
+ compareFiles(decompressedJavaFlz, decompressedNativeFlz);
+ compareFiles(decompressedNativeFlz, testData);
+ }
+
+// @Test
+// public void validateCompressSmall() throws IOException {
+// File nativeFlz = new File("compressed-small.data.native.flz");
+// long nativeCompressedSize = compressFlzNative(testData2, nativeFlz);
+// System.out.println("native compressed size: " + nativeCompressedSize);
+//
+// // Need to prime JVM JIT by performing multiple passes
+// File javaFlz = new File("compressed-small.data.java.flz");
+// long javaCompressedSize = compressFlzJava(testData2, javaFlz);
+// System.out.println("java compressed size: " + javaCompressedSize);
+//
+// Assert.assertEquals(nativeCompressedSize, javaCompressedSize);
+//
+// System.out.println("Comparing compressed outputs...");
+// compareFiles(nativeFlz, javaFlz);
+// System.out.println("Compressed outputs match.");
+// }
+
+// @Test
+// public void testNativeCompressPerformance() throws IOException {
+// File javaFlz = new File("compressed.data.native.flz");
+// for (int i = 0; i < 5; ++i) {
+// compressFlzNative(testData1, javaFlz);
+// }
+// }
+//
+// @Test
+// public void testJavaCompressPerformance() throws IOException {
+// // Need to prime JVM JIT by performing multiple passes
+// File javaFlz = new File("compressed.data.java.flz");
+// for (int i = 0; i < 5; ++i) {
+// compressFlzJava(testData1, javaFlz);
+// }
+// }
+
+// @Test
+// public void testCompressNative() throws IOException {
+// File flz = new File("compressed.data.native.flz");
+// for (int i = 0; i < 5; ++i) {
+// long compressedSize = compressFlzNative(testData1, flz);
+// System.out.println("native compressed size: " + compressedSize);
+// }
+// }
+//
+// @Test
+// public void testCompressionJava() throws IOException {
+// // Need to prime JVM JIT by performing multiple passes
+// File flz = new File("compressed.data.java.flz");
+// for (int i = 0; i < 5; ++i) {
+// long compressedSize = compressFlzJava(testData1, flz);
+// System.out.println("java compressed size: " + compressedSize);
+// }
+// }
+
+ @SuppressWarnings("unused")
+ @Test
+ public void testDecompress() throws IOException {
+ File nativeFlz = new File("compressed.data.native.flz");
+ long nativeCompressedSize = compressFlzNative(testData1, nativeFlz);
+ System.out.println("native compressed size: " + nativeCompressedSize);
+
+ // Need to prime JVM JIT by performing multiple passes
+ File javaFlz = new File("compressed.data.java.flz");
+ long javaCompressedSize = compressFlzJava(testData1, javaFlz);
+ System.out.println("java compressed size: " + javaCompressedSize);
+
+ Assert.assertEquals(nativeCompressedSize, javaCompressedSize);
+
+ System.out.println("Comparing compressed outputs...");
+ compareFiles(nativeFlz, javaFlz);
+ System.out.println("Compressed outputs match.");
+
+ File java1 = new File("java-compressed.data.decompressed-with-native");
+ long nativeDecompressedSize = decompressFlzNative(javaFlz, java1);
+ System.out.println("Comparing native-decompressed output...");
+ compareFiles(testData1, java1);
+ System.out.println("Native-decompressed output matches original.");
+
+ File java2 = new File("java-compressed.data.decompressed-with-java");
+ long javaDecompressedSize = decompressFlzJava(javaFlz, java2);
+ System.out.println("Comparing java-decompressed output...");
+ compareFiles(testData1, java2);
+ System.out.println("Java-decompressed output matches original.");
+
+ for (int i = 0; i < 5; ++i)
+ decompressFlz(javaFlz, FastLZ.read(javaFlz), java1, NullOutputStream.INSTANCE);
+ for (int i = 0; i < 5; ++i)
+ decompressFlz(javaFlz, FastLZJava.read(javaFlz), java2, NullOutputStream.INSTANCE);
+ }
+