private void testCreateLdapContextSSLSocketFactory(boolean trusting) throws Exception {
    Injector injector = getInjector();

    Configuration configuration = injector.getInstance(Configuration.class);
    expect(configuration.validateKerberosOperationSSLCertTrust()).andReturn(!trusting).once();

    LdapContext initialContext = createNiceMock(LdapContext.class);

    Capture<? extends Properties> capturedProperties = newCapture(CaptureType.FIRST);

    ADKerberosOperationHandler handler = createMockBuilder(ADKerberosOperationHandler.class)
        .addMockedMethod(ADKerberosOperationHandler.class.getDeclaredMethod("createInitialLdapContext", Properties.class, Control[].class))
        .createNiceMock();
    injector.injectMembers(handler);

    expect(handler.createInitialLdapContext(capture(capturedProperties), anyObject(Control[].class)))
        .andReturn(initialContext)
        .once();

    replayAll();

    handler.open(new PrincipalKeyCredential("principal", "key"), "EXAMPLE.COM", getKerberosEnv());

    Properties properties = capturedProperties.getValue();
    Assert.assertNotNull(properties);

    String socketFactoryClassName = properties.getProperty("java.naming.ldap.factory.socket");
    if (trusting) {
      Assert.assertEquals(InternalSSLSocketFactoryTrusting.class.getName(), socketFactoryClassName);
    } else {
      Assert.assertEquals(InternalSSLSocketFactoryNonTrusting.class.getName(), socketFactoryClassName);
    }
  }
Implementation to illustrate the use of operations on this class

@throws Throwable
ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandlerTest.java