From f2090c0d863b07e3bad8d16a3efddfad6ff77960 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Tue, 08 Oct 2013 14:16:54 +0000
Subject: [PATCH] Fix OPENDJ-346 Consider using java.util.ServiceLoader for loading extensions and requesting transport implementations This a a part of OPENDJ-175 - Decouple OpenDJ LDAP SDK from Grizzly CR-2440
---
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPConnectionFactoryTestCase.java | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPConnectionFactoryTestCase.java b/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPConnectionFactoryTestCase.java
index 01c2914..171df62 100644
--- a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPConnectionFactoryTestCase.java
+++ b/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());
}
}
--
Gitblit v1.10.0