Merge "BUG-2953: do not use a complete InMemoryDataStore"
authorTony Tkacik <ttkacik@cisco.com>
Wed, 15 Apr 2015 14:49:44 +0000 (14:49 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 15 Apr 2015 14:49:44 +0000 (14:49 +0000)
14 files changed:
opendaylight/md-sal/mdsal-artifacts/pom.xml
opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleFactoryTest.java
opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleTest.java
opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java [new file with mode: 0644]
opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopicTest.java
opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java
opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/NetconfEventSourceManagerTest.java
opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/NetconfEventSourceTest.java
opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/TopicDOMNotificationTest.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationServiceAdapter.java
opendaylight/md-sal/sal-distributed-datastore/pom.xml
opendaylight/md-sal/sal-dummy-distributed-datastore/pom.xml

index 23b2ea1..e8a4016 100644 (file)
                 <artifactId>sal-remoterpc-connector</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.opendaylight.controller</groupId>
+                <artifactId>sal-akka-raft</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.opendaylight.controller</groupId>
+                <artifactId>sal-akka-raft</artifactId>
+                <version>${project.version}</version>
+                <type>test-jar</type>
+                <scope>test</scope>
+            </dependency>
 
             <!-- OpenFlow stuff -->
             <dependency>
index 85d1a1b..e26502f 100644 (file)
@@ -7,17 +7,37 @@
  */
 package org.opendaylight.controller.config.yang.messagebus.app.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.JmxAttribute;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.core.api.Broker;
+import org.opendaylight.controller.sal.core.api.Provider;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.framework.BundleContext;
 
+import javax.management.ObjectName;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
 public class MessageBusAppImplModuleTest {
 
     MessageBusAppImplModule messageBusAppImplModule;
@@ -55,5 +75,34 @@ public class MessageBusAppImplModuleTest {
         assertEquals("Set and/or get method/s don't work correctly.", bundleContext, messageBusAppImplModule.getBundleContext());
     }
 
-    //TODO: create MessageBusAppImplModule.createInstance test
-}
+    @Test
+    public void createInstanceTest() throws Exception{
+        org.opendaylight.controller.sal.binding.api.BindingAwareBroker bindingAwareBrokerMock = mock(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.class);
+        Broker brokerMock = mock(Broker.class);
+        doReturn(brokerMock).when(dependencyResolverMock).resolveInstance(eq(org.opendaylight.controller.sal.core.api.Broker.class), any(ObjectName.class), any(JmxAttribute.class));
+        doReturn(bindingAwareBrokerMock).when(dependencyResolverMock).resolveInstance(eq(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class));
+        messageBusAppImplModule.resolveDependencies();
+
+        BindingAwareBroker.ProviderContext providerContext = mock(BindingAwareBroker.ProviderContext.class);
+        doReturn(providerContext).when(bindingAwareBrokerMock).registerProvider(any(BindingAwareProvider.class));
+        Broker.ProviderSession providerSessionMock = mock(Broker.ProviderSession.class);
+        doReturn(providerSessionMock).when(brokerMock).registerProvider(any(Provider.class));
+        DataBroker dataBrokerMock = mock(DataBroker.class);
+        doReturn(dataBrokerMock).when(providerContext).getSALService(eq(DataBroker.class));
+        DOMNotificationPublishService domNotificationPublishServiceMock = mock(DOMNotificationPublishService.class);
+        doReturn(domNotificationPublishServiceMock).when(providerSessionMock).getService(DOMNotificationPublishService.class);
+        DOMMountPointService domMountPointServiceMock = mock(DOMMountPointService.class);
+        doReturn(domMountPointServiceMock).when(providerSessionMock).getService(DOMMountPointService.class);
+        MountPointService mountPointServiceMock = mock(MountPointService.class);
+        doReturn(mountPointServiceMock).when(providerContext).getSALService(eq(MountPointService.class));
+        RpcProviderRegistry rpcProviderRegistryMock = mock(RpcProviderRegistry.class);
+        doReturn(rpcProviderRegistryMock).when(providerContext).getSALService(eq(RpcProviderRegistry.class));
+
+        WriteTransaction writeTransactionMock = mock(WriteTransaction.class);
+        doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction();
+        doNothing().when(writeTransactionMock).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class), eq(true));
+
+        assertNotNull("EventSourceRegistryWrapper has not been created correctly.", messageBusAppImplModule.createInstance());
+    }
+
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java
new file mode 100644 (file)
index 0000000..9cce623
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.messagebus.app.impl;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.messagebus.spi.EventSource;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+public class EventSourceRegistrationImplTest {
+
+    EventSourceRegistrationImplLocal eventSourceRegistrationImplLocal;
+    EventSourceTopology eventSourceTopologyMock;
+
+    @BeforeClass
+    public static void initTestClass() throws IllegalAccessException, InstantiationException {
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        EventSource eventSourceMock = mock(EventSource.class);
+        eventSourceTopologyMock = mock(EventSourceTopology.class);
+        eventSourceRegistrationImplLocal = new EventSourceRegistrationImplLocal(eventSourceMock, eventSourceTopologyMock);
+    }
+
+    @Test
+    public void removeRegistrationTest() {
+        eventSourceRegistrationImplLocal.removeRegistration();
+        verify(eventSourceTopologyMock, times(1)).unRegister(any(EventSource.class));
+    }
+
+
+    private class EventSourceRegistrationImplLocal extends EventSourceRegistrationImpl{
+
+        /**
+         * @param instance            of EventSource that has been registered by {@link EventSourceRegistryImpl#registerEventSource(Node, org.opendaylight.controller.messagebus.spi.EventSource)}
+         * @param eventSourceTopology
+         */
+        public EventSourceRegistrationImplLocal(EventSource instance, EventSourceTopology eventSourceTopology) {
+            super(instance, eventSourceTopology);
+        }
+    }
+
+}
\ No newline at end of file
index f369a12..9f513c4 100644 (file)
@@ -74,7 +74,7 @@ public class EventSourceTopicTest {
 
         nodeIdMock = mock(NodeId.class);
         doReturn(nodeIdMock).when(dataObjectMock).getId();
-        doReturn("0").when(nodeIdMock).getValue();
+        doReturn("nodeIdPattern1").when(nodeIdMock).getValue();
     }
 
     @Test
@@ -84,4 +84,4 @@ public class EventSourceTopicTest {
         verify(eventSourceServiceMock, times(1)).joinTopic(any(JoinTopicInput.class));
     }
 
-}
+}
\ No newline at end of file
index ced2e1f..50ae4d9 100644 (file)
@@ -16,13 +16,16 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
+import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -57,6 +60,7 @@ public class EventSourceTopologyTest {
     CreateTopicInput createTopicInputMock;
     ListenerRegistration listenerRegistrationMock;
     NodeKey nodeKey;
+    RpcRegistration<EventAggregatorService> aggregatorRpcReg;
 
     @BeforeClass
     public static void initTestClass() throws IllegalAccessException, InstantiationException {
@@ -76,7 +80,7 @@ public class EventSourceTopologyTest {
     }
 
     private void constructorTestHelper(){
-        RpcRegistration<EventAggregatorService> aggregatorRpcReg = mock(RpcRegistration.class);
+        aggregatorRpcReg = mock(RpcRegistration.class);
         EventSourceService eventSourceService = mock(EventSourceService.class);
         doReturn(aggregatorRpcReg).when(rpcProviderRegistryMock).addRpcImplementation(eq(EventAggregatorService.class), any(EventSourceTopology.class));
         doReturn(eventSourceService).when(rpcProviderRegistryMock).getRpcService(EventSourceService.class);
@@ -87,11 +91,11 @@ public class EventSourceTopologyTest {
         doReturn(checkedFutureMock).when(writeTransactionMock).submit();
     }
 
-//TODO: create test for createTopic
-//    public void createTopicTest() throws Exception{
-//        createTopicTestHelper();
-//        assertNotNull("Topic has not been created correctly.", eventSourceTopology.createTopic(createTopicInputMock));
-//    }
+    @Test
+    public void createTopicTest() throws Exception{
+        topicTestHelper();
+        assertNotNull("Topic has not been created correctly.", eventSourceTopology.createTopic(createTopicInputMock));
+    }
 
     private void topicTestHelper() throws Exception{
         constructorTestHelper();
@@ -138,6 +142,19 @@ public class EventSourceTopologyTest {
         assertNotNull("Instance has not been created correctly.", eventSourceTopology.destroyTopic(destroyTopicInput));
     }
 
+    @Test
+    public void closeTest() throws Exception{
+        constructorTestHelper();
+        topicTestHelper();
+        Map<DataChangeListener, ListenerRegistration<DataChangeListener>> localMap = getTopicListenerRegistrations();
+        DataChangeListener dataChangeListenerMock = mock(DataChangeListener.class);
+        ListenerRegistration<DataChangeListener> listenerListenerRegistrationMock = (ListenerRegistration<DataChangeListener>) mock(ListenerRegistration.class);
+        localMap.put(dataChangeListenerMock, listenerListenerRegistrationMock);
+        eventSourceTopology.close();
+        verify(aggregatorRpcReg, times(1)).close();
+        verify(listenerListenerRegistrationMock, times(1)).close();
+    }
+
     @Test
     public void registerTest() throws Exception {
         topicTestHelper();
@@ -154,4 +171,46 @@ public class EventSourceTopologyTest {
         verify(routedRpcRegistrationMock, times(1)).registerPath(eq(NodeContext.class), any(KeyedInstanceIdentifier.class));
     }
 
-}
+    @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 = (BindingAwareBroker.RoutedRpcRegistration<EventSourceService>) mock(BindingAwareBroker.RoutedRpcRegistration.class);
+        localMap.put(nodeKeyMock, routedRpcRegistrationMock);
+        eventSourceTopology.unRegister(eventSourceMock);
+        verify(routedRpcRegistrationMock, times(1)).close();
+    }
+
+    @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));
+    }
+
+    private Map getTopicListenerRegistrations() throws Exception{
+        Field nesField = EventSourceTopology.class.getDeclaredField("topicListenerRegistrations");
+        nesField.setAccessible(true);
+        return (Map) nesField.get(eventSourceTopology);
+    }
+
+    private Map getRoutedRpcRegistrations() throws Exception{
+        Field nesField = EventSourceTopology.class.getDeclaredField("routedRpcRegistrations");
+        nesField.setAccessible(true);
+        return (Map) nesField.get(eventSourceTopology);
+    }
+
+}
\ No newline at end of file
index 61fa30f..1d6b825 100644 (file)
@@ -84,11 +84,11 @@ public class NetconfEventSourceManagerTest {
 
         netconfEventSourceManager =
                 NetconfEventSourceManager.create(dataBrokerMock,
-                                                 domNotificationPublishServiceMock,
-                                                 domMountPointServiceMock,
-                                                 mountPointServiceMock,
-                                                 eventSourceRegistry,
-                                                 namespaceToStreamList);
+                        domNotificationPublishServiceMock,
+                        domMountPointServiceMock,
+                        mountPointServiceMock,
+                        eventSourceRegistry,
+                        namespaceToStreamList);
     }
 
     @Test
@@ -125,12 +125,14 @@ public class NetconfEventSourceManagerTest {
         Map<InstanceIdentifier, DataObject> mapUpdate = new HashMap<>();
         InstanceIdentifier instanceIdentifierMock = mock(InstanceIdentifier.class);
         Node dataObjectMock = mock(Node.class);
+
         if(create){
             mapCreate.put(instanceIdentifierMock, dataObjectMock);
         }
         if(update){
             mapUpdate.put(instanceIdentifierMock, dataObjectMock);
         }
+
         doReturn(mapCreate).when(asyncDataChangeEventMock).getCreatedData();
         doReturn(mapUpdate).when(asyncDataChangeEventMock).getUpdatedData();
         NetconfNode netconfNodeMock = mock(NetconfNode.class);
@@ -171,4 +173,4 @@ public class NetconfEventSourceManagerTest {
         doReturn(esrMock).when(eventSourceRegistry).registerEventSource(any(EventSource.class));
     }
 
-}
+}
\ No newline at end of file
index 58da9e3..ed90257 100644 (file)
@@ -7,22 +7,8 @@
  */
 package org.opendaylight.controller.messagebus.app.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.lang.reflect.Field;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.BindingService;
@@ -53,21 +39,32 @@ import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 
 public class NetconfEventSourceTest {
 
     NetconfEventSource netconfEventSource;
     DOMMountPoint domMountPointMock;
     JoinTopicInput joinTopicInputMock;
-    AsyncDataChangeEvent asyncDataChangeEventMock;
-    Node dataObjectMock;
 
     @Before
     public void setUp() throws Exception {
         Map<String, String> streamMap = new HashMap<>();
-        streamMap.put("string1", "string2");
+        streamMap.put("uriStr1", "string2");
         domMountPointMock = mock(DOMMountPoint.class);
         DOMNotificationPublishService domNotificationPublishServiceMock = mock(DOMNotificationPublishService.class);
         MountPoint mountPointMock = mock(MountPoint.class);
@@ -80,9 +77,9 @@ public class NetconfEventSourceTest {
         doReturn(rpcConsumerRegistryMock).when(onlyOptionalMock).get();
         doReturn(notificationsServiceMock).when(rpcConsumerRegistryMock).getRpcService(NotificationsService.class);
         org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node node
-            = mock(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class);
+                = mock(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class);
         org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId nodeId
-            = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId("NodeId1");
+                = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId("NodeId1");
         doReturn(nodeId).when(node).getNodeId();
         netconfEventSource = new NetconfEventSource(node, streamMap, domMountPointMock, domNotificationPublishServiceMock, mountPointMock);
     }
@@ -143,7 +140,7 @@ public class NetconfEventSourceTest {
         doReturn(topicId).when(joinTopicInputMock).getTopicId();
         NotificationPattern notificationPatternMock = mock(NotificationPattern.class);
         doReturn(notificationPatternMock).when(joinTopicInputMock).getNotificationPattern();
-        doReturn("regexString1").when(notificationPatternMock).getValue();
+        doReturn("uriStr1").when(notificationPatternMock).getValue();
 
         SchemaContext schemaContextMock = mock(SchemaContext.class);
         doReturn(schemaContextMock).when(domMountPointMock).getSchemaContext();
@@ -165,6 +162,13 @@ public class NetconfEventSourceTest {
         doReturn(domNotificationServiceMock).when(domNotificationServiceOptionalMock).get();
         ListenerRegistration listenerRegistrationMock = mock(ListenerRegistration.class);
         doReturn(listenerRegistrationMock).when(domNotificationServiceMock).registerNotificationListener(any(NetconfEventSource.class), any(List.class));
+
+        Optional<DOMService> optionalMock = (Optional<DOMService>) mock(Optional.class);
+        doReturn(optionalMock).when(domMountPointMock).getService(DOMRpcService.class);
+        DOMRpcService domRpcServiceMock = mock(DOMRpcService.class);
+        doReturn(domRpcServiceMock).when(optionalMock).get();
+        CheckedFuture checkedFutureMock = mock(CheckedFuture.class);
+        doReturn(checkedFutureMock).when(domRpcServiceMock).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
     }
 
 //TODO: create Test for NetConfEventSource#onNotification
@@ -175,4 +179,4 @@ public class NetconfEventSourceTest {
         return (Set) nesField.get(netconfEventSource);
     }
 
-}
+}
\ No newline at end of file
index 6dacb97..b3f6438 100644 (file)
@@ -57,4 +57,4 @@ public class TopicDOMNotificationTest {
         String bodyString = "TopicDOMNotification [body=" + containerNodeBodyMockToString + "]";
         assertEquals("String has not been created correctly.", bodyString, topicDOMNotification.toString());
     }
-}
+}
\ No newline at end of file
index 2c433f9..bdfdd9b 100644 (file)
@@ -460,7 +460,7 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior {
             long followerNextIndex = followerLogInformation.getNextIndex();
             boolean isFollowerActive = followerLogInformation.isFollowerActive();
             boolean sendAppendEntries = false;
-            List<ReplicatedLogEntry> entries = Collections.EMPTY_LIST;
+            List<ReplicatedLogEntry> entries = Collections.emptyList();
 
             if (mapFollowerToSnapshot.get(followerId) != null) {
                 // if install snapshot is in process , then sent next chunk if possible
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java
new file mode 100644 (file)
index 0000000..03da296
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.sal.binding.impl;
+
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
+import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
+import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+class BindingDOMNotificationListenerAdapter implements DOMNotificationListener {
+
+    private final NotificationInvokerFactory.NotificationInvoker invoker;
+    private final BindingNormalizedNodeSerializer codec;
+
+    public BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec, final NotificationInvokerFactory.NotificationInvoker invoker) {
+        this.codec = codec;
+        this.invoker = invoker;
+    }
+
+    @Override
+    public void onNotification(@Nonnull final DOMNotification notification) {
+        final Notification baNotification =
+                codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody());
+        invoker.getInvocationProxy().onNotification(baNotification);
+    }
+}
\ No newline at end of file
index 50a0a28..6006266 100644 (file)
@@ -13,10 +13,8 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
-import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
 import org.opendaylight.controller.md.sal.dom.api.DOMService;
@@ -44,16 +42,16 @@ public class BindingDOMNotificationServiceAdapter implements NotificationService
     private final DOMNotificationService domNotifService;
     private final NotificationInvokerFactory notificationInvokerFactory;
 
-    public BindingDOMNotificationServiceAdapter(BindingNormalizedNodeSerializer codec, DOMNotificationService domNotifService, NotificationInvokerFactory notificationInvokerFactory) {
+    public BindingDOMNotificationServiceAdapter(final BindingNormalizedNodeSerializer codec, final DOMNotificationService domNotifService, final NotificationInvokerFactory notificationInvokerFactory) {
         this.codec = codec;
         this.domNotifService = domNotifService;
         this.notificationInvokerFactory = notificationInvokerFactory;
     }
 
     @Override
-    public <T extends NotificationListener> ListenerRegistration<T> registerNotificationListener(T listener) {
+    public <T extends NotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener) {
         final NotificationInvokerFactory.NotificationInvoker invoker = notificationInvokerFactory.invokerFor(listener);
-        final DOMNotificationListener domListener = new NotificationInvokerImpl(invoker);
+        final DOMNotificationListener domListener = new BindingDOMNotificationListenerAdapter(codec, invoker);
         final Collection<SchemaPath> schemaPaths = convertNotifTypesToSchemaPath(invoker.getSupportedNotifications());
         final ListenerRegistration<DOMNotificationListener> domRegistration =
                 domNotifService.registerNotificationListener(domListener, schemaPaths);
@@ -62,9 +60,9 @@ public class BindingDOMNotificationServiceAdapter implements NotificationService
 
 
 
-    private Collection<SchemaPath> convertNotifTypesToSchemaPath(Set<Class<? extends Notification>> notificationTypes) {
+    private Collection<SchemaPath> convertNotifTypesToSchemaPath(final Set<Class<? extends Notification>> notificationTypes) {
         final List<SchemaPath> schemaPaths = new ArrayList<>();
-        for (Class<? extends Notification> notificationType : notificationTypes) {
+        for (final Class<? extends Notification> notificationType : notificationTypes) {
             schemaPaths.add(SchemaPath.create(true, BindingReflections.findQName(notificationType)));
         }
         return schemaPaths;
@@ -78,7 +76,7 @@ public class BindingDOMNotificationServiceAdapter implements NotificationService
     private static class ListenerRegistrationImpl<T extends NotificationListener> extends AbstractListenerRegistration<T> {
         private final ListenerRegistration<?> listenerRegistration;
 
-        public ListenerRegistrationImpl(T listener, ListenerRegistration<?> listenerRegistration) {
+        public ListenerRegistrationImpl(final T listener, final ListenerRegistration<?> listenerRegistration) {
             super(listener);
             this.listenerRegistration = listenerRegistration;
         }
@@ -89,30 +87,14 @@ public class BindingDOMNotificationServiceAdapter implements NotificationService
         }
     }
 
-    private class NotificationInvokerImpl implements DOMNotificationListener {
-        private final NotificationInvokerFactory.NotificationInvoker invoker;
-
-        public NotificationInvokerImpl(NotificationInvokerFactory.NotificationInvoker invoker) {
-            this.invoker = invoker;
-        }
-
-        @Override
-        public void onNotification(@Nonnull DOMNotification notification) {
-            final Notification baNotification =
-                    codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody());
-            invoker.getInvocationProxy().onNotification(baNotification);
-
-        }
-    }
-
     private static class Builder extends BindingDOMAdapterBuilder<NotificationService> {
 
 
         @Override
-        protected NotificationService createInstance(BindingToNormalizedNodeCodec codec,
-                ClassToInstanceMap<DOMService> delegates) {
-            DOMNotificationService domNotification = delegates.getInstance(DOMNotificationService.class);
-            NotificationInvokerFactory invokerFactory = SingletonHolder.INVOKER_FACTORY;
+        protected NotificationService createInstance(final BindingToNormalizedNodeCodec codec,
+                final ClassToInstanceMap<DOMService> delegates) {
+            final DOMNotificationService domNotification = delegates.getInstance(DOMNotificationService.class);
+            final NotificationInvokerFactory invokerFactory = SingletonHolder.INVOKER_FACTORY;
             return new BindingDOMNotificationServiceAdapter(codec.getCodecRegistry(), domNotification, invokerFactory);
         }
 
index 10ea2be..159c913 100644 (file)
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-akka-raft</artifactId>
-      <version>1.2.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-akka-raft</artifactId>
-      <version>1.2.0-SNAPSHOT</version>
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
index a8c05a1..4a17273 100644 (file)
@@ -58,7 +58,6 @@
       <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>sal-akka-raft</artifactId>
-          <version>1.2.0-SNAPSHOT</version>
       </dependency>
 
       <dependency>

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.