CompressedFile { InputStream getInputStream() throws IOException { switch (filetype) { case GZ: LOG.debug("Decompressing .gz file"); return new GzipCompressorInputStream(new FileInputStream(compressedFile)); case BZ2: LOG.debug("Decompressing .bz2 file"); return new BZip2CompressorInputStream(new FileInputStream(compressedFile)); } return null; } CompressedFile(File compressedFile);   }
@Test(expected = IOException.class) public void passingInAFileThatIsNotAGZFileThrowsErrorWhenYouTryToGetAnInputStream() throws Exception { File somefile = File.createTempFile("somefile", ".tmp.gz"); CompressedFile compressedFile = new CompressedFile(somefile); compressedFile.getInputStream(); }
@Test(expected = IOException.class) public void passingInAFileThatIsNotABZ2FileThrowsErrorWhenYouTryToGetAnInputStream() throws Exception { File somefile = File.createTempFile("somefile", ".tmp.bz2"); CompressedFile compressedFile = new CompressedFile(somefile); compressedFile.getInputStream(); }