You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2011/02/09 20:20:46 UTC

svn commit: r1069045 - /uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/utils/ActiveMQSupport.java

Author: cwiklik
Date: Wed Feb  9 19:20:46 2011
New Revision: 1069045

URL: http://svn.apache.org/viewvc?rev=1069045&view=rev
Log:
UIMA-2038 Modified to clean broker between each test

Modified:
    uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/utils/ActiveMQSupport.java

Modified: uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/utils/ActiveMQSupport.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/utils/ActiveMQSupport.java?rev=1069045&r1=1069044&r2=1069045&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/utils/ActiveMQSupport.java (original)
+++ uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/utils/ActiveMQSupport.java Wed Feb  9 19:20:46 2011
@@ -23,10 +23,12 @@ import java.io.IOException;
 import java.lang.reflect.Method;
 import java.net.ServerSocket;
 import java.net.URI;
+import java.util.Set;
 import java.util.concurrent.Semaphore;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
+import javax.management.ObjectName;
 
 import junit.framework.TestCase;
 
@@ -37,6 +39,7 @@ import org.apache.activemq.broker.Transp
 import org.apache.activemq.broker.region.policy.PolicyEntry;
 import org.apache.activemq.broker.region.policy.PolicyMap;
 import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy;
+import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
 import org.apache.uima.UIMAFramework;
 import org.apache.uima.adapter.jms.JmsConstants;
@@ -106,11 +109,32 @@ public class ActiveMQSupport extends Tes
         brokerSemaphore.release();
       }
     } else {
-      // Remove messages from all queues
-      broker.deleteAllMessages();
+      cleanBroker(broker);
     }
   }
+  protected void cleanBroker( BrokerService targetBroker) throws Exception {
+    // Remove messages from all queues
+    targetBroker.deleteAllMessages();
+    org.apache.activemq.broker.Connection[] connections = targetBroker.getRegionBroker().getClients();
+    for( org.apache.activemq.broker.Connection connection : connections) {
+      try {
+        connection.stop();
+      } catch( Exception e) {
+        e.printStackTrace();
+      }
+    }
+
+    ActiveMQDestination[] destinations = targetBroker.getRegionBroker().getDestinations();
 
+    if ( destinations != null ) {
+      for( ActiveMQDestination destination: destinations ) {
+        if ( !destination.isTopic() ) {
+          targetBroker.removeDestination(destination);
+        }
+      }
+    }
+  }
+  
   protected String addHttpConnector(int aDefaultPort) throws Exception {
     return addHttpConnector(broker, aDefaultPort);
   }