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
The following commit(s) were added to refs/heads/main by this push:
new 81bd3150 PROTON-2795 Additional tests and cleanups of message format
handling
81bd3150 is described below
commit 81bd31500c4f8102409876cfc47a38f806d69fb3
Author: Timothy Bish <[email protected]>
AuthorDate: Wed Feb 28 16:15:12 2024 -0500
PROTON-2795 Additional tests and cleanups of message format handling
Ensure tests cover more cases of split frame transfers and message
format expectations. Improve test driver scripting for setting defaults
on outgoing Declare and Discharge frames.
---
.../apache/qpid/protonj2/test/driver/ScriptWriter.java | 16 ++++++++++++----
.../protonj2/test/driver/TransactionHandlingTest.java | 13 ++-----------
.../engine/impl/ProtonSessionOutgoingWindow.java | 7 ++-----
.../qpid/protonj2/engine/impl/ProtonSenderTest.java | 4 ++++
4 files changed, 20 insertions(+), 20 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 e92b9098..002c6824 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
@@ -179,7 +179,7 @@ public abstract class ScriptWriter {
expecting.withHandle(notNullValue());
expecting.withDeliveryId(notNullValue());
expecting.withDeliveryTag(notNullValue());
- expecting.withMessageFormat(Matchers.oneOf(null, 0,
UnsignedInteger.ZERO));
+ expecting.withMessageFormat(Matchers.oneOf(0, UnsignedInteger.ZERO));
getDriver().addScriptedElement(expecting);
return expecting;
@@ -191,7 +191,7 @@ public abstract class ScriptWriter {
expecting.withHandle(notNullValue());
expecting.withDeliveryId(notNullValue());
expecting.withDeliveryTag(notNullValue());
- expecting.withMessageFormat(Matchers.oneOf(null, 0,
UnsignedInteger.ZERO));
+ expecting.withMessageFormat(Matchers.oneOf(0, UnsignedInteger.ZERO));
getDriver().addScriptedElement(expecting);
return expecting;
@@ -294,11 +294,19 @@ public abstract class ScriptWriter {
}
public DeclareInjectAction remoteDeclare() {
- return new DeclareInjectAction(getDriver());
+ DeclareInjectAction declare = new DeclareInjectAction(getDriver());
+
+ declare.withMessageFormat(0);
+
+ return declare;
}
public DischargeInjectAction remoteDischarge() {
- return new DischargeInjectAction(getDriver());
+ DischargeInjectAction discharge = new
DischargeInjectAction(getDriver());
+
+ discharge.withMessageFormat(0);
+
+ return discharge;
}
public EmptyFrameInjectAction remoteEmptyFrame() {
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 8c8d2b69..42e8a54f 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
@@ -164,17 +164,8 @@ class TransactionHandlingTest extends TestPeerTestsBase {
}
}
- @Test
- 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()) {
@@ -183,7 +174,7 @@ class TransactionHandlingTest extends TestPeerTestsBase {
peer.expectBegin().respond();
peer.expectCoordinatorAttach().ofSender().respond();
peer.remoteFlow().withLinkCredit(2).queue();
- peer.expectDeclare().withMessageFormat(messageFormat).declared(new
byte[] { 0, 1, 2, 3 });
+
peer.expectDeclare().withMessageFormat(UnsignedInteger.ZERO).declared(new
byte[] { 0, 1, 2, 3 });
peer.expectDischarge().accept();
peer.expectDetach().respond();
peer.expectEnd().respond();
@@ -208,7 +199,7 @@ class TransactionHandlingTest extends TestPeerTestsBase {
.and().now();
client.waitForScriptToComplete(5, TimeUnit.SECONDS);
client.expectDisposition().withState().declared(new byte[] {0, 1,
2, 3});
-
client.remoteDeclare().withMessageFormat(messageFormat).withDeliveryTag(new
byte[] {0}).withDeliveryId(0).now();
+ client.remoteDeclare().withDeliveryTag(new byte[]
{0}).withDeliveryId(0).now();
client.waitForScriptToComplete(5, TimeUnit.SECONDS);
client.expectDisposition().withState().accepted();
diff --git
a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonSessionOutgoingWindow.java
b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonSessionOutgoingWindow.java
index 35729bd8..50a6388e 100644
---
a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonSessionOutgoingWindow.java
+++
b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonSessionOutgoingWindow.java
@@ -267,11 +267,6 @@ public class ProtonSessionOutgoingWindow {
try {
cachedTransfer.setDeliveryId(delivery.getDeliveryId());
- if (delivery.getTransferCount() == 0) {
- cachedTransfer.setMessageFormat(delivery.getMessageFormat());
- } else {
- cachedTransfer.clearMessageFormat();
- }
cachedTransfer.setHandle(sender.getHandle());
cachedTransfer.setSettled(delivery.isSettled());
cachedTransfer.setState(delivery.getState());
@@ -286,8 +281,10 @@ public class ProtonSessionOutgoingWindow {
// Only the first transfer requires the delivery tag,
afterwards we can omit it for efficiency.
if (delivery.getTransferCount() == 0) {
+
cachedTransfer.setMessageFormat(delivery.getMessageFormat());
cachedTransfer.setDeliveryTag(delivery.getTag());
} else {
+ cachedTransfer.clearMessageFormat();
cachedTransfer.setDeliveryTag((DeliveryTag) null);
}
cachedTransfer.setMore(!complete);
diff --git
a/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonSenderTest.java
b/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonSenderTest.java
index 22843ed2..168aa2fc 100644
---
a/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonSenderTest.java
+++
b/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonSenderTest.java
@@ -1852,18 +1852,21 @@ public class ProtonSenderTest extends
ProtonEngineTestSupport {
.withState().accepted()
.withDeliveryId(0)
.withMore(true)
+ .withMessageFormat(0)
.withDeliveryTag(new byte[] {1});
peer.expectTransfer().withHandle(0)
.withSettled(true)
.withState().accepted()
.withDeliveryId(0)
.withMore(false)
+ .withMessageFormat((UnsignedInteger) null)
.withDeliveryTag(nullValue());
peer.expectTransfer().withHandle(1)
.withSettled(true)
.withState().accepted()
.withDeliveryId(1)
.withMore(bothDeliveriesMultiFrame)
+ .withMessageFormat(0)
.withDeliveryTag(new byte[] {2});
if (bothDeliveriesMultiFrame) {
peer.expectTransfer().withHandle(1)
@@ -1871,6 +1874,7 @@ public class ProtonSenderTest extends
ProtonEngineTestSupport {
.withState().accepted()
.withDeliveryId(1)
.withMore(false)
+ .withMessageFormat((UnsignedInteger) null)
.withDeliveryTag(nullValue());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]