Repository: qpid-jms
Updated Branches:
  refs/heads/master cc9f8dfea -> 52e02b692


Add some initial testing and cleanup around
JmsMessagePropertyIntercepter

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/bb6959dc
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/bb6959dc
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/bb6959dc

Branch: refs/heads/master
Commit: bb6959dc5a91d7ece4221041e36c0cd4d266ddc4
Parents: cc9f8df
Author: Timothy Bish <tabish...@gmail.com>
Authored: Mon Sep 29 10:38:59 2014 -0400
Committer: Timothy Bish <tabish...@gmail.com>
Committed: Mon Sep 29 10:38:59 2014 -0400

----------------------------------------------------------------------
 .../message/JmsMessagePropertyIntercepter.java  |  43 ++++--
 .../qpid/jms/message/JmsMessageSupport.java     |  40 ++++++
 .../JmsMessagePropertyIntercepterTest.java      | 139 +++++++++++++++++++
 3 files changed, 208 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/bb6959dc/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepter.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepter.java
 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepter.java
index 22116ee..6b2d3e3 100644
--- 
a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepter.java
+++ 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepter.java
@@ -16,6 +16,21 @@
  */
 package org.apache.qpid.jms.message;
 
+import static 
org.apache.qpid.jms.message.JmsMessageSupport.JMSX_DELIVERY_COUNT;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMSX_GROUPID;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMSX_GROUPSEQ;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMSX_USERID;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_CORRELATIONID;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_DELIVERY_MODE;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_DESTINATION;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_EXPIRATION;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_MESSAGEID;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_PRIORITY;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_REDELIVERED;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_REPLYTO;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_TIMESTAMP;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_TYPE;
+
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -86,7 +101,7 @@ public class JmsMessagePropertyIntercepter {
     }
 
     static {
-        PROPERTY_INTERCEPTERS.put("JMSXDeliveryCount", new 
PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMSX_DELIVERY_COUNT, new 
PropertyIntercepter() {
             @Override
             public void setProperty(JmsMessageFacade message, Object value) 
throws JMSException {
                 Integer rc = (Integer) TypeConversionSupport.convert(value, 
Integer.class);
@@ -106,7 +121,7 @@ public class JmsMessagePropertyIntercepter {
                 return true;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSDestination", new PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMS_DESTINATION, new PropertyIntercepter() {
             @Override
             public void setProperty(JmsMessageFacade message, Object value) 
throws JMSException {
                 JmsDestination rc = (JmsDestination) 
TypeConversionSupport.convert(value, JmsDestination.class);
@@ -130,7 +145,7 @@ public class JmsMessagePropertyIntercepter {
                 return message.getDestination() != null;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSReplyTo", new PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMS_REPLYTO, new PropertyIntercepter() {
             @Override
             public void setProperty(JmsMessageFacade message, Object value) 
throws JMSException {
                 JmsDestination rc = (JmsDestination) 
TypeConversionSupport.convert(value, JmsDestination.class);
@@ -153,7 +168,7 @@ public class JmsMessagePropertyIntercepter {
                 return message.getReplyTo() != null;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSType", new PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMS_TYPE, new PropertyIntercepter() {
             @Override
             public Object getProperty(JmsMessageFacade message) throws 
JMSException {
                 return message.getType();
@@ -173,7 +188,7 @@ public class JmsMessagePropertyIntercepter {
                 return message.getType() != null;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSDeliveryMode", new PropertyIntercepter() 
{
+        PROPERTY_INTERCEPTERS.put(JMS_DELIVERY_MODE, new PropertyIntercepter() 
{
             @Override
             public Object getProperty(JmsMessageFacade message) throws 
JMSException {
                 return message.isPersistent() ? "PERSISTENT" : 
"NON_PERSISTENT";
@@ -212,7 +227,7 @@ public class JmsMessagePropertyIntercepter {
                 return true;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSPriority", new PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMS_PRIORITY, new PropertyIntercepter() {
             @Override
             public Object getProperty(JmsMessageFacade message) throws 
JMSException {
                 return Integer.valueOf(message.getPriority());
@@ -232,7 +247,7 @@ public class JmsMessagePropertyIntercepter {
                 return true;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSMessageID", new PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMS_MESSAGEID, new PropertyIntercepter() {
             @Override
             public Object getProperty(JmsMessageFacade message) throws 
JMSException {
                 if (message.getMessageId() == null) {
@@ -255,7 +270,7 @@ public class JmsMessagePropertyIntercepter {
                 return message.getMessageId() != null;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSTimestamp", new PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMS_TIMESTAMP, new PropertyIntercepter() {
             @Override
             public Object getProperty(JmsMessageFacade message) throws 
JMSException {
                 return Long.valueOf(message.getTimestamp());
@@ -275,7 +290,7 @@ public class JmsMessagePropertyIntercepter {
                 return true;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSCorrelationID", new 
PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMS_CORRELATIONID, new PropertyIntercepter() 
{
             @Override
             public Object getProperty(JmsMessageFacade message) throws 
JMSException {
                 return message.getCorrelationId();
@@ -295,7 +310,7 @@ public class JmsMessagePropertyIntercepter {
                 return message.getCorrelationId() != null;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSExpiration", new PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMS_EXPIRATION, new PropertyIntercepter() {
             @Override
             public Object getProperty(JmsMessageFacade message) throws 
JMSException {
                 return Long.valueOf(message.getExpiration());
@@ -315,7 +330,7 @@ public class JmsMessagePropertyIntercepter {
                 return true;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSRedelivered", new PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMS_REDELIVERED, new PropertyIntercepter() {
             @Override
             public Object getProperty(JmsMessageFacade message) throws 
JMSException {
                 return Boolean.valueOf(message.isRedelivered());
@@ -335,7 +350,7 @@ public class JmsMessagePropertyIntercepter {
                 return true;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSXGroupID", new PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMSX_GROUPID, new PropertyIntercepter() {
             @Override
             public Object getProperty(JmsMessageFacade message) throws 
JMSException {
                 return message.getGroupId();
@@ -355,7 +370,7 @@ public class JmsMessagePropertyIntercepter {
                 return message.getGroupId() != null;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSXGroupSeq", new PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMSX_GROUPSEQ, new PropertyIntercepter() {
             @Override
             public Object getProperty(JmsMessageFacade message) throws 
JMSException {
                 return message.getGroupSequence();
@@ -375,7 +390,7 @@ public class JmsMessagePropertyIntercepter {
                 return true;
             }
         });
-        PROPERTY_INTERCEPTERS.put("JMSXUserID", new PropertyIntercepter() {
+        PROPERTY_INTERCEPTERS.put(JMSX_USERID, new PropertyIntercepter() {
             @Override
             public Object getProperty(JmsMessageFacade message) throws 
JMSException {
                 Object userId = message.getUserId();

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/bb6959dc/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessageSupport.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessageSupport.java
 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessageSupport.java
new file mode 100644
index 0000000..29a70b4
--- /dev/null
+++ 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessageSupport.java
@@ -0,0 +1,40 @@
+/**
+ * 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.qpid.jms.message;
+
+/**
+ * Set of common utilities and definitions useful for JMS Message handling.
+ */
+public class JmsMessageSupport {
+
+    public static final String JMS_DESTINATION = "JMSDestination";
+    public static final String JMS_REPLYTO = "JMSReplyTo";
+    public static final String JMS_TYPE = "JMSType";
+    public static final String JMS_DELIVERY_MODE = "JMSDeliveryMode";
+    public static final String JMS_PRIORITY = "JMSPriority";
+    public static final String JMS_MESSAGEID = "JMSMessageID";
+    public static final String JMS_TIMESTAMP = "JMSTimestamp";
+    public static final String JMS_CORRELATIONID = "JMSCorrelationID";
+    public static final String JMS_EXPIRATION = "JMSExpiration";
+    public static final String JMS_REDELIVERED = "JMSRedelivered";
+
+    public static final String JMSX_GROUPID = "JMSXGroupID";
+    public static final String JMSX_GROUPSEQ = "JMSXGroupSeq";
+    public static final String JMSX_DELIVERY_COUNT = "JMSXDeliveryCount";
+    public static final String JMSX_USERID = "JMSXUserID";
+
+}

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/bb6959dc/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepterTest.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepterTest.java
 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepterTest.java
new file mode 100644
index 0000000..535d203
--- /dev/null
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsMessagePropertyIntercepterTest.java
@@ -0,0 +1,139 @@
+/**
+ * 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.qpid.jms.message;
+
+import static 
org.apache.qpid.jms.message.JmsMessageSupport.JMSX_DELIVERY_COUNT;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMSX_GROUPID;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMSX_GROUPSEQ;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMSX_USERID;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_CORRELATIONID;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_DELIVERY_MODE;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_DESTINATION;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_EXPIRATION;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_MESSAGEID;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_PRIORITY;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_REDELIVERED;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_REPLYTO;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_TIMESTAMP;
+import static org.apache.qpid.jms.message.JmsMessageSupport.JMS_TYPE;
+import static org.junit.Assert.assertTrue;
+
+import javax.jms.JMSException;
+
+import org.junit.Test;
+
+public class JmsMessagePropertyIntercepterTest {
+
+    //---------- JMSReplyTo 
--------------------------------------------------//
+
+    @Test
+    public void testJMSDestinationInGetAllPropertyNames() throws JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_DESTINATION));
+    }
+
+    //---------- JMSReplyTo 
--------------------------------------------------//
+
+    @Test
+    public void testJMSReplyToInGetAllPropertyNames() throws JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_REPLYTO));
+    }
+
+    //---------- JMSType 
-----------------------------------------------------//
+
+    @Test
+    public void testJMSTypeInGetAllPropertyNames() throws JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_TYPE));
+    }
+
+    //---------- JMSDeliveryMode 
---------------------------------------------//
+
+    @Test
+    public void testJMSDeliveryModeInGetAllPropertyNames() throws JMSException 
{
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_DELIVERY_MODE));
+    }
+
+    //---------- JMSPriority ---------------------------------------------//
+
+    @Test
+    public void testJMSPriorityInGetAllPropertyNames() throws JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_PRIORITY));
+    }
+
+    //---------- JMSMessageID ---------------------------------------------//
+
+    @Test
+    public void testJMSMessageIDInGetAllPropertyNames() throws JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_MESSAGEID));
+    }
+
+    //---------- JMSTimestamp ---------------------------------------------//
+
+    @Test
+    public void testJMSTimestampInGetAllPropertyNames() throws JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_TIMESTAMP));
+    }
+
+    //---------- JMSCorrelationID 
---------------------------------------------//
+
+    @Test
+    public void testJMSCorrelationIDInGetAllPropertyNames() throws 
JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_CORRELATIONID));
+    }
+
+    //---------- JMSExpiration ---------------------------------------------//
+
+    @Test
+    public void testJMSExpirationInGetAllPropertyNames() throws JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_EXPIRATION));
+    }
+
+    //---------- JMSRedelivered ---------------------------------------------//
+
+    @Test
+    public void testJMSRedeliveredInGetAllPropertyNames() throws JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMS_REDELIVERED));
+    }
+
+    //---------- JMSXGroupID ---------------------------------------------//
+
+    @Test
+    public void testJMSXGroupIDInGetAllPropertyNames() throws JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMSX_GROUPID));
+    }
+
+    //---------- JMSXGroupSeq ---------------------------------------------//
+
+    @Test
+    public void testJMSXGroupSeqInGetAllPropertyNames() throws JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMSX_GROUPSEQ));
+    }
+
+    //---------- JMSXDeliveryCount 
---------------------------------------------//
+
+    @Test
+    public void testJMSXDeliveryCountInGetAllPropertyNames() throws 
JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMSX_DELIVERY_COUNT));
+    }
+
+    //---------- JMSXUserID ---------------------------------------------//
+
+    @Test
+    public void testJMSXUserIDInGetAllPropertyNames() throws JMSException {
+        
assertTrue(JmsMessagePropertyIntercepter.getAllPropertyNames().contains(JMSX_USERID));
+    }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to