Merge "Added more (de)serialization factories + ByteBufUtils methods"
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / BarrierInputMessageFactoryTest.java
index b65beb215627983103599f75f7a95a854d8d3e5b..37b6d6761f90cd14aba443946310e4d433c5cbc7 100644 (file)
@@ -4,10 +4,9 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
 import io.netty.buffer.ByteBuf;\r
 import io.netty.buffer.UnpooledByteBufAllocator;\r
 \r
-import org.junit.Assert;\r
 import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;\r
 \r
@@ -21,22 +20,19 @@ public class BarrierInputMessageFactoryTest {
     \r
     /**\r
      * Testing of {@link BarrierInputMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
      */\r
     @Test\r
-    public void test() {\r
+    public void test() throws Exception {\r
         BarrierInputBuilder bib = new BarrierInputBuilder();\r
-        bib.setVersion(HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
-        bib.setXid(16909060L);\r
+        BufferHelper.setupHeader(bib);\r
         BarrierInput bi = bib.build();\r
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
         BarrierInputMessageFactory bimf = BarrierInputMessageFactory.getInstance();\r
         bimf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, bi);\r
         \r
-        Assert.assertTrue(out.readByte() == HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
-        Assert.assertTrue(out.readByte() == BARRIER_REQUEST_MESSAGE_CODE_TYPE);\r
-        Assert.assertTrue(out.readUnsignedShort() == OFFrameDecoder.LENGTH_OF_HEADER);\r
-        Assert.assertTrue(out.readUnsignedInt() == 16909060L);\r
+        BufferHelper.checkHeaderV13(out, BARRIER_REQUEST_MESSAGE_CODE_TYPE, 8);\r
     }\r
 \r
 }\r