You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2021/06/02 17:22:05 UTC

[qpid-protonj2] branch main updated (524fd3d -> 34170e0)

This is an automated email from the ASF dual-hosted git repository.

tabish pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git.


    from 524fd3d  PROTON-2390: fix direction indicator on incoming protocol headers
     new fc3713e  PROTON-2392 Fix issue with Declare expectation and message format
     new 34170e0  PROTON-2393 Allow AMQP Frames to be fired on connection established

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../qpid/protonj2/test/driver/AMQPTestDriver.java  |   9 ++
 .../protonj2/test/driver/ProtonTestClient.java     |  14 +-
 .../protonj2/test/driver/ProtonTestConnector.java  |   5 +
 .../qpid/protonj2/test/driver/ProtonTestPeer.java  |   2 +
 .../protonj2/test/driver/ProtonTestServer.java     |  12 ++
 .../qpid/protonj2/test/driver/ScriptWriter.java    |   9 +-
 .../test/driver/actions/TransferInjectAction.java  |  10 ++
 .../driver/expectations/DeclareExpectation.java    | 172 +++++++++++++++++++++
 .../driver/expectations/DischargeExpectation.java  | 172 +++++++++++++++++++++
 .../test/driver/TransactionHandlingTest.java       |  16 +-
 10 files changed, 412 insertions(+), 9 deletions(-)

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


[qpid-protonj2] 01/02: PROTON-2392 Fix issue with Declare expectation and message format

Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git

commit fc3713ee6bb35ea32daf920bff180f9f25520272
Author: Timothy Bish <ta...@gmail.com>
AuthorDate: Fri May 28 10:30:22 2021 -0400

    PROTON-2392 Fix issue with Declare expectation and message format
    
    Fix an issue with the matcher that was created for the expectDeclare
    scripted element which wasn't correclty handling null or zero cases.
    Also improves the API a bit when scripting expectations for delcare and
    discharge.
---
 .../qpid/protonj2/test/driver/ScriptWriter.java    |   9 +-
 .../test/driver/actions/TransferInjectAction.java  |  10 ++
 .../driver/expectations/DeclareExpectation.java    | 172 +++++++++++++++++++++
 .../driver/expectations/DischargeExpectation.java  | 172 +++++++++++++++++++++
 .../test/driver/TransactionHandlingTest.java       |  16 +-
 5 files changed, 371 insertions(+), 8 deletions(-)

diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ScriptWriter.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ScriptWriter.java
index 15e2ab5..951e8b5 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ScriptWriter.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ScriptWriter.java
@@ -16,11 +16,8 @@
  */
 package org.apache.qpid.protonj2.test.driver;
 
-import static org.hamcrest.CoreMatchers.anyOf;
-import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.isA;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.nio.charset.StandardCharsets;
@@ -51,6 +48,7 @@ import org.apache.qpid.protonj2.test.driver.actions.TransferInjectAction;
 import org.apache.qpid.protonj2.test.driver.codec.messaging.Source;
 import org.apache.qpid.protonj2.test.driver.codec.messaging.Target;
 import org.apache.qpid.protonj2.test.driver.codec.primitives.DescribedType;
+import org.apache.qpid.protonj2.test.driver.codec.primitives.UnsignedInteger;
 import org.apache.qpid.protonj2.test.driver.codec.security.SaslCode;
 import org.apache.qpid.protonj2.test.driver.codec.transactions.Coordinator;
 import org.apache.qpid.protonj2.test.driver.codec.transport.AMQPHeader;
@@ -73,6 +71,7 @@ import org.apache.qpid.protonj2.test.driver.expectations.SaslMechanismsExpectati
 import org.apache.qpid.protonj2.test.driver.expectations.SaslOutcomeExpectation;
 import org.apache.qpid.protonj2.test.driver.expectations.SaslResponseExpectation;
 import org.apache.qpid.protonj2.test.driver.expectations.TransferExpectation;
+import org.hamcrest.Matchers;
 
 /**
  * Class used to create test scripts using the {@link AMQPTestDriver}
@@ -174,7 +173,7 @@ public abstract class ScriptWriter {
         expecting.withHandle(notNullValue());
         expecting.withDeliveryId(notNullValue());
         expecting.withDeliveryTag(notNullValue());
-        expecting.withMessageFormat(anyOf(nullValue(), equalTo(0)));
+        expecting.withMessageFormat(Matchers.oneOf(null, 0, UnsignedInteger.ZERO));
 
         getDriver().addScriptedElement(expecting);
         return expecting;
@@ -186,7 +185,7 @@ public abstract class ScriptWriter {
         expecting.withHandle(notNullValue());
         expecting.withDeliveryId(notNullValue());
         expecting.withDeliveryTag(notNullValue());
-        expecting.withMessageFormat(anyOf(nullValue(), equalTo(0)));
+        expecting.withMessageFormat(Matchers.oneOf(null, 0, UnsignedInteger.ZERO));
 
         getDriver().addScriptedElement(expecting);
         return expecting;
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/actions/TransferInjectAction.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/actions/TransferInjectAction.java
index 82a44a3..4024d81 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/actions/TransferInjectAction.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/actions/TransferInjectAction.java
@@ -137,11 +137,21 @@ public class TransferInjectAction extends AbstractPerformativeInjectAction<Trans
         return this;
     }
 
+    public TransferInjectAction withMessageFormat(int messageFormat) {
+        transfer.setMessageFormat(UnsignedInteger.valueOf(messageFormat));
+        return this;
+    }
+
     public TransferInjectAction withMessageFormat(long messageFormat) {
         transfer.setMessageFormat(UnsignedInteger.valueOf(messageFormat));
         return this;
     }
 
+    public TransferInjectAction withMessageFormat(UnsignedInteger messageFormat) {
+        transfer.setMessageFormat(messageFormat);
+        return this;
+    }
+
     public TransferInjectAction withSettled(Boolean settled) {
         transfer.setSettled(settled);
         return this;
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/DeclareExpectation.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/DeclareExpectation.java
index 88708b3..0c6b86d 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/DeclareExpectation.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/DeclareExpectation.java
@@ -16,14 +16,21 @@
  */
 package org.apache.qpid.protonj2.test.driver.expectations;
 
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.nullValue;
+
 import java.util.Random;
 
 import org.apache.qpid.protonj2.test.driver.AMQPTestDriver;
 import org.apache.qpid.protonj2.test.driver.actions.DispositionInjectAction;
 import org.apache.qpid.protonj2.test.driver.codec.primitives.Binary;
+import org.apache.qpid.protonj2.test.driver.codec.primitives.UnsignedInteger;
 import org.apache.qpid.protonj2.test.driver.codec.transactions.Declare;
 import org.apache.qpid.protonj2.test.driver.codec.transactions.Declared;
+import org.apache.qpid.protonj2.test.driver.codec.transport.DeliveryState;
+import org.apache.qpid.protonj2.test.driver.codec.transport.ReceiverSettleMode;
 import org.apache.qpid.protonj2.test.driver.matchers.types.EncodedAmqpValueMatcher;
+import org.hamcrest.Matcher;
 
 /**
  * Expectation used to script incoming transaction declarations.
@@ -110,4 +117,169 @@ public class DeclareExpectation extends TransferExpectation {
         withPayload(new EncodedAmqpValueMatcher(null));
         return this;
     }
+
+    //----- Type specific with methods that perform simple equals checks
+
+    @Override
+    public DeclareExpectation withHandle(int handle) {
+        return withHandle(equalTo(UnsignedInteger.valueOf(handle)));
+    }
+
+    @Override
+    public DeclareExpectation withHandle(long handle) {
+        return withHandle(equalTo(UnsignedInteger.valueOf(handle)));
+    }
+
+    @Override
+    public DeclareExpectation withHandle(UnsignedInteger handle) {
+        return withHandle(equalTo(handle));
+    }
+
+    @Override
+    public DeclareExpectation withDeliveryId(int deliveryId) {
+        return withDeliveryId(equalTo(UnsignedInteger.valueOf(deliveryId)));
+    }
+
+    @Override
+    public DeclareExpectation withDeliveryId(long deliveryId) {
+        return withDeliveryId(equalTo(UnsignedInteger.valueOf(deliveryId)));
+    }
+
+    @Override
+    public DeclareExpectation withDeliveryId(UnsignedInteger deliveryId) {
+        return withDeliveryId(equalTo(deliveryId));
+    }
+
+    @Override
+    public DeclareExpectation withDeliveryTag(byte[] tag) {
+        return withDeliveryTag(new Binary(tag));
+    }
+
+    @Override
+    public DeclareExpectation withDeliveryTag(Binary deliveryTag) {
+        return withDeliveryTag(equalTo(deliveryTag));
+    }
+
+    @Override
+    public DeclareExpectation withMessageFormat(int messageFormat) {
+        return withMessageFormat(equalTo(UnsignedInteger.valueOf(messageFormat)));
+    }
+
+    @Override
+    public DeclareExpectation withMessageFormat(long messageFormat) {
+        return withMessageFormat(equalTo(UnsignedInteger.valueOf(messageFormat)));
+    }
+
+    @Override
+    public DeclareExpectation withMessageFormat(UnsignedInteger messageFormat) {
+        return withMessageFormat(equalTo(messageFormat));
+    }
+
+    @Override
+    public DeclareExpectation withSettled(boolean settled) {
+        return withSettled(equalTo(settled));
+    }
+
+    @Override
+    public DeclareExpectation withMore(boolean more) {
+        return withMore(equalTo(more));
+    }
+
+    @Override
+    public DeclareExpectation withRcvSettleMode(ReceiverSettleMode rcvSettleMode) {
+        return withRcvSettleMode(equalTo(rcvSettleMode.getValue()));
+    }
+
+    @Override
+    public DeclareExpectation withState(DeliveryState state) {
+        return withState(equalTo(state));
+    }
+
+    @Override
+    public DeclareExpectation withNullState() {
+        return withState(nullValue());
+    }
+
+    @Override
+    public DeclareExpectation withResume(boolean resume) {
+        return withResume(equalTo(resume));
+    }
+
+    @Override
+    public DeclareExpectation withAborted(boolean aborted) {
+        return withAborted(equalTo(aborted));
+    }
+
+    @Override
+    public DeclareExpectation withBatchable(boolean batchable) {
+        return withBatchable(equalTo(batchable));
+    }
+
+    //----- Matcher based with methods for more complex validation
+
+    @Override
+    public DeclareExpectation withHandle(Matcher<?> m) {
+        super.withHandle(m);
+        return this;
+    }
+
+    @Override
+    public DeclareExpectation withDeliveryId(Matcher<?> m) {
+        super.withDeliveryId(m);
+        return this;
+    }
+
+    @Override
+    public DeclareExpectation withDeliveryTag(Matcher<?> m) {
+        super.withDeliveryTag(m);
+        return this;
+    }
+
+    @Override
+    public DeclareExpectation withMessageFormat(Matcher<?> m) {
+        super.withMessageFormat(m);
+        return this;
+    }
+
+    @Override
+    public DeclareExpectation withSettled(Matcher<?> m) {
+        super.withSettled(m);
+        return this;
+    }
+
+    @Override
+    public DeclareExpectation withMore(Matcher<?> m) {
+        super.withMore(m);
+        return this;
+    }
+
+    @Override
+    public DeclareExpectation withRcvSettleMode(Matcher<?> m) {
+        super.withRcvSettleMode(m);
+        return this;
+    }
+
+    @Override
+    public DeclareExpectation withState(Matcher<?> m) {
+        super.withState(m);
+        return this;
+    }
+
+    @Override
+    public DeclareExpectation withResume(Matcher<?> m) {
+        super.withResume(m);
+        return this;
+    }
+
+    @Override
+    public DeclareExpectation withAborted(Matcher<?> m) {
+        super.withAborted(m);
+        return this;
+    }
+
+    @Override
+    public DeclareExpectation withBatchable(Matcher<?> m) {
+        super.withBatchable(m);
+        return this;
+    }
 }
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/DischargeExpectation.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/DischargeExpectation.java
index cf6e431..f3956dd 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/DischargeExpectation.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/DischargeExpectation.java
@@ -16,11 +16,18 @@
  */
 package org.apache.qpid.protonj2.test.driver.expectations;
 
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.nullValue;
+
 import org.apache.qpid.protonj2.test.driver.AMQPTestDriver;
 import org.apache.qpid.protonj2.test.driver.codec.primitives.Binary;
+import org.apache.qpid.protonj2.test.driver.codec.primitives.UnsignedInteger;
 import org.apache.qpid.protonj2.test.driver.codec.transactions.Discharge;
+import org.apache.qpid.protonj2.test.driver.codec.transport.DeliveryState;
+import org.apache.qpid.protonj2.test.driver.codec.transport.ReceiverSettleMode;
 import org.apache.qpid.protonj2.test.driver.matchers.transactions.DischargeMatcher;
 import org.apache.qpid.protonj2.test.driver.matchers.types.EncodedAmqpValueMatcher;
+import org.hamcrest.Matcher;
 
 /**
  * Expectation used to script incoming transaction declarations.
@@ -66,4 +73,169 @@ public class DischargeExpectation extends TransferExpectation {
         withPayload(new EncodedAmqpValueMatcher(null));
         return this;
     }
+
+    //----- Type specific with methods that perform simple equals checks
+
+    @Override
+    public DischargeExpectation withHandle(int handle) {
+        return withHandle(equalTo(UnsignedInteger.valueOf(handle)));
+    }
+
+    @Override
+    public DischargeExpectation withHandle(long handle) {
+        return withHandle(equalTo(UnsignedInteger.valueOf(handle)));
+    }
+
+    @Override
+    public DischargeExpectation withHandle(UnsignedInteger handle) {
+        return withHandle(equalTo(handle));
+    }
+
+    @Override
+    public DischargeExpectation withDeliveryId(int deliveryId) {
+        return withDeliveryId(equalTo(UnsignedInteger.valueOf(deliveryId)));
+    }
+
+    @Override
+    public DischargeExpectation withDeliveryId(long deliveryId) {
+        return withDeliveryId(equalTo(UnsignedInteger.valueOf(deliveryId)));
+    }
+
+    @Override
+    public DischargeExpectation withDeliveryId(UnsignedInteger deliveryId) {
+        return withDeliveryId(equalTo(deliveryId));
+    }
+
+    @Override
+    public DischargeExpectation withDeliveryTag(byte[] tag) {
+        return withDeliveryTag(new Binary(tag));
+    }
+
+    @Override
+    public DischargeExpectation withDeliveryTag(Binary deliveryTag) {
+        return withDeliveryTag(equalTo(deliveryTag));
+    }
+
+    @Override
+    public DischargeExpectation withMessageFormat(int messageFormat) {
+        return withMessageFormat(equalTo(UnsignedInteger.valueOf(messageFormat)));
+    }
+
+    @Override
+    public DischargeExpectation withMessageFormat(long messageFormat) {
+        return withMessageFormat(equalTo(UnsignedInteger.valueOf(messageFormat)));
+    }
+
+    @Override
+    public DischargeExpectation withMessageFormat(UnsignedInteger messageFormat) {
+        return withMessageFormat(equalTo(messageFormat));
+    }
+
+    @Override
+    public DischargeExpectation withSettled(boolean settled) {
+        return withSettled(equalTo(settled));
+    }
+
+    @Override
+    public DischargeExpectation withMore(boolean more) {
+        return withMore(equalTo(more));
+    }
+
+    @Override
+    public DischargeExpectation withRcvSettleMode(ReceiverSettleMode rcvSettleMode) {
+        return withRcvSettleMode(equalTo(rcvSettleMode.getValue()));
+    }
+
+    @Override
+    public DischargeExpectation withState(DeliveryState state) {
+        return withState(equalTo(state));
+    }
+
+    @Override
+    public DischargeExpectation withNullState() {
+        return withState(nullValue());
+    }
+
+    @Override
+    public DischargeExpectation withResume(boolean resume) {
+        return withResume(equalTo(resume));
+    }
+
+    @Override
+    public DischargeExpectation withAborted(boolean aborted) {
+        return withAborted(equalTo(aborted));
+    }
+
+    @Override
+    public DischargeExpectation withBatchable(boolean batchable) {
+        return withBatchable(equalTo(batchable));
+    }
+
+    //----- Matcher based with methods for more complex validation
+
+    @Override
+    public DischargeExpectation withHandle(Matcher<?> m) {
+        super.withHandle(m);
+        return this;
+    }
+
+    @Override
+    public DischargeExpectation withDeliveryId(Matcher<?> m) {
+        super.withDeliveryId(m);
+        return this;
+    }
+
+    @Override
+    public DischargeExpectation withDeliveryTag(Matcher<?> m) {
+        super.withDeliveryTag(m);
+        return this;
+    }
+
+    @Override
+    public DischargeExpectation withMessageFormat(Matcher<?> m) {
+        super.withMessageFormat(m);
+        return this;
+    }
+
+    @Override
+    public DischargeExpectation withSettled(Matcher<?> m) {
+        super.withSettled(m);
+        return this;
+    }
+
+    @Override
+    public DischargeExpectation withMore(Matcher<?> m) {
+        super.withMore(m);
+        return this;
+    }
+
+    @Override
+    public DischargeExpectation withRcvSettleMode(Matcher<?> m) {
+        super.withRcvSettleMode(m);
+        return this;
+    }
+
+    @Override
+    public DischargeExpectation withState(Matcher<?> m) {
+        super.withState(m);
+        return this;
+    }
+
+    @Override
+    public DischargeExpectation withResume(Matcher<?> m) {
+        super.withResume(m);
+        return this;
+    }
+
+    @Override
+    public DischargeExpectation withAborted(Matcher<?> m) {
+        super.withAborted(m);
+        return this;
+    }
+
+    @Override
+    public DischargeExpectation withBatchable(Matcher<?> m) {
+        super.withBatchable(m);
+        return this;
+    }
 }
diff --git a/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/TransactionHandlingTest.java b/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/TransactionHandlingTest.java
index 3690890..0a40d60 100644
--- a/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/TransactionHandlingTest.java
+++ b/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/TransactionHandlingTest.java
@@ -22,6 +22,7 @@ import static org.hamcrest.Matchers.notNullValue;
 import java.net.URI;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.qpid.protonj2.test.driver.codec.primitives.UnsignedInteger;
 import org.apache.qpid.protonj2.test.driver.codec.transport.AMQPHeader;
 import org.apache.qpid.protonj2.test.driver.utils.TestPeerTestsBase;
 import org.junit.jupiter.api.Test;
@@ -164,7 +165,16 @@ class TransactionHandlingTest extends TestPeerTestsBase {
     }
 
     @Test
-    public void testTxnDeclarationAndDischarge() throws Exception {
+    public void testTxnDeclarationAndDischargeNullMessageFormat() throws Exception {
+        doTestTxnDeclarationAndDischarge(null);
+    }
+
+    @Test
+    public void testTxnDeclarationAndDischargeZeroMessageFormat() throws Exception {
+        doTestTxnDeclarationAndDischarge(UnsignedInteger.ZERO);
+    }
+
+    private void doTestTxnDeclarationAndDischarge(UnsignedInteger messageFormat) throws Exception {
         try (ProtonTestServer peer = new ProtonTestServer();
              ProtonTestClient client = new ProtonTestClient()) {
 
@@ -173,7 +183,7 @@ class TransactionHandlingTest extends TestPeerTestsBase {
             peer.expectBegin().respond();
             peer.expectCoordinatorAttach().ofSender().respond();
             peer.remoteFlow().withLinkCredit(2).queue();
-            peer.expectDeclare().declared(new byte[] { 0, 1, 2, 3 });
+            peer.expectDeclare().withMessageFormat(messageFormat).declared(new byte[] { 0, 1, 2, 3 });
             peer.expectDischarge().accept();
             peer.expectDetach().respond();
             peer.expectEnd().respond();
@@ -198,7 +208,7 @@ class TransactionHandlingTest extends TestPeerTestsBase {
             client.expectFlow().withLinkCredit(2);
             client.waitForScriptToComplete(5, TimeUnit.SECONDS);
             client.expectDisposition().withState().declared(new byte[] {0, 1, 2, 3});
-            client.remoteDeclare().withDeliveryTag(new byte[] {0}).withDeliveryId(0).now();
+            client.remoteDeclare().withMessageFormat(messageFormat).withDeliveryTag(new byte[] {0}).withDeliveryId(0).now();
 
             client.waitForScriptToComplete(5, TimeUnit.SECONDS);
             client.expectDisposition().withState().accepted();

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


[qpid-protonj2] 02/02: PROTON-2393 Allow AMQP Frames to be fired on connection established

Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git

commit 34170e03cc2f8ba807d22bdc7d2402d31c16b76a
Author: Timothy Bish <ta...@gmail.com>
AuthorDate: Fri May 28 13:41:15 2021 -0400

    PROTON-2393 Allow AMQP Frames to be fired on connection established
    
    Allows for actions to be queued for fire on connect either from server
    accepting new client connection or client connecting successfully to a
    server.
---
 .../apache/qpid/protonj2/test/driver/AMQPTestDriver.java   |  9 +++++++++
 .../apache/qpid/protonj2/test/driver/ProtonTestClient.java | 14 +++++++++++++-
 .../qpid/protonj2/test/driver/ProtonTestConnector.java     |  5 +++++
 .../apache/qpid/protonj2/test/driver/ProtonTestPeer.java   |  2 ++
 .../apache/qpid/protonj2/test/driver/ProtonTestServer.java | 12 ++++++++++++
 5 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/AMQPTestDriver.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/AMQPTestDriver.java
index bd95058..0540588 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/AMQPTestDriver.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/AMQPTestDriver.java
@@ -247,6 +247,15 @@ public class AMQPTestDriver implements Consumer<ByteBuffer> {
 
     //----- Test driver handling of decoded AMQP frames
 
+    void handleConnectedEstablished() throws AssertionError {
+        synchronized (script) {
+            ScriptedElement peekNext = script.peek();
+            if (peekNext instanceof ScriptedAction) {
+                prcessScript(peekNext);
+            }
+        }
+    }
+
     void handleHeader(AMQPHeader header) throws AssertionError {
         synchronized (script) {
             final ScriptedElement scriptEntry = script.poll();
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestClient.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestClient.java
index 9541f4b..324119f 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestClient.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestClient.java
@@ -79,6 +79,12 @@ public class ProtonTestClient extends ProtonTestPeer implements AutoCloseable {
     }
 
     @Override
+    protected void processConnectionEstablished() {
+        LOG.trace("AMQP Client connected to remote.");
+        driver.handleConnectedEstablished();
+    }
+
+    @Override
     protected void processCloseRequest() {
         try {
             client.close();
@@ -89,7 +95,7 @@ public class ProtonTestClient extends ProtonTestPeer implements AutoCloseable {
 
     @Override
     protected void processDriverOutput(ByteBuffer frame) {
-        LOG.trace("AMQP Server Channel writing: {}", frame);
+        LOG.trace("AMQP Client Channel writing: {}", frame);
         client.write(frame);
     }
 
@@ -183,6 +189,12 @@ public class ProtonTestClient extends ProtonTestPeer implements AutoCloseable {
             return new SimpleChannelInboundHandler<ByteBuf>() {
 
                 @Override
+                public void channelActive(ChannelHandlerContext ctx) throws Exception {
+                    processConnectionEstablished();
+                    ctx.fireChannelActive();
+                }
+
+                @Override
                 protected void channelRead0(ChannelHandlerContext ctx, ByteBuf input) throws Exception {
                     LOG.trace("AMQP Test Client Channel read: {}", input);
 
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestConnector.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestConnector.java
index c85dd50..5375fe3 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestConnector.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestConnector.java
@@ -72,4 +72,9 @@ public class ProtonTestConnector extends ProtonTestPeer implements Consumer<Byte
     protected void processDriverOutput(ByteBuffer frame) {
         inputConsumer.accept(frame);
     }
+
+    @Override
+    protected void processConnectionEstablished() {
+        driver.handleConnectedEstablished();
+    }
 }
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestPeer.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestPeer.java
index 4a1ac4e..6dc4d1a 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestPeer.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestPeer.java
@@ -105,6 +105,8 @@ public abstract class ProtonTestPeer extends ScriptWriter implements AutoCloseab
 
     protected abstract void processDriverOutput(ByteBuffer frame);
 
+    protected abstract void processConnectionEstablished();
+
     protected void checkClosed() {
         if (closed.get()) {
             throw new IllegalStateException("The test peer is closed");
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestServer.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestServer.java
index dfdfff0..61e42cc 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestServer.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ProtonTestServer.java
@@ -131,6 +131,12 @@ public class ProtonTestServer extends ProtonTestPeer {
             return new SimpleChannelInboundHandler<ByteBuf>() {
 
                 @Override
+                public void channelActive(ChannelHandlerContext ctx) throws Exception {
+                    processConnectionEstablished();
+                    ctx.fireChannelActive();
+                }
+
+                @Override
                 protected void channelRead0(ChannelHandlerContext ctx, ByteBuf input) throws Exception {
                     LOG.trace("AMQP Test Server Channel read: {}", input);
 
@@ -231,6 +237,12 @@ public class ProtonTestServer extends ProtonTestPeer {
         server.write(frame);
     }
 
+    @Override
+    protected void processConnectionEstablished() {
+        LOG.trace("AMQP Server has a client connected.");
+        driver.handleConnectedEstablished();
+    }
+
     protected void processDriverAssertion(AssertionError error) {
         LOG.trace("AMQP Server Closing due to error: {}", error.getMessage());
         close();

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