X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=openflowjava-util%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Futil%2FByteBufUtilsTest.java;fp=openflowjava-util%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Futil%2FByteBufUtilsTest.java;h=b7f0f593caed035f5481f86576537c4c7979c42a;hb=95ebf4e412c17c30adca24757e3c5dc51e1ae492;hp=8196e69ba095f5f035f1a557e48ef7de0d6dd333;hpb=37b396c43ec3d71120f0948016cdc7c278a8c6c8;p=openflowjava.git diff --git a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java index 8196e69b..b7f0f593 100644 --- a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java +++ b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java @@ -448,4 +448,22 @@ public class ByteBufUtilsTest { Assert.assertTrue(bytes.length == shorts.size()*2); Assert.assertArrayEquals(EXPECTEDVALUES1AND255, bytes); } + + @Test + public void testUpdateHeader() throws IOException { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeInt(1); + int start = buffer.writerIndex(); + buffer.writeShort(4); + buffer.writeShort(EncodeConstants.EMPTY_LENGTH); + buffer.writeLong(8); + int end = buffer.writerIndex(); + + ByteBufUtils.updateOFHeaderLength(buffer, start); + Assert.assertEquals(buffer.readInt(), 1); + Assert.assertEquals(buffer.readShort(), 4); + Assert.assertEquals(buffer.readShort(), 12); + Assert.assertEquals(buffer.readLong(), 8l); + Assert.assertEquals(buffer.getShort(start + EncodeConstants.OFHEADER_LENGTH_INDEX), end - start); + } }