use of java.nio.channels.IllegalBlockingModeException in project j2objc by google.
the class SocketChannelTest method test_socket_getOutputStream_nonBlocking_write_Exception.
public void test_socket_getOutputStream_nonBlocking_write_Exception() throws IOException {
byte[] buf = new byte[1];
channel1.connect(this.localAddr1);
OutputStream os = channel1.socket().getOutputStream();
channel1.configureBlocking(false);
try {
os.write(1);
fail();
} catch (IllegalBlockingModeException expected) {
}
try {
os.write(null);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (NullPointerException expected) {
// Any of these exceptions are possible.
}
try {
os.write(buf, -1, 1);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (IndexOutOfBoundsException expected) {
// Any of these exceptions are possible.
}
try {
os.write(buf, 0, -1);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (IndexOutOfBoundsException expected) {
// Any of these exceptions are possible.
}
try {
os.write(buf, 0, 2);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (IndexOutOfBoundsException expected) {
// Any of these exceptions are possible.
}
try {
os.write(buf, 2, 1);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (IndexOutOfBoundsException expected) {
// Any of these exceptions are possible.
}
try {
os.write(null, 0, 1);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (NullPointerException expected) {
// Any of these exceptions are possible.
}
os.close();
try {
os.write(1);
fail();
} catch (IllegalBlockingModeException expected) {
}
try {
os.write(null);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (NullPointerException expected) {
// Any of these exceptions are possible.
}
try {
os.write(buf, -1, 1);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (IndexOutOfBoundsException expected) {
// Any of these exceptions are possible.
}
try {
os.write(buf, 0, -1);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (IndexOutOfBoundsException expected) {
// Any of these exceptions are possible.
}
try {
os.write(buf, 0, 2);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (IndexOutOfBoundsException expected) {
// Any of these exceptions are possible.
}
try {
os.write(buf, 2, 0);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (IndexOutOfBoundsException expected) {
// Any of these exceptions are possible.
}
try {
os.write(null, 0, 0);
fail();
} catch (IllegalBlockingModeException expected) {
// Any of these exceptions are possible.
} catch (NullPointerException expected) {
// Any of these exceptions are possible.
}
}
Aggregations