コード例 #1
0
ファイル: SSLSelectorTest.java プロジェクト: xiahome/ambry
 /**
  * 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
ファイル: SSLSelectorTest.java プロジェクト: xiahome/ambry
 /** 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
ファイル: SSLSelectorTest.java プロジェクト: xiahome/ambry
 /* 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
ファイル: SSLSelectorTest.java プロジェクト: xiahome/ambry
 @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
ファイル: SSLSelectorTest.java プロジェクト: xiahome/ambry
 @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));
 }