Search in sources :

Example 6 with PacketContext

use of org.onosproject.net.packet.PacketContext in project onos by opennetworkinglab.

the class DhcpRelayManagerTest method testDhcp4DualHome.

@Test
public void testDhcp4DualHome() {
    PacketContext packetContext = new TestDhcpAckPacketContext(CLIENT_DH_CP, CLIENT_MAC, CLIENT_VLAN, INTERFACE_IP.ipAddress().getIp4Address(), false);
    reset(manager.hostService);
    expect(manager.hostService.getHost(CLIENT_HOST_ID)).andReturn(EXISTS_HOST).anyTimes();
    Capture<HostDescription> capturedHostDesc = newCapture();
    mockHostProviderService.hostDetected(eq(CLIENT_HOST_ID), capture(capturedHostDesc), eq(false));
    replay(mockHostProviderService, manager.hostService);
    packetService.processPacket(packetContext);
    assertAfter(PKT_PROCESSING_MS, () -> verify(mockHostProviderService));
    assertAfter(PKT_PROCESSING_MS, () -> assertTrue(capturedHostDesc.hasCaptured()));
    HostDescription hostDesc = capturedHostDesc.getValue();
    Set<HostLocation> hostLocations = hostDesc.locations();
    assertAfter(PKT_PROCESSING_MS, () -> assertEquals(2, hostLocations.size()));
    assertAfter(PKT_PROCESSING_MS, () -> assertTrue(hostLocations.contains(CLIENT_LOCATION)));
    assertAfter(PKT_PROCESSING_MS, () -> assertTrue(hostLocations.contains(CLIENT_DH_LOCATION)));
}
Also used : HostLocation(org.onosproject.net.HostLocation) PacketContext(org.onosproject.net.packet.PacketContext) HostDescription(org.onosproject.net.host.HostDescription) Test(org.junit.Test)

Example 7 with PacketContext

use of org.onosproject.net.packet.PacketContext in project onos by opennetworkinglab.

the class MQEventHandlerTest method knownPktCtx.

@Test
public void knownPktCtx() {
    deviceListener.event(deviceEvent(DEVICE_ADDED, DID1));
    deviceListener.event(deviceEvent(DEVICE_ADDED, DID2));
    PacketContext pktCtx = new TestPacketContext(deviceService.getDevice(DID2));
    /*
         * EasyMock.expectLastCall(); EasyMock.replay(manageSender);
         */
    testProcessor.process(pktCtx);
}
Also used : PacketContext(org.onosproject.net.packet.PacketContext) AbstractEventTest(org.onosproject.event.AbstractEventTest) Test(org.junit.Test)

Example 8 with PacketContext

use of org.onosproject.net.packet.PacketContext in project onos by opennetworkinglab.

the class MQEventHandlerTest method unknownPktCtx.

@Test
public void unknownPktCtx() {
    // Note: DID3 hasn't been added to TestDeviceService
    PacketContext pktCtx = new TestPacketContext(device1(DID3));
    testProcessor.process(pktCtx);
    assertFalse("Context should still be free", pktCtx.isHandled());
}
Also used : PacketContext(org.onosproject.net.packet.PacketContext) AbstractEventTest(org.onosproject.event.AbstractEventTest) Test(org.junit.Test)

Example 9 with PacketContext

use of org.onosproject.net.packet.PacketContext in project onos by opennetworkinglab.

the class LldpLinkProviderTest method unknownPktCtx.

@Test
public void unknownPktCtx() {
    // Note: DID3 hasn't been added to TestDeviceService
    PacketContext pktCtx = new TestPacketContext(device(DID3));
    testProcessor.process(pktCtx);
    assertFalse("Context should still be free", pktCtx.isHandled());
}
Also used : PacketContext(org.onosproject.net.packet.PacketContext) Test(org.junit.Test)

Example 10 with PacketContext

use of org.onosproject.net.packet.PacketContext in project onos by opennetworkinglab.

the class LldpLinkProviderTest method knownPktCtx.

@Test
public void knownPktCtx() {
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID2));
    PacketContext pktCtx = new TestPacketContext(deviceService.getDevice(DID2));
    testProcessor.process(pktCtx);
    assertTrue("Link not detected", detectedLink(DID1, DID2));
}
Also used : PacketContext(org.onosproject.net.packet.PacketContext) Test(org.junit.Test)

Aggregations

PacketContext (org.onosproject.net.packet.PacketContext)24 ByteBuffer (java.nio.ByteBuffer)11 Ethernet (org.onlab.packet.Ethernet)11 DeviceId (org.onosproject.net.DeviceId)11 Logger (org.slf4j.Logger)10 Set (java.util.Set)9 IpAddress (org.onlab.packet.IpAddress)9 DefaultOutboundPacket (org.onosproject.net.packet.DefaultOutboundPacket)9 MacAddress (org.onlab.packet.MacAddress)8 ApplicationId (org.onosproject.core.ApplicationId)8 ConnectPoint (org.onosproject.net.ConnectPoint)8 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)8 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)8 TrafficSelector (org.onosproject.net.flow.TrafficSelector)8 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)8 InboundPacket (org.onosproject.net.packet.InboundPacket)8 PacketService (org.onosproject.net.packet.PacketService)8 Executors.newSingleThreadExecutor (java.util.concurrent.Executors.newSingleThreadExecutor)7 Tools.groupedThreads (org.onlab.util.Tools.groupedThreads)7 CoreService (org.onosproject.core.CoreService)7