activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [activemq-artemis] branch master updated: NO-JIRA: add test of defaulted durable field
Date Fri, 03 May 2019 09:54:49 GMT
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/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new bfe0c5c  NO-JIRA: add test of defaulted durable field
bfe0c5c is described below

commit bfe0c5cc10c9b365c998ba24dfd9374a5b922caa
Author: Robbie Gemmell <robbie@apache.org>
AuthorDate: Thu May 2 15:54:15 2019 +0100

    NO-JIRA: add test of defaulted durable field
    
    Verifies broker isnt affected by same behaviour from 5.x issue AMQ 7189
---
 .../integration/amqp/AmqpSendReceiveTest.java      | 50 +++++++++++++++-------
 1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java
index 9dc1138..559364e 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java
@@ -45,7 +45,11 @@ import org.apache.activemq.transport.amqp.client.AmqpSender;
 import org.apache.activemq.transport.amqp.client.AmqpSession;
 import org.apache.activemq.transport.amqp.client.AmqpValidator;
 import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedByte;
+import org.apache.qpid.proton.amqp.messaging.AmqpValue;
+import org.apache.qpid.proton.amqp.messaging.Header;
 import org.apache.qpid.proton.engine.Sender;
+import org.apache.qpid.proton.message.Message;
 import org.jgroups.util.UUID;
 import org.junit.Assert;
 import org.junit.Test;
@@ -770,20 +774,25 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport {
 
    @Test(timeout = 60000)
    public void testMessageWithHeaderMarkedDurableIsPersisted() throws Exception {
-      doTestBrokerRestartAndDurability(true, true);
+      doTestBrokerRestartAndDurability(true, true, false);
    }
 
    @Test(timeout = 60000)
    public void testMessageWithHeaderMarkedNonDurableIsNotPersisted() throws Exception {
-      doTestBrokerRestartAndDurability(false, true);
+      doTestBrokerRestartAndDurability(false, true, true);
+   }
+
+   @Test(timeout = 60000)
+   public void testMessageWithHeaderDefaultedNonDurableIsNotPersisted() throws Exception
{
+      doTestBrokerRestartAndDurability(false, true, false);
    }
 
    @Test(timeout = 60000)
    public void testMessageWithNoHeaderIsNotPersisted() throws Exception {
-      doTestBrokerRestartAndDurability(false, false);
+      doTestBrokerRestartAndDurability(false, false, false);
    }
 
-   private void doTestBrokerRestartAndDurability(boolean durable, boolean enforceHeader)
throws Exception {
+   private void doTestBrokerRestartAndDurability(boolean durable, boolean enforceHeader,
boolean explicitSetNonDurable) throws Exception {
       AmqpClient client = createAmqpClient();
       AmqpConnection connection = addConnection(client.connect());
       AmqpSession session = connection.createSession();
@@ -792,28 +801,37 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport {
 
       final Queue queueView1 = getProxyToQueue(getQueueName());
 
-      // Create default message that should be sent as non-durable
-      AmqpMessage message = new AmqpMessage();
-      message.setText("Test-Message -> non-durable");
-      message.setMessageId("ID:Message:1");
-
-      if (durable) {
-         message.setDurable(true);
-      } else {
-         if (enforceHeader) {
-            message.setDurable(false);
-            assertNotNull(message.getWrappedMessage().getHeader());
+      Message protonMessage = Message.Factory.create();
+      protonMessage.setMessageId("ID:Message:1");
+      protonMessage.setBody(new AmqpValue("Test-Message -> " + (durable ? "durable" :
"non-durable")));
+      if (durable || enforceHeader) {
+         Header header = new Header();
+         if (durable) {
+            header.setDurable(true);
          } else {
-            assertNull(message.getWrappedMessage().getHeader());
+            if (explicitSetNonDurable) {
+               header.setDurable(false);
+            } else {
+               // Set priority so the durable field gets defaulted
+               header.setPriority(UnsignedByte.valueOf((byte) 5));
+               assertNull(header.getDurable());
+            }
          }
+
+         protonMessage.setHeader(header);
+      } else {
+         assertNull("Should not have a header", protonMessage.getHeader());
       }
 
+      AmqpMessage message = new AmqpMessage(protonMessage);
+
       sender.send(message);
       connection.close();
 
       Wait.assertEquals(1, queueView1::getMessageCount);
 
       // Restart the server and the Queue should be empty
+      // if the message was non-durable
       server.stop();
       server.start();
 


Mime
View raw message