use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage in project activemq-artemis by apache.
the class JMSMappingOutboundTransformerTest method testConvertMapMessageToAmqpMessageWithByteArrayValueInBody.
@Test
public void testConvertMapMessageToAmqpMessageWithByteArrayValueInBody() throws Exception {
final byte[] byteArray = new byte[] { 1, 2, 3, 4, 5 };
ServerJMSMapMessage outbound = createMapMessage();
outbound.setBytes("bytes", byteArray);
outbound.encode();
Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
assertNotNull(amqp.getBody());
assertTrue(amqp.getBody() instanceof AmqpValue);
assertTrue(((AmqpValue) amqp.getBody()).getValue() instanceof Map);
@SuppressWarnings("unchecked") Map<Object, Object> amqpMap = (Map<Object, Object>) ((AmqpValue) amqp.getBody()).getValue();
assertEquals(1, amqpMap.size());
Binary readByteArray = (Binary) amqpMap.get("bytes");
assertNotNull(readByteArray);
}
use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage in project activemq-artemis by apache.
the class JMSMappingOutboundTransformerTest method testConvertMapMessageToAmqpMessageWithNoBody.
// ----- MapMessage type tests --------------------------------------------//
@Test
public void testConvertMapMessageToAmqpMessageWithNoBody() throws Exception {
ServerJMSMapMessage outbound = createMapMessage();
outbound.encode();
Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
assertNotNull(amqp.getBody());
assertTrue(amqp.getBody() instanceof AmqpValue);
assertTrue(((AmqpValue) amqp.getBody()).getValue() instanceof Map);
}
use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage in project activemq-artemis by apache.
the class TestConversions method testSimpleConversionMap.
@Test
public void testSimpleConversionMap() throws Exception {
Map<String, Object> mapprop = createPropertiesMap();
ApplicationProperties properties = new ApplicationProperties(mapprop);
MessageImpl message = (MessageImpl) Message.Factory.create();
message.setApplicationProperties(properties);
Map<String, Object> mapValues = new HashMap<>();
mapValues.put("somestr", "value");
mapValues.put("someint", Integer.valueOf(1));
message.setBody(new AmqpValue(mapValues));
AMQPMessage encodedMessage = new AMQPMessage(message);
ICoreMessage serverMessage = encodedMessage.toCore();
serverMessage.getReadOnlyBodyBuffer();
ServerJMSMapMessage mapMessage = (ServerJMSMapMessage) ServerJMSMessage.wrapCoreMessage(serverMessage);
mapMessage.decode();
verifyProperties(mapMessage);
Assert.assertEquals(1, mapMessage.getInt("someint"));
Assert.assertEquals("value", mapMessage.getString("somestr"));
AMQPMessage newAMQP = CoreAmqpConverter.fromCore(mapMessage.getInnerMessage());
System.out.println(newAMQP.getProtonMessage().getBody());
}
use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage in project activemq-artemis by apache.
the class AMQPMessageSupport method createMapMessage.
public static ServerJMSMapMessage createMapMessage(long id, Map<String, Object> content, CoreMessageObjectPools coreMessageObjectPools) throws JMSException {
ServerJMSMapMessage message = createMapMessage(id, coreMessageObjectPools);
final Set<Map.Entry<String, Object>> set = content.entrySet();
for (Map.Entry<String, Object> entry : set) {
Object value = entry.getValue();
if (value instanceof Binary) {
Binary binary = (Binary) value;
value = Arrays.copyOfRange(binary.getArray(), binary.getArrayOffset(), binary.getLength());
}
message.setObject(entry.getKey(), value);
}
return message;
}
use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage in project activemq-artemis by apache.
the class AmqpManagementTest method testUnsignedValues.
/**
* Some clients use Unsigned types from org.apache.qpid.proton.amqp
* @throws Exception
*/
@Test(timeout = 60000)
public void testUnsignedValues() throws Exception {
int sequence = 42;
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
map.put("sequence", new UnsignedInteger(sequence));
ServerJMSMapMessage msg = createMapMessage(1, map, null);
assertEquals(msg.getInt("sequence"), sequence);
map.clear();
map.put("sequence", new UnsignedLong(sequence));
msg = createMapMessage(1, map, null);
assertEquals(msg.getLong("sequence"), sequence);
map.clear();
map.put("sequence", new UnsignedShort((short) sequence));
msg = createMapMessage(1, map, null);
assertEquals(msg.getShort("sequence"), sequence);
map.clear();
map.put("sequence", new UnsignedByte((byte) sequence));
msg = createMapMessage(1, map, null);
assertEquals(msg.getByte("sequence"), sequence);
}
Aggregations