/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.airlift.compress.snappy;

import com.google.common.base.Throwables;
import com.google.common.io.ByteStreams;
import io.airlift.compress.AbstractTestCompression;
import io.airlift.compress.Compressor;
import io.airlift.compress.Decompressor;
import io.airlift.compress.HadoopCodecDecompressor;
import io.airlift.compress.HadoopNative;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.compress.CompressionOutputStream;

import java.io.ByteArrayInputStream;
import java.io.IOException;

public class TestSnappyCodec
    extends AbstractTestCompression
{
    static {
        HadoopNative.initialize();
    }

    private static final Configuration HADOOP_CONF = new Configuration();

    protected byte[] prepareCompressedData(byte[] uncompressed)
    {
        org.apache.hadoop.io.compress.SnappyCodec codec = new org.apache.hadoop.io.compress.SnappyCodec();
        codec.setConf(HADOOP_CONF);

        try {
            java.io.ByteArrayOutputStream buffer = new java.io.ByteArrayOutputStream();
            CompressionOutputStream out = codec.createOutputStream(buffer);
            ByteStreams.copy(new ByteArrayInputStream(uncompressed, 0, uncompressed.length), out);
            out.close();
            return buffer.toByteArray();
        }
        catch (IOException e) {
            throw Throwables.propagate(e);
        }
    }

    @Override
    public void testCompress(AbstractTestCompression.TestCase testCase)
            throws Exception
    {
        // not yet supported
    }

    @Override
    protected Compressor getCompressor()
    {
        throw new UnsupportedOperationException("not yet implemented");
    }

    @Override
    protected Decompressor getDecompressor()
    {
        return new HadoopCodecDecompressor(new SnappyCodec());
    }
}

@@ -799,32 +799,82 @@
 s.Decompressor;%0A
+import io.airlift.compress.HadoopCodecCompressor;%0A
 import io.airlif
@@ -1153,16 +1153,20 @@
 pyCodec%0A
+    
     exte
@@ -1992,291 +1992,133 @@
     
-@Override%0A    public void testCompress(AbstractTestCompression.TestCase testCase)%0A            throws Exception%0A    %7B%0A        // not yet supported%0A    %7D%0A%0A    @Override%0A    protected Compressor getCompressor()%0A    %7B%0A        throw new UnsupportedOperationException(%22not yet implemented%22
+protected Compressor getCompressor()%0A    %7B%0A        return new HadoopCodecCompressor(new SnappyCodec(), new SnappyCompressor()
 );%0A 

Enable SnappyCodec compression test