GetAsyncReplyMessageFactory, QueueGetConfigReplyMessageFactoryTest
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / TableModInputMessageFactoryTest.java
1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
2 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
3
4 import io.netty.buffer.ByteBuf;
5 import io.netty.buffer.UnpooledByteBufAllocator;
6 import junit.framework.Assert;
7 import org.junit.Test;
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;
14
15 /**
16  * @author timotej.kubas
17  * @author michal.polkorab
18  */
19 public class TableModInputMessageFactoryTest {
20     
21     private static final byte MESSAGE_TYPE = 17;
22     private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;
23     
24     @Test
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();
31         
32         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
33         TableModInputMessageFactory factory = TableModInputMessageFactory.getInstance();
34         factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
35         
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());
40     }
41 }