From afcefa0111b71226294f4c2ed1b7777a6aa8aa8a Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Wed, 25 Jan 2006 20:06:17 +0000 Subject: [PATCH] Added durable topic test for master/slave git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@372300 13f79535-47bb-0310-9956-ffa450edef68 --- ...opicSendReceiveWithTwoConnectionsTest.java | 9 +++- .../broker/ft/TopicMasterSlaveTest.java | 41 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 activemq-core/src/test/java/org/apache/activemq/broker/ft/TopicMasterSlaveTest.java diff --git a/activemq-core/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java b/activemq-core/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java index 53c1fb3ede..cc20abc5ce 100755 --- a/activemq-core/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java @@ -18,6 +18,9 @@ package org.apache.activemq; import javax.jms.Connection; import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; import javax.jms.Session; import org.apache.activemq.ActiveMQConnectionFactory; @@ -72,7 +75,7 @@ public class JmsTopicSendReceiveWithTwoConnectionsTest extends JmsSendReceiveTes log.info("Created consumer destination: " + consumerDestination + " of type: " + consumerDestination.getClass()); log.info("Created producer destination: " + producerDestination + " of type: " + producerDestination.getClass()); - consumer = receiveSession.createConsumer(consumerDestination); + consumer = createConsumer(receiveSession,consumerDestination); consumer.setMessageListener(this); @@ -86,6 +89,10 @@ public class JmsTopicSendReceiveWithTwoConnectionsTest extends JmsSendReceiveTes protected Connection createSendConnection() throws Exception { return createConnection(); } + + protected MessageConsumer createConsumer(Session session, Destination dest) throws JMSException{ + return session.createConsumer(dest); + } protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { return new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); diff --git a/activemq-core/src/test/java/org/apache/activemq/broker/ft/TopicMasterSlaveTest.java b/activemq-core/src/test/java/org/apache/activemq/broker/ft/TopicMasterSlaveTest.java new file mode 100644 index 0000000000..5a1f511515 --- /dev/null +++ b/activemq-core/src/test/java/org/apache/activemq/broker/ft/TopicMasterSlaveTest.java @@ -0,0 +1,41 @@ +/** + * + * Copyright 2005-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package org.apache.activemq.broker.ft; + +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import javax.jms.Topic; +/** + * Test failover for Queues + * + */ +public class TopicMasterSlaveTest extends QueueMasterSlaveTest{ + + protected boolean isTopic(){ + return true; + } + + protected MessageConsumer createConsumer(Session session,Destination dest) throws JMSException{ + return session.createDurableSubscriber((Topic) dest,dest.toString()); + } + + protected Connection createReceiveConnection() throws Exception{ + Connection result=super.createReceiveConnection(); + result.setClientID(getClass().getName()); + return result; + } +}