Repository: qpid-jms Updated Branches: refs/heads/master ec13a0d50 -> e68072910
remove stale comment, add some tests around the disableMessageId/disableTimestamp producer hints Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/e6807291 Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/e6807291 Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/e6807291 Branch: refs/heads/master Commit: e680729102d67b05e16178f1ed01c14c6ef341f2 Parents: ec13a0d Author: Robert Gemmell <[email protected]> Authored: Fri Oct 17 10:57:01 2014 +0100 Committer: Robert Gemmell <[email protected]> Committed: Fri Oct 17 10:57:01 2014 +0100 ---------------------------------------------------------------------- .../amqp/message/AmqpJmsMessageFacade.java | 2 - .../jms/integration/SenderIntegrationTest.java | 82 ++++++++++++++++++++ 2 files changed, 82 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/e6807291/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java index b767632..9776b94 100644 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java +++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java @@ -229,8 +229,6 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade { } if (disableMsgId) { - // TODO - ActiveMQ will synthesize a message Id, but I don't think it has been - // really well tested, so we should investigate before enabling this. setMessageId(null); } http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/e6807291/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SenderIntegrationTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SenderIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SenderIntegrationTest.java index 327c293..c82462b 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SenderIntegrationTest.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SenderIntegrationTest.java @@ -221,6 +221,47 @@ public class SenderIntegrationTest extends QpidJmsTestCase { } } + /** + * Test that after sending a message with the disableMessageTimestamp hint set, the + * message object has a 0 JMSTimestamp value, and no creation-time field value was set. + */ + @Test(timeout = 5000) + public void testSendingMessageWithDisableMessageTimestampHint() throws Exception { + try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);) { + Connection connection = testFixture.establishConnecton(testPeer); + testPeer.expectBegin(true); + testPeer.expectSenderAttach(); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + String queueName = "myQueue"; + Queue queue = session.createQueue(queueName); + MessageProducer producer = session.createProducer(queue); + + String text = "myMessage"; + MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true)); + MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true); + MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true); + propsMatcher.withCreationTime(nullValue()); // Check there is no creation-time value; + TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher(); + messageMatcher.setHeadersMatcher(headersMatcher); + messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher); + messageMatcher.setPropertiesMatcher(propsMatcher); + messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(text)); + testPeer.expectTransfer(messageMatcher); + + Message message = session.createTextMessage(text); + + assertEquals("JMSTimestamp should not yet be set", 0, message.getJMSTimestamp()); + + producer.setDisableMessageTimestamp(true); + + producer.send(message); + testPeer.waitForAllHandlersToComplete(1000); + + assertEquals("JMSTimestamp should still not be set", 0, message.getJMSTimestamp()); + } + } + @Test(timeout = 10000) public void testSendingMessageSetsJMSExpirationRelatedAbsoluteExpiryAndTtlFields() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);) { @@ -441,4 +482,45 @@ public class SenderIntegrationTest extends QpidJmsTestCase { assertTrue("Expected JMSMessageId value to be present in AMQP message", jmsMessageID.endsWith((String)receivedMessageId)); } } + + /** + * Test that after sending a message with the disableMessageID hint set, the message + * object has a null JMSMessageID value, and no message-id field value was set. + */ + @Test(timeout = 5000) + public void testSendingMessageWithDisableMessageIDHint() throws Exception { + try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);) { + Connection connection = testFixture.establishConnecton(testPeer); + testPeer.expectBegin(true); + testPeer.expectSenderAttach(); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + String queueName = "myQueue"; + Queue queue = session.createQueue(queueName); + MessageProducer producer = session.createProducer(queue); + + String text = "myMessage"; + MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true)); + MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true); + MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true); + propsMatcher.withMessageId(nullValue()); // Check there is no message-id value; + TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher(); + messageMatcher.setHeadersMatcher(headersMatcher); + messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher); + messageMatcher.setPropertiesMatcher(propsMatcher); + messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(text)); + testPeer.expectTransfer(messageMatcher); + + Message message = session.createTextMessage(text); + + assertNull("JMSMessageID should not yet be set", message.getJMSMessageID()); + + producer.setDisableMessageID(true); + + producer.send(message); + testPeer.waitForAllHandlersToComplete(1000); + + assertNull("JMSMessageID should still not yet be set", message.getJMSMessageID()); + } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
