activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r634281 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/advisory/DestinationSource.java test/java/org/apache/activemq/advisory/DestinationListenerTest.java
Date Thu, 06 Mar 2008 14:40:15 GMT
Author: jstrachan
Date: Thu Mar  6 06:40:14 2008
New Revision: 634281

URL: http://svn.apache.org/viewvc?rev=634281&view=rev
Log:
updated the test case for http://issues.apache.org/activemq/browse/AMQ-1199 to make it a better
test

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/DestinationSource.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/DestinationSource.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/DestinationSource.java?rev=634281&r1=634280&r2=634281&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/DestinationSource.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/DestinationSource.java
Thu Mar  6 06:40:14 2008
@@ -67,7 +67,7 @@
         return listener;
     }
 
-    public void setConsumerListener(DestinationListener listener) {
+    public void setDestinationListener(DestinationListener listener) {
         this.listener = listener;
     }
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java?rev=634281&r1=634280&r2=634281&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java
Thu Mar  6 06:40:14 2008
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.advisory;
 
+import java.util.Set;
+
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.EmbeddedBrokerTestSupport;
 import org.apache.activemq.broker.BrokerService;
@@ -29,23 +31,36 @@
  * @version $Revision$
  */
 public class DestinationListenerTest extends EmbeddedBrokerTestSupport implements DestinationListener
{
-    private static final Log LOG = LogFactory.getLog(DestinationListenerTest.class);
+    private static final transient Log LOG = LogFactory.getLog(DestinationListenerTest.class);
+
     protected ActiveMQConnection connection;
-    protected DestinationSource destinationSource;
+    protected ActiveMQQueue sampleQueue = new ActiveMQQueue("foo.bar");
+    protected ActiveMQTopic sampleTopic = new ActiveMQTopic("cheese");
 
     public void testDestiationSource() throws Exception {
         Thread.sleep(1000);
-        System.out.println("Queues: " + destinationSource.getQueues());
-        System.out.println("Topics: " + destinationSource.getTopics());
+
+        DestinationSource destinationSource = connection.getDestinationSource();
+        Set<ActiveMQQueue> queues = destinationSource.getQueues();
+        Set<ActiveMQTopic> topics = destinationSource.getTopics();
+
+        LOG.info("Queues: " + queues);
+        LOG.info("Topics: " + topics);
+
+        assertTrue("The queues should not be empty!", !queues.isEmpty());
+        assertTrue("The topics should not be empty!", !topics.isEmpty());
+
+        assertTrue("queues contains initial queue: " + queues, queues.contains(sampleQueue));
+        assertTrue("topics contains initial topic: " + queues, topics.contains(sampleTopic));
     }
 
     public void onDestinationEvent(DestinationEvent event) {
         ActiveMQDestination destination = event.getDestination();
         if (event.isAddOperation()) {
-            System.out.println("Added:   " + destination);
+            LOG.info("Added:   " + destination);
         }
         else {
-            System.out.println("Removed: " + destination);
+            LOG.info("Removed: " + destination);
         }
     }
 
@@ -54,16 +69,15 @@
 
         connection = (ActiveMQConnection) createConnection();
         connection.start();
-
-        destinationSource = connection.getDestinationSource();
+        connection.getDestinationSource().setDestinationListener(this);
     }
 
     @Override
     protected BrokerService createBroker() throws Exception {
         BrokerService broker = super.createBroker();
         broker.setDestinations(new ActiveMQDestination[]{
-                new ActiveMQQueue("foo.bar"),
-                new ActiveMQTopic("cheese")
+                sampleQueue,
+                sampleTopic
         });
         return broker;
     }



Mime
View raw message