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.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.util.Filter;
@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")
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.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.ops4j.pax.exam.util.Filter;
/**
* 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;
/**
*
*/
@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);
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 javax.inject.Inject;
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.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.ops4j.pax.exam.util.Filter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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
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.");
- notifyProviderService.publish(noDustNotification("rainy day", 42));
+ notificationService.publish(noDustNotification("rainy day", 42));
Thread.sleep(100);
/**
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");
- 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
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
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 javax.inject.Inject;
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.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.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;
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
@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);
+
+ RoutedRpcRegistration<OpendaylightTestRoutedRpcService> firstReg = rpcProviderRegistry
+ .addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService1);
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);
+
+ RoutedRpcRegistration<OpendaylightTestRoutedRpcService> secondReg = rpcProviderRegistry
+ .addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService2);
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);
- 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");