summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2008-03-17 17:25:12 +0000
committerMartin Ritchie <ritchiem@apache.org>2008-03-17 17:25:12 +0000
commitfb03c42a89ce3d647416bb075d3a750b7b564e05 (patch)
tree3cb11bbf180d040a7b238af2f25eec448d54ffae
parent9be19ae547c592691ac4f3f085d8ffcdc23c4390 (diff)
downloadqpid-python-fb03c42a89ce3d647416bb075d3a750b7b564e05.tar.gz
QPID-854 : Fixed QueueBrowser tests that use ClientAck and Transacted, which appear to leave msgs behind per test. Even though each test should be on a new VM broker.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@637979 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java b/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java
index 624d9c9f3d..b6646ba0e4 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java
@@ -26,10 +26,19 @@ import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
import org.apache.qpid.server.registry.ApplicationRegistry;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
import javax.naming.Context;
+import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.Map;
public class VMTestCase extends TestCase
@@ -104,12 +113,38 @@ public class VMTestCase extends TestCase
protected void tearDown() throws Exception
{
+ purgeQueues();
+
TransportConnection.killVMBroker(1);
ApplicationRegistry.remove(1);
super.tearDown();
}
+ private void purgeQueues() throws NamingException, JMSException
+ {
+ Connection connection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Iterator<String> queueNames = new HashSet<String>(_queues.values()).iterator();
+
+
+ //todo this could be replaced with an AMQP purge queue command.
+ while (queueNames.hasNext())
+ {
+ MessageConsumer consumer = session.createConsumer(session.createQueue(queueNames.next()));
+
+ Message message = consumer.receive(RECEIVE_TIMEOUT);
+
+ while (message != null)
+ {
+ message = consumer.receive(RECEIVE_TIMEOUT);
+ }
+
+ }
+ }
+
public int getMessageCount(String queueName)
{
return ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost(_virtualhost.substring(1))