Search in sources :

Example 1 with EventSource

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();
}
Also used : BindingAwareBroker(org.opendaylight.controller.sal.binding.api.BindingAwareBroker) EventSource(org.opendaylight.controller.messagebus.spi.EventSource) EventSourceService(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) Test(org.junit.Test)

Example 2 with EventSource

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));
}
Also used : BindingAwareBroker(org.opendaylight.controller.sal.binding.api.BindingAwareBroker) EventSource(org.opendaylight.controller.messagebus.spi.EventSource) NodeContext(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) Test(org.junit.Test)

Example 3 with EventSource

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);
        }
    };
}
Also used : EventSource(org.opendaylight.controller.messagebus.spi.EventSource) EventSourceRegistry(org.opendaylight.controller.messagebus.spi.EventSourceRegistry)

Example 4 with 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);
}
Also used : EventSource(org.opendaylight.controller.messagebus.spi.EventSource) Before(org.junit.Before)

Example 5 with EventSource

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));
}
Also used : BindingAwareBroker(org.opendaylight.controller.sal.binding.api.BindingAwareBroker) EventSource(org.opendaylight.controller.messagebus.spi.EventSource) NodeContext(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) Test(org.junit.Test)

Aggregations

EventSource (org.opendaylight.controller.messagebus.spi.EventSource)5 Test (org.junit.Test)3 BindingAwareBroker (org.opendaylight.controller.sal.binding.api.BindingAwareBroker)3 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)3 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)3 NodeContext (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext)2 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)2 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)2 Before (org.junit.Before)1 EventSourceRegistry (org.opendaylight.controller.messagebus.spi.EventSourceRegistry)1 EventSourceService (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService)1