mirror of https://github.com/apache/activemq.git
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
This commit is contained in:
parent
f6efc5660d
commit
5e897d6c38
activemq-core/src
main/java/org/apache/activemq/advisory
test/java/org/apache/activemq/advisory
|
@ -67,7 +67,7 @@ public class DestinationSource implements MessageListener {
|
||||||
return listener;
|
return listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConsumerListener(DestinationListener listener) {
|
public void setDestinationListener(DestinationListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.advisory;
|
package org.apache.activemq.advisory;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.activemq.ActiveMQConnection;
|
import org.apache.activemq.ActiveMQConnection;
|
||||||
import org.apache.activemq.EmbeddedBrokerTestSupport;
|
import org.apache.activemq.EmbeddedBrokerTestSupport;
|
||||||
import org.apache.activemq.broker.BrokerService;
|
import org.apache.activemq.broker.BrokerService;
|
||||||
|
@ -29,23 +31,36 @@ import org.apache.commons.logging.LogFactory;
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
public class DestinationListenerTest extends EmbeddedBrokerTestSupport implements DestinationListener {
|
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 ActiveMQConnection connection;
|
||||||
protected DestinationSource destinationSource;
|
protected ActiveMQQueue sampleQueue = new ActiveMQQueue("foo.bar");
|
||||||
|
protected ActiveMQTopic sampleTopic = new ActiveMQTopic("cheese");
|
||||||
|
|
||||||
public void testDestiationSource() throws Exception {
|
public void testDestiationSource() throws Exception {
|
||||||
Thread.sleep(1000);
|
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) {
|
public void onDestinationEvent(DestinationEvent event) {
|
||||||
ActiveMQDestination destination = event.getDestination();
|
ActiveMQDestination destination = event.getDestination();
|
||||||
if (event.isAddOperation()) {
|
if (event.isAddOperation()) {
|
||||||
System.out.println("Added: " + destination);
|
LOG.info("Added: " + destination);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
System.out.println("Removed: " + destination);
|
LOG.info("Removed: " + destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,16 +69,15 @@ public class DestinationListenerTest extends EmbeddedBrokerTestSupport implement
|
||||||
|
|
||||||
connection = (ActiveMQConnection) createConnection();
|
connection = (ActiveMQConnection) createConnection();
|
||||||
connection.start();
|
connection.start();
|
||||||
|
connection.getDestinationSource().setDestinationListener(this);
|
||||||
destinationSource = connection.getDestinationSource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BrokerService createBroker() throws Exception {
|
protected BrokerService createBroker() throws Exception {
|
||||||
BrokerService broker = super.createBroker();
|
BrokerService broker = super.createBroker();
|
||||||
broker.setDestinations(new ActiveMQDestination[]{
|
broker.setDestinations(new ActiveMQDestination[]{
|
||||||
new ActiveMQQueue("foo.bar"),
|
sampleQueue,
|
||||||
new ActiveMQTopic("cheese")
|
sampleTopic
|
||||||
});
|
});
|
||||||
return broker;
|
return broker;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue