Package org.apache.avro.file.codec

Examples of org.apache.avro.file.codec.CustomCodec


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()));
View Full Code Here

TOP

Related Classes of org.apache.avro.file.codec.CustomCodec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.