activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-2058 Support any kind of extraProperties in AmqpCoreConverter
Date Tue, 04 Sep 2018 17:23:48 GMT
ARTEMIS-2058 Support any kind of extraProperties in AmqpCoreConverter


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

Branch: refs/heads/master
Commit: fab96c4b1c65e2cf552d3bf89d24b7b414a6a980
Parents: 2f63260
Author: Carsten Lohmann <carsten.lohmann@bosch-si.com>
Authored: Tue Aug 28 15:38:40 2018 +0200
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Sep 4 13:17:22 2018 -0400

----------------------------------------------------------------------
 .../amqp/converter/AmqpCoreConverter.java       |  2 +-
 .../amqp/converter/TestConversions.java         | 34 ++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fab96c4b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/AmqpCoreConverter.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/AmqpCoreConverter.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/AmqpCoreConverter.java
index e199d1f..45ba931 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/AmqpCoreConverter.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/AmqpCoreConverter.java
@@ -199,7 +199,7 @@ public class AmqpCoreConverter {
             if (str.equals(AMQPMessage.ADDRESS_PROPERTY)) {
                continue;
             }
-            result.getInnerMessage().putBytesProperty(str, properties.getBytesProperty(str));
+            result.getInnerMessage().putObjectProperty(str, properties.getProperty(str));
          }
       }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fab96c4b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java
b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java
index 8ced348..94df3a5 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java
@@ -22,12 +22,14 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.activemq.artemis.api.core.ICoreMessage;
+import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage;
+import org.apache.activemq.artemis.utils.collections.TypedProperties;
 import org.apache.qpid.proton.amqp.Binary;
 import org.apache.qpid.proton.amqp.messaging.AmqpSequence;
 import org.apache.qpid.proton.amqp.messaging.AmqpValue;
@@ -112,6 +114,14 @@ public class TestConversions extends Assert {
       return mapprop;
    }
 
+   private TypedProperties createTypedPropertiesMap() {
+      TypedProperties typedProperties = new TypedProperties();
+      typedProperties.putBooleanProperty(new SimpleString("true"), Boolean.TRUE);
+      typedProperties.putBooleanProperty(new SimpleString("false"), Boolean.FALSE);
+      typedProperties.putSimpleStringProperty(new SimpleString("foo"), new SimpleString("bar"));
+      return typedProperties;
+   }
+
    @Test
    public void testSimpleConversionMap() throws Exception {
       Map<String, Object> mapprop = createPropertiesMap();
@@ -192,4 +202,28 @@ public class TestConversions extends Assert {
 
    }
 
+   @Test
+   public void testSimpleConversionWithExtraProperties() throws Exception {
+      MessageImpl message = (MessageImpl) Message.Factory.create();
+
+      String text = "someText";
+      message.setBody(new AmqpValue(text));
+
+      AMQPMessage encodedMessage = new AMQPMessage(message);
+      TypedProperties extraProperties = createTypedPropertiesMap();
+      extraProperties.putBytesProperty(new SimpleString("bytesProp"), "value".getBytes());
+      encodedMessage.setExtraProperties(extraProperties);
+
+      ICoreMessage serverMessage = encodedMessage.toCore();
+
+      ServerJMSTextMessage textMessage = (ServerJMSTextMessage) ServerJMSMessage.wrapCoreMessage(serverMessage);
+      textMessage.decode();
+
+      verifyProperties(textMessage);
+      assertEquals("value", new String(((byte[]) textMessage.getObjectProperty("bytesProp"))));
+
+      Assert.assertEquals(text, textMessage.getText());
+
+   }
+
 }


Mime
View raw message