/**
* @tests java.util.zip.InflaterOutputStream#write(byte[],int,int)
*/
public void test_write_$BII_Illegal() throws IOException {
// write error compression (ZIP) format
InflaterOutputStream ios = new InflaterOutputStream(os);
byte[] bytes = { 0, 1, 2, 3 };
try {
ios.write(bytes, 0, 4);
fail("Should throw ZipException");
} catch (ZipException e) {
// expected
}
try {
ios.flush();
fail("Should throw ZipException");
} catch (ZipException e) {
// expected
}
// write after close
ios = new InflaterOutputStream(os);
ios.close();
try {
ios.write(bytes, 0, 4);
fail("Should throw IOException");
} catch (IOException e) {
// expected
}
try {
ios.write(bytes, -1, 4);
fail("Should throw IOException");
} catch (IOException e) {
// expected
}
try {
ios.write(bytes, -1, -4);
fail("Should throw IOException");
} catch (IOException e) {
// expected
}
try {
ios.write(bytes, 0, 400);
fail("Should throw IOException");
} catch (IOException e) {
// expected
}
try {
ios.write(null, -1, 4);
fail("Should throw IOException");
} catch (IOException e) {
// expected
}
ios = new InflaterOutputStream(os);
try {
ios.write(null, 0, 4);
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
ios.write(null, -1, 4);
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
ios.write(null, 0, -4);
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
ios.write(null, 0, 1000);
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
ios.write(bytes, -1, 4);
fail("Should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
ios.write(bytes, 0, -4);
fail("Should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
ios.write(bytes, 0, 100);
fail("Should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
ios.write(bytes, -100, 100);
fail("Should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
ios = new InflaterOutputStream(os);
ios.finish();
try {
ios.write(bytes, -1,-100);
fail("Should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
ios.write(null, -1,-100);
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
ios = new InflaterOutputStream(os);
ios.flush();
try {
ios.write(bytes, 0, 4);
fail("Should throw ZipException");
} catch (ZipException e) {
// expected
}
}