use of org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener in project controller by opendaylight.
the class AbstractInvokableServiceMetadata method retrievedDOMRpcService.
private void retrievedDOMRpcService(final Object service) {
log.debug("{}: retrievedDOMRpcService {}", logName(), service);
final DOMRpcService domRpcService = (DOMRpcService) service;
setDependencyDesc("Available DOM RPC for binding RPC: " + rpcInterface);
rpcListenerReg = domRpcService.registerRpcListener(new DOMRpcAvailabilityListener() {
@Override
public void onRpcAvailable(final Collection<DOMRpcIdentifier> rpcs) {
onRpcsAvailable(rpcs);
}
@Override
public void onRpcUnavailable(final Collection<DOMRpcIdentifier> rpcs) {
}
});
}
use of org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener in project mdsal by opendaylight.
the class ForwardingDOMRpcServiceTest method basicTest.
@Test
public void basicTest() throws Exception {
final DOMRpcAvailabilityListener domRpcAvailabilityListener = mock(DOMRpcAvailabilityListener.class);
final QName id = QName.create("urn:foo", "foo");
doReturn(null).when(domRpcService).invokeRpc(id, null);
this.invokeRpc(id, null);
verify(domRpcService).invokeRpc(id, null);
doReturn(null).when(domRpcService).registerRpcListener(domRpcAvailabilityListener);
this.registerRpcListener(domRpcAvailabilityListener);
verify(domRpcService).registerRpcListener(domRpcAvailabilityListener);
}
use of org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener in project mdsal by opendaylight.
the class DOMRpcRouterTest method testRpcListener.
@Test
public void testRpcListener() {
try (DOMRpcRouter rpcRouter = new DOMRpcRouter()) {
assertEquals(List.of(), rpcRouter.listeners());
final DOMRpcAvailabilityListener listener = mock(DOMRpcAvailabilityListener.class);
doCallRealMethod().when(listener).acceptsImplementation(any());
doNothing().when(listener).onRpcAvailable(any());
doNothing().when(listener).onRpcUnavailable(any());
final Registration reg = rpcRouter.getRpcService().registerRpcListener(listener);
assertNotNull(reg);
assertEquals(List.of(reg), rpcRouter.listeners());
final Registration implReg = rpcRouter.getRpcProviderService().registerRpcImplementation(getTestRpcImplementation(), DOMRpcIdentifier.create(Rpcs.FOO, null));
verify(listener, timeout(1000)).onRpcAvailable(any());
implReg.close();
verify(listener, timeout(1000)).onRpcUnavailable(any());
reg.close();
assertEquals(List.of(), rpcRouter.listeners());
}
}
Aggregations