You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2019/04/25 11:23:10 UTC
[qpid-jms] branch master updated: NO-JIRA: add some additional
tests created when investigating behaviour
This is an automated email from the ASF dual-hosted git repository.
robbie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-jms.git
The following commit(s) were added to refs/heads/master by this push:
new a717564 NO-JIRA: add some additional tests created when investigating behaviour
a717564 is described below
commit a7175644fc170886342bf0cb17740e680ca1fcb3
Author: Robbie Gemmell <ro...@apache.org>
AuthorDate: Thu Apr 25 12:22:16 2019 +0100
NO-JIRA: add some additional tests created when investigating behaviour
---
.../jms/integration/ProducerIntegrationTest.java | 120 +++++++++++++++++++--
1 file changed, 113 insertions(+), 7 deletions(-)
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
index 924453f..315abee 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.qpid.jms.integration;
+import static org.apache.qpid.jms.provider.amqp.AmqpSupport.ANONYMOUS_RELAY;
import static org.apache.qpid.jms.provider.amqp.AmqpSupport.DELAYED_DELIVERY;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayContaining;
@@ -264,28 +265,117 @@ public class ProducerIntegrationTest extends QpidJmsTestCase {
/**
* Test that when a message is sent and the producer is set to send as NON_PERSISTENT
+ * the resulting sent message has durable false, in this case due to setting the
+ * header field null (header only being sent due to Priority also being set).
+ *
+ * @throws Exception if an error occurs during the test.
+ */
+ @Test(timeout = 20000)
+ public void testSendingMessageNonPersistentProducerSetDurableFalse() throws Exception {
+ doSendingMessageNonPersistentTestImpl(false, true, true);
+ }
+
+
+ //As above but with an anonymous producer.
+ @Test(timeout = 20000)
+ public void testSendingMessageNonPersistentProducerSetDurableFalseAnonymousProducer() throws Exception {
+ doSendingMessageNonPersistentTestImpl(true, true, true);
+ }
+
+ /**
+ * Test that when a message is sent and the send is passed NON_PERSISTENT delivery mode
+ * the resulting sent message has durable false, in this case due to setting the
+ * header field null (header only being sent due to Priority also being set).
+ *
+ * @throws Exception if an error occurs during the test.
+ */
+ @Test(timeout = 20000)
+ public void testSendingMessageNonPersistentSendSetDurableFalse() throws Exception {
+ doSendingMessageNonPersistentTestImpl(false, true, false);
+ }
+
+ //As above but with an anonymous producer.
+ @Test(timeout = 20000)
+ public void testSendingMessageNonPersistentSendSetDurableFalseAnonymousProducer() throws Exception {
+ doSendingMessageNonPersistentTestImpl(true, true, false);
+ }
+
+ /**
+ * Test that when a message is sent and the producer is set to send as NON_PERSISTENT
* the resulting sent message has durable false, in this case due to omitting the
* header section due to it having all default values.
*
* @throws Exception if an error occurs during the test.
*/
@Test(timeout = 20000)
- public void testSendingMessageNonPersistentSetDurableFalse() throws Exception {
+ public void testSendingMessageNonPersistentProducerOmitsHeader() throws Exception {
+ doSendingMessageNonPersistentTestImpl(false, false, true);
+ }
+
+ //As above but with an anonymous producer.
+ @Test(timeout = 20000)
+ public void testSendingMessageNonPersistentProducerOmitsHeaderAnonymousProducer() throws Exception {
+ doSendingMessageNonPersistentTestImpl(true, false, true);
+ }
+
+ /**
+ * Test that when a message is sent and the send is passed NON_PERSISTENT delivery mode
+ * the resulting sent message has durable false, in this case due to omitting the
+ * header section due to it having all default values.
+ *
+ * @throws Exception if an error occurs during the test.
+ */
+ @Test(timeout = 20000)
+ public void testSendingMessageNonPersistentSendOmitsHeader() throws Exception {
+ doSendingMessageNonPersistentTestImpl(false, false, false);
+ }
+
+ //As above but with an anonymous producer.
+ @Test(timeout = 20000)
+ public void testSendingMessageNonPersistentSendOmitsHeaderAnonymousProducer() throws Exception {
+ doSendingMessageNonPersistentTestImpl(true, false, false);
+ }
+
+ private void doSendingMessageNonPersistentTestImpl(boolean anonymousProducer, boolean setPriority, boolean setOnProducer) throws Exception {
try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
- Connection connection = testFixture.establishConnecton(testPeer);
+ //Add capability to indicate support for ANONYMOUS-RELAY
+ Symbol[] serverCapabilities = new Symbol[]{ANONYMOUS_RELAY};
+ Connection connection = testFixture.establishConnecton(testPeer, serverCapabilities);
+
testPeer.expectBegin();
- testPeer.expectSenderAttach();
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
String queueName = "myQueue";
+ TargetMatcher targetMatcher = new TargetMatcher();
+ if(anonymousProducer) {
+ targetMatcher.withAddress(nullValue());
+ } else {
+ targetMatcher.withAddress(equalTo(queueName));
+ }
+
+ testPeer.expectSenderAttach(targetMatcher, false, false);
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(queueName);
- MessageProducer producer = session.createProducer(queue);
+ MessageProducer producer;
+ if(anonymousProducer) {
+ producer = session.createProducer(null);
+ } else {
+ producer = session.createProducer(queue);
+ }
+ byte priority = 5;
String text = "myMessage";
MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true);
TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
+ if(setPriority) {
+ MessageHeaderSectionMatcher headerMatcher = new MessageHeaderSectionMatcher(true);
+ headerMatcher.withDurable(nullValue());
+ headerMatcher.withPriority(equalTo(UnsignedByte.valueOf(priority)));
+
+ messageMatcher.setHeadersMatcher(headerMatcher);
+ }
messageMatcher.setPropertiesMatcher(propsMatcher);
messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(text));
testPeer.expectTransfer(messageMatcher);
@@ -295,8 +385,24 @@ public class ProducerIntegrationTest extends QpidJmsTestCase {
assertNull("Should not yet have a JMSDestination", message.getJMSDestination());
- producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- producer.send(message);
+ if(setOnProducer) {
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ if(setPriority) {
+ producer.setPriority(priority);
+ }
+
+ if(anonymousProducer) {
+ producer.send(queue, message);
+ } else {
+ producer.send(message);
+ }
+ } else {
+ if(anonymousProducer) {
+ producer.send(queue, message, DeliveryMode.NON_PERSISTENT, setPriority ? priority : Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+ } else {
+ producer.send(message, DeliveryMode.NON_PERSISTENT, setPriority ? priority : Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+ }
+ }
assertEquals("Should have NON_PERSISTENT delivery mode set", DeliveryMode.NON_PERSISTENT, message.getJMSDeliveryMode());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org