コード例 #1
0
ファイル: SSLSelectorTest.java プロジェクト: xiahome/ambry
  /**
   * Validate that when the server disconnects, a client send ends up with that node in the
   * disconnected list.
   */
  @Test
  public void testServerDisconnect() throws Exception {
    // connect and do a simple request
    String connectionId = blockingSSLConnect();
    assertEquals("hello", blockingRequest(connectionId, "hello"));

    // disconnect
    server.closeConnections();
    while (!selector.disconnected().contains(connectionId)) {
      selector.poll(1000L);
    }

    // reconnect and do another request
    connectionId = blockingSSLConnect();
    assertEquals("hello", blockingRequest(connectionId, "hello"));
  }
コード例 #2
0
ファイル: SSLSelectorTest.java プロジェクト: xiahome/ambry
 @Before
 public void setup() throws Exception {
   trustStoreFile = File.createTempFile("truststore", ".jks");
   SSLConfig sslConfig =
       new SSLConfig(
           TestSSLUtils.createSslProps(
               "DC1,DC2,DC3", SSLFactory.Mode.SERVER, trustStoreFile, "server"));
   SSLConfig clientSSLConfig =
       new SSLConfig(
           TestSSLUtils.createSslProps(
               "DC1,DC2,DC3", SSLFactory.Mode.CLIENT, trustStoreFile, "client"));
   SSLFactory serverSSLFactory = new SSLFactory(sslConfig);
   SSLFactory clientSSLFactory = new SSLFactory(clientSSLConfig);
   server = new EchoServer(serverSSLFactory, 18383);
   server.start();
   selector =
       new Selector(
           new NetworkMetrics(new MetricRegistry()), SystemTime.getInstance(), clientSSLFactory);
 }
コード例 #3
0
ファイル: SSLSelectorTest.java プロジェクト: xiahome/ambry
 @After
 public void teardown() throws Exception {
   selector.close();
   server.close();
 }