diff --git a/activemq-core/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithLastImagePolicyWithWildcardTest.java b/activemq-core/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithLastImagePolicyWithWildcardTest.java new file mode 100644 index 0000000000..8f3f30f318 --- /dev/null +++ b/activemq-core/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithLastImagePolicyWithWildcardTest.java @@ -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"; + } +} diff --git a/activemq-core/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithSimpleMessageListTest.java b/activemq-core/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithSimpleMessageListTest.java index c826173a37..d8277a29a6 100644 --- a/activemq-core/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithSimpleMessageListTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithSimpleMessageListTest.java @@ -26,6 +26,7 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import javax.jms.JMSException; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.EmbeddedBrokerTestSupport; @@ -47,10 +48,10 @@ public class RetroactiveConsumerTestWithSimpleMessageListTest extends EmbeddedBr // lets some messages connection = createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(destination); + MessageProducer producer = createProducer(); for (int i = 0; i < messageCount; i++) { TextMessage message = session.createTextMessage("Message: " + i + " sent at: " + new Date()); - producer.send(message); + sendMessage(producer, message); } producer.close(); session.close(); @@ -60,7 +61,7 @@ public class RetroactiveConsumerTestWithSimpleMessageListTest extends EmbeddedBr connection.start(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer consumer = session.createConsumer(destination); + MessageConsumer consumer = createConsumer(); MessageIdList listener = new MessageIdList(); consumer.setMessageListener(listener); listener.waitForMessagesToArrive(messageCount); @@ -105,4 +106,16 @@ public class RetroactiveConsumerTestWithSimpleMessageListTest extends EmbeddedBr 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); + } } diff --git a/activemq-core/src/test/java/org/apache/activemq/util/MessageIdList.java b/activemq-core/src/test/java/org/apache/activemq/util/MessageIdList.java index ecff2dff62..fd3e439377 100644 --- a/activemq-core/src/test/java/org/apache/activemq/util/MessageIdList.java +++ b/activemq-core/src/test/java/org/apache/activemq/util/MessageIdList.java @@ -104,8 +104,8 @@ public class MessageIdList extends Assert implements MessageListener { messageIds.add(id); semaphore.notifyAll(); } - if (verbose) { - log.info("Received message: " + message); + if (log.isDebugEnabled()) { + log.debug("Received message: " + message); } } catch (JMSException e) { e.printStackTrace(); diff --git a/activemq-core/src/test/resources/org/apache/activemq/test/retroactive/activemq-lastimage-policy.xml b/activemq-core/src/test/resources/org/apache/activemq/test/retroactive/activemq-lastimage-policy.xml new file mode 100644 index 0000000000..dcf3d80cd0 --- /dev/null +++ b/activemq-core/src/test/resources/org/apache/activemq/test/retroactive/activemq-lastimage-policy.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +