<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-notifications-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
</dependencies>
</project>
<relativePath>../netconf-parent</relativePath>
</parent>
- <groupId>org.opendaylight.netconf</groupId>
<artifactId>mdsal-netconf-notification</artifactId>
<version>1.6.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
<dependencies>
- <!-- compile dependencies -->
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-mapping-api</artifactId>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-notifications-impl</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-util</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-notifications-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-generator-impl</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-binding-api</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-dom-codec</artifactId>
</dependency>
-
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ietf-netconf-notifications</artifactId>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>netconf-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>netconf-notifications-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>netconf-mapping-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>netconf-util</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-legacy</artifactId>
+ <scope>test</scope>
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Embed-Dependency>netconf-notifications-impl</Embed-Dependency>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
* 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.config.yang.netconf.mdsal.notification;
+package org.opendaylight.netconf.mdsal.notification.impl;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
* 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.netconf.notifications.impl;
+package org.opendaylight.netconf.mdsal.notification.impl;
import com.google.common.base.Preconditions;
import com.google.common.collect.HashMultimap;
import java.util.Set;
import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.ThreadSafe;
+import org.opendaylight.netconf.mdsal.notification.impl.ops.NotificationsTransformUtil;
import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
import org.opendaylight.netconf.notifications.NetconfNotification;
import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
import org.opendaylight.netconf.notifications.NotificationListenerRegistration;
import org.opendaylight.netconf.notifications.NotificationPublisherRegistration;
import org.opendaylight.netconf.notifications.NotificationRegistration;
-import org.opendaylight.netconf.notifications.impl.ops.NotificationsTransformUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.StreamsBuilder;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.mdsal.notification;
+package org.opendaylight.netconf.mdsal.notification.impl;
import java.util.Collections;
import java.util.Set;
import org.opendaylight.netconf.mapping.api.NetconfOperation;
import org.opendaylight.netconf.mapping.api.NetconfOperationService;
+import org.opendaylight.netconf.mdsal.notification.impl.ops.CreateSubscription;
import org.opendaylight.netconf.notifications.NetconfNotificationRegistry;
-import org.opendaylight.netconf.notifications.impl.ops.CreateSubscription;
public class NetconfNotificationOperationService implements NetconfOperationService {
private final Set<NetconfOperation> netconfOperations;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.mdsal.notification;
+package org.opendaylight.netconf.mdsal.notification.impl;
import java.util.Collections;
import java.util.Set;
* 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.config.yang.netconf.mdsal.notification;
+package org.opendaylight.netconf.mdsal.notification.impl;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
* 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.config.yang.netconf.mdsal.notification;
+package org.opendaylight.netconf.mdsal.notification.impl;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
* 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.config.yang.netconf.mdsal.notification;
+package org.opendaylight.netconf.mdsal.notification.impl;
import com.google.common.base.Preconditions;
import java.util.Collection;
* 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.netconf.notifications.impl.ops;
+package org.opendaylight.netconf.mdsal.notification.impl.ops;
import com.google.common.base.Preconditions;
import java.util.ArrayList;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.mapping.api.SessionAwareNetconfOperation;
+import org.opendaylight.netconf.mdsal.notification.impl.NetconfNotificationManager;
import org.opendaylight.netconf.notifications.NetconfNotification;
import org.opendaylight.netconf.notifications.NetconfNotificationListener;
import org.opendaylight.netconf.notifications.NetconfNotificationRegistry;
import org.opendaylight.netconf.notifications.NotificationListenerRegistration;
-import org.opendaylight.netconf.notifications.impl.NetconfNotificationManager;
import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
import org.opendaylight.netconf.util.messages.SubtreeFilter;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput;
* 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.netconf.notifications.impl.ops;
+package org.opendaylight.netconf.mdsal.notification.impl.ops;
import com.google.common.base.Preconditions;
import com.google.common.collect.Collections2;
<!--This is the MD-SAL netconf server notification blueprint xml file-->
<bean id="netconfNotificationManager"
- class="org.opendaylight.netconf.notifications.impl.NetconfNotificationManager"
+ class="org.opendaylight.netconf.mdsal.notification.impl.NetconfNotificationManager"
destroy-method="close">
</bean>
<service ref="netconfNotificationManager"
</service>
<bean id="notificationToMdsalWriter"
- class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.NotificationToMdsalWriter"
+ class="org.opendaylight.netconf.mdsal.notification.impl.NotificationToMdsalWriter"
init-method="start"
destroy-method="close">
<argument ref="netconfNotificationManager"/>
</bean>
<bean id="capabilityChangeNotificationProducer"
- class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.CapabilityChangeNotificationProducer"
+ class="org.opendaylight.netconf.mdsal.notification.impl.CapabilityChangeNotificationProducer"
destroy-method="close">
<argument ref="netconfNotificationManager"/>
<argument ref="dataBroker"/>
</bean>
<bean id="sessionNotificationProducer"
- class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.SessionNotificationProducer"
+ class="org.opendaylight.netconf.mdsal.notification.impl.SessionNotificationProducer"
destroy-method="close">
<argument ref="netconfNotificationManager"/>
<argument ref="dataBroker"/>
</bean>
<bean id="netconfNotificationOperationServiceFactory"
- class="org.opendaylight.netconf.mdsal.notification.NetconfNotificationOperationServiceFactory"
+ class="org.opendaylight.netconf.mdsal.notification.impl.NetconfNotificationOperationServiceFactory"
destroy-method="close">
<argument ref="netconfNotificationManager"/>
<argument ref="netconfOperationServiceFactoryListener"/>
* 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.config.yang.netconf.mdsal.notification;
+package org.opendaylight.netconf.mdsal.notification.impl;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.notifications.impl;
+package org.opendaylight.netconf.mdsal.notification.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
* 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.config.yang.netconf.mdsal.notification;
+package org.opendaylight.netconf.mdsal.notification.impl;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.config.yang.netconf.mdsal.notification;
+package org.opendaylight.netconf.mdsal.notification.impl;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
* 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.config.yang.netconf.mdsal.notification;
+package org.opendaylight.netconf.mdsal.notification.impl;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.notifications.impl.ops;
+package org.opendaylight.netconf.mdsal.notification.impl.ops;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.notifications.impl.ops;
+package org.opendaylight.netconf.mdsal.notification.impl.ops;
import static org.junit.Assert.assertTrue;
<artifactId>netconf-notifications-api</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-notifications-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mdsal-netconf-notification</artifactId>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-notifications-api</artifactId>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-notifications-impl</artifactId>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-netty-util</artifactId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-parent</artifactId>
- <version>1.6.0-SNAPSHOT</version>
- <relativePath>../netconf-parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-notifications-impl</artifactId>
- <version>1.6.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-notifications-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-generator-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-dom-codec</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ietf-netconf-notifications</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.xmlunit</groupId>
- <artifactId>xmlunit-legacy</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-Activator>org.opendaylight.netconf.notifications.impl.osgi.Activator</Bundle-Activator>
- <Export-Package>org.opendaylight.netconf.notifications.impl.*</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * 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.netconf.notifications.impl.ops;
-
-import com.google.common.base.Preconditions;
-import java.io.IOException;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.transform.dom.DOMResult;
-import org.opendaylight.netconf.api.DocumentedException;
-import org.opendaylight.netconf.api.xml.XmlElement;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.mapping.api.HandlingPriority;
-import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
-import org.opendaylight.netconf.notifications.NetconfNotificationRegistry;
-import org.opendaylight.netconf.util.NetconfUtil;
-import org.opendaylight.netconf.util.mapping.AbstractNetconfOperation;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.Netconf;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.NetconfBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Serialize the subtree for netconf notifications into the response of get rpc.
- * This operation just adds its subtree into the common response of get rpc.
- */
-public class Get extends AbstractNetconfOperation implements AutoCloseable {
-
- private static final String GET = "get";
- private static final InstanceIdentifier<Netconf> NETCONF_SUBTREE_INSTANCE_IDENTIFIER =
- InstanceIdentifier.builder(Netconf.class).build();
-
- private final NetconfNotificationRegistry notificationRegistry;
-
- public Get(final String netconfSessionIdForReporting, final NetconfNotificationRegistry notificationRegistry) {
- super(netconfSessionIdForReporting);
- Preconditions.checkNotNull(notificationRegistry);
- this.notificationRegistry = notificationRegistry;
- }
-
- @Override
- protected String getOperationName() {
- return GET;
- }
-
- @Override
- protected Element handle(final Document document, final XmlElement message,
- final NetconfOperationChainedExecution subsequentOperation) {
- throw new UnsupportedOperationException("Never gets called");
- }
-
- @Override
- public Document handle(final Document requestMessage, final NetconfOperationChainedExecution subsequentOperation)
- throws DocumentedException {
- final Document partialResponse = subsequentOperation.execute(requestMessage);
- final Streams availableStreams = notificationRegistry.getNotificationPublishers();
- if (!availableStreams.getStream().isEmpty()) {
- serializeStreamsSubtree(partialResponse, availableStreams);
- }
- return partialResponse;
- }
-
- static void serializeStreamsSubtree(final Document partialResponse, final Streams availableStreams)
- throws DocumentedException {
- final Netconf netconfSubtree = new NetconfBuilder().setStreams(availableStreams).build();
- final NormalizedNode<?, ?> normalized = toNormalized(netconfSubtree);
-
- final DOMResult result = new DOMResult(getPlaceholder(partialResponse));
-
- try {
- NetconfUtil.writeNormalizedNode(normalized, result, SchemaPath.ROOT,
- NotificationsTransformUtil.NOTIFICATIONS_SCHEMA_CTX);
- } catch (final XMLStreamException | IOException e) {
- throw new IllegalStateException("Unable to serialize " + netconfSubtree, e);
- }
- }
-
- private static Element getPlaceholder(final Document innerResult)
- throws DocumentedException {
- final XmlElement rootElement = XmlElement.fromDomElementWithExpected(innerResult.getDocumentElement(),
- XmlNetconfConstants.RPC_REPLY_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
- return rootElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY).getDomElement();
- }
-
- private static NormalizedNode<?, ?> toNormalized(final Netconf netconfSubtree) {
- return NotificationsTransformUtil.CODEC_REGISTRY
- .toNormalizedNode(NETCONF_SUBTREE_INSTANCE_IDENTIFIER, netconfSubtree).getValue();
- }
-
- @Override
- protected HandlingPriority getHandlingPriority() {
- return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.increasePriority(2);
- }
-
- @Override
- public void close() {
-
- }
-}
+++ /dev/null
-/*
- * 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.netconf.notifications.impl.osgi;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Sets;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Set;
-import org.opendaylight.netconf.api.capability.BasicCapability;
-import org.opendaylight.netconf.api.capability.Capability;
-import org.opendaylight.netconf.api.monitoring.CapabilityListener;
-import org.opendaylight.netconf.api.util.NetconfConstants;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-import org.opendaylight.netconf.notifications.NetconfNotification;
-import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
-import org.opendaylight.netconf.notifications.impl.NetconfNotificationManager;
-import org.opendaylight.netconf.notifications.impl.ops.CreateSubscription;
-import org.opendaylight.netconf.notifications.impl.ops.Get;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class Activator implements BundleActivator {
-
- private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
-
- private ServiceRegistration<NetconfNotificationCollector> netconfNotificationCollectorServiceRegistration;
- private ServiceRegistration<NetconfOperationServiceFactory> operationaServiceRegistration;
- private NetconfNotificationManager netconfNotificationManager;
-
- @Override
- public void start(final BundleContext context) {
- netconfNotificationManager = new NetconfNotificationManager();
- // Add properties to autowire with netconf-impl instance for cfg subsystem
- final Dictionary<String, String> props = new Hashtable<>();
- props.put(NetconfConstants.SERVICE_NAME, NetconfConstants.NETCONF_NOTIFICATION);
- netconfNotificationCollectorServiceRegistration = context.registerService(NetconfNotificationCollector.class,
- netconfNotificationManager, new Hashtable<>());
-
- final NetconfOperationServiceFactory netconfOperationServiceFactory = new NetconfOperationServiceFactory() {
-
- private final Set<Capability> capabilities =
- Collections.singleton(new BasicCapability(NetconfNotification.NOTIFICATION_NAMESPACE));
-
- @Override
- public Set<Capability> getCapabilities() {
- return capabilities;
- }
-
- @Override
- public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
- listener.onCapabilitiesChanged(capabilities, Collections.emptySet());
- return () -> listener.onCapabilitiesChanged(Collections.emptySet(), capabilities);
- }
-
- @Override
- public NetconfOperationService createService(final String netconfSessionIdForReporting) {
- return new NetconfOperationService() {
-
- private final CreateSubscription createSubscription =
- new CreateSubscription(netconfSessionIdForReporting, netconfNotificationManager);
-
- @Override
- public Set<NetconfOperation> getNetconfOperations() {
- return Sets.newHashSet(
- new Get(netconfSessionIdForReporting, netconfNotificationManager),
- createSubscription);
- }
-
- @Override
- public void close() {
- createSubscription.close();
- }
- };
- }
- };
-
- final Dictionary<String, String> properties = new Hashtable<>();
- properties.put(NetconfConstants.SERVICE_NAME, NetconfConstants.NETCONF_MONITORING);
- operationaServiceRegistration = context.registerService(NetconfOperationServiceFactory.class,
- netconfOperationServiceFactory, properties);
- }
-
- @Override
- public void stop(final BundleContext context) {
- if (netconfNotificationCollectorServiceRegistration != null) {
- netconfNotificationCollectorServiceRegistration.unregister();
- netconfNotificationCollectorServiceRegistration = null;
- }
- if (netconfNotificationManager != null) {
- netconfNotificationManager.close();
- }
- if (operationaServiceRegistration != null) {
- operationaServiceRegistration.unregister();
- operationaServiceRegistration = null;
- }
- }
-
- @VisibleForTesting
- NetconfNotificationManager getNetconfNotificationManager() {
- return netconfNotificationManager;
- }
-}
+++ /dev/null
-/*
- * 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.netconf.notifications.impl.ops;
-
-import com.google.common.collect.Lists;
-import java.io.IOException;
-import org.junit.Test;
-import org.opendaylight.netconf.api.xml.XmlUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.StreamsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamKey;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-public class GetTest {
-
- @Test
- public void testSerializeStreamsSubtree() throws Exception {
- final StreamsBuilder streamsBuilder = new StreamsBuilder();
- final StreamBuilder streamBuilder = new StreamBuilder();
- final StreamNameType base = new StreamNameType("base");
- streamBuilder.setName(base);
- streamBuilder.withKey(new StreamKey(base));
- streamBuilder.setDescription("description");
- streamBuilder.setReplaySupport(false);
- streamsBuilder.setStream(Lists.newArrayList(streamBuilder.build()));
- final Streams streams = streamsBuilder.build();
-
- final Document response = getBlankResponse();
- Get.serializeStreamsSubtree(response, streams);
- NotificationsTransformUtilTest.compareXml(XmlUtil.toString(response),
- "<rpc-reply message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
- + "<data>\n"
- + "<netconf xmlns=\"urn:ietf:params:xml:ns:netmod:notification\">\n"
- + "<streams>\n"
- + "<stream>\n"
- + "<name>base</name>\n"
- + "<description>description</description>\n"
- + "<replaySupport>false</replaySupport>\n"
- + "</stream>\n"
- + "</streams>\n"
- + "</netconf>\n"
- + "</data>\n"
- + "</rpc-reply>\n");
- }
-
- private static Document getBlankResponse() throws IOException, SAXException {
-
- return XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\"\n"
- + "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
- + "<data>\n"
- + "</data>\n"
- + "</rpc-reply>");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 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.netconf.notifications.impl.osgi;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doNothing;
-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.util.Collections;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Set;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.opendaylight.netconf.api.capability.BasicCapability;
-import org.opendaylight.netconf.api.capability.Capability;
-import org.opendaylight.netconf.api.monitoring.CapabilityListener;
-import org.opendaylight.netconf.api.util.NetconfConstants;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-import org.opendaylight.netconf.notifications.NetconfNotification;
-import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
-import org.opendaylight.netconf.notifications.impl.NetconfNotificationManager;
-import org.opendaylight.netconf.notifications.impl.ops.CreateSubscription;
-import org.opendaylight.netconf.notifications.impl.ops.Get;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-public class ActivatorTest {
-
- @Test
- public void testActivator() throws Exception {
- final Activator activator = new Activator();
- final BundleContext context = mock(BundleContext.class);
-
-
- final ServiceRegistration netconfNotificationCollectorServiceRegistration = mock(ServiceRegistration.class);
- final ServiceRegistration operationaServiceRegistration = mock(ServiceRegistration.class);
-
- // test registering services
- doReturn(netconfNotificationCollectorServiceRegistration).when(context)
- .registerService(eq(NetconfNotificationCollector.class), any(NetconfNotificationManager.class), any());
- doReturn(operationaServiceRegistration).when(context).registerService(eq(NetconfOperationServiceFactory.class),
- any(NetconfOperationServiceFactory.class), any());
-
- activator.start(context);
-
- verify(context, times(1)).registerService(eq(NetconfNotificationCollector.class),
- any(NetconfNotificationManager.class), eq(new Hashtable<>()));
-
- final ArgumentCaptor<NetconfOperationServiceFactory> serviceFactoryArgumentCaptor =
- ArgumentCaptor.forClass(NetconfOperationServiceFactory.class);
-
- final Dictionary<String, String> properties = new Hashtable<>();
- properties.put(NetconfConstants.SERVICE_NAME, NetconfConstants.NETCONF_MONITORING);
-
- verify(context, times(1)).registerService(eq(NetconfOperationServiceFactory.class),
- serviceFactoryArgumentCaptor.capture(), eq(properties));
-
- // test service factory argument requisites
- final NetconfOperationServiceFactory serviceFactory = serviceFactoryArgumentCaptor.getValue();
-
- final Set<Capability> capabilities =
- Collections.singleton(new BasicCapability(NetconfNotification.NOTIFICATION_NAMESPACE));
-
- assertEquals(capabilities.iterator().next()
- .getCapabilityUri(), serviceFactory.getCapabilities().iterator().next().getCapabilityUri());
- assertEquals(capabilities.iterator().next()
- .getCapabilitySchema(), serviceFactory.getCapabilities().iterator().next().getCapabilitySchema());
- assertEquals(capabilities.iterator().next()
- .getModuleNamespace(), serviceFactory.getCapabilities().iterator().next().getModuleNamespace());
- assertEquals(capabilities.iterator().next()
- .getModuleName(), serviceFactory.getCapabilities().iterator().next().getModuleName());
-
- final CapabilityListener listener = mock(CapabilityListener.class);
-
- doNothing().when(listener).onCapabilitiesChanged(any(), any());
-
- serviceFactory.registerCapabilityListener(listener);
-
- verify(listener).onCapabilitiesChanged(serviceFactory.getCapabilities(), Collections.emptySet());
-
- final NetconfOperationService netconfOperationService = serviceFactory.createService("id");
- final Set<NetconfOperation> netconfOperations = netconfOperationService.getNetconfOperations();
-
- final CreateSubscription createSubscription =
- new CreateSubscription("id", activator.getNetconfNotificationManager());
-
- netconfOperations.forEach(
- operation -> {
- if (operation instanceof CreateSubscription) {
- assertEquals(createSubscription.toString(), operation.toString());
- }
- if (operation instanceof Get) {
- assertEquals("id", ((Get) operation).getNetconfSessionIdForReporting());
- }
- }
- );
-
- // test unregister after stop
- doNothing().when(netconfNotificationCollectorServiceRegistration).unregister();
- doNothing().when(operationaServiceRegistration).unregister();
-
- activator.stop(context);
-
- verify(netconfNotificationCollectorServiceRegistration, times(1)).unregister();
- verify(operationaServiceRegistration, times(1)).unregister();
-
- }
-
-
-}
<module>netconf-client</module>
<module>netconf-auth</module>
<module>aaa-authn-odl-plugin</module>
- <module>netconf-notifications-impl</module>
<module>netconf-notifications-api</module>
<module>netconf-topology</module>
<module>netconf-topology-singleton</module>