You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2017/08/30 16:33:09 UTC

[1/3] qpid-proton-j git commit: PROTON-1551: Fix length encoding for binary over 255 bytes in length when using DataImpl

Repository: qpid-proton-j
Updated Branches:
  refs/heads/master 9936ba482 -> 68f30de35


PROTON-1551: Fix length encoding for binary over 255 bytes in length when using DataImpl


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

Branch: refs/heads/master
Commit: e78dbff323f2749c563e0f9a4a8b6fdf479611b6
Parents: 9936ba4
Author: Viktor Kolomeyko <vi...@r3.com>
Authored: Wed Aug 30 17:06:07 2017 +0100
Committer: Viktor Kolomeyko <vi...@r3.com>
Committed: Wed Aug 30 17:06:07 2017 +0100

----------------------------------------------------------------------
 .../qpid/proton/codec/impl/BinaryElement.java   |  2 +-
 .../qpid/proton/codec/impl/DataImplTest.java    | 28 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/e78dbff3/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BinaryElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BinaryElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BinaryElement.java
index fd05243..90bf5ee 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BinaryElement.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BinaryElement.java
@@ -119,7 +119,7 @@ class BinaryElement extends AtomicElement<Binary>
         else
         {
             b.put((byte)0xb0);
-            b.put((byte)_value.getLength());
+            b.putInt(_value.getLength());
         }
         b.put(_value.getArray(),_value.getArrayOffset(),_value.getLength());
         return size;

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/e78dbff3/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java
index b650aed..d02a088 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java
@@ -274,4 +274,32 @@ public class DataImplTest
 
         return payload;
     }
+
+    @Test
+    public void testEncodeDecodeBinary32()
+    {
+        byte[] initialPayload = createStringPayloadBytes(1025);
+        String initialContent = new String(initialPayload, StandardCharsets.UTF_8);
+        assertTrue("Length must be over 255 to ensure use of str32 encoding", initialContent.length() > 255);
+
+        byte[] bytesReadBack = doEncodeDecodeBinaryTestImpl(initialPayload);
+        String readBackContent = new String(bytesReadBack, StandardCharsets.UTF_8);
+        assertEquals(initialContent, readBackContent);
+    }
+
+    private byte[] doEncodeDecodeBinaryTestImpl(byte[] payload)
+    {
+        Data data = new DataImpl();
+        data.putBinary(payload);
+
+        Binary encoded = data.encode();
+
+        ByteBuffer byteBuffer = encoded.asByteBuffer();
+        Data data2 = new DataImpl();
+        long decodeResult = data2.decode(byteBuffer);
+        assertTrue(Long.toString(decodeResult), decodeResult > 0);
+
+        assertEquals("unexpected type", Data.DataType.BINARY, data2.type());
+        return data2.getBinary().getArray();
+    }
 }


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


[2/3] qpid-proton-j git commit: PROTON-1551: merge PR fixing encoding of vbin32 binary using Data API. This closes #10.

Posted by ro...@apache.org.
PROTON-1551: merge PR fixing encoding of vbin32 binary using Data API. This closes #10.


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

Branch: refs/heads/master
Commit: 054693405bb252762e09c3473c3de588cb6c4dda
Parents: 9936ba4 e78dbff
Author: Robbie Gemmell <ro...@apache.org>
Authored: Wed Aug 30 17:11:21 2017 +0100
Committer: Robbie Gemmell <ro...@apache.org>
Committed: Wed Aug 30 17:11:21 2017 +0100

----------------------------------------------------------------------
 .../qpid/proton/codec/impl/BinaryElement.java   |  2 +-
 .../qpid/proton/codec/impl/DataImplTest.java    | 28 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



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


[3/3] qpid-proton-j git commit: PROTON-1551: add more specific encode test

Posted by ro...@apache.org.
PROTON-1551: add more specific encode test


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/commit/68f30de3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/tree/68f30de3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/diff/68f30de3

Branch: refs/heads/master
Commit: 68f30de3597e5d2cb1ce7801741038575b49e1b8
Parents: 0546934
Author: Robbie Gemmell <ro...@apache.org>
Authored: Wed Aug 30 17:25:10 2017 +0100
Committer: Robbie Gemmell <ro...@apache.org>
Committed: Wed Aug 30 17:25:10 2017 +0100

----------------------------------------------------------------------
 .../qpid/proton/codec/impl/DataImplTest.java    | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/68f30de3/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java
index d02a088..ac56f7f 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java
@@ -276,6 +276,26 @@ public class DataImplTest
     }
 
     @Test
+    public void testEncodeStringBinary32()
+    {
+        byte[] payload = createStringPayloadBytes(1372);
+        assertTrue("Length must be over 255 to ensure use of vbin32 encoding", payload.length > 255);
+
+        int encodedSize = 1 + 4 + payload.length; // 1b type + 4b length + content
+        ByteBuffer expectedEncoding = ByteBuffer.allocate(encodedSize);
+        expectedEncoding.put((byte) 0xB0);
+        expectedEncoding.putInt(payload.length);
+        expectedEncoding.put(payload);
+
+        Data data = new DataImpl();
+        data.putBinary(new Binary(payload));
+
+        Binary encoded = data.encode();
+
+        assertEquals("unexpected encoding", new Binary(expectedEncoding.array()), encoded);
+    }
+
+    @Test
     public void testEncodeDecodeBinary32()
     {
         byte[] initialPayload = createStringPayloadBytes(1025);


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