CompressorStream extends CompressionOutputStream { @Override public void close() throws IOException { if (!closed) { try { super.close(); } finally { closed = true; } } } CompressorStream(OutputStream out, Compressor compressor, int bufferSize);  CompressorStream(OutputStream out, Compressor compressor); protected  CompressorStream(OutputStream out); @Override void write(byte[] b, int off, int len); @Override void finish(); @Override void resetState(); @Override void close(); @Override void write(int b);  }
@Test public void testClose() { TestCompressorStream testCompressorStream = new TestCompressorStream(); try { testCompressorStream.close(); } catch(IOException e) { System.out.println("Expected IOException"); } Assert.assertTrue("closed shoud be true", ((CompressorStream)testCompressorStream).closed); file.delete(); }