From 0a3a1f1060a2f94800dcc0fd70e53713d7fad6c8 Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Mon, 12 Mar 2007 14:44:09 +0000
Subject: [PATCH] - Enable the checkPostconnectDisconnectPlugin test case in the   postConnectedDisconnectTest class: Daily builds aren't failed due to this test

---
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/postConnectedDisconnectTest.java |   35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/postConnectedDisconnectTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/postConnectedDisconnectTest.java
index 4e9e325..6ca04f8 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/postConnectedDisconnectTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/postConnectedDisconnectTest.java
@@ -62,7 +62,7 @@
    * Perform a simple connect.
    * @throws Exception If something wrong occurs.
    */
-  @Test(enabled = false)
+  @Test(enabled = true, groups = {"slow"})
   public void checkPostconnectDisconnectPlugin() throws Exception
   {
     // Before the test, how many time postconnect and postdisconnect
@@ -81,20 +81,39 @@
     assertNotNull(opendsConnector);
 
     // Check that number of postconnect has been incremented.
-    Thread.sleep(3000);
-    int postConnectAfter = InvocationCounterPlugin.getPostConnectCount();
-    int postDisconnectAfter = InvocationCounterPlugin.getPostDisconnectCount();
+    // Don't wait more than 5 seconds
+    long endTime = System.currentTimeMillis() + 5000;
+    int postConnectAfter = postConnectBefore;
+
+    while ((System.currentTimeMillis() < endTime)
+        && (postConnectAfter == postConnectAfter))
+    {
+      Thread.sleep(10);
+      postConnectAfter = InvocationCounterPlugin.getPostConnectCount();
+    }
     assertEquals(postConnectBefore +1, postConnectAfter);
+
+    // Check that postDisconnect is not incremented.
+    int postDisconnectAfter = InvocationCounterPlugin.getPostDisconnectCount();
     assertEquals(postDisconnectBefore, postDisconnectAfter);
 
     // Close the client connection
     opendsConnector.close();
-    Thread.sleep(3000);
 
     // Check that number of postdisconnect has been incremented.
-    postConnectAfter = InvocationCounterPlugin.getPostConnectCount();
-    postDisconnectAfter = InvocationCounterPlugin.getPostDisconnectCount();
-    assertEquals(postConnectBefore +1 , postConnectAfter);
+    // Don't wait more than 5 seconds
+    endTime = System.currentTimeMillis() + 5000;
+    postDisconnectAfter = postDisconnectBefore;
+    while ((System.currentTimeMillis() < endTime)
+        && (postDisconnectAfter == postDisconnectBefore))
+    {
+      Thread.sleep(10);
+      postDisconnectAfter = InvocationCounterPlugin.getPostDisconnectCount();
+    }
     assertEquals(postDisconnectBefore +1 , postDisconnectAfter);
+
+    // Check that postDisconnect is not incremented again.
+    postConnectAfter = InvocationCounterPlugin.getPostConnectCount();
+    assertEquals(postConnectBefore +1 , postConnectAfter);
   }
 }

--
Gitblit v1.10.0