-
Notifications
You must be signed in to change notification settings - Fork 251
Expand file tree
/
Copy pathSnappyIntegrationTest.java
More file actions
32 lines (27 loc) · 1.2 KB
/
SnappyIntegrationTest.java
File metadata and controls
32 lines (27 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import org.xerial.snappy.Snappy;
/**
* Simple integration test to verify snappy-java works in a separate JVM.
* This is compiled and run as a standalone program to test the JAR manifest
* and native library loading on different JDK versions.
*/
public class SnappyIntegrationTest {
public static void main(String[] args) throws Exception {
String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of "
+ "Snappy, a fast compresser/decompresser.";
// Test compression
byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
System.out.println("Compressed " + input.length() + " bytes to " + compressed.length + " bytes");
// Test decompression
byte[] uncompressed = Snappy.uncompress(compressed);
String result = new String(uncompressed, "UTF-8");
// Verify result matches input
if (!result.equals(input)) {
System.err.println("ERROR: Decompressed data does not match input!");
System.err.println("Expected: " + input);
System.err.println("Got: " + result);
System.exit(1);
}
System.out.println("SUCCESS: " + result);
System.exit(0);
}
}