Skip to content

Commit

Permalink
ARTEMIS-2058 Support any kind of extraProperties in AmqpCoreConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
calohmn authored and clebertsuconic committed Sep 4, 2018
1 parent 2f63260 commit fab96c4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Expand Up @@ -199,7 +199,7 @@ public static ICoreMessage toCore(AMQPMessage message, CoreMessageObjectPools co
if (str.equals(AMQPMessage.ADDRESS_PROPERTY)) {
continue;
}
result.getInnerMessage().putBytesProperty(str, properties.getBytesProperty(str));
result.getInnerMessage().putObjectProperty(str, properties.getProperty(str));
}
}

Expand Down
Expand Up @@ -22,12 +22,14 @@
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;
Expand Down Expand Up @@ -112,6 +114,14 @@ private Map<String, Object> createPropertiesMap() {
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();
Expand Down Expand Up @@ -192,4 +202,28 @@ public void testSimpleConversionText() throws Exception {

}

@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());

}

}

0 comments on commit fab96c4

Please sign in to comment.