Search in sources :

Example 6 with MultipartRequestInputBuilder

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

the class OF10StatsRequestInputFactoryTest method testPort.

/**
 * Testing OF10StatsRequestInputFactory (Port) for correct serialization.
 */
@Test
public void testPort() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setType(MultipartType.OFPMPPORTSTATS);
    builder.setFlags(new MultipartRequestFlags(false));
    MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder();
    MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder();
    portBuilder.setPortNo(15L);
    caseBuilder.setMultipartRequestPortStats(portBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    multipartFactory.serialize(message, out);
    BufferHelper.checkHeaderV10(out, (byte) 16, 20);
    Assert.assertEquals("Wrong type", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
    Assert.assertEquals("Wrong port-no", 15, out.readUnsignedShort());
    out.skipBytes(6);
    Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestPortStatsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) MultipartRequestPortStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 7 with MultipartRequestInputBuilder

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

the class OF10StatsRequestInputFactoryTest method testDesc.

/**
 * Testing OF10StatsRequestInputFactory (Desc) for correct serialization.
 */
@Test
public void testDesc() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setType(MultipartType.OFPMPDESC);
    builder.setFlags(new MultipartRequestFlags(false));
    MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder();
    MultipartRequestDescBuilder descBuilder = new MultipartRequestDescBuilder();
    caseBuilder.setMultipartRequestDesc(descBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    multipartFactory.serialize(message, out);
    BufferHelper.checkHeaderV10(out, (byte) 16, 12);
    Assert.assertEquals("Wrong type", 0, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
    Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartRequestDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder) ByteBuf(io.netty.buffer.ByteBuf) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 8 with MultipartRequestInputBuilder

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

the class OF10StatsRequestInputFactoryTest method testTable.

/**
 * Testing OF10StatsRequestInputFactory (Table) for correct serialization.
 */
@Test
public void testTable() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setType(MultipartType.OFPMPTABLE);
    builder.setFlags(new MultipartRequestFlags(false));
    MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder();
    MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder();
    caseBuilder.setMultipartRequestTable(tableBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    multipartFactory.serialize(message, out);
    BufferHelper.checkHeaderV10(out, (byte) 16, 12);
    Assert.assertEquals("Wrong type", 3, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
    Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartRequestTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder) ByteBuf(io.netty.buffer.ByteBuf) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 9 with MultipartRequestInputBuilder

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

the class MultipartRequestPortDescTest method test.

/**
 * Tests {@link MultipartRequestInputFactory} - PortDesc case.
 */
@Test
public void test() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setType(MultipartType.OFPMPPORTDESC);
    builder.setFlags(new MultipartRequestFlags(false));
    MultipartRequestPortDescCaseBuilder caseBuilder = new MultipartRequestPortDescCaseBuilder();
    MultipartRequestPortDescBuilder descBuilder = new MultipartRequestPortDescBuilder();
    descBuilder.setEmpty(true);
    caseBuilder.setMultipartRequestPortDesc(descBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    multipartFactory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, (byte) 18, 16);
    Assert.assertEquals("Wrong type", 13, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
    // skip padding
    out.skipBytes(4);
    Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestPortDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.desc._case.MultipartRequestPortDescBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartRequestPortDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 10 with MultipartRequestInputBuilder

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

the class MultipartRequestTableTest method test.

/**
 * Tests {@link MultipartRequestInputFactory} - Table case.
 */
@Test
public void test() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setType(MultipartType.OFPMPTABLE);
    builder.setFlags(new MultipartRequestFlags(false));
    MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder();
    MultipartRequestTableBuilder tablesBuilder = new MultipartRequestTableBuilder();
    tablesBuilder.setEmpty(true);
    caseBuilder.setMultipartRequestTable(tablesBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    multipartFactory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, (byte) 18, 16);
    Assert.assertEquals("Wrong type", 3, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
    // skip padding
    out.skipBytes(4);
    Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartRequestTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder) ByteBuf(io.netty.buffer.ByteBuf) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Aggregations

MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)45 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)26 ByteBuf (io.netty.buffer.ByteBuf)25 Test (org.junit.Test)25 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)25 MultipartRequestFlowCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder)4 MultipartRequestFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)3 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)3 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)3 MultipartRequestTableCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder)3 MultipartRequestTableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder)3 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 MultipartRequestInputFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory)2 MultipartRequestInputFactoryTest (org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest)2 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)2 TableConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig)2 MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)2 MultipartRequestAggregateCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder)2