1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
\r
2 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
\r
4 import io.netty.buffer.ByteBuf;
\r
5 import io.netty.buffer.UnpooledByteBufAllocator;
\r
7 import org.junit.Assert;
\r
8 import org.junit.Test;
\r
9 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
\r
10 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
\r
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
\r
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;
\r
15 * @author michal.polkorab
\r
18 public class ExperimenterInputMessageFactoryTest {
\r
20 private static final byte EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE = ExperimenterInputMessageFactory.MESSAGE_TYPE;
\r
23 * Testing of {@link ExperimenterInputMessageFactory} for correct translation from POJO
\r
24 * @throws Exception
\r
27 public void test() throws Exception {
\r
28 ExperimenterInputBuilder eib = new ExperimenterInputBuilder();
\r
29 BufferHelper.setupHeader(eib);
\r
30 eib.setExperimenter(0x0001020304L);
\r
31 eib.setExpType(0x0001020304L);
\r
32 ExperimenterInput ei = eib.build();
\r
34 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
35 ExperimenterInputMessageFactory eimf = ExperimenterInputMessageFactory.getInstance();
\r
36 eimf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, ei);
\r
38 BufferHelper.checkHeaderV13(out, EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE, 16);
\r
39 Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt());
\r
40 Assert.assertEquals("Wrong expType", 0x0001020304L, out.readUnsignedInt());
\r