use of org.opendaylight.controller.messagebus.spi.EventSource in project controller by opendaylight.
the class EventSourceTopologyTest method unregisterTest.
@Test
public void unregisterTest() throws Exception {
topicTestHelper();
EventSource eventSourceMock = mock(EventSource.class);
NodeId nodeId = new NodeId("nodeIdValue1");
nodeKey = new NodeKey(nodeId);
Map<NodeKey, BindingAwareBroker.RoutedRpcRegistration<EventSourceService>> localMap = getRoutedRpcRegistrations();
NodeKey nodeKeyMock = mock(NodeKey.class);
doReturn(nodeKeyMock).when(eventSourceMock).getSourceNodeKey();
BindingAwareBroker.RoutedRpcRegistration<EventSourceService> routedRpcRegistrationMock = mock(BindingAwareBroker.RoutedRpcRegistration.class);
localMap.put(nodeKeyMock, routedRpcRegistrationMock);
eventSourceTopology.unRegister(eventSourceMock);
verify(routedRpcRegistrationMock, times(1)).close();
}
use of org.opendaylight.controller.messagebus.spi.EventSource in project controller by opendaylight.
the class EventSourceTopologyTest method registerTest.
@Test
public void registerTest() throws Exception {
topicTestHelper();
Node nodeMock = mock(Node.class);
EventSource eventSourceMock = mock(EventSource.class);
NodeId nodeId = new NodeId("nodeIdValue1");
nodeKey = new NodeKey(nodeId);
doReturn(nodeKey).when(nodeMock).getKey();
doReturn(nodeKey).when(eventSourceMock).getSourceNodeKey();
BindingAwareBroker.RoutedRpcRegistration routedRpcRegistrationMock = mock(BindingAwareBroker.RoutedRpcRegistration.class);
doReturn(routedRpcRegistrationMock).when(rpcProviderRegistryMock).addRoutedRpcImplementation(EventSourceService.class, eventSourceMock);
doNothing().when(routedRpcRegistrationMock).registerPath(eq(NodeContext.class), any(KeyedInstanceIdentifier.class));
eventSourceTopology.register(eventSourceMock);
verify(routedRpcRegistrationMock, times(1)).registerPath(eq(NodeContext.class), any(KeyedInstanceIdentifier.class));
}
use of org.opendaylight.controller.messagebus.spi.EventSource in project controller by opendaylight.
the class MessageBusAppImplModule method createInstance.
@Override
public java.lang.AutoCloseable createInstance() {
final WaitingServiceTracker<EventSourceRegistry> tracker = WaitingServiceTracker.create(EventSourceRegistry.class, bundleContext);
final EventSourceRegistry service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
return new EventSourceRegistry() {
@Override
public void close() {
// We need to close the WaitingServiceTracker however we don't want to close the actual
// service instance because its life-cycle is controlled via blueprint.
tracker.close();
}
@Override
public <T extends EventSource> EventSourceRegistration<T> registerEventSource(T eventSource) {
return service.registerEventSource(eventSource);
}
};
}
use of org.opendaylight.controller.messagebus.spi.EventSource in project controller by opendaylight.
the class EventSourceRegistrationImplTest method setUp.
@Before
public void setUp() throws Exception {
EventSource eventSourceMock = mock(EventSource.class);
eventSourceTopologyMock = mock(EventSourceTopology.class);
eventSourceRegistrationImplLocal = new EventSourceRegistrationImplLocal(eventSourceMock, eventSourceTopologyMock);
}
use of org.opendaylight.controller.messagebus.spi.EventSource in project controller by opendaylight.
the class EventSourceTopologyTest method registerEventSourceTest.
@Test
public void registerEventSourceTest() throws Exception {
topicTestHelper();
Node nodeMock = mock(Node.class);
EventSource eventSourceMock = mock(EventSource.class);
NodeId nodeId = new NodeId("nodeIdValue1");
nodeKey = new NodeKey(nodeId);
doReturn(nodeKey).when(nodeMock).getKey();
doReturn(nodeKey).when(eventSourceMock).getSourceNodeKey();
BindingAwareBroker.RoutedRpcRegistration routedRpcRegistrationMock = mock(BindingAwareBroker.RoutedRpcRegistration.class);
doReturn(routedRpcRegistrationMock).when(rpcProviderRegistryMock).addRoutedRpcImplementation(EventSourceService.class, eventSourceMock);
doNothing().when(routedRpcRegistrationMock).registerPath(eq(NodeContext.class), any(KeyedInstanceIdentifier.class));
assertNotNull("Return value has not been created correctly.", eventSourceTopology.registerEventSource(eventSourceMock));
}
Aggregations