This commit is contained in:
rajdavies 2013-11-14 09:47:40 +00:00
parent c55a666921
commit 291ec5ea17
2 changed files with 47 additions and 0 deletions

View File

@ -174,6 +174,32 @@ public class JmsTopicWildcardSendReceiveTest extends JmsTopicSendReceiveTest {
assertNull(consumer.receiveNoWait()); assertNull(consumer.receiveNoWait());
} }
public void testReceiveWildcardTopicMatchSinglePastTheEndWildcard() throws Exception {
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQDestination destination1 = (ActiveMQDestination)session.createTopic("a.>");
ActiveMQDestination destination2 = (ActiveMQDestination)session.createTopic("a");
Message m = null;
MessageConsumer consumer = null;
String text = null;
consumer = session.createConsumer(destination1);
sendMessage(session, destination2, destination3String);
m = consumer.receive(1000);
assertNotNull(m);
text = ((TextMessage)m).getText();
if (!(text.equals(destination1String) || text.equals(destination3String))) {
fail("unexpected message:" + text);
}
assertNull(consumer.receiveNoWait());
}
private void sendMessage(Session session, Destination destination, String text) throws JMSException { private void sendMessage(Session session, Destination destination, String text) throws JMSException {
MessageProducer producer = session.createProducer(destination); MessageProducer producer = session.createProducer(destination);

View File

@ -41,4 +41,25 @@ public class DestinationFilterTest extends TestCase {
assertTrue("Filter not parsed well: " + filter.getClass(), filter instanceof CompositeDestinationFilter); assertTrue("Filter not parsed well: " + filter.getClass(), filter instanceof CompositeDestinationFilter);
assertFalse("Filter matched wrong destination type", filter.matches(new ActiveMQTopic("A.B"))); assertFalse("Filter matched wrong destination type", filter.matches(new ActiveMQTopic("A.B")));
} }
public void testMatchesChild() throws Exception{
DestinationFilter filter = DestinationFilter.parseFilter(new ActiveMQQueue("A.*.C"));
assertFalse("Filter matched wrong destination type", filter.matches(new ActiveMQTopic("A.B")));
assertTrue("Filter did not match", filter.matches(new ActiveMQQueue("A.B.C")));
filter = DestinationFilter.parseFilter(new ActiveMQQueue("A.*"));
assertTrue("Filter did not match", filter.matches(new ActiveMQQueue("A.B")));
assertFalse("Filter did match", filter.matches(new ActiveMQQueue("A")));
}
public void testMatchesAny() throws Exception{
DestinationFilter filter = DestinationFilter.parseFilter(new ActiveMQQueue("A.>.>"));
assertTrue("Filter did not match", filter.matches(new ActiveMQQueue("A.C")));
assertFalse("Filter did match", filter.matches(new ActiveMQQueue("B")));
assertTrue("Filter did not match", filter.matches(new ActiveMQQueue("A.B")));
assertTrue("Filter did not match", filter.matches(new ActiveMQQueue("A.B.C.D.E.F")));
assertTrue("Filter did not match", filter.matches(new ActiveMQQueue("A")));
}
} }