mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Nicolas Capponi
08.16.2013 f2090c0d863b07e3bad8d16a3efddfad6ff77960
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPConnectionFactoryTestCase.java
@@ -27,6 +27,7 @@
import static org.fest.assertions.Assertions.assertThat;
import static org.forgerock.opendj.ldap.TestCaseUtils.findFreeSocketAddress;
import static org.forgerock.opendj.ldap.TestCaseUtils.getLDAPTestOptions;
import static org.mockito.Mockito.mock;
import java.io.IOException;
@@ -44,6 +45,21 @@
    // Test timeout for tests which need to wait for network events.
    private static final long TEST_TIMEOUT = 30L;
    @Test
    public void testCreateLDAPConnectionFactory() throws Exception {
        // test no exception is thrown, which means transport provider is correctly loaded
        LDAPConnectionFactory factory = new LDAPConnectionFactory(findFreeSocketAddress(), getLDAPTestOptions());
        factory.close();
    }
    @Test(expectedExceptions = { ProviderNotFoundException.class },
            expectedExceptionsMessageRegExp = "^The requested provider 'unknown' .*")
    public void testCreateLDAPConnectionFactoryFailureProviderNotFound() throws Exception {
        LDAPOptions options = getLDAPTestOptions().setTransportProvider("unknown");
        LDAPConnectionFactory factory = new LDAPConnectionFactory(findFreeSocketAddress(), options);
        factory.close();
    }
    /**
     * This unit test exposes the bug raised in issue OPENDJ-1156: NPE in
     * ReferenceCountedObject after shutting down directory.
@@ -53,7 +69,8 @@
        final AtomicReference<LDAPClientContext> context = new AtomicReference<LDAPClientContext>();
        final Semaphore latch = new Semaphore(0);
        final LDAPListener server = createServer(latch, context);
        final ConnectionFactory factory = new LDAPConnectionFactory(server.getSocketAddress());
        final ConnectionFactory factory = new LDAPConnectionFactory(server.getSocketAddress(),
                getLDAPTestOptions());
        try {
            for (int i = 0; i < 100; i++) {
                // Connect to the server.
@@ -92,6 +109,7 @@
                        latch.release();
                        return mock(ServerConnection.class);
                    }
                });
                },
                TestCaseUtils.getLDAPListenerTestOptions());
    }
}