public class TestCustomCodec {
@Test
public void testCustomCodec() {
CustomCodec customCodec = new CustomCodec();
Codec snappyCodec = new SnappyCodec.Option().createInstance();
assertTrue(customCodec.equals(new CustomCodec()));
assertFalse(customCodec.equals(snappyCodec));
String testString = "Testing 123";
ByteBuffer original = ByteBuffer.allocate(testString.getBytes().length);
original.put(testString.getBytes());
original.rewind();
ByteBuffer decompressed = null;
try {
ByteBuffer compressed = customCodec.compress(original);
compressed.rewind();
decompressed = customCodec.decompress(compressed);
} catch (IOException e) {
e.printStackTrace();
}
assertEquals(testString, new String(decompressed.array()));