-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #533 from bpow/bzip2-fixes
Bzip2 fixes in cram.io.ExternalCompression
- Loading branch information
Showing
4 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/tests/java/htsjdk/samtools/cram/io/ExternalCompressionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package htsjdk.samtools.cram.io; | ||
|
||
import org.apache.commons.compress.utils.IOUtils; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
|
||
public class ExternalCompressionTest { | ||
public static final File BZIP2_FILE = new File("testdata/htsjdk/samtools/io/bzip2-test.bz2"); | ||
public static final byte [] TEST_BYTES = "This is a simple string to test BZip2".getBytes(); | ||
|
||
@Test | ||
public void testBZip2Decompression() throws IOException { | ||
final byte [] input = Files.readAllBytes(BZIP2_FILE.toPath()); | ||
final byte [] output = ExternalCompression.unbzip2(input); | ||
Assert.assertEquals(output, "BZip2 worked".getBytes()); | ||
} | ||
|
||
@Test | ||
public void testBZip2Roundtrip() throws IOException { | ||
final byte [] compressed = ExternalCompression.bzip2(TEST_BYTES); | ||
final byte [] restored = ExternalCompression.unbzip2(compressed); | ||
Assert.assertEquals(TEST_BYTES, restored); | ||
} | ||
} |
Binary file not shown.