@Test
public void testClientAliasedX509ExtendedKeyManager() {

    SSLUtils.ClientAliasedX509ExtendedKeyManager keyManager = new SSLUtils.ClientAliasedX509ExtendedKeyManager(null, "testKeyAlias");
    assertNull(keyManager.getDelegate());
    assertThrows(RuntimeException.class, () -> {
        keyManager.chooseEngineServerAlias(null, null, null);
    });
    assertThrows(RuntimeException.class, () -> {
        keyManager.getServerAliases(null, null);
    });
    assertThrows(RuntimeException.class, () -> {
        keyManager.chooseServerAlias(null, null, null);
    });
    assertThrows(IllegalArgumentException.class, () -> {
        SSLUtils.loadServicePrivateKey("testFactoryClassFail");
    });
    String[] temp = new String[1];
    temp[0] = "tempTest";
    String[] clientAliases  = new String[2];
    clientAliases[0] = "testClientAlias1";
    clientAliases[1] = "testClientAlias2";
    X509ExtendedKeyManager mockKeyManager = Mockito.mock(X509ExtendedKeyManager.class);
    when(mockKeyManager.chooseEngineClientAlias(any(), any(), any())).thenReturn("testPass");
    when(mockKeyManager.chooseClientAlias(any(), any(), any())).thenReturn("testPass");
    when(mockKeyManager.getClientAliases(anyString(), any())).thenReturn(clientAliases);
    SSLUtils.ClientAliasedX509ExtendedKeyManager keyManagerTemp = new SSLUtils.ClientAliasedX509ExtendedKeyManager(mockKeyManager, null);
    assertEquals(keyManagerTemp.chooseEngineClientAlias(temp, null, null), "testPass");
    assertEquals(keyManagerTemp.chooseClientAlias(temp, null, null), "testPass");
    assertEquals(keyManagerTemp.getClientAliases("testKeyType", null), clientAliases);
    when(mockKeyManager.getClientAliases(anyString(), any())).thenReturn(clientAliases);
    keyManagerTemp = new SSLUtils.ClientAliasedX509ExtendedKeyManager(mockKeyManager, "testClientAlias2");
    assertEquals(keyManagerTemp.chooseEngineClientAlias(temp, null, null), "testClientAlias2");
    when(mockKeyManager.getClientAliases(anyString(), any())).thenReturn(null);
    assertNull(keyManagerTemp.chooseEngineClientAlias(temp, null, null));
}