You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2017/10/05 19:20:05 UTC

[03/10] qpid-broker-j git commit: QPID-7531: [Java Broker] Add more transaction tests to AMQP 1.0 protocol tests

QPID-7531: [Java Broker] Add more transaction tests to AMQP 1.0 protocol tests


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/634eb6a9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/634eb6a9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/634eb6a9

Branch: refs/heads/master
Commit: 634eb6a90f221eced9e3ff971846a574de8f87ad
Parents: a963d54
Author: Lorenz Quack <lq...@apache.org>
Authored: Wed Oct 4 15:48:51 2017 +0100
Committer: Alex Rudyy <or...@apache.org>
Committed: Thu Oct 5 12:18:29 2017 +0100

----------------------------------------------------------------------
 .../qpid/tests/protocol/v1_0/Interaction.java   |   6 ++
 .../v1_0/transaction/DischargeTest.java         | 100 ++++++++++++++++++-
 2 files changed, 101 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/634eb6a9/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/Interaction.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/Interaction.java b/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/Interaction.java
index bb5c236..6b59960 100644
--- a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/Interaction.java
+++ b/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/Interaction.java
@@ -567,6 +567,12 @@ public class Interaction
         return this;
     }
 
+    public Interaction detachHandle(UnsignedInteger handle)
+    {
+        _detach.setHandle(handle);
+        return this;
+    }
+
     public Interaction detach() throws Exception
     {
         sendPerformativeAndChainFuture(copyDetach(_detach), _sessionChannel);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/634eb6a9/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/DischargeTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/DischargeTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/DischargeTest.java
index 5f9fa96..42f6114 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/DischargeTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/DischargeTest.java
@@ -34,7 +34,6 @@ import java.net.InetSocketAddress;
 import java.util.List;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import org.apache.qpid.server.protocol.v1_0.type.Binary;
@@ -56,12 +55,12 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
 import org.apache.qpid.server.protocol.v1_0.type.transport.ReceiverSettleMode;
 import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
 import org.apache.qpid.server.protocol.v1_0.type.transport.Transfer;
-import org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState;
-import org.apache.qpid.tests.utils.BrokerAdmin;
 import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
 import org.apache.qpid.tests.protocol.v1_0.Interaction;
-import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
+import org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState;
 import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
+import org.apache.qpid.tests.utils.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
 
 public class DischargeTest extends BrokerAdminUsingTestBase
 {
@@ -165,7 +164,7 @@ public class DischargeTest extends BrokerAdminUsingTestBase
                           + " To associate an outcome with a transaction the controller sends a disposition"
                           + " performative which sets the state of the delivery to a transactional-state with the"
                           + " desired transaction identifier and the outcome to be applied upon a successful discharge.")
-    public void commitAfterDetach() throws Exception
+    public void dischargeSettledAfterReceiverDetach() throws Exception
     {
         assumeThat(getBrokerAdmin().isQueueDepthSupported(), is(true));
 
@@ -208,4 +207,95 @@ public class DischargeTest extends BrokerAdminUsingTestBase
         }
     }
 
+    @Test
+    @SpecificationTest(section = "4.4.4.1",
+            description = "Transactional Posting [...]"
+                          + " Delivery Sent Unsettled By Controller; Resource Settles [...]"
+                          + " The resource MUST determine the outcome of the delivery before committing the"
+                          + " transaction, and this MUST be communicated to the controller before the acceptance"
+                          + " of a successful discharge. The outcome communicated by the resource MUST be associated"
+                          + " with the same transaction with which the transfer from controller to resource"
+                          + " was associated.")
+    public void dischargeSettledAfterSenderDetach() throws Exception
+    {
+        assumeThat(getBrokerAdmin().isQueueDepthSupported(), is(true));
+
+        try (FrameTransport transport = new FrameTransport(_brokerAddress).connect())
+        {
+            final Interaction interaction = transport.newInteraction();
+            final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
+            interaction.negotiateProtocol().consumeResponse()
+                       .open().consumeResponse(Open.class)
+                       .begin().consumeResponse(Begin.class)
+
+                       .txnAttachCoordinatorLink(txnState)
+                       .txnDeclare(txnState)
+
+                       .attachRole(Role.SENDER)
+                       .attachHandle(UnsignedInteger.ONE)
+                       .attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME)
+                       .attach().consumeResponse(Attach.class)
+                       .consumeResponse(Flow.class)
+
+                       .transferTransactionalState(txnState.getCurrentTransactionId())
+                       .transferPayloadData("test message")
+                       .transferHandle(UnsignedInteger.ONE)
+                       .transfer().consumeResponse(Disposition.class)
+
+                       .detachHandle(UnsignedInteger.ONE)
+                       .detach().consumeResponse(Detach.class);
+
+            assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
+
+            interaction.txnDischarge(txnState, false);
+
+            assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
+        }
+    }
+
+    @Test
+    @SpecificationTest(section = "4.4.4.1",
+            description = "Transactional Posting [...]"
+                          + " Delivery Sent Unsettled By Controller; Resource Does Not Settle [...]"
+                          + " After a successful discharge, the state of unsettled deliveries at the resource MUST"
+                          + " reflect the outcome that was applied.")
+    public void dischargeUnsettledAfterSenderClose() throws Exception
+    {
+        assumeThat(getBrokerAdmin().isQueueDepthSupported(), is(true));
+
+        try (FrameTransport transport = new FrameTransport(_brokerAddress).connect())
+        {
+            final Interaction interaction = transport.newInteraction();
+            final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
+            interaction.negotiateProtocol().consumeResponse()
+                       .open().consumeResponse(Open.class)
+                       .begin().consumeResponse(Begin.class)
+
+                       .txnAttachCoordinatorLink(txnState)
+                       .txnDeclare(txnState)
+
+                       .attachRole(Role.SENDER)
+                       .attachHandle(UnsignedInteger.ONE)
+                       .attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME)
+                       .attachRcvSettleMode(ReceiverSettleMode.SECOND)
+                       .attach().consumeResponse(Attach.class)
+                       .consumeResponse(Flow.class)
+
+                       .transferTransactionalState(txnState.getCurrentTransactionId())
+                       .transferPayloadData("test message")
+                       .transferHandle(UnsignedInteger.ONE)
+                       .transfer().consumeResponse(Disposition.class)
+
+                       .detachHandle(UnsignedInteger.ONE)
+                       .detachClose(true)
+                       .detach().consumeResponse(Detach.class);
+
+            assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
+
+            interaction.txnDischarge(txnState, false);
+
+            assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
+        }
+    }
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org