KeyManagerProxy extends X509ExtendedKeyManager { @Override public String chooseServerAlias(String s, Principal[] principals, Socket socket) { return keyManager.chooseServerAlias(s, principals, socket); } KeyManagerProxy(KeyManager[] keyManagers); void setKeyManager(final KeyManager[] keyManagers); @Override String[] getClientAliases(String s, Principal[] principals); @Override String chooseClientAlias(String[] strings, Principal[] principals, Socket socket); @Override String[] getServerAliases(String s, Principal[] principals); @Override String chooseServerAlias(String s, Principal[] principals, Socket socket); @Override X509Certificate[] getCertificateChain(String s); @Override PrivateKey getPrivateKey(String s); @Override String chooseEngineClientAlias(String[] keyType, Principal[] issuers, SSLEngine engine); @Override String chooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine engine);  }
@SuppressWarnings("ConstantConditions") @Test public void testKeyManagerProxyChooseServerAlias(@Mocked X509ExtendedKeyManager mockedKeyManager) { new Expectations() {{ mockedKeyManager.chooseServerAlias("cert", (Principal[]) any, (Socket) any); times = 1; }}; KeyManagerProxy keyManagerProxy = new KeyManagerProxy(new KeyManager[]{mockedKeyManager}); keyManagerProxy.chooseServerAlias("cert", null, null); }