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.util.BufferHelper;
\r
10 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
\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 OF10VendorInputMessageFactoryTest {
\r
21 * Testing of {@link OF10VendorInputMessageFactory} for correct translation from POJO
\r
22 * @throws Exception
\r
25 public void test() throws Exception {
\r
26 ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
\r
27 BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
\r
28 builder.setExperimenter(0x0001020304L);
\r
29 builder.setData(new byte[] {0x01, 0x02, 0x03, 0x04});
\r
30 ExperimenterInput message = builder.build();
\r
32 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
33 OF10VendorInputMessageFactory factory = OF10VendorInputMessageFactory.getInstance();
\r
34 factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);
\r
36 BufferHelper.checkHeaderV10(out, (byte) 4, factory.computeLength(message));
\r
37 Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt());
\r
38 byte[] data = new byte[4];
\r
39 out.readBytes(data);
\r
40 Assert.assertArrayEquals("Wrong data", message.getData(), data);
\r