2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.UnpooledByteBufAllocator;
14 import org.junit.Assert;
15 import org.junit.Test;
16 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
17 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;
22 * @author michal.polkorab
25 public class OF10VendorInputMessageFactoryTest {
28 * Testing of {@link OF10VendorInputMessageFactory} for correct translation from POJO
32 public void test() throws Exception {
33 ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
34 BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
35 builder.setExperimenter(0x0001020304L);
36 builder.setData(new byte[] {0x01, 0x02, 0x03, 0x04});
37 ExperimenterInput message = builder.build();
39 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
40 OF10VendorInputMessageFactory factory = OF10VendorInputMessageFactory.getInstance();
41 factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);
43 BufferHelper.checkHeaderV10(out, (byte) 4, factory.computeLength(message));
44 Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt());
45 byte[] data = new byte[4];
47 Assert.assertArrayEquals("Wrong data", message.getData(), data);