activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-2001 - JMSXGroupID and JMSXUserID in getPropertyNames
Date Tue, 31 Jul 2018 18:19:08 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 1aa211f90 -> f92c931fa


ARTEMIS-2001 - JMSXGroupID and JMSXUserID in getPropertyNames

Ensure JMSXGroupID and JMSXUserID is correctly returned by JMS getPropertyNames when set.


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

Branch: refs/heads/master
Commit: 7764072c49bb0c70d74a8e828363089994acecb5
Parents: 1aa211f
Author: Michael André Pearce <michael.andre.pearce@me.com>
Authored: Tue Jul 31 14:49:39 2018 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Jul 31 14:19:03 2018 -0400

----------------------------------------------------------------------
 .../activemq/artemis/reader/MessageUtil.java    |  8 ++-
 .../client/ActiveMQMessagePropertiesTest.java   | 68 ++++++++++++++++++++
 2 files changed, 73 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7764072c/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java
index e8f5920..db1f3dc 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java
@@ -152,9 +152,11 @@ public class MessageUtil {
       HashSet<String> set = new HashSet<>();
 
       for (SimpleString propName : message.getPropertyNames()) {
-         if ((!propName.startsWith(JMS) || propName.startsWith(JMSX) ||
-            propName.startsWith(JMS_)) && !propName.startsWith(CONNECTION_ID_PROPERTY_NAME)
&& !propName.equals(Message.HDR_ROUTING_TYPE) &&
-            !propName.startsWith(Message.HDR_ROUTE_TO_IDS)) {
+         if (propName.equals(Message.HDR_GROUP_ID)) {
+            set.add(MessageUtil.JMSXGROUPID);
+         } else if (propName.equals(Message.HDR_VALIDATED_USER)) {
+            set.add(MessageUtil.JMSXUSERID);
+         } else if ((!propName.startsWith(JMS) || propName.startsWith(JMSX) || propName.startsWith(JMS_))
&& !propName.startsWith(CONNECTION_ID_PROPERTY_NAME) && !propName.equals(Message.HDR_ROUTING_TYPE)
&& !propName.startsWith(Message.HDR_ROUTE_TO_IDS)) {
             set.add(propName.toString());
          }
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7764072c/artemis-jms-client/src/test/java/org/apache/activemq/artemis/jms/client/ActiveMQMessagePropertiesTest.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/test/java/org/apache/activemq/artemis/jms/client/ActiveMQMessagePropertiesTest.java
b/artemis-jms-client/src/test/java/org/apache/activemq/artemis/jms/client/ActiveMQMessagePropertiesTest.java
new file mode 100644
index 0000000..cf9bc56
--- /dev/null
+++ b/artemis-jms-client/src/test/java/org/apache/activemq/artemis/jms/client/ActiveMQMessagePropertiesTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.artemis.jms.client;
+
+import java.util.Enumeration;
+import javax.jms.JMSException;
+import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+public class ActiveMQMessagePropertiesTest {
+
+   @Test
+   public void testJMSXGroupID() throws JMSException {
+      ActiveMQMessage activeMQMessage = newBlankActiveMQMessage();
+
+      assertFalse(contains(activeMQMessage.getPropertyNames(), "JMSXGroupID"));
+
+      activeMQMessage.setStringProperty("JMSXGroupID", "Bob");
+      assertEquals("Bob", activeMQMessage.getStringProperty("JMSXGroupID"));
+
+      assertTrue(contains(activeMQMessage.getPropertyNames(), "JMSXGroupID"));
+   }
+
+   @Test
+   public void testJMSXUserID() throws JMSException {
+      ActiveMQMessage activeMQMessage = newBlankActiveMQMessage();
+
+      assertFalse(contains(activeMQMessage.getPropertyNames(), "JMSXUserID"));
+
+      activeMQMessage.setStringProperty("JMSXUserID", "Bob");
+      assertEquals("Bob", activeMQMessage.getStringProperty("JMSXUserID"));
+
+      assertTrue(contains(activeMQMessage.getPropertyNames(), "JMSXUserID"));
+   }
+
+   private boolean contains(Enumeration<String> enumeration, String key) {
+      while (enumeration.hasMoreElements()) {
+         if (enumeration.nextElement().equals(key)) {
+            return true;
+         }
+      }
+      return false;
+   }
+
+   private ActiveMQMessage newBlankActiveMQMessage() throws JMSException {
+      ActiveMQMessage activeMQMessage = new ActiveMQMessage(new ClientMessageImpl(), null);
+      activeMQMessage.clearBody();
+      activeMQMessage.clearProperties();
+      return activeMQMessage;
+   }
+}


Mime
View raw message