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());
}
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));
}
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));
}
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());
}
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);
}
Aggregations