Search in sources :

Example 1 with SendToController

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController in project openflowplugin by opendaylight.

the class PacketReceivedTranslatorTest method testTranslate.

@Test
public void testTranslate() throws Exception {
    final KeyedInstanceIdentifier<Node, NodeKey> nodePath = KeyedInstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:10")));
    final PacketReceivedTranslator packetReceivedTranslator = new PacketReceivedTranslator(convertorManager);
    final PacketInMessage packetInMessage = createPacketInMessage(DATA.getBytes(), PORT_NO);
    Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
    final PacketReceived packetReceived = packetReceivedTranslator.translate(packetInMessage, deviceInfo, null);
    Assert.assertArrayEquals(packetInMessage.getData(), packetReceived.getPayload());
    Assert.assertEquals("org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController", packetReceived.getPacketInReason().getName());
    Assert.assertEquals("openflow:10:" + PORT_NO, packetReceived.getIngress().getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue());
    Assert.assertEquals(0L, packetReceived.getFlowCookie().getValue().longValue());
    Assert.assertEquals(42L, packetReceived.getTableId().getValue().longValue());
}
Also used : NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) PacketInMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)1 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)1 NodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector)1 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)1 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)1 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)1 PacketInMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage)1 PacketReceived (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived)1