org.apache.qpid.proton.message.impl.MessageImpl Java Examples
The following examples show how to use
org.apache.qpid.proton.message.impl.MessageImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AmqpMaxFrameSizeTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
private void verifyMessage(final AmqpMessage message, final int payloadSize) { MessageImpl wrapped = (MessageImpl) message.getWrappedMessage(); assertNotNull("Message has no body", wrapped.getBody()); assertTrue("Unexpected body type: " + wrapped.getBody().getClass(), wrapped.getBody() instanceof Data); Data data = (Data) wrapped.getBody(); Binary binary = data.getValue(); assertNotNull("Data section has no content", binary); assertEquals("Unexpected payload length", payloadSize, binary.getLength()); byte[] binaryContent = binary.getArray(); int offset = binary.getArrayOffset(); for (int i = 0; i < payloadSize; i++) { byte expected = (byte) (48 + (i % 7)); assertEquals("Unexpected content at payload index " + i, expected, binaryContent[i + offset]); } }
Example #2
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testGetProperties() { MessageImpl protonMessage = createProtonMessage(); AMQPStandardMessage message = new AMQPStandardMessage(0, encodeMessage(protonMessage), null, null); Properties decoded = message.getProperties(); assertNotSame(decoded, protonMessage.getProperties()); assertPropertiesEquals(protonMessage.getProperties(), decoded); // Update the values decoded.setAbsoluteExpiryTime(new Date(System.currentTimeMillis())); decoded.setGroupSequence(UnsignedInteger.valueOf(255)); decoded.setSubject(UUID.randomUUID().toString()); // Check that the message is unaffected. assertPropertiesNotEquals(protonMessage.getProperties(), decoded); }
Example #3
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testExtraByteProperty() { MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); byte[] value = RandomUtil.randomBytes(); SimpleString name = SimpleString.toSimpleString("myProperty"); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertNull(decoded.getExtraProperties()); assertNull(decoded.getExtraBytesProperty(name)); assertNull(decoded.removeExtraBytesProperty(name)); decoded.putExtraBytesProperty(name, value); assertFalse(decoded.getExtraProperties().isEmpty()); assertTrue(Arrays.equals(value, decoded.getExtraBytesProperty(name))); assertTrue(Arrays.equals(value, decoded.removeExtraBytesProperty(name))); }
Example #4
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testGetFooter() { MessageImpl protonMessage = createProtonMessage(); Footer footer = new Footer(new HashMap<>()); footer.getValue().put(Symbol.valueOf(UUID.randomUUID().toString()), "test-1"); protonMessage.setFooter(footer); AMQPStandardMessage message = new AMQPStandardMessage(0, encodeMessage(protonMessage), null, null); Footer decoded = message.getFooter(); assertNotSame(decoded, protonMessage.getFooter()); assertFootersEquals(protonMessage.getFooter(), decoded); // Update the values decoded.getValue().put(Symbol.valueOf(UUID.randomUUID().toString()), "test-2"); // Check that the message is unaffected. assertFootersNotEquals(protonMessage.getFooter(), decoded); }
Example #5
Source File: TestConversions.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testSimpleConversionWithExtraProperties() throws Exception { MessageImpl message = (MessageImpl) Message.Factory.create(); String text = "someText"; message.setBody(new AmqpValue(text)); AMQPMessage encodedMessage = encodeAndCreateAMQPMessage(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")))); assertEquals(text, textMessage.getText()); }
Example #6
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testSetExpirationUpdatesProperties() { final Date originalExpirationTime = new Date(System.currentTimeMillis()); final Date expirationTime = new Date(System.currentTimeMillis()); MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); protonMessage.setProperties(new Properties()); protonMessage.setExpiryTime(originalExpirationTime.getTime()); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertEquals(originalExpirationTime.getTime(), decoded.getExpiration()); decoded.setExpiration(expirationTime.getTime()); assertEquals(expirationTime.getTime(), decoded.getExpiration()); decoded.reencode(); assertEquals(expirationTime, decoded.getProperties().getAbsoluteExpiryTime()); }
Example #7
Source File: TestConversions.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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 = encodeAndCreateAMQPMessage(message); ICoreMessage serverMessage = encodedMessage.toCore(); ServerJMSTextMessage textMessage = (ServerJMSTextMessage) ServerJMSMessage.wrapCoreMessage(serverMessage); textMessage.decode(); verifyProperties(textMessage); assertEquals(text, textMessage.getText()); }
Example #8
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testSetUserIDHasNoEffectOnMessagePropertiesWhenNotPresent() { final String ID = UUID.randomUUID().toString(); MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertNull(decoded.getUserID()); assertNull(decoded.getProperties()); decoded.setUserID(ID); decoded.reencode(); assertNull(decoded.getUserID()); assertNull(decoded.getProperties()); }
Example #9
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testSetUserIDHasNoEffectOnMessagePropertiesWhenPresentButNoMessageID() { final String ID = UUID.randomUUID().toString(); MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); protonMessage.setProperties(new Properties()); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertNull(decoded.getUserID()); assertNotNull(decoded.getProperties()); assertNull(decoded.getProperties().getMessageId()); decoded.setUserID(ID); decoded.reencode(); assertNull(decoded.getUserID()); assertNotNull(decoded.getProperties()); assertNull(decoded.getProperties().getMessageId()); }
Example #10
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testGetHeader() { MessageImpl protonMessage = createProtonMessage(); AMQPStandardMessage message = new AMQPStandardMessage(0, encodeMessage(protonMessage), null, null); Header decoded = message.getHeader(); assertNotSame(decoded, protonMessage.getHeader()); assertHeaderEquals(protonMessage.getHeader(), decoded); // Update the values decoded.setDeliveryCount(UnsignedInteger.ZERO); decoded.setTtl(UnsignedInteger.valueOf(255)); decoded.setFirstAcquirer(true); // Check that the message is unaffected. assertHeaderNotEquals(protonMessage.getHeader(), decoded); }
Example #11
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testGetSendBufferRemoveDeliveryAnnotations() { MessageImpl protonMessage = createProtonMessage(); DeliveryAnnotations deliveryAnnotations = new DeliveryAnnotations(new HashMap<>()); deliveryAnnotations.getValue().put(Symbol.valueOf("testGetSendBufferRemoveDeliveryAnnotations"), "X"); protonMessage.setDeliveryAnnotations(deliveryAnnotations); AMQPStandardMessage message = new AMQPStandardMessage(0, encodeMessage(protonMessage), null, null); ReadableBuffer buffer = message.getSendBuffer(1); assertNotNull(buffer); AMQPStandardMessage copy = new AMQPStandardMessage(0, buffer, null, null); MessageImpl copyProtonMessage = copy.getProtonMessage(); assertProtonMessageNotEquals(message.getProtonMessage(), copyProtonMessage); assertNull(copyProtonMessage.getDeliveryAnnotations()); }
Example #12
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testCreateMessageForPersistenceDataReload() throws ActiveMQException { MessageImpl protonMessage = createProtonMessage(); ActiveMQBuffer encoded = encodeMessageAsPersistedBuffer(protonMessage); AMQPStandardMessage message = new AMQPStandardMessage(0); try { message.getProtonMessage(); fail("Should throw NPE due to not being initialized yet"); } catch (NullPointerException npe) { } final long persistedSize = (long) encoded.readableBytes(); // Now reload from encoded data message.reloadPersistence(encoded, null); assertEquals(persistedSize, message.getPersistSize()); assertEquals(persistedSize - Integer.BYTES, message.getPersistentSize()); assertEquals(persistedSize - Integer.BYTES, message.getEncodeSize()); assertEquals(true, message.getHeader().getDurable()); assertEquals(TEST_TO_ADDRESS, message.getAddress()); }
Example #13
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
@Test public void testDeliveryCountSetFromMessageWithNonDefaultValue() throws Exception { MessageImpl message = (MessageImpl) Message.Factory.create(); message.setDeliveryCount(2); message.setBody(new AmqpValue("test")); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass()); assertTrue(jmsMessage.getJMSRedelivered()); assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, jmsMessage.getFacade().getClass()); AmqpJmsTextMessageFacade facade = (AmqpJmsTextMessageFacade) jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals(2, facade.getRedeliveryCount()); assertEquals(2, facade.getAmqpHeader().getDeliveryCount()); assertEquals(UnsignedInteger.valueOf(2), facade.getHeader().getDeliveryCount()); }
Example #14
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testSetScheduledDeliveryTimeToNoneClearsDelayAndTimeValues() { final long scheduledTime = System.currentTimeMillis(); final long scheduledDelay = 100000; MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); MessageAnnotations annotations = new MessageAnnotations(new HashMap<>()); annotations.getValue().put(AMQPMessageSupport.SCHEDULED_DELIVERY_DELAY, scheduledDelay); annotations.getValue().put(AMQPMessageSupport.SCHEDULED_DELIVERY_TIME, scheduledTime); protonMessage.setMessageAnnotations(annotations); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertEquals(scheduledTime, decoded.getScheduledDeliveryTime().longValue()); decoded.setScheduledDeliveryTime((long) 0); decoded.reencode(); assertNull(decoded.getMessageAnnotations().getValue().get(AMQPMessageSupport.SCHEDULED_DELIVERY_TIME)); assertNull(decoded.getMessageAnnotations().getValue().get(AMQPMessageSupport.SCHEDULED_DELIVERY_DELAY)); }
Example #15
Source File: JMSMappingInboundTransformerTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
private void doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(Object replyToTypeAnnotationValue, Class<? extends Destination> expectedClass) throws Exception { String replyToAddress = "replyToAddress"; MessageImpl message = (MessageImpl) Message.Factory.create(); message.setBody(new AmqpValue("myTextMessageContent")); message.setReplyTo(replyToAddress); if (replyToTypeAnnotationValue != null) { Map<Symbol, Object> map = new HashMap<>(); map.put(Symbol.valueOf("x-opt-reply-type"), replyToTypeAnnotationValue); MessageAnnotations ma = new MessageAnnotations(map); message.setMessageAnnotations(ma); } javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(encodeAndCreateAMQPMessage(message).toCore()); assertTrue("Expected TextMessage", jmsMessage instanceof TextMessage); }
Example #16
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testSetScheduledDeliveryTimeMessageSentWithFixedDelay() { final long scheduledDelay = 100000; final long newScheduledTime = System.currentTimeMillis() + 1000; MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); MessageAnnotations annotations = new MessageAnnotations(new HashMap<>()); annotations.getValue().put(AMQPMessageSupport.SCHEDULED_DELIVERY_DELAY, scheduledDelay); protonMessage.setMessageAnnotations(annotations); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertTrue(decoded.getScheduledDeliveryTime().longValue() > System.currentTimeMillis()); decoded.setScheduledDeliveryTime(newScheduledTime); assertEquals(newScheduledTime, decoded.getScheduledDeliveryTime().longValue()); decoded.reencode(); assertEquals(newScheduledTime, decoded.getMessageAnnotations().getValue().get(AMQPMessageSupport.SCHEDULED_DELIVERY_TIME)); }
Example #17
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test public void testTimeToLiveSetFromMessageWithNonDefaultValue() throws Exception { MessageImpl message = (MessageImpl) Message.Factory.create(); message.setTtl(65535); message.setBody(new AmqpValue("test")); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass()); assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, jmsMessage.getFacade().getClass()); AmqpJmsTextMessageFacade facade = (AmqpJmsTextMessageFacade) jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals(65535, facade.getAmqpHeader().getTimeToLive()); }
Example #18
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testHasScheduledDeliveryTimeReloadPersistence() { final long scheduledTime = System.currentTimeMillis(); MessageImpl protonMessage = createProtonMessage(); MessageAnnotations annotations = protonMessage.getMessageAnnotations(); annotations.getValue().put(AMQPMessageSupport.SCHEDULED_DELIVERY_TIME, scheduledTime); ActiveMQBuffer encoded = encodeMessageAsPersistedBuffer(protonMessage); AMQPMessage message = new AMQPStandardMessage(0); try { message.getProtonMessage(); fail("Should throw NPE due to not being initialized yet"); } catch (NullPointerException npe) { } Assert.assertEquals(AMQPMessage.MessageDataScanningStatus.NOT_SCANNED, message.messageDataScanned()); // Now reload from encoded data message.reloadPersistence(encoded, null); Assert.assertEquals(AMQPMessage.MessageDataScanningStatus.RELOAD_PERSISTENCE, message.messageDataScanned()); assertTrue(message.hasScheduledDeliveryTime()); Assert.assertEquals(AMQPMessage.MessageDataScanningStatus.RELOAD_PERSISTENCE, message.messageDataScanned()); message.getHeader(); Assert.assertEquals(AMQPMessage.MessageDataScanningStatus.SCANNED, message.messageDataScanned()); assertTrue(message.hasScheduledDeliveryTime()); }
Example #19
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testGetAddressFromMessageWithNoValueSet() { MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertNull(decoded.getAddress()); assertNull(decoded.getAddressSimpleString()); }
Example #20
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testGetUserIDFromMessageWithNoProperties() { MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertNull(decoded.getAMQPUserID()); }
Example #21
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testIsDurableFromMessageWithHeaderTaggedAsTrue() { MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); protonMessage.setHeader(new Header()); protonMessage.setDurable(true); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertTrue(decoded.isDurable()); }
Example #22
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testGetConnectionIDFromProperties() { MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); final String ID = UUID.randomUUID().toString(); assertEquals(null, decoded.getConnectionID()); decoded.setConnectionID(ID); assertEquals(ID, decoded.getConnectionID()); assertEquals(ID, decoded.getStringProperty(MessageUtil.CONNECTION_ID_PROPERTY_NAME)); }
Example #23
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testGetUserIDFromMessage() { final String USER_NAME = "foo"; MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); protonMessage.setUserId(USER_NAME.getBytes(StandardCharsets.UTF_8)); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertEquals(USER_NAME, decoded.getAMQPUserID()); }
Example #24
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testGetBody() { MessageImpl protonMessage = createProtonMessage(); AMQPStandardMessage message = new AMQPStandardMessage(0, encodeMessage(protonMessage), null, null); Object body = message.getBody(); assertTrue(body instanceof AmqpValue); AmqpValue amqpValueBody = (AmqpValue) body; assertNotNull(amqpValueBody.getValue()); assertNotSame(((AmqpValue)protonMessage.getBody()).getValue(), amqpValueBody.getValue()); assertEquals(((AmqpValue)protonMessage.getBody()).getValue(), amqpValueBody.getValue()); }
Example #25
Source File: TestConversions.java From activemq-artemis with Apache License 2.0 | 5 votes |
@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 = encodeAndCreateAMQPMessage(message); ICoreMessage serverMessage = encodedMessage.toCore(); serverMessage.getReadOnlyBodyBuffer(); ServerJMSMapMessage mapMessage = (ServerJMSMapMessage) ServerJMSMessage.wrapCoreMessage(serverMessage); mapMessage.decode(); verifyProperties(mapMessage); assertEquals(1, mapMessage.getInt("someint")); assertEquals("value", mapMessage.getString("somestr")); AMQPMessage newAMQP = CoreAmqpConverter.fromCore(mapMessage.getInnerMessage(), null); assertNotNull(newAMQP.getBody()); }
Example #26
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testSetScheduledDeliveryTimeWhenNonPresent() { final long scheduledTime = System.currentTimeMillis() + 5000; MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertEquals(0, decoded.getScheduledDeliveryTime().longValue()); decoded.setScheduledDeliveryTime(scheduledTime); assertEquals(scheduledTime, decoded.getScheduledDeliveryTime().longValue()); decoded.reencode(); assertEquals(scheduledTime, decoded.getMessageAnnotations().getValue().get(AMQPMessageSupport.SCHEDULED_DELIVERY_TIME)); }
Example #27
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test public void testFirstAcquirerSetFromMessageWithNonDefaultValue() throws Exception { MessageImpl message = (MessageImpl) Message.Factory.create(); message.setFirstAcquirer(true); message.setBody(new AmqpValue("test")); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass()); assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, jmsMessage.getFacade().getClass()); AmqpJmsTextMessageFacade facade = (AmqpJmsTextMessageFacade) jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertTrue(facade.getAmqpHeader().isFirstAcquirer()); }
Example #28
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
private void doTestJMSMessageEncodingAddsProperMessageAnnotations(byte msgType, byte toType, byte replyToType) throws Exception { final AmqpJmsMessageFacade message = createMessageFacadeFromTypeId(msgType); final JmsDestination to = createDestinationFromTypeId(toType); final JmsDestination replyTo = createDestinationFromTypeId(replyToType); message.setDestination(to); message.setReplyTo(replyTo); // Allows the code to run through what should be cached in the TLS portion of the codec // and not be using the globally cached bits, this checks that nothing NPEs or otherwise // fails and should show in test coverage that the cache fill + cache use is exercised. for (int i = 0; i <= 2; ++i) { MessageImpl amqpMessage = (MessageImpl) AmqpMessageSupport.decodeMessage(AmqpCodec.encodeMessage(message)); MessageAnnotations messageAnnotations = amqpMessage.getMessageAnnotations(); assertNotNull(messageAnnotations); assertNotNull(messageAnnotations.getValue()); Map<Symbol, Object> messageAnnotationsMap = messageAnnotations.getValue(); assertTrue(messageAnnotationsMap.containsKey(AmqpMessageSupport.JMS_MSG_TYPE)); if (toType != AmqpDestinationHelper.UNKNOWN_TYPE) { assertTrue(messageAnnotationsMap.containsKey(AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL)); assertEquals(toType, messageAnnotationsMap.get(AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL)); } else { assertFalse(messageAnnotationsMap.containsKey(AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL)); } if (replyToType != AmqpDestinationHelper.UNKNOWN_TYPE) { assertTrue(messageAnnotationsMap.containsKey(AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL)); assertEquals(replyToType, messageAnnotationsMap.get(AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL)); } else { assertFalse(messageAnnotationsMap.containsKey(AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL)); } } }
Example #29
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testApplicationPropertiesReencodeAfterUpdate() { MessageImpl protonMessage = createProtonMessage(); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertProtonMessageEquals(protonMessage, decoded.getProtonMessage()); decoded.putStringProperty("key-2", "value-2"); decoded.reencode(); assertProtonMessageNotEquals(protonMessage, decoded.getProtonMessage()); assertEquals(decoded.getStringProperty(TEST_APPLICATION_PROPERTY_KEY), TEST_APPLICATION_PROPERTY_VALUE); assertEquals(decoded.getStringProperty("key-2"), "value-2"); }
Example #30
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private MessageImpl createProtonMessage() { MessageImpl message = (MessageImpl) Proton.message(); Header header = new Header(); header.setDurable(true); header.setPriority(UnsignedByte.valueOf((byte) 9)); Properties properties = new Properties(); properties.setCreationTime(new Date(System.currentTimeMillis())); properties.setTo(TEST_TO_ADDRESS); properties.setMessageId(UUID.randomUUID()); MessageAnnotations annotations = new MessageAnnotations(new LinkedHashMap<>()); annotations.getValue().put(Symbol.valueOf(TEST_MESSAGE_ANNOTATION_KEY), TEST_MESSAGE_ANNOTATION_VALUE); ApplicationProperties applicationProperties = new ApplicationProperties(new LinkedHashMap<>()); applicationProperties.getValue().put(TEST_APPLICATION_PROPERTY_KEY, TEST_APPLICATION_PROPERTY_VALUE); AmqpValue body = new AmqpValue(TEST_STRING_BODY); message.setHeader(header); message.setMessageAnnotations(annotations); message.setProperties(properties); message.setApplicationProperties(applicationProperties); message.setBody(body); return message; }