use of java.net.ServerSocket in project robovm by robovm.
the class SocketChannelTest method assertSocketAction_NonBlock_BeforeConnect.
private void assertSocketAction_NonBlock_BeforeConnect(Socket s) throws IOException {
assertFalse(this.channel1.isConnected());
this.server2 = new ServerSocket(localAddr2.getPort());
try {
s.connect(localAddr2);
fail("Should throw IllegalBlockingModeException");
} catch (IllegalBlockingModeException e1) {
// OK.
}
if (this.channel1.isConnectionPending()) {
try {
s.bind(localAddr2);
fail("Should throw ConnectionPendingException");
} catch (ConnectionPendingException e1) {
// OK.
}
} else {
try {
s.bind(localAddr2);
fail("Should throw BindException");
} catch (BindException e1) {
// OK.
}
}
assertFalse(this.channel1.isConnected());
assertFalse(s.isConnected());
s.close();
assertTrue(s.isClosed());
assertFalse(this.channel1.isOpen());
}
use of java.net.ServerSocket in project robovm by robovm.
the class SocketChannelTest method testCFII_EmptyHost.
public void testCFII_EmptyHost() throws Exception {
statusNotConnected_NotPending();
ServerSocket server = new ServerSocket(0);
int port = server.getLocalPort();
server.close();
try {
this.channel1.connect(new InetSocketAddress("", port));
fail("Should throw ConnectException");
} catch (ConnectException e) {
// correct
}
}
use of java.net.ServerSocket in project robovm by robovm.
the class ServerSocketChannelTest method testSocket_NonBlock_BeforeClose.
public void testSocket_NonBlock_BeforeClose() throws Exception {
assertTrue(this.serverChannel.isOpen());
this.serverChannel.configureBlocking(false);
ServerSocket s1 = this.serverChannel.socket();
assertFalse(s1.isClosed());
assertSocketNotAccepted(s1);
ServerSocket s2 = this.serverChannel.socket();
// same
assertSame(s1, s2);
// socket close makes the channel close
s1.close();
assertFalse(this.serverChannel.isOpen());
}
use of java.net.ServerSocket in project robovm by robovm.
the class ServerSocketChannelTest method testSocket_Block_Closed.
public void testSocket_Block_Closed() throws Exception {
this.serverChannel.close();
assertFalse(this.serverChannel.isOpen());
assertTrue(this.serverChannel.isBlocking());
ServerSocket s1 = this.serverChannel.socket();
assertTrue(s1.isClosed());
assertSocketNotAccepted(s1);
ServerSocket s2 = this.serverChannel.socket();
// same
assertSame(s1, s2);
}
use of java.net.ServerSocket in project robovm by robovm.
the class ServerSocketChannelTest method test_socket_accept_Blocking_Bound.
/**
* @tests ServerSocket#socket().accept()
*/
public void test_socket_accept_Blocking_Bound() throws IOException {
// regression test for Harmony-748
serverChannel.configureBlocking(true);
ServerSocket gotSocket = serverChannel.socket();
gotSocket.bind(localAddr1);
serverChannel.close();
try {
gotSocket.accept();
fail("Should throw a ClosedChannelException");
} catch (ClosedChannelException e) {
// expected
}
}
Aggregations