Пример #1
0
 /**
  * Sending a request to a node with a bad hostname should result in an exception during connect
  */
 @Test(expected = IOException.class)
 public void testNoRouteToHost() throws Exception {
   selector.connect(
       new InetSocketAddress("asdf.asdf.dsc", server.port),
       BUFFER_SIZE,
       BUFFER_SIZE,
       PortType.SSL);
 }
Пример #2
0
 /** Sending a request to a node not listening on that port should result in disconnection */
 @Test
 public void testConnectionRefused() throws Exception {
   String connectionId =
       selector.connect(
           new InetSocketAddress("localhost", 6668), BUFFER_SIZE, BUFFER_SIZE, PortType.SSL);
   while (selector.disconnected().contains(connectionId)) {
     selector.poll(1000L);
   }
 }
Пример #3
0
 /* connect and wait for the connection to complete */
 private String blockingSSLConnect() throws IOException {
   String connectionId =
       selector.connect(
           new InetSocketAddress("localhost", server.port),
           BUFFER_SIZE,
           BUFFER_SIZE,
           PortType.SSL);
   while (!selector.connected().contains(connectionId)) {
     selector.poll(10000L);
   }
   return connectionId;
 }
Пример #4
0
 @Test
 public void testCloseAfterConnectCall() throws IOException {
   String connectionId =
       selector.connect(
           new InetSocketAddress("localhost", server.port),
           BUFFER_SIZE,
           BUFFER_SIZE,
           PortType.SSL);
   selector.close(connectionId);
   selector.poll(0);
   Assert.assertTrue(
       "Channel should have been added to disconnected list",
       selector.disconnected().contains(connectionId));
 }
Пример #5
0
 @Test
 public void testSSLConnect() throws IOException {
   String connectionId =
       selector.connect(
           new InetSocketAddress("localhost", server.port),
           BUFFER_SIZE,
           BUFFER_SIZE,
           PortType.SSL);
   while (!selector.connected().contains(connectionId)) {
     selector.poll(10000L);
   }
   Assert.assertTrue(
       "Channel should have been ready by now ", selector.isChannelReady(connectionId));
 }