@Test(groups = "broken") public void testDevNull() throws Exception { final BlockCompressedOutputStream bcos = new BlockCompressedOutputStream("/dev/null"); bcos.write("Hi, Mom!".getBytes()); bcos.close(); }
private static File getValidCompressedFile() throws IOException { final File tmpCompressedFile = File.createTempFile("test.", ".bgzf"); tmpCompressedFile.deleteOnExit(); final BlockCompressedOutputStream os = new BlockCompressedOutputStream(tmpCompressedFile); os.write("Hi, Mom!\n".getBytes()); os.close(); return tmpCompressedFile; }
@Test public void testOverflow() throws Exception { final File f = File.createTempFile("BCOST.", ".gz"); f.deleteOnExit(); final List<String> linesWritten = new ArrayList<>(); System.out.println("Creating file " + f); final BlockCompressedOutputStream bcos = new BlockCompressedOutputStream(f); Random r = new Random(15555); final int INPUT_SIZE = 64 * 1024; byte[] input = new byte[INPUT_SIZE]; r.nextBytes(input); bcos.write(input); bcos.close(); final BlockCompressedInputStream bcis = new BlockCompressedInputStream(f); byte[] output = new byte[INPUT_SIZE]; int len; int i = 0; while ((len = bcis.read(output, 0, output.length)) != -1) { for (int j = 0; j < len; j++) { Assert.assertEquals(output[j], input[i++]); } } Assert.assertEquals(i, INPUT_SIZE); bcis.close(); }
bcos.close(); final BlockCompressedInputStream bcis = new BlockCompressedInputStream(f); final BufferedReader reader = new BufferedReader(new InputStreamReader(bcis));
bcos.close(); final BlockCompressedInputStream bcis = new BlockCompressedInputStream(f); final BufferedReader reader = new BufferedReader(new InputStreamReader(bcis));