/**
*
* Copyright 2004 Protique Ltd
*
* 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.codehaus.activemq.service;
import org.codehaus.activemq.DuplicateDurableSubscriptionException;
import org.codehaus.activemq.message.ActiveMQDestination;
import org.codehaus.activemq.message.ActiveMQMessage;
import org.codehaus.activemq.message.ActiveMQTopic;
import org.codehaus.activemq.message.ConsumerInfo;
import javax.jms.JMSException;
/**
* @version $Revision: 1.8 $
*/
public abstract class TopicMessageStoreTestSupport extends MessageStoreTestSupport {
public void testDuplicateSubscription() throws Exception {
ConsumerInfo info = createConsumerInfo();
// lets change the subscription
info.setSelector("priority > 3");
// this should fail as we'll have duplicate consumeres
try {
messageContainerManager.addMessageConsumer(client, info);
info = createConsumerInfo();
messageContainerManager.addMessageConsumer(client, info);
fail("Should have failed by now adding duplicate subscriptions to container manager: " + messageContainerManager);
}
catch (DuplicateDurableSubscriptionException e) {
System.out.println("Worked. Generated: " + e);
}
}
protected void acknowledgeMessage(int i) throws JMSException {
getTopicMessageContainer().setLastAcknowledgedMessageID(subscription, getMessage(i).getJMSMessageIdentity());
}
protected TopicMessageContainer getTopicMessageContainer() {
return (TopicMessageContainer) container;
}
protected ActiveMQDestination createDestination() {
return new ActiveMQTopic(getSubject());
}
protected void recover() throws JMSException {
getTopicMessageContainer().recoverSubscription(subscription);
}
protected ActiveMQMessage[] getMessagesToDispatch() throws JMSException {
return subscription.getMessagesToDispatch();
}
}