use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestDescMessageFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestDescMessageFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(0));
builder.setFlags(new MultipartRequestFlags(true));
builder.setMultipartRequestBody(createRequestDesc());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 16);
Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedShort());
Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestFlowInputFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestFlowInputFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(1));
builder.setFlags(new MultipartRequestFlags(true));
builder.setMultipartRequestBody(createRequestFlow());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 48);
Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
Assert.assertEquals("Wrong flow", message.getMultipartRequestBody(), decodeRequestFlow(out));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags 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);
}
Aggregations