added a test case to test out AMQ-980 and from the looks of things, things are actually working fine for last image policy with wildcards

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@465266 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-10-18 14:50:53 +00:00
parent 7a1d626a00
commit d287bb1d49
4 changed files with 111 additions and 5 deletions

View File

@ -0,0 +1,51 @@
/**
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.test.retroactive;
import org.apache.activemq.command.ActiveMQTopic;
import javax.jms.MessageProducer;
import javax.jms.TextMessage;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
/**
*
* @version $Revision$
*/
public class RetroactiveConsumerTestWithLastImagePolicyWithWildcardTest extends RetroactiveConsumerTestWithSimpleMessageListTest {
private int counter = 1;
protected void sendMessage(MessageProducer producer, TextMessage message) throws JMSException {
ActiveMQTopic topic = new ActiveMQTopic(destination.toString() + "." + (counter++));
System.out.println("Sending to destination: " + topic);
producer.send(topic, message);
}
protected MessageProducer createProducer() throws JMSException {
return session.createProducer(null);
}
protected MessageConsumer createConsumer() throws JMSException {
return session.createConsumer( new ActiveMQTopic(destination.toString() + ".>"));
}
protected String getBrokerXml() {
return "org/apache/activemq/test/retroactive/activemq-lastimage-policy.xml";
}
}

View File

@ -26,6 +26,7 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer; import javax.jms.MessageProducer;
import javax.jms.Session; import javax.jms.Session;
import javax.jms.TextMessage; import javax.jms.TextMessage;
import javax.jms.JMSException;
import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.EmbeddedBrokerTestSupport;
@ -47,10 +48,10 @@ public class RetroactiveConsumerTestWithSimpleMessageListTest extends EmbeddedBr
// lets some messages // lets some messages
connection = createConnection(); connection = createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination); MessageProducer producer = createProducer();
for (int i = 0; i < messageCount; i++) { for (int i = 0; i < messageCount; i++) {
TextMessage message = session.createTextMessage("Message: " + i + " sent at: " + new Date()); TextMessage message = session.createTextMessage("Message: " + i + " sent at: " + new Date());
producer.send(message); sendMessage(producer, message);
} }
producer.close(); producer.close();
session.close(); session.close();
@ -60,7 +61,7 @@ public class RetroactiveConsumerTestWithSimpleMessageListTest extends EmbeddedBr
connection.start(); connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(destination); MessageConsumer consumer = createConsumer();
MessageIdList listener = new MessageIdList(); MessageIdList listener = new MessageIdList();
consumer.setMessageListener(listener); consumer.setMessageListener(listener);
listener.waitForMessagesToArrive(messageCount); listener.waitForMessagesToArrive(messageCount);
@ -105,4 +106,16 @@ public class RetroactiveConsumerTestWithSimpleMessageListTest extends EmbeddedBr
return "org/apache/activemq/test/retroactive/activemq-fixed-buffer.xml"; return "org/apache/activemq/test/retroactive/activemq-fixed-buffer.xml";
} }
protected MessageProducer createProducer() throws JMSException {
return session.createProducer(destination);
}
protected void sendMessage(MessageProducer producer, TextMessage message) throws JMSException {
producer.send(message);
}
protected MessageConsumer createConsumer() throws JMSException {
return session.createConsumer(destination);
}
} }

View File

@ -104,8 +104,8 @@ public class MessageIdList extends Assert implements MessageListener {
messageIds.add(id); messageIds.add(id);
semaphore.notifyAll(); semaphore.notifyAll();
} }
if (verbose) { if (log.isDebugEnabled()) {
log.info("Received message: " + message); log.debug("Received message: " + message);
} }
} catch (JMSException e) { } catch (JMSException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
-->
<!-- this file can only be parsed using the xbean-spring library -->
<!-- START SNIPPET: xbean -->
<beans>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<broker persistent="false" xmlns="http://activemq.org/config/1.0">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic="org.apache.activemq.test.>">
<subscriptionRecoveryPolicy>
<lastImageSubscriptionRecoveryPolicy/>
</subscriptionRecoveryPolicy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
</broker>
</beans>
<!-- END SNIPPET: xbean -->