Fix unit test regression after netty version bump 85/40085/1
authorMilos Fabian <milfabia@cisco.com>
Thu, 9 Jun 2016 07:10:00 +0000 (09:10 +0200)
committerMilos Fabian <milfabia@cisco.com>
Thu, 9 Jun 2016 07:10:00 +0000 (09:10 +0200)
Fixed:
java.lang.UnsupportedOperationException: direct buffer
at io.netty.buffer.UnpooledUnsafeDirectByteBuf.array(UnpooledUnsafeDirectByteBuf.java:198)

Direct buffer do not have a backing byte array, use utility function
instead.

Change-Id: I5317255bbbca733181a7dcb477ee30449757f0e7
Signed-off-by: Milos Fabian <milfabia@cisco.com>
rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/CommonPathKeyParserTest.java

index a96e682f6c15f822802788475e5c2bbcf9110d3d..fc9a206aea84b3af7fb6d7eb5f668ff14bcab6d5 100644 (file)
@@ -9,10 +9,12 @@ package org.opendaylight.protocol.rsvp.parser.spi.subobjects;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
@@ -49,7 +51,7 @@ public class CommonPathKeyParserTest {
     @Test
     public void testSerialization() {
         final ByteBuf output = this.parser.serializePathKey(this.key3);
-        assertArrayEquals(this.bytes, output.readBytes(output.readableBytes()).array());
+        assertArrayEquals(this.bytes, ByteArray.readAllBytes(output));
     }
 
     @Test