Inject MD_SAL services directly in sal-binding-it tests 54/70854/3
authorTom Pantelis <tompantelis@gmail.com>
Thu, 12 Apr 2018 14:19:54 +0000 (10:19 -0400)
committerTom Pantelis <tompantelis@gmail.com>
Wed, 18 Apr 2018 14:07:05 +0000 (14:07 +0000)
This is in lieu of obtaining them via the BindingAwareBroker
which is obsolete in lieu of blueprint. Also remove the CSS
module checkong in AbstractIT.

Change-Id: I259cec363e31759447392ee1dc940fccee46d27e
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractIT.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/DataServiceIT.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceIT.java

index 29a336e98ee168eb5496e91d0e46481a376459fb..4548114ac12b1858f7a520c73221278157fce2d4 100644 (file)
@@ -9,32 +9,15 @@ package org.opendaylight.controller.test.sal.binding.it;
 
 import static org.ops4j.pax.exam.CoreOptions.maven;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 
 import static org.ops4j.pax.exam.CoreOptions.maven;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import javax.inject.Inject;
+
 import org.junit.runner.RunWith;
 import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
 import org.junit.runner.RunWith;
 import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.options.MavenUrlReference;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.options.MavenUrlReference;
-import org.ops4j.pax.exam.util.Filter;
 
 @RunWith(PaxExam.class)
 public abstract class AbstractIT extends AbstractMdsalTestBase {
 
 @RunWith(PaxExam.class)
 public abstract class AbstractIT extends AbstractMdsalTestBase {
-
-    @Inject
-    @Filter(timeout=120*1000)
-    BindingAwareBroker broker;
-
-    @Override
-    public String getModuleName() {
-        return "binding-broker-impl";
-    }
-
-    @Override
-    public String getInstanceName() {
-        return "binding-broker-impl";
-    }
-
     @Override
     public MavenUrlReference getFeatureRepo() {
         return maven().groupId("org.opendaylight.controller").artifactId("features-mdsal").classifier("features")
     @Override
     public MavenUrlReference getFeatureRepo() {
         return maven().groupId("org.opendaylight.controller").artifactId("features-mdsal").classifier("features")
index baa2c129b8892fc859a8d8e947508cc3092e1458..5a1d16634e26f31bf89b938f7fe479fd51cf7268 100644 (file)
@@ -14,23 +14,26 @@ import static org.junit.Assert.assertTrue;
 
 import com.google.common.base.Optional;
 import java.util.concurrent.TimeUnit;
 
 import com.google.common.base.Optional;
 import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.UnorderedContainer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.UnorderedContainer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.ops4j.pax.exam.util.Filter;
 
 /**
  * covers creating, reading and deleting of an item in dataStore
  */
 public class DataServiceIT extends AbstractIT {
 
 /**
  * covers creating, reading and deleting of an item in dataStore
  */
 public class DataServiceIT extends AbstractIT {
-    protected DataBroker dataBroker;
+    @Inject
+    @Filter(timeout = 120 * 1000)
+    DataBroker dataBroker;
 
     /**
      *
 
     /**
      *
@@ -42,13 +45,6 @@ public class DataServiceIT extends AbstractIT {
      */
     @Test
     public void test() throws Exception {
      */
     @Test
     public void test() throws Exception {
-        BindingAwareConsumer consumer = session -> dataBroker = session.getSALService(DataBroker.class);
-
-        broker.registerConsumer(consumer);
-
-        assertNotNull(dataBroker);
-
-
         final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         assertNotNull(transaction);
 
         final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         assertNotNull(transaction);
 
index db978dbeec8b8861441800713939bb0f6be3c531..468fc1b1fc834c60f3e924bc0dca5142853f33d5 100644 (file)
@@ -8,22 +8,18 @@
 package org.opendaylight.controller.test.sal.binding.it;
 
 import static org.junit.Assert.assertEquals;
 package org.opendaylight.controller.test.sal.binding.it;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 
 import java.util.ArrayList;
 import java.util.List;
 
 import java.util.ArrayList;
 import java.util.List;
-
+import javax.inject.Inject;
 import org.junit.Test;
 import org.junit.Test;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OpendaylightTestNotificationListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotification;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotificationBuilder;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.NotificationListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OpendaylightTestNotificationListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotification;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotificationBuilder;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.ops4j.pax.exam.util.Filter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,13 +31,9 @@ public class NotificationIT extends AbstractIT {
     private static final Logger LOG = LoggerFactory
             .getLogger(NotificationIT.class);
 
     private static final Logger LOG = LoggerFactory
             .getLogger(NotificationIT.class);
 
-    protected final NotificationTestListener listener1 = new NotificationTestListener();
-    protected final NotificationTestListener listener2 = new NotificationTestListener();
-
-    protected ListenerRegistration<NotificationListener> listener1Reg;
-    protected ListenerRegistration<NotificationListener> listener2Reg;
-
-    protected NotificationProviderService notifyProviderService;
+    @Inject
+    @Filter(timeout = 120 * 1000)
+    NotificationProviderService notificationService;
 
     /**
      * test of delivering of notification
 
     /**
      * test of delivering of notification
@@ -49,34 +41,14 @@ public class NotificationIT extends AbstractIT {
      */
     @Test
     public void notificationTest() throws Exception {
      */
     @Test
     public void notificationTest() throws Exception {
-        LOG.info("The registration of the Provider 1.");
-        AbstractTestProvider provider1 = new AbstractTestProvider() {
-            @Override
-            public void onSessionInitiated(ProviderContext session) {
-                notifyProviderService = session.getSALService(NotificationProviderService.class);
-            }
-        };
-
-        // registerProvider method calls onSessionInitiated method above
-        broker.registerProvider(provider1);
-        assertNotNull(notifyProviderService);
-
-        LOG.info("The registration of the Consumer 1. It retrieves Notification Service "
-                + "from MD-SAL and registers OpendaylightTestNotificationListener as notification listener");
-        BindingAwareConsumer consumer1 = session -> {
-            NotificationService notificationService = session.getSALService(NotificationService.class);
-            assertNotNull(notificationService);
-            listener1Reg = notificationService.registerNotificationListener(listener1);
-        };
-        // registerConsumer method calls onSessionInitialized method above
-        broker.registerConsumer(consumer1);
-
-        assertNotNull(listener1Reg);
+        NotificationTestListener listener1 = new NotificationTestListener();
+        ListenerRegistration<NotificationListener> listener1Reg =
+                notificationService.registerNotificationListener(listener1);
 
         LOG.info("The notification of type FlowAdded with cookie ID 0 is created. The "
                 + "delay 100ms to make sure that the notification was delivered to "
                 + "listener.");
 
         LOG.info("The notification of type FlowAdded with cookie ID 0 is created. The "
                 + "delay 100ms to make sure that the notification was delivered to "
                 + "listener.");
-        notifyProviderService.publish(noDustNotification("rainy day", 42));
+        notificationService.publish(noDustNotification("rainy day", 42));
         Thread.sleep(100);
 
         /**
         Thread.sleep(100);
 
         /**
@@ -89,16 +61,15 @@ public class NotificationIT extends AbstractIT {
 
         LOG.info("The registration of the Consumer 2. SalFlowListener is registered "
                 + "registered as notification listener.");
 
         LOG.info("The registration of the Consumer 2. SalFlowListener is registered "
                 + "registered as notification listener.");
-        BindingAwareProvider provider = session -> listener2Reg = session.getSALService(NotificationProviderService.class).registerNotificationListener(
-                listener2);
 
 
-        // registerConsumer method calls onSessionInitialized method above
-        broker.registerProvider(provider);
+        NotificationTestListener listener2 = new NotificationTestListener();
+        final ListenerRegistration<NotificationListener> listener2Reg =
+                notificationService.registerNotificationListener(listener2);
 
         LOG.info("3 notifications are published");
 
         LOG.info("3 notifications are published");
-        notifyProviderService.publish(noDustNotification("rainy day", 5));
-        notifyProviderService.publish(noDustNotification("rainy day", 10));
-        notifyProviderService.publish(noDustNotification("tax collector", 2));
+        notificationService.publish(noDustNotification("rainy day", 5));
+        notificationService.publish(noDustNotification("rainy day", 10));
+        notificationService.publish(noDustNotification("tax collector", 2));
 
         /**
          * The delay 100ms to make sure that the notifications were delivered to
 
         /**
          * The delay 100ms to make sure that the notifications were delivered to
@@ -121,7 +92,7 @@ public class NotificationIT extends AbstractIT {
         listener2Reg.close();
 
         LOG.info("The notification 5 is published");
         listener2Reg.close();
 
         LOG.info("The notification 5 is published");
-        notifyProviderService.publish(noDustNotification("entomologist hunt", 10));
+        notificationService.publish(noDustNotification("entomologist hunt", 10));
 
         /**
          * The delay 100ms to make sure that the notification was delivered to
 
         /**
          * The delay 100ms to make sure that the notification was delivered to
index a394bcba89e0731dae13e92f00a5be549cf3d6c5..66a12edf340d0d46425b995e1642b4a5b718ad11 100644 (file)
@@ -13,14 +13,14 @@ import static org.junit.Assert.assertSame;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
+
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.Futures;
+import javax.inject.Inject;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.OpendaylightTestRoutedRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.OpendaylightTestRoutedRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder;
@@ -31,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.ops4j.pax.exam.util.Filter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,10 +46,9 @@ public class RoutedServiceIT extends AbstractIT {
     protected OpendaylightTestRoutedRpcService odlRoutedService1;
     protected OpendaylightTestRoutedRpcService odlRoutedService2;
 
     protected OpendaylightTestRoutedRpcService odlRoutedService1;
     protected OpendaylightTestRoutedRpcService odlRoutedService2;
 
-    protected OpendaylightTestRoutedRpcService consumerService;
-
-    protected RoutedRpcRegistration<OpendaylightTestRoutedRpcService> firstReg;
-    protected RoutedRpcRegistration<OpendaylightTestRoutedRpcService> secondReg;
+    @Inject
+    @Filter(timeout = 120 * 1000)
+    RpcProviderRegistry rpcProviderRegistry;
 
     /**
      * prepare mocks
 
     /**
      * prepare mocks
@@ -65,43 +65,26 @@ public class RoutedServiceIT extends AbstractIT {
 
     @Test
     public void 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");
         LOG.info("Register provider 1 with first implementation of routeSimpleService - service1");
-        broker.registerProvider(provider1);
+
+        RoutedRpcRegistration<OpendaylightTestRoutedRpcService> firstReg = rpcProviderRegistry
+                .addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService1);
         assertNotNull("Registration should not be null", firstReg);
         assertSame(odlRoutedService1, firstReg.getInstance());
 
         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");
         LOG.info("Register provider 2 with second implementation of routeSimpleService - service2");
-        broker.registerProvider(provider2);
+
+        RoutedRpcRegistration<OpendaylightTestRoutedRpcService> secondReg = rpcProviderRegistry
+                .addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService2);
         assertNotNull("Registration should not be null", firstReg);
         assertSame(odlRoutedService2, secondReg.getInstance());
         assertNotSame(secondReg, firstReg);
 
         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);
-
+        OpendaylightTestRoutedRpcService consumerService =
+                rpcProviderRegistry.getRpcService(OpendaylightTestRoutedRpcService.class);
         assertNotNull("MD-SAL instance of test Service should be returned", consumerService);
         assertNotNull("MD-SAL instance of test Service should be returned", consumerService);
-        assertNotSame("Provider instance and consumer instance should not be same.", odlRoutedService1, consumerService);
+        assertNotSame("Provider instance and consumer instance should not be same.", odlRoutedService1,
+                consumerService);
 
         final InstanceIdentifier<UnorderedList> nodeOnePath = createNodeRef("foo:node:1");
 
 
         final InstanceIdentifier<UnorderedList> nodeOnePath = createNodeRef("foo:node:1");