From 409dccd8ab1c190568228262d1ff0f4ac18fb9d8 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 20 Sep 2013 20:46:25 +0000
Subject: [PATCH] Unit test for OPENDJ-1121: Closing a connection after closing the connectionfactory causes NPE

---
 opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java b/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java
index 9c2ec9a..4ad9e45 100644
--- a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java
+++ b/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java
@@ -28,6 +28,7 @@
 package org.forgerock.opendj.ldap;
 
 import static org.fest.assertions.Assertions.assertThat;
+import static org.forgerock.opendj.ldap.Connections.newFixedConnectionPool;
 import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
 import static org.forgerock.opendj.ldap.TestCaseUtils.findFreeSocketAddress;
 import static org.forgerock.opendj.ldap.TestCaseUtils.getServerSocketAddress;
@@ -650,6 +651,21 @@
         }
     }
 
+    @Test(description = "Test for OPENDJ-1121", enabled = false)
+    public void testFactoryCloseBeforeConnectionClose() throws Exception {
+        final ConnectionFactory factory =
+                newFixedConnectionPool(new LDAPConnectionFactory(getServerSocketAddress()), 2);
+        Connection conn = null;
+        try {
+            conn = factory.getConnection();
+            factory.close();
+        } finally {
+            if (conn != null) {
+                conn.close();
+            }
+        }
+    }
+
     private void waitForCondition(Callable<Boolean> condition) throws Exception {
         long timeout = System.currentTimeMillis() + TEST_TIMEOUT_MS;
         while (!condition.call()) {

--
Gitblit v1.10.0