Search in sources :

Example 1 with RoutedSimpleRouteInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput in project controller by opendaylight.

the class ContextExtractorTest method testRoutedSimpleExtraction.

@Test
public void testRoutedSimpleExtraction() {
    final ContextReferenceExtractor extractor = ContextReferenceExtractor.from(RoutedSimpleRouteInput.class);
    final RoutedSimpleRouteInput input = new RoutedSimpleRouteInputBuilder().setRoute(TEST_ROUTE).build();
    final InstanceIdentifier<?> extractedValue = extractor.extract(input);
    assertSame(TEST_ROUTE, extractedValue);
}
Also used : RoutedSimpleRouteInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput) RoutedSimpleRouteInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder) Test(org.junit.Test)

Example 2 with RoutedSimpleRouteInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput in project controller by opendaylight.

the class RoutedServiceIT method createSimpleRouteInput.

/**
 * Creates flow AddFlowInput for which only node and cookie are set
 *
 * @param node
 *            NodeRef value
 * @return simpleRouteInput instance
 */
static RoutedSimpleRouteInput createSimpleRouteInput(final InstanceIdentifier<UnorderedList> node) {
    final RoutedSimpleRouteInputBuilder ret = new RoutedSimpleRouteInputBuilder();
    ret.setRoute(node);
    return ret.build();
}
Also used : RoutedSimpleRouteInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder)

Example 3 with RoutedSimpleRouteInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput in project controller by opendaylight.

the class RoutedServiceIT method testServiceRegistration.

@Test
public void testServiceRegistration() {
    assertNotNull(broker);
    final BindingAwareProvider provider1 = new AbstractTestProvider() {

        @Override
        public void onSessionInitiated(final ProviderContext session) {
            assertNotNull(session);
            firstReg = session.addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService1);
        }
    };
    LOG.info("Register provider 1 with first implementation of routeSimpleService - service1");
    broker.registerProvider(provider1);
    assertNotNull("Registration should not be null", firstReg);
    assertSame(odlRoutedService1, firstReg.getInstance());
    final BindingAwareProvider provider2 = new AbstractTestProvider() {

        @Override
        public void onSessionInitiated(final ProviderContext session) {
            assertNotNull(session);
            secondReg = session.addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService2);
        }
    };
    LOG.info("Register provider 2 with second implementation of routeSimpleService - service2");
    broker.registerProvider(provider2);
    assertNotNull("Registration should not be null", firstReg);
    assertSame(odlRoutedService2, secondReg.getInstance());
    assertNotSame(secondReg, firstReg);
    final BindingAwareConsumer consumer = session -> consumerService = session.getRpcService(OpendaylightTestRoutedRpcService.class);
    LOG.info("Register routeService consumer");
    broker.registerConsumer(consumer);
    assertNotNull("MD-SAL instance of test Service should be returned", consumerService);
    assertNotSame("Provider instance and consumer instance should not be same.", odlRoutedService1, consumerService);
    final InstanceIdentifier<UnorderedList> nodeOnePath = createNodeRef("foo:node:1");
    LOG.info("Provider 1 registers path of node 1");
    firstReg.registerPath(TestContext.class, nodeOnePath);
    /**
     * Consumer creates addFlow message for node one and sends it to the
     * MD-SAL
     */
    final RoutedSimpleRouteInput simpleRouteFirstFoo = createSimpleRouteInput(nodeOnePath);
    consumerService.routedSimpleRoute(simpleRouteFirstFoo);
    /**
     * Verifies that implementation of the first provider received the same
     * message from MD-SAL.
     */
    verify(odlRoutedService1).routedSimpleRoute(simpleRouteFirstFoo);
    /**
     * Verifies that second instance was not invoked with first message
     */
    verify(odlRoutedService2, times(0)).routedSimpleRoute(simpleRouteFirstFoo);
    LOG.info("Provider 2 registers path of node 2");
    final InstanceIdentifier<UnorderedList> nodeTwo = createNodeRef("foo:node:2");
    secondReg.registerPath(TestContext.class, nodeTwo);
    /**
     * Consumer sends message to nodeTwo for three times. Should be
     * processed by second instance.
     */
    final RoutedSimpleRouteInput simpleRouteSecondFoo = createSimpleRouteInput(nodeTwo);
    consumerService.routedSimpleRoute(simpleRouteSecondFoo);
    consumerService.routedSimpleRoute(simpleRouteSecondFoo);
    consumerService.routedSimpleRoute(simpleRouteSecondFoo);
    /**
     * Verifies that second instance was invoked 3 times with second message
     * and first instance wasn't invoked.
     */
    verify(odlRoutedService2, times(3)).routedSimpleRoute(simpleRouteSecondFoo);
    verify(odlRoutedService1, times(0)).routedSimpleRoute(simpleRouteSecondFoo);
    LOG.info("Unregistration of the path for the node one in the first provider");
    firstReg.unregisterPath(TestContext.class, nodeOnePath);
    LOG.info("Provider 2 registers path of node 1");
    secondReg.registerPath(TestContext.class, nodeOnePath);
    /**
     * A consumer sends third message to node 1
     */
    final RoutedSimpleRouteInput simpleRouteThirdFoo = createSimpleRouteInput(nodeOnePath);
    consumerService.routedSimpleRoute(simpleRouteThirdFoo);
    /**
     * Verifies that provider 1 wasn't invoked and provider 2 was invoked 1
     * time.
     * TODO: fix unregister path
     */
    // verify(odlRoutedService1, times(0)).routedSimpleRoute(simpleRouteThirdFoo);
    verify(odlRoutedService2).routedSimpleRoute(simpleRouteThirdFoo);
}
Also used : OpendaylightTestRoutedRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.OpendaylightTestRoutedRpcService) UnorderedListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Assert.assertNotSame(org.junit.Assert.assertNotSame) LoggerFactory(org.slf4j.LoggerFactory) ProviderContext(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext) Lists(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists) Assert.assertSame(org.junit.Assert.assertSame) Before(org.junit.Before) UnorderedList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList) Logger(org.slf4j.Logger) Assert.assertNotNull(org.junit.Assert.assertNotNull) OpendaylightTestRoutedRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.OpendaylightTestRoutedRpcService) RoutedSimpleRouteInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder) RoutedRpcRegistration(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) UnorderedContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.UnorderedContainer) Mockito.verify(org.mockito.Mockito.verify) BindingAwareConsumer(org.opendaylight.controller.sal.binding.api.BindingAwareConsumer) Mockito(org.mockito.Mockito) Futures(com.google.common.util.concurrent.Futures) BindingAwareProvider(org.opendaylight.controller.sal.binding.api.BindingAwareProvider) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TestContext(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext) RoutedSimpleRouteInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput) Mockito.mock(org.mockito.Mockito.mock) ProviderContext(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext) BindingAwareProvider(org.opendaylight.controller.sal.binding.api.BindingAwareProvider) UnorderedList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList) RoutedSimpleRouteInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput) BindingAwareConsumer(org.opendaylight.controller.sal.binding.api.BindingAwareConsumer) Test(org.junit.Test)

Aggregations

RoutedSimpleRouteInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder)3 Test (org.junit.Test)2 RoutedSimpleRouteInput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput)2 Futures (com.google.common.util.concurrent.Futures)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertNotSame (org.junit.Assert.assertNotSame)1 Assert.assertSame (org.junit.Assert.assertSame)1 Before (org.junit.Before)1 Mockito (org.mockito.Mockito)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.times (org.mockito.Mockito.times)1 Mockito.verify (org.mockito.Mockito.verify)1 ProviderContext (org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext)1 RoutedRpcRegistration (org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration)1 BindingAwareConsumer (org.opendaylight.controller.sal.binding.api.BindingAwareConsumer)1 BindingAwareProvider (org.opendaylight.controller.sal.binding.api.BindingAwareProvider)1 OpendaylightTestRoutedRpcService (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.OpendaylightTestRoutedRpcService)1 TestContext (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext)1 Lists (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists)1 UnorderedContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.UnorderedContainer)1