use of java.io.PushbackInputStream in project robovm by robovm.
the class FilterInputStreamNullSourceTest method testPushbackInputStream.
public void testPushbackInputStream() throws IOException {
assertReadsFailWithIoException(new PushbackInputStream(null));
assertReadsFailWithIoException(new PushbackInputStream(null, 1024));
}
use of java.io.PushbackInputStream in project robovm by robovm.
the class OldPushbackInputStreamTest method test_close.
public void test_close() throws IOException {
PushbackInputStream tobj;
tobj = new PushbackInputStream(underlying);
tobj.close();
tobj.close();
tobj = new PushbackInputStream(underlying);
underlying.throwExceptionOnNextUse = true;
try {
tobj.close();
fail("IOException not thrown.");
} catch (IOException e) {
// expected
}
}
use of java.io.PushbackInputStream in project robovm by robovm.
the class OldPushbackInputStreamTest method test_available.
public void test_available() throws IOException {
PushbackInputStream tobj;
tobj = new PushbackInputStream(underlying);
assertEquals("Wrong number!", 30, tobj.available());
underlying.throwExceptionOnNextUse = true;
try {
tobj.available();
fail("IOException not thrown.");
} catch (IOException e) {
// expected
}
}
use of java.io.PushbackInputStream in project robovm by robovm.
the class OldPushbackInputStreamTest method test_read.
public void test_read() throws IOException {
PushbackInputStream tobj;
tobj = new PushbackInputStream(underlying);
assertEquals("Test 1: Incorrect byte read;", 66, tobj.read());
underlying.throwExceptionOnNextUse = true;
try {
tobj.read();
fail("Test 2: IOException expected.");
} catch (IOException e) {
// expected
}
assertEquals("Test 3: Incorrect byte read;", fileString.getBytes()[0], pis.read());
}
use of java.io.PushbackInputStream in project robovm by robovm.
the class OldPushbackInputStreamTest method test_unread$BII.
public void test_unread$BII() throws IOException {
PushbackInputStream tobj;
String str2 = "0123456789";
byte[] buf2 = (str2 + str2 + str2).getBytes();
byte[] readBuf = new byte[10];
tobj = new PushbackInputStream(underlying, 10);
tobj.unread(buf2, 15, 10);
assertEquals("Wrong number!", 30 + 10, tobj.available());
try {
tobj.unread(buf2, 15, 10);
fail("IOException not thrown.");
} catch (IOException e) {
// expected
}
tobj.read(readBuf);
assertEquals("Incorrect bytes read", "5678901234", new String(readBuf));
underlying.throwExceptionOnNextUse = true;
try {
tobj.read(buf2, 15, 10);
fail("IOException not thrown.");
} catch (IOException e) {
// expected
}
// int)
try {
byte[] buf = new byte[100];
pis.read(buf, 0, buf.length);
assertTrue("Incorrect bytes read", new String(buf).equals(fileString.substring(0, 100)));
pis.unread(buf, 50, 50);
pis.read(buf, 0, 50);
assertTrue("Failed to unread bytes", new String(buf, 0, 50).equals(fileString.substring(50, 100)));
} catch (IOException e) {
fail("IOException during unread test : " + e.getMessage());
}
try {
byte[] buf = new byte[10];
pis.unread(buf, 0, -1);
fail("IndexOutOfBoundsException was not thrown");
} catch (IndexOutOfBoundsException e) {
// Expected
}
try {
byte[] buf = new byte[10];
pis.unread(buf, -1, 1);
fail("IndexOutOfBoundsException was not thrown");
} catch (IndexOutOfBoundsException e) {
// Expected
}
try {
byte[] buf = new byte[10];
pis.unread(buf, 10, 1);
fail("IndexOutOfBoundsException was not thrown");
} catch (IndexOutOfBoundsException e) {
// Expected
}
}
Aggregations