Search in sources :

Example 1 with RoleRequestInput

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

the class RoleRequestInputMessageFactory method deserialize.

@Override
public RoleRequestInput deserialize(ByteBuf rawMessage) {
    RoleRequestInputBuilder builder = new RoleRequestInputBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setRole(ControllerRole.forValue(rawMessage.readInt()));
    rawMessage.skipBytes(PADDING);
    byte[] generationId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(generationId);
    builder.setGenerationId(new BigInteger(1, generationId));
    return builder.build();
}
Also used : RoleRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder) BigInteger(java.math.BigInteger)

Example 2 with RoleRequestInput

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

the class RoleRequestInputMessageFactoryTest method testRoleRequestInputMessage.

/**
 * Testing of {@link RoleRequestInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testRoleRequestInputMessage() throws Exception {
    RoleRequestInputBuilder builder = new RoleRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setRole(ControllerRole.forValue(2));
    byte[] generationId = new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
    builder.setGenerationId(new BigInteger(1, generationId));
    RoleRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    roleFactory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
    Assert.assertEquals("Wrong role", message.getRole().getIntValue(), ControllerRole.forValue((int) out.readUnsignedInt()).getIntValue());
    out.skipBytes(PADDING_IN_ROLE_REQUEST_MESSAGE);
    byte[] genId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    out.readBytes(genId);
    Assert.assertEquals("Wrong generation ID", message.getGenerationId(), new BigInteger(1, genId));
}
Also used : RoleRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder) BigInteger(java.math.BigInteger) ByteBuf(io.netty.buffer.ByteBuf) RoleRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput) Test(org.junit.Test)

Example 3 with RoleRequestInput

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

the class RoleRequestInputMessageFactoryTest method test.

@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 02 00 00 00 00 ff 01 01 01 01 01 01 01");
    RoleRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(deserializedMessage);
    Assert.assertEquals("Wrong role", ControllerRole.forValue(2), deserializedMessage.getRole());
    byte[] generationId = new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
    Assert.assertEquals("Wrong generation Id", new BigInteger(1, generationId), deserializedMessage.getGenerationId());
}
Also used : BigInteger(java.math.BigInteger) ByteBuf(io.netty.buffer.ByteBuf) RoleRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput) Test(org.junit.Test)

Aggregations

BigInteger (java.math.BigInteger)3 ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 RoleRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput)2 RoleRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder)2