use of tests.support.Support_OutputStream in project j2objc by google.
the class OldFilterOutputStreamTest method test_writeI.
public void test_writeI() throws IOException {
Support_OutputStream sos = new Support_OutputStream(1);
os = new FilterOutputStream(sos);
os.write(42);
bis = new ByteArrayInputStream(sos.toByteArray());
assertTrue("Test 1: Byte has not been written.", bis.available() == 1);
assertEquals("Test 2: Incorrect byte written or read;", 42, bis.read());
try {
// Support_OutputStream throws an IOException if the internal
// buffer is full, which it should be now.
os.write(42);
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of tests.support.Support_OutputStream in project j2objc by google.
the class OldFilterOutputStreamTest method test_write$BII_Exception.
public void test_write$BII_Exception() throws IOException {
Support_OutputStream sos = new Support_OutputStream(testLength);
os = new FilterOutputStream(sos);
byte[] buf = new byte[10];
try {
os.write(buf, -1, 1);
fail("IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
os.write(buf, 0, -1);
fail("IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
os.write(buf, 10, 1);
fail("IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
}
use of tests.support.Support_OutputStream in project j2objc by google.
the class OldObjectOutputStreamTest method test_reset.
public void test_reset() throws Exception {
String o = "HelloWorld";
sos = new Support_OutputStream(200);
oos.close();
oos = new ObjectOutputStream(sos);
oos.writeObject(o);
oos.writeObject(o);
oos.reset();
oos.writeObject(o);
sos.setThrowsException(true);
try {
oos.reset();
fail("Test 1: IOException expected.");
} catch (IOException e) {
// Expected.
}
sos.setThrowsException(false);
ois = new ObjectInputStream(new ByteArrayInputStream(sos.toByteArray()));
assertEquals("Test 2: Incorrect object read.", o, ois.readObject());
assertEquals("Test 3: Incorrect object read.", o, ois.readObject());
assertEquals("Test 4: Incorrect object read.", o, ois.readObject());
ois.close();
}
Aggregations