1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
2 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
4 import io.netty.buffer.ByteBuf;
5 import io.netty.buffer.UnpooledByteBufAllocator;
6 import junit.framework.Assert;
8 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
9 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder;
16 * @author timotej.kubas
17 * @author michal.polkorab
19 public class TableModInputMessageFactoryTest {
21 private static final byte MESSAGE_TYPE = 17;
22 private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;
25 public void testTableModInput() throws Exception {
26 TableModInputBuilder builder = new TableModInputBuilder();
27 BufferHelper.setupHeader(builder);
28 builder.setTableId(new TableId(9L));
29 builder.setConfig(new PortConfig(true, false, true, false));
30 TableModInput message = builder.build();
32 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
33 TableModInputMessageFactory factory = TableModInputMessageFactory.getInstance();
34 factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
36 BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16);
37 Assert.assertEquals("Wrong TableID", 0x09, out.readByte());
38 out.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE);
39 Assert.assertEquals("Wrong PortConfig", 33, out.readInt());