@Test
public void testCreateKeyManager() throws Exception {

  ProxyCA proxyCA = new ProxyCA();
  proxyCA.init();
  X509KeyManager keyManager = proxyCA.getX509KeyManager();
  Assert.assertArrayEquals(new String[]{"client"},
      keyManager.getClientAliases(null, null));
  Assert.assertEquals("client",
      keyManager.chooseClientAlias(null, null, null));
  Assert.assertNull(keyManager.getServerAliases(null, null));
  Assert.assertNull(keyManager.chooseServerAlias(null, null, null));
  byte[] truststoreBytes = proxyCA.getChildTrustStore("password");
  KeyStore truststore = KeyStoreTestUtil.bytesToKeyStore(truststoreBytes,
      "password");
  Assert.assertEquals(1, truststore.size());
  X509Certificate caCert =
      (X509Certificate) truststore.getCertificate("client");
  Assert.assertArrayEquals(new X509Certificate[]{caCert},
      keyManager.getCertificateChain(null));
  Assert.assertEquals(proxyCA.getCaCert(), caCert);
  PrivateKey caPrivateKey = keyManager.getPrivateKey(null);
  PublicKey caPublicKey = caCert.getPublicKey();
  checkPrivatePublicKeys(caPrivateKey, caPublicKey);
  Assert.assertEquals(proxyCA.getCaKeyPair().getPublic(), caPublicKey);
  Assert.assertEquals(proxyCA.getCaKeyPair().getPrivate(), caPrivateKey);
}