import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

class DeflaterOutputStreamTest {

    public static void main(final String[] args) throws Exception {
        System.out.println("running test against Java " + System.getProperty("java.version") + " (" + System.getProperty("java.vm.version") + ")");

        final OutputStream os = new ByteArrayOutputStream() {
            @Override
            public void close() throws IOException {
                super.close();
                throw new IOException("intentional from close");
            }
        };
        final ZipOutputStream zos = new ZipOutputStream(os);
        try {
            zos.close(); // expect it to throw an exception
            throw new AssertionError("ZipOutputStream.close() was expected to throw but didn't");
        } catch (IOException ioe) {
            // expected
        }
        zos.putNextEntry(new ZipEntry("does_not_matter"));

        try {
            zos.write(0x02); // expected to fail, since zos is closed
            throw new AssertionError("ZipOutputStream.write() was expected to throw but didn't");
        } catch (IOException ioe) {
            // expected
        }
    }

}
