Search in sources :

Example 1 with DynamicConfigListener

use of org.onosproject.config.DynamicConfigListener 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);
}
Also used : ResourceId(org.onosproject.yang.model.ResourceId) DynamicConfigEvent(org.onosproject.config.DynamicConfigEvent) DynamicConfigListener(org.onosproject.config.DynamicConfigListener) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1 DynamicConfigEvent (org.onosproject.config.DynamicConfigEvent)1 DynamicConfigListener (org.onosproject.config.DynamicConfigListener)1 ResourceId (org.onosproject.yang.model.ResourceId)1