From b97dbff52ac698284cb1a232b8a94b711717522c Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Wed, 1 Jul 2009 09:28:56 +0000 Subject: [PATCH] basic test case for https://issues.apache.org/activemq/browse/AMQ-1763 - but does not show the problem atm git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@790087 13f79535-47bb-0310-9956-ffa450edef68 --- .../virtual/VirtualTopicPubSubTest.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubTest.java b/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubTest.java index b6b5432358..f2c03a6bfd 100644 --- a/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubTest.java @@ -17,10 +17,14 @@ package org.apache.activemq.broker.virtual; import javax.jms.Connection; +import javax.jms.JMSException; +import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import junit.framework.Test; + import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; @@ -33,14 +37,35 @@ import org.apache.activemq.spring.ConsumerBean; public class VirtualTopicPubSubTest extends EmbeddedBrokerTestSupport { private Connection connection; + public int ackMode = Session.AUTO_ACKNOWLEDGE; + public static Test suite() { + return suite(VirtualTopicPubSubTest.class); + } + + public void initCombosForTestVirtualTopicCreation() { + addCombinationValues("ackMode", new Object[] {new Integer(Session.AUTO_ACKNOWLEDGE), new Integer(Session.CLIENT_ACKNOWLEDGE) }); + } + public void testVirtualTopicCreation() throws Exception { if (connection == null) { connection = createConnection(); } connection.start(); - ConsumerBean messageList = new ConsumerBean(); + ConsumerBean messageList = new ConsumerBean() { + public synchronized void onMessage(Message message) { + super.onMessage(message); + if (ackMode == Session.CLIENT_ACKNOWLEDGE) { + try { + message.acknowledge(); + } catch (JMSException e) { + e.printStackTrace(); + } + } + + } + }; messageList.setVerbose(true); String queueAName = getVirtualTopicConsumerName(); @@ -48,7 +73,7 @@ public class VirtualTopicPubSubTest extends EmbeddedBrokerTestSupport { ActiveMQQueue queue1 = new ActiveMQQueue(queueAName); ActiveMQQueue queue2 = new ActiveMQQueue(queueAName); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Session session = connection.createSession(false, ackMode); MessageConsumer c1 = session.createConsumer(queue1); MessageConsumer c2 = session.createConsumer(queue2);