use of java.util.zip.DeflaterInputStream in project j2objc by google.
the class DeflaterInputStreamTest method testReadExceptions.
public void testReadExceptions() throws IOException {
byte[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
byte[] buffer = new byte[8];
InputStream in = new DeflaterInputStream(new ByteArrayInputStream(data));
try {
in.read(buffer, 0, 10);
fail();
} catch (IndexOutOfBoundsException expected) {
}
try {
in.read(null, 0, 5);
fail();
} catch (NullPointerException expected) {
}
try {
in.read(buffer, -1, 5);
fail();
} catch (IndexOutOfBoundsException expected) {
}
in.close();
try {
in.read(buffer, 0, 5);
fail();
} catch (IOException expected) {
}
}
use of java.util.zip.DeflaterInputStream in project j2objc by google.
the class DeflaterInputStreamTest method testReadByteByByte.
public void testReadByteByByte() throws IOException {
byte[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
InputStream in = new DeflaterInputStream(new ByteArrayInputStream(data));
ByteArrayOutputStream out = new ByteArrayOutputStream();
assertEquals(1, in.available());
int b;
while ((b = in.read()) != -1) {
out.write(b);
}
assertEquals(0, in.available());
assertEquals(Arrays.toString(data), Arrays.toString(inflate(out.toByteArray())));
in.close();
try {
in.available();
fail();
} catch (IOException expected) {
}
}
use of java.util.zip.DeflaterInputStream in project j2objc by google.
the class DeflaterInputStreamTest method testReadWithBuffer.
public void testReadWithBuffer() throws IOException {
byte[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
byte[] buffer = new byte[8];
InputStream in = new DeflaterInputStream(new ByteArrayInputStream(data));
ByteArrayOutputStream out = new ByteArrayOutputStream();
assertEquals(1, in.available());
int count;
while ((count = in.read(buffer, 0, 5)) != -1) {
assertTrue(count <= 5);
out.write(buffer, 0, count);
}
assertEquals(0, in.available());
assertEquals(Arrays.toString(data), Arrays.toString(inflate(out.toByteArray())));
in.close();
try {
in.available();
fail();
} catch (IOException expected) {
}
}
use of java.util.zip.DeflaterInputStream in project robovm by robovm.
the class DeflaterInputStreamTest method testReadWithBuffer.
public void testReadWithBuffer() throws IOException {
byte[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
byte[] buffer = new byte[8];
InputStream in = new DeflaterInputStream(new ByteArrayInputStream(data));
ByteArrayOutputStream out = new ByteArrayOutputStream();
assertEquals(1, in.available());
int count;
while ((count = in.read(buffer, 0, 5)) != -1) {
assertTrue(count <= 5);
out.write(buffer, 0, count);
}
assertEquals(0, in.available());
assertEquals(Arrays.toString(data), Arrays.toString(inflate(out.toByteArray())));
in.close();
try {
in.available();
fail();
} catch (IOException expected) {
}
}
Aggregations