https://issues.apache.org/activemq/browse/AMQ-2980 - modify the test case to show dupliacte problem

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1033468 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2010-11-10 13:52:40 +00:00
parent 8ba8b61688
commit 69dc0d4940
2 changed files with 14 additions and 5 deletions

View File

@ -45,8 +45,8 @@ abstract public class MessagePriorityTest extends CombinationTestSupport {
BrokerService broker; BrokerService broker;
PersistenceAdapter adapter; PersistenceAdapter adapter;
ActiveMQConnectionFactory factory; protected ActiveMQConnectionFactory factory;
Connection conn; protected Connection conn;
protected Session sess; protected Session sess;
public boolean useCache = true; public boolean useCache = true;

View File

@ -21,7 +21,9 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Vector; import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import javax.jms.Connection;
import javax.jms.Message; import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TopicSubscriber; import javax.jms.TopicSubscriber;
import junit.framework.Test; import junit.framework.Test;
import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.command.ActiveMQTopic;
@ -101,7 +103,12 @@ public class JDBCMessagePriorityTest extends MessagePriorityTest {
public void testConcurrentDurableSubsReconnectWithXLevels() throws Exception { public void testConcurrentDurableSubsReconnectWithXLevels() throws Exception {
ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST"); ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST");
final String subName = "priorityDisconnect"; final String subName = "priorityDisconnect";
TopicSubscriber sub = sess.createDurableSubscriber(topic, subName); Connection consumerConn = factory.createConnection();
consumerConn.setClientID("priorityDisconnect");
consumerConn.start();
Session consumerSession = consumerConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
TopicSubscriber sub = consumerSession.createDurableSubscriber(topic, subName);
sub.close(); sub.close();
final int maxPriority = 5; final int maxPriority = 5;
@ -119,7 +126,7 @@ public class JDBCMessagePriorityTest extends MessagePriorityTest {
final int closeFrequency = MSG_NUM/2; final int closeFrequency = MSG_NUM/2;
HashMap dups = new HashMap(); HashMap dups = new HashMap();
sub = sess.createDurableSubscriber(topic, subName); sub = consumerSession.createDurableSubscriber(topic, subName);
for (int i=0; i < MSG_NUM * maxPriority; i++) { for (int i=0; i < MSG_NUM * maxPriority; i++) {
Message msg = sub.receive(10000); Message msg = sub.receive(10000);
assertNull("no duplicate message", dups.put(msg.getJMSMessageID(), subName)); assertNull("no duplicate message", dups.put(msg.getJMSMessageID(), subName));
@ -131,11 +138,13 @@ public class JDBCMessagePriorityTest extends MessagePriorityTest {
if (i > 0 && i % closeFrequency == 0) { if (i > 0 && i % closeFrequency == 0) {
LOG.info("Closing durable sub.. on: " + i + ", counts: " + Arrays.toString(messageCounts)); LOG.info("Closing durable sub.. on: " + i + ", counts: " + Arrays.toString(messageCounts));
sub.close(); sub.close();
sub = sess.createDurableSubscriber(topic, subName); sub = consumerSession.createDurableSubscriber(topic, subName);
} }
} }
LOG.info("closing on done!"); LOG.info("closing on done!");
sub.close(); sub.close();
consumerSession.close();
consumerConn.close();
for (ProducerThread producer : producers) { for (ProducerThread producer : producers) {
producer.join(); producer.join();