Search in sources :

Example 36 with DeviceEvent

use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.

the class LldpLinkProviderTest method switchAdd.

@Test
public void switchAdd() {
    DeviceEvent de = deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1);
    deviceListener.event(de);
    assertFalse("Device not added", provider.discoverers.isEmpty());
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) Test(org.junit.Test)

Example 37 with DeviceEvent

use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.

the class NetworkConfigLinksProviderTest method testRemoveDevice.

/**
 * Tests removing a device via an event.
 */
@Test
public void testRemoveDevice() {
    assertThat(provider.discoverers.entrySet(), hasSize(2));
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, dev3));
    assertThat(provider.discoverers.entrySet(), hasSize(3));
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_REMOVED, dev3));
    assertThat(provider.discoverers.entrySet(), hasSize(2));
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) Test(org.junit.Test)

Example 38 with DeviceEvent

use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.

the class NetworkConfigLinksProviderTest method testAddPort.

/**
 * Tests adding a new port via an event.
 */
@Test
public void testAddPort() {
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.PORT_ADDED, dev3, new DefaultPort(dev3, portNumber3, true)));
    assertThat(provider.discoverers.entrySet(), hasSize(3));
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Example 39 with DeviceEvent

use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.

the class NetconfDeviceProviderTest method testDiscoverPortsAfterDeviceAdded.

@Test
public void testDiscoverPortsAfterDeviceAdded() {
    provider.connectionExecutor = MoreExecutors.newDirectExecutorService();
    prepareMocks(PORT_COUNT);
    deviceService.listener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, netconfDevice));
    assertEquals("Ports should be added", PORT_COUNT, providerService.ports.get(netconfDevice.id()).size());
    provider.triggerDisconnect(netconfDevice.id());
    assertEquals("Ports should be removed", 0, providerService.ports.get(netconfDevice.id()).size());
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) Test(org.junit.Test)

Example 40 with DeviceEvent

use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.

the class HostLocationProviderTest method removeHostByDevicePortDown.

@Test
public void removeHostByDevicePortDown() {
    provider.modified(CTX_FOR_REMOVE);
    testProcessor.process(new TestArpPacketContext(DEV1));
    testProcessor.process(new TestArpPacketContext(DEV4));
    Device device = new DefaultDevice(ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
    assertEquals("incorrect remove count", 1, providerService.locationRemoveCount);
    device = new DefaultDevice(ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
    assertEquals("incorrect remove count", 2, providerService.locationRemoveCount);
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) ChassisId(org.onlab.packet.ChassisId) DefaultDevice(org.onosproject.net.DefaultDevice) Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Aggregations

DeviceEvent (org.onosproject.net.device.DeviceEvent)77 Test (org.junit.Test)42 Device (org.onosproject.net.Device)26 DefaultDevice (org.onosproject.net.DefaultDevice)17 DefaultPort (org.onosproject.net.DefaultPort)17 PortDescription (org.onosproject.net.device.PortDescription)14 PortNumber (org.onosproject.net.PortNumber)11 Port (org.onosproject.net.Port)10 DefaultPortDescription (org.onosproject.net.device.DefaultPortDescription)10 ProviderId (org.onosproject.net.provider.ProviderId)10 ArrayList (java.util.ArrayList)8 ConnectPoint (org.onosproject.net.ConnectPoint)8 Timestamp (org.onosproject.store.Timestamp)8 MessageSubject (org.onosproject.store.cluster.messaging.MessageSubject)8 MastershipBasedTimestamp (org.onosproject.store.impl.MastershipBasedTimestamp)8 MultiValuedTimestamp (org.onosproject.store.service.MultiValuedTimestamp)8 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)8 BiFunction (java.util.function.BiFunction)7 Function (java.util.function.Function)7 DeviceDescription (org.onosproject.net.device.DeviceDescription)7