use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.
the class DefaultTopologyProviderTest method eventDriven.
@Test
public void eventDriven() throws InterruptedException, TimeoutException {
assertEquals(1, topologyChangedCounts.awaitAdvanceInterruptibly(0, 1, TimeUnit.SECONDS));
validateSubmission();
deviceService.postEvent(new DeviceEvent(DEVICE_ADDED, device("z"), null));
linkService.postEvent(new LinkEvent(LINK_ADDED, link("z", 1, "a", 4)));
assertThat(topologyChangedCounts.awaitAdvanceInterruptibly(1, 1, TimeUnit.SECONDS), is(greaterThanOrEqualTo(2)));
// Note: posting event, to trigger topologyChanged call,
// but dummy topology will not change.
validateSubmission();
}
use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.
the class NetworkConfigLinksProviderTest method testDeviceAvailabilityChanged.
/**
* Tests changing device availability via an event.
*/
@Test
public void testDeviceAvailabilityChanged() {
assertThat(providerService.vanishedDpid(), hasSize(0));
deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, dev3));
assertThat(providerService.vanishedDpid(), hasSize(0));
deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED, dev3));
assertThat(providerService.vanishedDpid(), hasSize(1));
}
use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.
the class NetworkConfigLinksProviderTest method testAddDevice.
/**
* Tests adding a new device via an event.
*/
@Test
public void testAddDevice() {
deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, dev3));
assertThat(provider.discoverers.entrySet(), hasSize(3));
}
use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.
the class NetworkConfigLinksProviderTest method testRemovePort.
/**
* Tests removing a port via an event.
*/
@Test
public void testRemovePort() {
assertThat(provider.discoverers.entrySet(), hasSize(2));
deviceListener.event(new DeviceEvent(DeviceEvent.Type.PORT_ADDED, dev3, new DefaultPort(dev3, portNumber3, true)));
assertThat(provider.discoverers.entrySet(), hasSize(3));
deviceListener.event(new DeviceEvent(DeviceEvent.Type.PORT_REMOVED, 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 SimpleDeviceStoreTest method testCreateOrUpdateDevice.
@Test
public final void testCreateOrUpdateDevice() {
DeviceDescription description = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW1, SN, CID);
DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description);
assertEquals(DEVICE_ADDED, event.type());
assertDevice(DID1, SW1, event.subject());
DeviceDescription description2 = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW2, SN, CID);
DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2);
assertEquals(DEVICE_UPDATED, event2.type());
assertDevice(DID1, SW2, event2.subject());
assertNull("No change expected", deviceStore.createOrUpdateDevice(PID, DID1, description2));
}
Aggregations