@Test
  public void validateConnectionTest() throws Exception {
    //sslSession is null
    TestUtils.assertException(IllegalArgumentException.class,
        () -> serverSecurityService.validateConnection(null).get(), null);

    //success case
    SSLSession sslSession = Mockito.mock(SSLSession.class);
    serverSecurityService.validateConnection(sslSession, (r, e) -> {
      Assert.assertNull("result not null", r);
      Assert.assertNull("exception not null", e);
    });


    //service is closed
    serverSecurityService.close();
    ThrowingConsumer<ExecutionException> errorAction = e -> {
      Assert.assertTrue("Exception should have been an instance of RestServiceException",
          e.getCause() instanceof RestServiceException);
      RestServiceException re = (RestServiceException) e.getCause();
      Assert.assertEquals("Unexpected RestServerErrorCode (Future)", RestServiceErrorCode.ServiceUnavailable,
          re.getErrorCode());
    };
    TestUtils.assertException(ExecutionException.class, () -> serverSecurityService.validateConnection(sslSession).get(),
        errorAction);
  }
Tests for {@link AmbryServerSecurityService#validateConnection(SSLSession, Callback)}
@throws Exception
ambry-server/src/test/java/com/github/ambry/server/AmbryServerSecurityServiceTest.java