use of org.onosproject.config.DynamicConfigEvent in project onos by opennetworkinglab.
the class DynamicDeviceConfigServiceViewTest method testListener.
// FIXME add test scenario where irrelevant event get discarded.
@Test
public void testListener() throws CloneNotSupportedException, InterruptedException {
ResourceId realIntf = ResourceId.builder().append(rid).addBranchPointSchema("intf", "test").build();
final CountDownLatch received = new CountDownLatch(1);
DynamicConfigListener lsnr = new DynamicConfigListener() {
@Override
public boolean isRelevant(DynamicConfigEvent event) {
viewRelevantEvent = event;
return true;
}
@Override
public void event(DynamicConfigEvent event) {
viewEvent = event;
received.countDown();
}
};
view.addListener(lsnr);
service.post(new DynamicConfigEvent(Type.NODE_ADDED, realIntf));
assertTrue(received.await(5, TimeUnit.SECONDS));
assertFalse("Expect relative path but was" + viewRelevantEvent.subject(), ResourceIds.isPrefix(rid, viewRelevantEvent.subject()));
assertFalse("Expect relative path but was" + viewEvent.subject(), ResourceIds.isPrefix(rid, viewEvent.subject()));
view.removeListener(lsnr);
}
Aggregations