From 5e897d6c384623061a757470af4978fb201e11a4 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Thu, 6 Mar 2008 14:40:14 +0000 Subject: [PATCH] updated the test case for http://issues.apache.org/activemq/browse/AMQ-1199 to make it a better test git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@634281 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/advisory/DestinationSource.java | 2 +- .../advisory/DestinationListenerTest.java | 34 +++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/advisory/DestinationSource.java b/activemq-core/src/main/java/org/apache/activemq/advisory/DestinationSource.java index 8533148585..e9dcb75af5 100644 --- a/activemq-core/src/main/java/org/apache/activemq/advisory/DestinationSource.java +++ b/activemq-core/src/main/java/org/apache/activemq/advisory/DestinationSource.java @@ -67,7 +67,7 @@ public class DestinationSource implements MessageListener { return listener; } - public void setConsumerListener(DestinationListener listener) { + public void setDestinationListener(DestinationListener listener) { this.listener = listener; } diff --git a/activemq-core/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java b/activemq-core/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java index f39064ffc1..6b5575f520 100644 --- a/activemq-core/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java @@ -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 @@ import org.apache.commons.logging.LogFactory; * @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 queues = destinationSource.getQueues(); + Set 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 @@ public class DestinationListenerTest extends EmbeddedBrokerTestSupport implement 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; }