Search in sources :

Example 1 with MultipartReplyDescBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder in project openflowplugin by opendaylight.

the class OF13DeviceInitializerTest method initializeSingleLayer.

@Test
public void initializeSingleLayer() throws Exception {
    when(deviceContext.canUseSingleLayerSerialization()).thenReturn(true);
    when(requestContext.getFuture()).thenReturn(RpcResultBuilder.success(Collections.singletonList(new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyDescBuilder().build()).build())).buildFuture());
    final Future<Void> initialize = deviceInitializer.initialize(deviceContext, true, false, multipartWriterProvider, convertorExecutor);
    initialize.get();
    verify(messageSpy, times(5)).spyMessage(eq(MultipartType.class), any());
    verify(requestContext, times(5)).getFuture();
    verify(featuresReply).getCapabilities();
    verify(deviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
}
Also used : MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder) MultipartReplyDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder) Test(org.junit.Test)

Example 2 with MultipartReplyDescBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method setDesc.

private static MultipartReplyDescCase setDesc(final ByteBuf input) {
    final MultipartReplyDescCaseBuilder caseBuilder = new MultipartReplyDescCaseBuilder();
    MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder();
    byte[] mfrDescBytes = new byte[DESC_STR_LEN];
    input.readBytes(mfrDescBytes);
    String mfrDesc = new String(mfrDescBytes, StandardCharsets.UTF_8);
    descBuilder.setMfrDesc(mfrDesc.trim());
    byte[] hwDescBytes = new byte[DESC_STR_LEN];
    input.readBytes(hwDescBytes);
    String hwDesc = new String(hwDescBytes, StandardCharsets.UTF_8);
    descBuilder.setHwDesc(hwDesc.trim());
    byte[] swDescBytes = new byte[DESC_STR_LEN];
    input.readBytes(swDescBytes);
    String swDesc = new String(swDescBytes, StandardCharsets.UTF_8);
    descBuilder.setSwDesc(swDesc.trim());
    byte[] serialNumBytes = new byte[SERIAL_NUM_LEN];
    input.readBytes(serialNumBytes);
    String serialNum = new String(serialNumBytes, StandardCharsets.UTF_8);
    descBuilder.setSerialNum(serialNum.trim());
    byte[] dpDescBytes = new byte[DESC_STR_LEN];
    input.readBytes(dpDescBytes);
    String dpDesc = new String(dpDescBytes, StandardCharsets.UTF_8);
    descBuilder.setDpDesc(dpDesc.trim());
    caseBuilder.setMultipartReplyDesc(descBuilder.build());
    return caseBuilder.build();
}
Also used : MultipartReplyDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder) MultipartReplyDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder)

Example 3 with MultipartReplyDescBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method decodeDescBody.

private static MultipartReplyDescCase decodeDescBody(ByteBuf output) {
    final MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder();
    MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder();
    byte[] mfrDesc = new byte[256];
    output.readBytes(mfrDesc);
    desc.setMfrDesc(new String(mfrDesc).trim());
    byte[] hwDesc = new byte[256];
    output.readBytes(hwDesc);
    desc.setHwDesc(new String(hwDesc).trim());
    byte[] swDesc = new byte[256];
    output.readBytes(swDesc);
    desc.setSwDesc(new String(swDesc).trim());
    byte[] serialNumber = new byte[32];
    output.readBytes(serialNumber);
    desc.setSerialNum(new String(serialNumber).trim());
    byte[] dpDesc = new byte[256];
    output.readBytes(dpDesc);
    desc.setDpDesc(new String(dpDesc).trim());
    descCase.setMultipartReplyDesc(desc.build());
    return descCase.build();
}
Also used : MultipartReplyDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder) MultipartReplyDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder)

Example 4 with MultipartReplyDescBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testDescSerialize.

@Test
public void testDescSerialize() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(0));
    final MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder();
    MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder();
    desc.setMfrDesc("Test");
    desc.setHwDesc("Test");
    desc.setSwDesc("Test");
    desc.setSerialNum("12345");
    desc.setDpDesc("Test");
    descCase.setMultipartReplyDesc(desc.build());
    builder.setMultipartReplyBody(descCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 1072);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPDESC.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    Assert.assertEquals("Wrong desc body", message.getMultipartReplyBody(), decodeDescBody(serializedBuffer));
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartReplyDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder) Test(org.junit.Test)

Example 5 with MultipartReplyDescBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactoryTest method decodeDescBody.

private static MultipartReplyDescCase decodeDescBody(ByteBuf output) {
    final MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder();
    MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder();
    byte[] mfrDesc = new byte[256];
    output.readBytes(mfrDesc);
    desc.setMfrDesc(new String(mfrDesc).trim());
    byte[] hwDesc = new byte[256];
    output.readBytes(hwDesc);
    desc.setHwDesc(new String(hwDesc).trim());
    byte[] swDesc = new byte[256];
    output.readBytes(swDesc);
    desc.setSwDesc(new String(swDesc).trim());
    byte[] serialNumber = new byte[32];
    output.readBytes(serialNumber);
    desc.setSerialNum(new String(serialNumber).trim());
    byte[] dpDesc = new byte[256];
    output.readBytes(dpDesc);
    desc.setDpDesc(new String(dpDesc).trim());
    descCase.setMultipartReplyDesc(desc.build());
    return descCase.build();
}
Also used : MultipartReplyDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder) MultipartReplyDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder)

Aggregations

MultipartReplyDescCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder)8 MultipartReplyDescBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder)8 Test (org.junit.Test)4 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)3 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)3 ByteBuf (io.netty.buffer.ByteBuf)2 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)2 MultipartReplyDescBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder)1 MultipartReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder)1 MultipartType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType)1 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)1 MultipartReplyDescCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase)1 MultipartReplyDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc)1