use of org.onosproject.net.device.DeviceStoreDelegate in project onos by opennetworkinglab.
the class GossipDeviceStoreTest method testEvents.
// If Delegates should be called only on remote events,
// then Simple* should never call them, thus not test required.
// TODO add test for Port events when we have them
@Ignore("Ignore until Delegate spec. is clear.")
@Test
public final void testEvents() throws InterruptedException {
final CountDownLatch addLatch = new CountDownLatch(1);
DeviceStoreDelegate checkAdd = event -> {
assertEquals(DEVICE_ADDED, event.type());
assertDevice(DID1, SW1, event.subject());
addLatch.countDown();
};
final CountDownLatch updateLatch = new CountDownLatch(1);
DeviceStoreDelegate checkUpdate = event -> {
assertEquals(DEVICE_UPDATED, event.type());
assertDevice(DID1, SW2, event.subject());
updateLatch.countDown();
};
final CountDownLatch removeLatch = new CountDownLatch(1);
DeviceStoreDelegate checkRemove = event -> {
assertEquals(DEVICE_REMOVED, event.type());
assertDevice(DID1, SW2, event.subject());
removeLatch.countDown();
};
DeviceDescription description = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW1, SN, CID);
deviceStore.setDelegate(checkAdd);
deviceStore.createOrUpdateDevice(PID, DID1, description);
assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS));
DeviceDescription description2 = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW2, SN, CID);
deviceStore.unsetDelegate(checkAdd);
deviceStore.setDelegate(checkUpdate);
deviceStore.createOrUpdateDevice(PID, DID1, description2);
assertTrue("Update event fired", updateLatch.await(1, TimeUnit.SECONDS));
deviceStore.unsetDelegate(checkUpdate);
deviceStore.setDelegate(checkRemove);
deviceStore.removeDevice(DID1);
assertTrue("Remove event fired", removeLatch.await(1, TimeUnit.SECONDS));
}
use of org.onosproject.net.device.DeviceStoreDelegate in project onos by opennetworkinglab.
the class SimpleDeviceStoreTest method testEvents.
// If Delegates should be called only on remote events,
// then Simple* should never call them, thus not test required.
// TODO add test for Port events when we have them
@Ignore("Ignore until Delegate spec. is clear.")
@Test
public final void testEvents() throws InterruptedException {
final CountDownLatch addLatch = new CountDownLatch(1);
DeviceStoreDelegate checkAdd = event -> {
assertEquals(DEVICE_ADDED, event.type());
assertDevice(DID1, SW1, event.subject());
addLatch.countDown();
};
final CountDownLatch updateLatch = new CountDownLatch(1);
DeviceStoreDelegate checkUpdate = event -> {
assertEquals(DEVICE_UPDATED, event.type());
assertDevice(DID1, SW2, event.subject());
updateLatch.countDown();
};
final CountDownLatch removeLatch = new CountDownLatch(1);
DeviceStoreDelegate checkRemove = event -> {
assertEquals(DEVICE_REMOVED, event.type());
assertDevice(DID1, SW2, event.subject());
removeLatch.countDown();
};
DeviceDescription description = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW1, SN, CID);
deviceStore.setDelegate(checkAdd);
deviceStore.createOrUpdateDevice(PID, DID1, description);
assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS));
DeviceDescription description2 = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW2, SN, CID);
deviceStore.unsetDelegate(checkAdd);
deviceStore.setDelegate(checkUpdate);
deviceStore.createOrUpdateDevice(PID, DID1, description2);
assertTrue("Update event fired", updateLatch.await(1, TimeUnit.SECONDS));
deviceStore.unsetDelegate(checkUpdate);
deviceStore.setDelegate(checkRemove);
deviceStore.removeDevice(DID1);
assertTrue("Remove event fired", removeLatch.await(1, TimeUnit.SECONDS));
}
Aggregations