Ejemplo n.º 1
0
  /**
   * 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"));
  }
Ejemplo n.º 2
0
 @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);
 }
Ejemplo n.º 3
0
 @After
 public void teardown() throws Exception {
   selector.close();
   server.close();
 }