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 db64796 PROTON-2393 Provide more readable frame logging for the test peer db64796 is described below commit db64796ac715a8eeff2be69aaffd5780b99c41c7 Author: Timothy Bish <tabish...@gmail.com> AuthorDate: Thu Jun 3 15:45:42 2021 -0400 PROTON-2393 Provide more readable frame logging for the test peer Produce more readable logging for the types that are read and written by the test peer during normal operations. --- .../test/driver/codec/ListDescribedType.java | 3 +- .../test/driver/codec/MapDescribedType.java | 2 +- .../test/driver/codec/messaging/AmqpSequence.java | 5 ++ .../test/driver/codec/messaging/AmqpValue.java | 5 ++ .../protonj2/test/driver/codec/messaging/Data.java | 5 ++ .../test/driver/codec/messaging/Header.java | 11 +++ .../test/driver/codec/messaging/Modified.java | 9 +++ .../test/driver/codec/messaging/Properties.java | 18 +++++ .../test/driver/codec/messaging/Received.java | 8 ++ .../test/driver/codec/messaging/Rejected.java | 5 ++ .../test/driver/codec/messaging/Released.java | 5 ++ .../test/driver/codec/messaging/Source.java | 18 +++++ .../test/driver/codec/messaging/Target.java | 14 ++++ .../test/driver/codec/security/SaslChallenge.java | 6 ++ .../test/driver/codec/security/SaslInit.java | 9 +++ .../test/driver/codec/security/SaslMechanisms.java | 6 ++ .../test/driver/codec/security/SaslOutcome.java | 9 +++ .../test/driver/codec/security/SaslResponse.java | 6 ++ .../driver/codec/transactions/Coordinator.java | 6 ++ .../test/driver/codec/transactions/Declare.java | 5 ++ .../test/driver/codec/transactions/Declared.java | 6 ++ .../test/driver/codec/transactions/Discharge.java | 5 ++ .../codec/transactions/TransactionalState.java | 5 ++ .../test/driver/codec/transport/Attach.java | 20 +++++ .../test/driver/codec/transport/Begin.java | 15 ++++ .../test/driver/codec/transport/Close.java | 5 ++ .../test/driver/codec/transport/Detach.java | 9 +++ .../test/driver/codec/transport/Disposition.java | 12 +++ .../protonj2/test/driver/codec/transport/End.java | 5 ++ .../driver/codec/transport/ErrorCondition.java | 9 +++ .../protonj2/test/driver/codec/transport/Flow.java | 17 +++++ .../protonj2/test/driver/codec/transport/Open.java | 17 +++++ .../test/driver/codec/transport/Transfer.java | 17 +++++ .../test/driver/codec/util/TypeMapper.java | 85 ++++++++++++++++++++++ .../protonj2/test/driver/ReceiverHandlingTest.java | 4 +- 35 files changed, 382 insertions(+), 4 deletions(-) diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/ListDescribedType.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/ListDescribedType.java index f134c44..6700f5b 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/ListDescribedType.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/ListDescribedType.java @@ -17,7 +17,6 @@ package org.apache.qpid.protonj2.test.driver.codec; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.apache.qpid.protonj2.test.driver.codec.primitives.DescribedType; @@ -115,6 +114,6 @@ public abstract class ListDescribedType implements DescribedType { @Override public String toString() { - return getClass().getSimpleName() + " [descriptor=" + getDescriptor() + " fields=" + Arrays.toString(getFields()) + "]"; + return getClass().getSimpleName() + " [descriptor=" + getDescriptor() + " fields=" + getList() + "]"; } } \ No newline at end of file diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/MapDescribedType.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/MapDescribedType.java index 1f3cd0b..0049b7c 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/MapDescribedType.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/MapDescribedType.java @@ -39,6 +39,6 @@ public abstract class MapDescribedType implements DescribedType { @Override public String toString() { - return "MapDescribedType [descriptor=" + getDescriptor() + " fields=" + fields + "]"; + return getClass().getSimpleName() + " [descriptor=" + getDescriptor() + " fields=" + fields + "]"; } } \ No newline at end of file diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/AmqpSequence.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/AmqpSequence.java index 6375a90..a42e8c8 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/AmqpSequence.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/AmqpSequence.java @@ -42,4 +42,9 @@ public class AmqpSequence implements DescribedType { public Object getDescribed() { return described; } + + @Override + public String toString() { + return "AmqpSequence: [ " + getDescribed() + " ]"; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/AmqpValue.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/AmqpValue.java index 3ac8d16..8cfe251 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/AmqpValue.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/AmqpValue.java @@ -40,4 +40,9 @@ public class AmqpValue implements DescribedType { public Object getDescribed() { return described; } + + @Override + public String toString() { + return "AmqpValue: [ " + getDescribed() + " ]"; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Data.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Data.java index e0860ce..f33f9af 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Data.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Data.java @@ -45,4 +45,9 @@ public class Data implements DescribedType { public Binary getDescribed() { return described; } + + @Override + public String toString() { + return "Data: [ " + getDescribed() + " ]"; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Header.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Header.java index a7f28dc..b7e1235 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Header.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Header.java @@ -102,4 +102,15 @@ public class Header extends ListDescribedType { public UnsignedInteger getDeliveryCount() { return (UnsignedInteger) getList().get(Field.DELIVERY_COUNT.ordinal()); } + + @Override + public String toString() { + return "Header{ " + + "durable=" + getDurable() + + ", priority=" + getPriority() + + ", ttl=" + getTtl() + + ", firstAcquirer=" + getFirstAcquirer() + + ", deliveryCount=" + getDeliveryCount() + + " }"; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Modified.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Modified.java index 69cb74e..9835a4c 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Modified.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Modified.java @@ -118,4 +118,13 @@ public class Modified extends ListDescribedType implements DeliveryState, Outcom public DeliveryStateType getType() { return DeliveryStateType.Modified; } + + @Override + public String toString() { + return "Modified{" + + "deliveryFailed=" + getDeliveryFailed() + + ", undeliverableHere=" + getUndeliverableHere() + + ", messageAnnotations=" + getMessageAnnotations() + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Properties.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Properties.java index 16e37b9..b1f48f4 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Properties.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Properties.java @@ -183,4 +183,22 @@ public class Properties extends ListDescribedType { public String getReplyToGroupId() { return (String) getList().get(Field.REPLY_TO_GROUP_ID.ordinal()); } + + @Override + public String toString() { + return "Properties{" + + "messageId=" + getMessageId() + + ", userId=" + getUserId() + + ", to='" + getTo() + '\'' + + ", subject='" + getSubject() + '\'' + + ", replyTo='" + getReplyTo() + '\'' + + ", correlationId=" + getCorrelationId() + + ", contentType=" + getContentType() + + ", contentEncoding=" + getContentEncoding() + + ", absoluteExpiryTime=" + getAbsoluteExpiryTime() + + ", creationTime=" + getCreationTime() + + ", groupId='" + getGroupId() + '\'' + + ", groupSequence=" + getGroupSequence() + + ", replyToGroupId='" + getReplyToGroupId() + '\'' + " }"; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Received.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Received.java index 73382eb..f198271 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Received.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Received.java @@ -76,4 +76,12 @@ public class Received extends ListDescribedType implements DeliveryState, Outcom public DeliveryStateType getType() { return DeliveryStateType.Received; } + + @Override + public String toString() { + return "Received{" + + "sectionNumber=" + getSectionNumber() + + ", sectionOffset=" + getSectionOffset() + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Rejected.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Rejected.java index fc2b1ab..4610903 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Rejected.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Rejected.java @@ -97,4 +97,9 @@ public class Rejected extends ListDescribedType implements DeliveryState, Outcom public DeliveryStateType getType() { return DeliveryStateType.Rejected; } + + @Override + public String toString() { + return "Rejected{" + "error=" + getError() + "}"; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Released.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Released.java index 296d6c5..d6f9270 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Released.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Released.java @@ -86,4 +86,9 @@ public class Released extends ListDescribedType implements DeliveryState, Outcom public DeliveryStateType getType() { return DeliveryStateType.Released; } + + @Override + public String toString() { + return "Released{}"; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Source.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Source.java index 3b2f224..76af391 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Source.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Source.java @@ -16,6 +16,7 @@ */ package org.apache.qpid.protonj2.test.driver.codec.messaging; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -180,4 +181,21 @@ public class Source extends ListDescribedType { public Symbol[] getCapabilities() { return (Symbol[]) getList().get(Field.CAPABILITIES.ordinal()); } + + @Override + public String toString() { + return "Source{" + + "address='" + getAddress() + '\'' + + ", durable=" + getDurable() + + ", expiryPolicy=" + getExpiryPolicy() + + ", timeout=" + getTimeout() + + ", dynamic=" + getDynamic() + + ", dynamicNodeProperties=" + getDynamicNodeProperties() + + ", distributionMode=" + getDistributionMode() + + ", filter=" + getFilter() + + ", defaultOutcome=" + getDefaultOutcome() + + ", outcomes=" + Arrays.toString(getOutcomes()) + + ", capabilities=" + Arrays.toString(getCapabilities()) + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Target.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Target.java index 6475a59..309b962 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Target.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/messaging/Target.java @@ -16,6 +16,7 @@ */ package org.apache.qpid.protonj2.test.driver.codec.messaging; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -127,4 +128,17 @@ public class Target extends ListDescribedType { public Symbol[] getCapabilities() { return (Symbol[]) getList().get(Field.CAPABILITIES.ordinal()); } + + @Override + public String toString() { + return "Target{" + + "address='" + getAddress() + '\'' + + ", durable=" + getDurable() + + ", expiryPolicy=" + getExpiryPolicy() + + ", timeout=" + getTimeout() + + ", dynamic=" + getDynamic() + + ", dynamicNodeProperties=" + getDynamicNodeProperties() + + ", capabilities=" + Arrays.toString(getCapabilities()) + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslChallenge.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslChallenge.java index ad48a1d..855484a 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslChallenge.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslChallenge.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.qpid.protonj2.test.driver.codec.primitives.Binary; import org.apache.qpid.protonj2.test.driver.codec.primitives.Symbol; import org.apache.qpid.protonj2.test.driver.codec.primitives.UnsignedLong; +import org.apache.qpid.protonj2.test.driver.codec.util.TypeMapper; public class SaslChallenge extends SaslDescribedType { @@ -70,4 +71,9 @@ public class SaslChallenge extends SaslDescribedType { public <E> void invoke(SaslPerformativeHandler<E> handler, int frameSzie, E context) { handler.handleChallenge(frameSzie, this, context); } + + @Override + public String toString() { + return "SaslChallenge{" + "challenge=" + TypeMapper.toQuotedString(getChallenge()) + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslInit.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslInit.java index 6d997d9..af42caa 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslInit.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslInit.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.qpid.protonj2.test.driver.codec.primitives.Binary; import org.apache.qpid.protonj2.test.driver.codec.primitives.Symbol; import org.apache.qpid.protonj2.test.driver.codec.primitives.UnsignedLong; +import org.apache.qpid.protonj2.test.driver.codec.util.TypeMapper; public class SaslInit extends SaslDescribedType { @@ -90,4 +91,12 @@ public class SaslInit extends SaslDescribedType { public <E> void invoke(SaslPerformativeHandler<E> handler, int frameSzie, E context) { handler.handleInit(frameSzie, this, context); } + + @Override + public String toString() { + return "SaslInit{" + + "mechanism=" + getMechanism() + + ", initialResponse=" + TypeMapper.toQuotedString(getInitialResponse()) + + ", hostname='" + getHostname() + '\'' + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslMechanisms.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslMechanisms.java index b3eb672..6321a5a 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslMechanisms.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslMechanisms.java @@ -16,6 +16,7 @@ */ package org.apache.qpid.protonj2.test.driver.codec.security; +import java.util.Arrays; import java.util.List; import org.apache.qpid.protonj2.test.driver.codec.primitives.Symbol; @@ -69,4 +70,9 @@ public class SaslMechanisms extends SaslDescribedType { public <E> void invoke(SaslPerformativeHandler<E> handler, int frameSzie, E context) { handler.handleMechanisms(frameSzie, this, context); } + + @Override + public String toString() { + return "SaslMechanisms{" + "saslServerMechanisms=" + Arrays.toString(getSaslServerMechanisms()) + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslOutcome.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslOutcome.java index c117a92..60210dd 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslOutcome.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslOutcome.java @@ -22,6 +22,7 @@ import org.apache.qpid.protonj2.test.driver.codec.primitives.Binary; import org.apache.qpid.protonj2.test.driver.codec.primitives.Symbol; import org.apache.qpid.protonj2.test.driver.codec.primitives.UnsignedByte; import org.apache.qpid.protonj2.test.driver.codec.primitives.UnsignedLong; +import org.apache.qpid.protonj2.test.driver.codec.util.TypeMapper; public class SaslOutcome extends SaslDescribedType { @@ -81,4 +82,12 @@ public class SaslOutcome extends SaslDescribedType { public <E> void invoke(SaslPerformativeHandler<E> handler, int frameSzie, E context) { handler.handleOutcome(frameSzie, this, context); } + + @Override + public String toString() { + return "SaslOutcome{" + + "code=" + getCode() + + ", additionalData=" + TypeMapper.toQuotedString(getAdditionalData()) + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslResponse.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslResponse.java index 989b90d..9d7065c 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslResponse.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/security/SaslResponse.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.qpid.protonj2.test.driver.codec.primitives.Binary; import org.apache.qpid.protonj2.test.driver.codec.primitives.Symbol; import org.apache.qpid.protonj2.test.driver.codec.primitives.UnsignedLong; +import org.apache.qpid.protonj2.test.driver.codec.util.TypeMapper; public class SaslResponse extends SaslDescribedType { @@ -70,4 +71,9 @@ public class SaslResponse extends SaslDescribedType { public <E> void invoke(SaslPerformativeHandler<E> handler, int frameSzie, E context) { handler.handleResponse(frameSzie, this, context); } + + @Override + public String toString() { + return "SaslResponse{" + "response=" + TypeMapper.toQuotedString(getResponse()) + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Coordinator.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Coordinator.java index 244bcb2..533c9fc 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Coordinator.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Coordinator.java @@ -16,6 +16,7 @@ */ package org.apache.qpid.protonj2.test.driver.codec.transactions; +import java.util.Arrays; import java.util.List; import org.apache.qpid.protonj2.test.driver.codec.ListDescribedType; @@ -60,4 +61,9 @@ public class Coordinator extends ListDescribedType { public Symbol[] getCapabilities() { return (Symbol[]) getList().get(Field.CAPABILITIES.ordinal()); } + + @Override + public String toString() { + return "Coordinator{" + "capabilities=" + Arrays.toString(getCapabilities()) + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Declare.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Declare.java index 7dd383f..e7e1653 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Declare.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Declare.java @@ -91,4 +91,9 @@ public class Declare extends ListDescribedType { public int hashCode() { return System.identityHashCode(this); } + + @Override + public String toString() { + return "Declare{" + "globalId=" + getGlobalId() + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Declared.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Declared.java index f2cc44f..f6f157a 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Declared.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Declared.java @@ -102,4 +102,10 @@ public class Declared extends ListDescribedType implements DeliveryState, Outcom public DeliveryStateType getType() { return DeliveryStateType.Declared; } + + @Override + public String toString() { + return "Declared{" + "txnId=" + getTxnId() + '}'; + } + } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Discharge.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Discharge.java index 9cf4a2b..7f59e88 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Discharge.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/Discharge.java @@ -101,4 +101,9 @@ public class Discharge extends ListDescribedType { public int hashCode() { return System.identityHashCode(this); } + + @Override + public String toString() { + return "Discharge{" + "txnId=" + getTxnId() + ", fail=" + getFail() + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/TransactionalState.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/TransactionalState.java index ebbef81..217bc3e 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/TransactionalState.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transactions/TransactionalState.java @@ -107,4 +107,9 @@ public class TransactionalState extends ListDescribedType implements DeliverySta public DeliveryStateType getType() { return DeliveryStateType.Transactional; } + + @Override + public String toString() { + return "TransactionalState{" + "txnId=" + getTxnId() + ", outcome=" + getOutcome() + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Attach.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Attach.java index 9e219dc..4641f5e 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Attach.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Attach.java @@ -16,6 +16,7 @@ */ package org.apache.qpid.protonj2.test.driver.codec.transport; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -275,4 +276,23 @@ public class Attach extends PerformativeDescribedType { } return result; } + + @Override + public String toString() { + return "Attach{" + + "name='" + getName() + '\'' + + ", handle=" + getHandle() + + ", role=" + getRole() + + ", sndSettleMode=" + getSenderSettleMode() + + ", rcvSettleMode=" + getReceiverSettleMode() + + ", source=" + getSource() + + ", target=" + getTarget() + + ", unsettled=" + getUnsettled() + + ", incompleteUnsettled=" + getIncompleteUnsettled() + + ", initialDeliveryCount=" + getInitialDeliveryCount() + + ", maxMessageSize=" + getMaxMessageSize() + + ", offeredCapabilities=" + Arrays.toString(getOfferedCapabilities()) + + ", desiredCapabilities=" + Arrays.toString(getDesiredCapabilities()) + + ", properties=" + getProperties() + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Begin.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Begin.java index 182e08d..84624d5 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Begin.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Begin.java @@ -16,6 +16,7 @@ */ package org.apache.qpid.protonj2.test.driver.codec.transport; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -161,4 +162,18 @@ public class Begin extends PerformativeDescribedType { } return result; } + + @Override + public String toString() { + return "Begin{" + + "remoteChannel=" + getRemoteChannel() + + ", nextOutgoingId=" + getNextOutgoingId() + + ", incomingWindow=" + getIncomingWindow() + + ", outgoingWindow=" + getOutgoingWindow() + + ", handleMax=" + getHandleMax() + + ", offeredCapabilities=" + Arrays.toString(getOfferedCapabilities()) + + ", desiredCapabilities=" + Arrays.toString(getDesiredCapabilities()) + + ", properties=" + getProperties() + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Close.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Close.java index c5e3b29..b4f0ab2 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Close.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Close.java @@ -71,4 +71,9 @@ public class Close extends PerformativeDescribedType { public <E> void invoke(PerformativeHandler<E> handler, int frameSize, ByteBuf payload, int channel, E context) { handler.handleClose(frameSize, this, payload, channel, context); } + + @Override + public String toString() { + return "Close{" + "error=" + getError() + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Detach.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Detach.java index 2167987..50958f3 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Detach.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Detach.java @@ -108,4 +108,13 @@ public class Detach extends PerformativeDescribedType { } return result; } + + @Override + public String toString() { + return "Detach{" + + "handle=" + getHandle() + + ", closed=" + getClosed() + + ", error=" + getError() + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Disposition.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Disposition.java index eb1b280..ec4a79c 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Disposition.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Disposition.java @@ -142,4 +142,16 @@ public class Disposition extends PerformativeDescribedType { } return result; } + + @Override + public String toString() { + return "Disposition{" + + "role=" + getRole() + + ", first=" + getFirst() + + ", last=" + getLast() + + ", settled=" + getSettled() + + ", state=" + getState() + + ", batchable=" + getBatchable() + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/End.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/End.java index 6e71a13..3854418 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/End.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/End.java @@ -71,4 +71,9 @@ public class End extends PerformativeDescribedType { public <E> void invoke(PerformativeHandler<E> handler, int frameSize, ByteBuf payload, int channel, E context) { handler.handleEnd(frameSize, this, payload, channel, context); } + + @Override + public String toString() { + return "End{" + "error=" + getError() + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/ErrorCondition.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/ErrorCondition.java index 04b9817..f16eb7b 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/ErrorCondition.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/ErrorCondition.java @@ -134,4 +134,13 @@ public class ErrorCondition extends ListDescribedType { return described.equals(described2); } } + + @Override + public String toString() { + return "Error{" + + "condition=" + getCondition() + + ", description='" + getDescription() + '\'' + + ", info=" + getInfo() + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Flow.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Flow.java index e381d98..2bbd4d9 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Flow.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Flow.java @@ -193,4 +193,21 @@ public class Flow extends PerformativeDescribedType { } return result; } + + @Override + public String toString() { + return "Flow{" + + "nextIncomingId=" + getNextIncomingId()+ + ", incomingWindow=" + getIncomingWindow() + + ", nextOutgoingId=" + getNextOutgoingId() + + ", outgoingWindow=" + getOutgoingWindow() + + ", handle=" + getHandle() + + ", deliveryCount=" + getDeliveryCount() + + ", linkCredit=" + getLinkCredit() + + ", available=" + getAvailable() + + ", drain=" + getDrain() + + ", echo=" + getEcho() + + ", properties=" + getProperties() + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Open.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Open.java index 94e9d6b..31ad53b 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Open.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Open.java @@ -16,6 +16,7 @@ */ package org.apache.qpid.protonj2.test.driver.codec.transport; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -184,4 +185,20 @@ public class Open extends PerformativeDescribedType { } return result; } + + @Override + public String toString() { + return "Open{" + + " containerId='" + getContainerId() + '\'' + + ", hostname='" + getHostname() + '\'' + + ", maxFrameSize=" + getMaxFrameSize() + + ", channelMax=" + getChannelMax() + + ", idleTimeOut=" + getIdleTimeOut() + + ", outgoingLocales=" + getOutgoingLocales() + + ", incomingLocales=" + getIncomingLocales() + + ", offeredCapabilities=" + Arrays.toString(getOfferedCapabilities()) + + ", desiredCapabilities=" + Arrays.toString(getDesiredCapabilities()) + + ", properties=" + getProperties() + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Transfer.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Transfer.java index 5ed2163..ddfaad0 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Transfer.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/transport/Transfer.java @@ -200,4 +200,21 @@ public class Transfer extends PerformativeDescribedType { } return result; } + + @Override + public String toString() { + return "Transfer{" + + "handle=" + getHandle() + + ", deliveryId=" + getDeliveryId() + + ", deliveryTag=" + getDeliveryTag() + + ", messageFormat=" + getMessageFormat() + + ", settled=" + getSettled() + + ", more=" + getMore() + + ", rcvSettleMode=" + getRcvSettleMode() + + ", state=" + getState() + + ", resume=" + getResume() + + ", aborted=" + getAborted() + + ", batchable=" + getBatchable() + + '}'; + } } diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/util/TypeMapper.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/util/TypeMapper.java index 4d6cfaa..16ebd3f 100644 --- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/util/TypeMapper.java +++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/codec/util/TypeMapper.java @@ -19,10 +19,13 @@ package org.apache.qpid.protonj2.test.driver.codec.util; import java.util.HashMap; import java.util.Map; +import org.apache.qpid.protonj2.test.driver.codec.primitives.Binary; import org.apache.qpid.protonj2.test.driver.codec.primitives.Symbol; public abstract class TypeMapper { + private static final int DEFAULT_QUOTED_STRING_LIMIT = 64; + private TypeMapper() { } @@ -53,4 +56,86 @@ public abstract class TypeMapper { return result; } + + /** + * Converts the Binary to a quoted string using a default max length before truncation value and + * appends a truncation indication if the string required truncation. + * + * @param buffer + * the {@link Binary} to convert into String format. + * + * @return the converted string + */ + public static String toQuotedString(final Binary buffer) { + return toQuotedString(buffer, DEFAULT_QUOTED_STRING_LIMIT, true); + } + + /** + * Converts the Binary to a quoted string using a default max length before truncation value. + * + * @param buffer + * the {@link Binary} to convert into String format. + * @param appendIfTruncated + * appends "...(truncated)" if not all of the payload is present in the string + * + * @return the converted string + */ + public static String toQuotedString(final Binary buffer, final boolean appendIfTruncated) { + return toQuotedString(buffer, DEFAULT_QUOTED_STRING_LIMIT, appendIfTruncated); + } + + /** + * Converts the Binary to a quoted string. + * + * @param buffer + * the {@link Binary} to convert into String format. + * @param stringLength + * the maximum length of stringified content (excluding the quotes, and truncated indicator) + * @param appendIfTruncated + * appends "...(truncated)" if not all of the payload is present in the string + * + * @return the converted string + */ + public static String toQuotedString(final Binary buffer, final int stringLength, final boolean appendIfTruncated) { + if (buffer == null || buffer.getArray() == null) { + return "\"\""; + } + + StringBuilder str = new StringBuilder(); + str.append("\""); + + final int byteToRead = buffer.getLength(); + int size = 0; + boolean truncated = false; + + for (int i = 0; i < byteToRead; ++i) { + byte c = buffer.getArray()[i]; + + if (c > 31 && c < 127 && c != '\\') { + if (size + 1 <= stringLength) { + size += 1; + str.append((char) c); + } else { + truncated = true; + break; + } + } else { + if (size + 4 <= stringLength) { + size += 4; + str.append(String.format("\\x%02x", c)); + } else { + truncated = true; + break; + } + } + } + + str.append("\""); + + if (truncated && appendIfTruncated) { + str.append("...(truncated)"); + } + + return str.toString(); + } } diff --git a/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/ReceiverHandlingTest.java b/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/ReceiverHandlingTest.java index 47a3357..ec664a6 100644 --- a/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/ReceiverHandlingTest.java +++ b/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/ReceiverHandlingTest.java @@ -333,7 +333,9 @@ class ReceiverHandlingTest extends TestPeerTestsBase { client.remoteHeader(AMQPHeader.getAMQPHeader()).now(); client.remoteOpen().now(); client.remoteBegin().now(); - client.remoteAttach().ofReceiver().withHandle(42).now(); + client.remoteAttach().ofReceiver().withHandle(42) + .withSource().withCapabilities("QUEUE") + .and().now(); // Wait for the above and then script next steps client.waitForScriptToComplete(5, TimeUnit.SECONDS); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org