Add Zstandard and Brotli alg tests
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package eu.mikroskeem.uurimustoo.algoritmidetest.algoritmid;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.meteogroup.jbrotli.BrotliStreamCompressor;
|
||||
import org.meteogroup.jbrotli.BrotliStreamDeCompressor;
|
||||
import org.meteogroup.jbrotli.libloader.BrotliLibraryLoader;
|
||||
|
||||
/**
|
||||
* @author Mark Vainomaa
|
||||
*/
|
||||
public class Brotli extends AbstractAlgorithm {
|
||||
@Getter private final String name = "Brotli";
|
||||
|
||||
static {
|
||||
BrotliLibraryLoader.loadBrotli();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] compress(byte[] input) {
|
||||
BrotliStreamCompressor compressor = new BrotliStreamCompressor();
|
||||
return compressor.compressArray(input, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] decompress(byte[] input) {
|
||||
BrotliStreamDeCompressor decompressor = new BrotliStreamDeCompressor();
|
||||
byte[] buf = new byte[8192]; // *sigh*
|
||||
decompressor.deCompress(input, buf);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package eu.mikroskeem.uurimustoo.algoritmidetest.algoritmid;
|
||||
|
||||
import com.github.luben.zstd.ZstdInputStream;
|
||||
import com.github.luben.zstd.ZstdOutputStream;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* @author Mark Vainomaa
|
||||
*/
|
||||
public class Zstandard extends AbstractAlgorithm {
|
||||
@Getter private final String name = "Zstandard";
|
||||
|
||||
@Override
|
||||
public OutputStream createCompressor(OutputStream outputStream) throws IOException {
|
||||
return new ZstdOutputStream(outputStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream createDecompressor(InputStream inputStream) throws IOException {
|
||||
return new ZstdInputStream(inputStream);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user