use of org.apache.qpid.proton.amqp.messaging.ApplicationProperties in project activemq-artemis by apache.
the class TestConversions method testSimpleConversionText.
@Test
public void testSimpleConversionText() throws Exception {
Map<String, Object> mapprop = createPropertiesMap();
ApplicationProperties properties = new ApplicationProperties(mapprop);
MessageImpl message = (MessageImpl) Message.Factory.create();
message.setApplicationProperties(properties);
String text = "someText";
message.setBody(new AmqpValue(text));
AMQPMessage encodedMessage = new AMQPMessage(message);
ICoreMessage serverMessage = encodedMessage.toCore();
ServerJMSTextMessage textMessage = (ServerJMSTextMessage) ServerJMSMessage.wrapCoreMessage(serverMessage);
textMessage.decode();
verifyProperties(textMessage);
Assert.assertEquals(text, textMessage.getText());
}
use of org.apache.qpid.proton.amqp.messaging.ApplicationProperties 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.qpid.proton.amqp.messaging.ApplicationProperties in project activemq-artemis by apache.
the class TestConversions method testAmqpValueOfBooleanIsPassedThrough.
@Test
public void testAmqpValueOfBooleanIsPassedThrough() throws Exception {
Map<String, Object> mapprop = createPropertiesMap();
ApplicationProperties properties = new ApplicationProperties(mapprop);
MessageImpl message = (MessageImpl) Message.Factory.create();
message.setApplicationProperties(properties);
byte[] bodyBytes = new byte[4];
for (int i = 0; i < bodyBytes.length; i++) {
bodyBytes[i] = (byte) 0xff;
}
message.setBody(new AmqpValue(new Boolean(true)));
AMQPMessage encodedMessage = new AMQPMessage(message);
ICoreMessage serverMessage = encodedMessage.toCore();
verifyProperties(ServerJMSMessage.wrapCoreMessage(serverMessage));
}
use of org.apache.qpid.proton.amqp.messaging.ApplicationProperties in project activemq-artemis by apache.
the class TestConversions method testSimpleConversionStream.
@Test
public void testSimpleConversionStream() throws Exception {
Map<String, Object> mapprop = createPropertiesMap();
ApplicationProperties properties = new ApplicationProperties(mapprop);
MessageImpl message = (MessageImpl) Message.Factory.create();
message.setApplicationProperties(properties);
List<Object> objects = new LinkedList<>();
objects.add(new Integer(10));
objects.add("10");
message.setBody(new AmqpSequence(objects));
AMQPMessage encodedMessage = new AMQPMessage(message);
ICoreMessage serverMessage = encodedMessage.toCore();
ServerJMSStreamMessage streamMessage = (ServerJMSStreamMessage) ServerJMSMessage.wrapCoreMessage(serverMessage);
verifyProperties(streamMessage);
streamMessage.reset();
assertEquals(10, streamMessage.readInt());
assertEquals("10", streamMessage.readString());
}
use of org.apache.qpid.proton.amqp.messaging.ApplicationProperties in project activemq-artemis by apache.
the class JMSTransformationSpeedComparisonTest method createComplexQpidJMSMessage.
private Message createComplexQpidJMSMessage() {
Map<String, Object> applicationProperties = new HashMap<>();
Map<Symbol, Object> messageAnnotations = new HashMap<>();
applicationProperties.put("property-1", "string-1");
applicationProperties.put("property-2", 512);
applicationProperties.put("property-3", true);
applicationProperties.put("property-4", "string-2");
applicationProperties.put("property-5", 512);
applicationProperties.put("property-6", true);
applicationProperties.put("property-7", "string-3");
applicationProperties.put("property-8", 512);
applicationProperties.put("property-9", true);
messageAnnotations.put(Symbol.valueOf("x-opt-jms-msg-type"), 0);
messageAnnotations.put(Symbol.valueOf("x-opt-jms-dest"), 0);
Message message = Proton.message();
// Header Values
message.setPriority((short) 9);
message.setDurable(true);
message.setDeliveryCount(2);
message.setTtl(5000);
// Properties
message.setMessageId("ID:SomeQualifier:0:0:1");
message.setGroupId("Group-ID-1");
message.setGroupSequence(15);
message.setAddress("queue://test-queue");
message.setReplyTo("queue://reply-queue");
message.setCreationTime(System.currentTimeMillis());
message.setContentType("text/plain");
message.setCorrelationId("ID:SomeQualifier:0:7:9");
message.setUserId("username".getBytes(StandardCharsets.UTF_8));
// Application Properties / Message Annotations / Body
message.setApplicationProperties(new ApplicationProperties(applicationProperties));
message.setMessageAnnotations(new MessageAnnotations(messageAnnotations));
message.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));
return message;
}
Aggregations