Search in sources :

Example 6 with MultipartReplyPortDesc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDesc in project openflowplugin by opendaylight.

the class MultipartReplyPortDescDeserializerTest method deserialize.

@Test
public void deserialize() throws Exception {
    ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    buffer.writeInt(PORT_NUMBER);
    buffer.writeZero(PADDING_IN_PORT_DESC_HEADER_01);
    buffer.writeBytes(MAC_ADDRESS);
    buffer.writeZero(PADDING_IN_PORT_DESC_HEADER_02);
    buffer.writeZero(EncodeConstants.MAX_PORT_NAME_LENGTH);
    Map<Integer, Boolean> portMap = new HashMap<>();
    portMap.put(0, PORT_CONFIG.isPORTDOWN());
    portMap.put(2, PORT_CONFIG.isNORECV());
    portMap.put(5, PORT_CONFIG.isNOFWD());
    portMap.put(6, PORT_CONFIG.isNOPACKETIN());
    buffer.writeInt(ByteBufUtils.fillBitMaskFromMap(portMap));
    buffer.writeInt(ByteBufUtils.fillBitMask(0, PS_BLOCKED, PS_LINK_DOWN, PS_LIVE));
    buffer.writeInt(ByteBufUtils.fillBitMask(0, CURRENT_FEATURE.isTenMbHd(), CURRENT_FEATURE.isTenMbFd(), CURRENT_FEATURE.isHundredMbHd(), CURRENT_FEATURE.isHundredMbFd(), CURRENT_FEATURE.isOneGbHd(), CURRENT_FEATURE.isOneGbFd(), CURRENT_FEATURE.isTenGbFd(), CURRENT_FEATURE.isFortyGbFd(), CURRENT_FEATURE.isHundredGbFd(), CURRENT_FEATURE.isOneTbFd(), CURRENT_FEATURE.isOther(), CURRENT_FEATURE.isFiber(), CURRENT_FEATURE.isAutoeng(), CURRENT_FEATURE.isCopper(), CURRENT_FEATURE.isPause(), CURRENT_FEATURE.isPauseAsym()));
    buffer.writeInt(ADVERTISED_FEATURE);
    buffer.writeInt(SUPPORTED_FEATURE);
    buffer.writeInt(PEER_FEATURES);
    buffer.writeInt(CURRENT_SPEED);
    buffer.writeInt(MAXIMUM_SPEED);
    final MultipartReplyPortDesc reply = (MultipartReplyPortDesc) deserializeMultipart(buffer);
    assertEquals(PORT_NUMBER, reply.getPorts().get(0).getPortNumber().getUint32().intValue());
    assertEquals("01:02:03:04:05:06", reply.getPorts().get(0).getHardwareAddress().getValue());
    assertEquals(PORT_CONFIG, reply.getPorts().get(0).getConfiguration());
    assertEquals(PS_BLOCKED, reply.getPorts().get(0).getState().isBlocked());
    assertEquals(PS_LINK_DOWN, reply.getPorts().get(0).getState().isLinkDown());
    assertEquals(PS_LIVE, reply.getPorts().get(0).getState().isLive());
    assertEquals(CURRENT_FEATURE, reply.getPorts().get(0).getCurrentFeature());
    assertEquals(CURRENT_SPEED, reply.getPorts().get(0).getCurrentSpeed().intValue());
    assertEquals(MAXIMUM_SPEED, reply.getPorts().get(0).getMaximumSpeed().intValue());
}
Also used : HashMap(java.util.HashMap) MultipartReplyPortDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDesc) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)4 MultipartReplyPortDescCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase)4 MultipartReplyPortDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc)4 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)3 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports)3 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)2 HashMap (java.util.HashMap)1 FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)1 FlowCapableNodeConnectorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder)1 MultipartReplyPortDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDesc)1 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)1 NodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector)1 NodeConnectorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder)1 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)1 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)1 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)1 PortFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures)1 PortState (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState)1 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)1