qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject qpid-jms git commit: update mapping for JMSType to the message Subject field
Date Wed, 04 Mar 2015 19:38:41 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master af8bf0ded -> 31dccb73a


update mapping for JMSType to the message Subject field


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

Branch: refs/heads/master
Commit: 31dccb73a56d383d813a842248dc8e22e755d021
Parents: af8bf0d
Author: Robert Gemmell <robbie@apache.org>
Authored: Wed Mar 4 19:33:48 2015 +0000
Committer: Robert Gemmell <robbie@apache.org>
Committed: Wed Mar 4 19:37:57 2015 +0000

----------------------------------------------------------------------
 .../jms/message/facade/JmsMessageFacade.java    |  8 ++---
 .../amqp/message/AmqpJmsMessageFacade.java      |  9 ++---
 .../amqp/message/AmqpMessageSupport.java        |  6 ----
 .../amqp/message/AmqpJmsMessageFacadeTest.java  | 26 ++++++--------
 .../qpid-jms-activemq-tests/pom.xml             |  9 +++++
 .../jms/consumer/JmsMessageConsumerTest.java    | 37 +++++++++++++++++++-
 6 files changed, 64 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/31dccb73/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsMessageFacade.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsMessageFacade.java
index 348311a..34079cb 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsMessageFacade.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsMessageFacade.java
@@ -276,17 +276,17 @@ public interface JmsMessageFacade {
     void setRedelivered(boolean redelivered);
 
     /**
-     * Returns the Type values as defined by the provider or set by the sending client.
+     * Returns the JMSType value as defined by the provider or set by the sending client.
      *
-     * @return a String value that defines the message type.
+     * @return a String value that defines the message JMSType.
      */
     String getType();
 
     /**
-     * Sets the String value used to define the Message type by the client.
+     * Sets the String value used to define the Message JMSType by the client.
      *
      * @param type
-     *        the type value the client assigns to this message.
+     *        the JMSType value the client assigns to this message.
      */
     void setType(String type);
 

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/31dccb73/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
index 9ee57eb..cca2683 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
@@ -19,7 +19,6 @@ package org.apache.qpid.jms.provider.amqp.message;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpMessageSupport.JMS_AMQP_TTL;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpMessageSupport.JMS_MESSAGE;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpMessageSupport.JMS_MSG_TYPE;
-import static org.apache.qpid.jms.provider.amqp.message.AmqpMessageSupport.JMS_TYPE;
 
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
@@ -538,15 +537,17 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
 
     @Override
     public String getType() {
-        return (String) getMessageAnnotation(JMS_TYPE);
+        return message.getSubject();
     }
 
     @Override
     public void setType(String type) {
         if (type != null) {
-            setMessageAnnotation(JMS_TYPE, type);
+            message.setSubject(type);
         } else {
-            removeMessageAnnotation(JMS_TYPE);
+            if (message.getProperties() != null) {
+                message.getProperties().setSubject(null);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/31dccb73/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageSupport.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageSupport.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageSupport.java
index 842cda9..644d50f 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageSupport.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageSupport.java
@@ -34,12 +34,6 @@ public final class AmqpMessageSupport {
     public static final String JMS_APP_CORRELATION_ID = "x-opt-app-correlation-id";
 
     /**
-     * Attribute used to mark the JMSType header string value set on the message by
-     * an application.
-     */
-    public static final String JMS_TYPE = "x-opt-jms-type";
-
-    /**
      * Attribute used to mark the class type of JMS message that a particular message
      * instance represents, used internally by the client.
      */

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/31dccb73/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
index 81fb84b..6c364c9 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
@@ -1579,43 +1579,37 @@ public class AmqpJmsMessageFacadeTest extends AmqpJmsMessageTypesTestCase
 {
     }
 
     @Test
-    public void testSetJMSTypeSetsUnderlyingMessageAnnotation() throws Exception {
+    public void testSetJMSTypeSetsUnderlyingMessageSubject() throws Exception {
         String jmsType = "myJMSType";
         AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
         amqpMessageFacade.setType(jmsType);
 
-        assertTrue("MessageAnnotation should exist to hold JMSType value",
-            amqpMessageFacade.messageAnnotationExists(AmqpMessageSupport.JMS_TYPE));
-        assertEquals("MessageAnnotation should be set to the provded JMSType string", jmsType,
-            amqpMessageFacade.getMessageAnnotation(AmqpMessageSupport.JMS_TYPE));
+        assertEquals("Subject should be set to the provded JMSType string", jmsType,
+                        amqpMessageFacade.getAmqpMessage().getSubject());
     }
 
     @Test
-    public void testSetTypeNullClearsExistingValue() throws Exception {
+    public void testSetTypeNullClearsExistingSubjectValue() throws Exception {
         String jmsType = "myJMSType";
         AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
 
         amqpMessageFacade.setType(jmsType);
-        assertTrue("MessageAnnotation should exist to hold JMSType value",
-            amqpMessageFacade.messageAnnotationExists(AmqpMessageSupport.JMS_TYPE));
+        assertEquals("Subject should be set to the provded JMSType string", jmsType,
+                        amqpMessageFacade.getAmqpMessage().getSubject());
         amqpMessageFacade.setType(null);
-        assertNull("JMSType value was not as expected", amqpMessageFacade.getType());
-        assertFalse("MessageAnnotation should exist to hold JMSType value",
-            amqpMessageFacade.messageAnnotationExists(AmqpMessageSupport.JMS_TYPE));
+        assertNull("Subject should be clear", amqpMessageFacade.getAmqpMessage().getSubject());
     }
 
     /**
-     * Test that {@link AmqpJmsMessageFacade#getType()} returns the expected value for a
message
-     * received with the {@link AmqpMessageSupport#JMS_TYPE} message annotation set.
+     * Test that {@link AmqpJmsMessageFacade#getType()} returns the expected value
+     * for a message received with the message Subject set.
      */
     @Test
     public void testGetJMSTypeWithReceivedMessage() throws Exception {
         String myJMSType = "myJMSType";
 
         Message message = Proton.message();
-        Map<Symbol, Object> annotationsMap = new HashMap<Symbol, Object>();
-        annotationsMap.put(Symbol.valueOf(AmqpMessageSupport.JMS_TYPE), myJMSType);
-        message.setMessageAnnotations(new MessageAnnotations(annotationsMap));
+        message.setSubject(myJMSType);
         AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(),
message);
 
         assertEquals("JMSType value was not as expected", myJMSType, amqpMessageFacade.getType());

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/31dccb73/qpid-jms-interop-tests/qpid-jms-activemq-tests/pom.xml
----------------------------------------------------------------------
diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/pom.xml b/qpid-jms-interop-tests/qpid-jms-activemq-tests/pom.xml
index cb1d7e5..1a01288 100644
--- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/pom.xml
+++ b/qpid-jms-interop-tests/qpid-jms-activemq-tests/pom.xml
@@ -112,6 +112,15 @@
   <build>
     <plugins>
       <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <!-- Need 5.12 snapshot -->
+            <exclude>**/JoramSelectorTest.java</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-deploy-plugin</artifactId>
         <configuration>

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/31dccb73/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/consumer/JmsMessageConsumerTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/consumer/JmsMessageConsumerTest.java
b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/consumer/JmsMessageConsumerTest.java
index d2a3b4d..e8b8fd4 100644
--- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/consumer/JmsMessageConsumerTest.java
+++ b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/consumer/JmsMessageConsumerTest.java
@@ -47,6 +47,7 @@ import org.apache.qpid.jms.JmsMessageAvailableListener;
 import org.apache.qpid.jms.JmsMessageConsumer;
 import org.apache.qpid.jms.support.AmqpTestSupport;
 import org.apache.qpid.jms.support.Wait;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -442,17 +443,51 @@ public class JmsMessageConsumerTest extends AmqpTestSupport {
         message.setText("hello + 9");
         p.send(message, DeliveryMode.PERSISTENT, 9, 0);
 
+        p.close();
+
         QueueViewMBean proxy = getProxyToQueue(name.getMethodName());
         assertEquals(2, proxy.getQueueSize());
 
         MessageConsumer consumer = session.createConsumer(queue, "JMSPriority > 8");
         Message msg = consumer.receive(5000);
-        assertNotNull(msg);
+        assertNotNull("No message was recieved", msg);
         assertTrue(msg instanceof TextMessage);
         assertEquals("hello + 9", ((TextMessage) msg).getText());
         assertNull(consumer.receive(1000));
     }
 
+    @Ignore //TODO: needs 5.12 snapshot
+    @Test(timeout=30000)
+    public void testSelectorsWithJMSType() throws Exception {
+        connection = createAmqpConnection();
+        connection.start();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Queue queue = session.createQueue(name.getMethodName());
+        MessageProducer p = session.createProducer(queue);
+
+        TextMessage message = session.createTextMessage();
+        message.setText("text");
+        p.send(message, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+
+        TextMessage message2 = session.createTextMessage();
+        String type = "myJMSType";
+        message2.setJMSType(type);
+        message2.setText("text + type");
+        p.send(message2, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+
+        p.close();
+
+        QueueViewMBean proxy = getProxyToQueue(name.getMethodName());
+        assertEquals(2, proxy.getQueueSize());
+
+        MessageConsumer consumer = session.createConsumer(queue, "JMSType = '" + type + "'");
+        Message msg = consumer.receive(5000);
+        assertNotNull("No message was recieved", msg);
+        assertTrue(msg instanceof TextMessage);
+        assertEquals("Unexpected JMSType value", type, msg.getJMSType());
+        assertEquals("Unexpected message content", "text + type", ((TextMessage) msg).getText());
+    }
+
     @Test(timeout=90000, expected=JMSSecurityException.class)
     public void testConsumerNotAuthorized() throws Exception{
         connection = createAmqpConnection("guest", "password");


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


Mime
View raw message