activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject [1/2] git commit: Fix for https://issues.apache.org/jira/browse/AMQ-4884
Date Thu, 14 Nov 2013 09:49:02 GMT
Updated Branches:
  refs/heads/trunk c55a66692 -> 0a67b12c6


Fix for https://issues.apache.org/jira/browse/AMQ-4884


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/291ec5ea
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/291ec5ea
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/291ec5ea

Branch: refs/heads/trunk
Commit: 291ec5ea17817cb374c1a2342dd280ee986ebaa3
Parents: c55a666
Author: rajdavies <rajdavies@gmail.com>
Authored: Thu Nov 14 09:47:40 2013 +0000
Committer: rajdavies <rajdavies@gmail.com>
Committed: Thu Nov 14 09:47:40 2013 +0000

----------------------------------------------------------------------
 .../JmsTopicWildcardSendReceiveTest.java        | 26 ++++++++++++++++++++
 .../activemq/filter/DestinationFilterTest.java  | 21 ++++++++++++++++
 2 files changed, 47 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/291ec5ea/activemq-unit-tests/src/test/java/org/apache/activemq/JmsTopicWildcardSendReceiveTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/JmsTopicWildcardSendReceiveTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/JmsTopicWildcardSendReceiveTest.java
index 52cf2be..eeb5999 100755
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/JmsTopicWildcardSendReceiveTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/JmsTopicWildcardSendReceiveTest.java
@@ -174,6 +174,32 @@ public class JmsTopicWildcardSendReceiveTest extends JmsTopicSendReceiveTest
{
         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 {
         MessageProducer producer = session.createProducer(destination);

http://git-wip-us.apache.org/repos/asf/activemq/blob/291ec5ea/activemq-unit-tests/src/test/java/org/apache/activemq/filter/DestinationFilterTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/filter/DestinationFilterTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/filter/DestinationFilterTest.java
index 53ea0e7..95af394 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/filter/DestinationFilterTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/filter/DestinationFilterTest.java
@@ -41,4 +41,25 @@ public class DestinationFilterTest extends TestCase {
 		assertTrue("Filter not parsed well: " + filter.getClass(), filter instanceof CompositeDestinationFilter);
 		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")));
+    }
 }


Mime
View raw message