Search in sources :

Example 1 with TableModInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput in project openflowplugin by opendaylight.

the class TableModInputMessageFactoryTest method testTableModInput.

/**
 * Testing of {@link TableModInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testTableModInput() throws Exception {
    TableModInputBuilder builder = new TableModInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setTableId(new TableId(9L));
    builder.setConfig(new TableConfig(true));
    TableModInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    tableModFactory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16);
    Assert.assertEquals("Wrong TableID", message.getTableId().getValue().intValue(), out.readUnsignedByte());
    out.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE);
    Assert.assertEquals("Wrong TableConfig", 8, out.readUnsignedInt());
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId) TableModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig) ByteBuf(io.netty.buffer.ByteBuf) TableModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder) Test(org.junit.Test)

Example 2 with TableModInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput in project openflowplugin by opendaylight.

the class TableModInputMessageFactory method deserialize.

@Override
public TableModInput deserialize(ByteBuf rawMessage) {
    TableModInputBuilder builder = new TableModInputBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setTableId(new TableId((long) rawMessage.readUnsignedByte()));
    rawMessage.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE);
    builder.setConfig(createTableConfig(rawMessage.readUnsignedInt()));
    return builder.build();
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId) TableModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder)

Example 3 with TableModInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput in project openflowplugin by opendaylight.

the class TableModInputMessageFactoryTest method test.

@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("09 00 00 00 00 00 00 01");
    TableModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(deserializedMessage);
    // Test Message
    Assert.assertEquals("Wrong table id ", new TableId(9L), deserializedMessage.getTableId());
    Assert.assertEquals("Wrong config ", new TableConfig(true), deserializedMessage.getConfig());
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId) TableModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId)3 ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 TableConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig)2 TableModInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput)2 TableModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder)2