summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2009-09-01 11:47:14 +0000
committerMartin Ritchie <ritchiem@apache.org>2009-09-01 11:47:14 +0000
commit979eff56851ccb79993a278487597cb3b539e2d3 (patch)
tree599755b73a8a24737d57df9750da5d55f5aae55f
parent52727c5caedfefbea07c102a06f6c4adb140a44d (diff)
downloadqpid-python-979eff56851ccb79993a278487597cb3b539e2d3.tar.gz
QPID-2077 : The problem with the tearDown is that we still have a race condition when a control thread trys to close the connection at the same time as the exception handling thread is also closing the connection.
Solution here is to wait for the exception handling thread to have done enough to mark the connnection closed so the race condition will not occur. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@809981 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java
index 7a2266902b..b4ba6e8156 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java
@@ -29,6 +29,8 @@ import org.apache.qpid.server.logging.AbstractTestLogging;
import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
import javax.jms.Connection;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
import javax.management.JMException;
import javax.management.MBeanException;
import javax.management.MBeanServerConnection;
@@ -38,6 +40,8 @@ import javax.management.remote.JMXConnector;
import java.io.IOException;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
/**
* Test class to test if any change in the broker JMX code is affesting the management console
@@ -161,6 +165,23 @@ public class ManagementActorLoggingTest extends AbstractTestLogging
//Create a connection to the broker
Connection connection = getConnection();
+ // Monitor the connection for an exception being thrown
+ // this should be a DisconnectionException but it is not this tests
+ // job to valiate that. Only use the exception as a synchronisation
+ // to check the log file for the Close message
+ final CountDownLatch exceptionReceived = new CountDownLatch(1);
+ connection.setExceptionListener(new ExceptionListener()
+ {
+ public void onException(JMSException e)
+ {
+ //Failover being attempted.
+ exceptionReceived.countDown();
+ }
+ });
+
+ //Remove the connection close from any 0-10 connections
+ _monitor.reset();
+
// Get all active AMQP connections
AllObjects allObject = new AllObjects(_mbsc);
allObject.querystring = "org.apache.qpid:type=VirtualHost.Connection,*";
@@ -175,16 +196,17 @@ public class ManagementActorLoggingTest extends AbstractTestLogging
newProxyInstance(_mbsc, connectionName,
ManagedConnection.class, false);
- //Remove the connection close from any 0-10 connections
- _monitor.reset();
//Close the connection
mangedConnection.closeConnection();
+ //Wait for the connection to close
+ assertTrue("Timed out waiting for conneciton to report close",
+ exceptionReceived.await(2, TimeUnit.SECONDS));
+
//Validate results
List<String> results = _monitor.findMatches("CON-1002");
-
assertEquals("Unexpected Connection Close count", 1, results.size());
}
}