You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2018/07/31 18:19:08 UTC

[1/2] activemq-artemis git commit: ARTEMIS-2001 - JMSXGroupID and JMSXUserID in getPropertyNames

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 <mi...@me.com>
Authored: Tue Jul 31 14:49:39 2018 +0100
Committer: Clebert Suconic <cl...@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;
+   }
+}


[2/2] activemq-artemis git commit: This closes #2204

Posted by cl...@apache.org.
This closes #2204


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

Branch: refs/heads/master
Commit: f92c931fa1102dc93308a1264472b5d46961a919
Parents: 1aa211f 7764072
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Jul 31 14:19:04 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Jul 31 14:19:04 2018 -0400

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