Merge "Add netconf parent pom"
authorJakub Morvay <jakub.morvay@gmail.com>
Wed, 28 Mar 2018 22:52:16 +0000 (22:52 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 28 Mar 2018 22:52:16 +0000 (22:52 +0000)
42 files changed:
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/OperationProvider.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/AbstractEdit.java [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/CopyConfig.java [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/EditConfig.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/AbstractNetconfOperationTest.java [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/CopyConfigTest.java [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/NetconfMDSalMappingTest.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/SchemaServiceStub.java [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices1.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices2.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices3.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices4.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete_setup.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete_setup_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_container.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_container_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_presence_container.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_presence_container_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_setup.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_setup_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_update.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_update_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_no_config.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_no_source.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_no_target.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_setup.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_setup_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_update.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_update_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_running.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_augmentation.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_augmentation_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_modules.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_modules_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_setup.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_setup_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_update.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_update_control.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/test/resources/yang/mdsal-netconf-mapping-test.yang

index e74b0bdf4bf0a0187744e159195f2d742f5f9d38..59ccc29f084472546ec3c8adfaf7e54161e28077 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.netconf.mdsal.connector.ops.Commit;
+import org.opendaylight.netconf.mdsal.connector.ops.CopyConfig;
 import org.opendaylight.netconf.mdsal.connector.ops.DiscardChanges;
 import org.opendaylight.netconf.mdsal.connector.ops.EditConfig;
 import org.opendaylight.netconf.mdsal.connector.ops.Lock;
@@ -35,6 +36,7 @@ final class OperationProvider {
             new Commit(netconfSessionIdForReporting, transactionProvider),
             new DiscardChanges(netconfSessionIdForReporting, transactionProvider),
             new EditConfig(netconfSessionIdForReporting, schemaContext, transactionProvider),
+            new CopyConfig(netconfSessionIdForReporting, schemaContext, transactionProvider),
             new Get(netconfSessionIdForReporting, schemaContext, transactionProvider),
             new GetConfig(netconfSessionIdForReporting, schemaContext, transactionProvider),
             new Lock(netconfSessionIdForReporting),
diff --git a/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/AbstractEdit.java b/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/AbstractEdit.java
new file mode 100644 (file)
index 0000000..125f6b9
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2018 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.mdsal.connector.ops;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableMap;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Iterator;
+import java.util.Map;
+import javax.xml.transform.dom.DOMSource;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
+import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.NetconfDocumentedException;
+import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
+import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+abstract class AbstractEdit extends AbstractSingletonNetconfOperation {
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractEdit.class);
+    private static final String TARGET_KEY = "target";
+
+    protected final CurrentSchemaContext schemaContext;
+
+    protected AbstractEdit(final String netconfSessionIdForReporting, final CurrentSchemaContext schemaContext) {
+        super(netconfSessionIdForReporting);
+        this.schemaContext = schemaContext;
+    }
+
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    protected void parseIntoNormalizedNode(final DataSchemaNode schemaNode, final XmlElement element,
+                                         final NormalizedNodeStreamWriter writer) throws DocumentedException {
+        if (!(schemaNode instanceof ContainerSchemaNode) && !(schemaNode instanceof ListSchemaNode)) {
+            // This should never happen since any edit operation on any other node type
+            // should not be possible nor makes sense
+            LOG.debug("DataNode from module is not ContainerSchemaNode nor ListSchemaNode, aborting..");
+            throw new UnsupportedOperationException("implement exception if parse fails");
+        }
+
+        final XmlParserStream xmlParser = XmlParserStream.create(writer, schemaContext.getCurrentContext(), schemaNode);
+        try {
+            xmlParser.traverse(new DOMSource(element.getDomElement()));
+        } catch (final Exception ex) {
+            throw new NetconfDocumentedException("Error parsing input: " + ex.getMessage(), ex, ErrorType.PROTOCOL,
+                ErrorTag.MALFORMED_MESSAGE, ErrorSeverity.ERROR);
+        }
+    }
+
+    protected DataSchemaNode getSchemaNodeFromNamespace(final String namespace, final XmlElement element)
+        throws DocumentedException {
+        final Iterator<Module> it;
+        try {
+            // Returns module with newest revision since findModuleByNamespace returns a set of modules and we only
+            // need the newest one
+            it = schemaContext.getCurrentContext().findModules(new URI(namespace)).iterator();
+        } catch (final URISyntaxException e) {
+            throw new NetconfDocumentedException("Unable to create URI for namespace : " + namespace, e,
+                ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
+        }
+
+        if (!it.hasNext()) {
+            // No module is present with this namespace
+            throw new NetconfDocumentedException("Unable to find module by namespace: " + namespace,
+                ErrorType.APPLICATION, ErrorTag.UNKNOWN_NAMESPACE, ErrorSeverity.ERROR);
+        }
+
+        final Module module = it.next();
+        final java.util.Optional<DataSchemaNode> schemaNode =
+            module.findDataChildByName(QName.create(module.getQNameModule(), element.getName()));
+        if (!schemaNode.isPresent()) {
+            throw new DocumentedException(
+                "Unable to find node with namespace: " + namespace + "in module: " + module.toString(),
+                ErrorType.APPLICATION,
+                ErrorTag.UNKNOWN_NAMESPACE,
+                ErrorSeverity.ERROR);
+        }
+
+        return schemaNode.get();
+    }
+
+    protected static Datastore extractTargetParameter(final XmlElement operationElement, final String operationName)
+        throws DocumentedException {
+        final NodeList elementsByTagName = getElementsByTagName(operationElement, TARGET_KEY);
+        // Direct lookup instead of using XmlElement class due to performance
+        if (elementsByTagName.getLength() == 0) {
+            final Map<String, String> errorInfo = ImmutableMap.of("bad-attribute", TARGET_KEY, "bad-element",
+                operationName);
+            throw new DocumentedException("Missing target element", ErrorType.PROTOCOL, ErrorTag.MISSING_ATTRIBUTE,
+                ErrorSeverity.ERROR, errorInfo);
+        } else if (elementsByTagName.getLength() > 1) {
+            throw new DocumentedException("Multiple target elements", ErrorType.RPC, ErrorTag.UNKNOWN_ATTRIBUTE,
+                ErrorSeverity.ERROR);
+        } else {
+            final XmlElement targetChildNode =
+                XmlElement.fromDomElement((Element) elementsByTagName.item(0)).getOnlyChildElement();
+            return Datastore.valueOf(targetChildNode.getName());
+        }
+    }
+
+    protected static XmlElement getElement(final XmlElement parent, final String elementName)
+        throws DocumentedException {
+        final Optional<XmlElement> childNode = parent.getOnlyChildElementOptionally(elementName);
+        if (!childNode.isPresent()) {
+            throw new DocumentedException(elementName + " element is missing",
+                ErrorType.PROTOCOL,
+                ErrorTag.MISSING_ELEMENT,
+                ErrorSeverity.ERROR);
+        }
+
+        return childNode.get();
+    }
+
+    protected static NodeList getElementsByTagName(final XmlElement parent, final String key) throws
+        DocumentedException {
+        final Element domParent = parent.getDomElement();
+        final NodeList elementsByTagName;
+
+        if (Strings.isNullOrEmpty(domParent.getPrefix())) {
+            elementsByTagName = domParent.getElementsByTagName(key);
+        } else {
+            elementsByTagName = domParent.getElementsByTagNameNS(parent.getNamespace(), key);
+        }
+
+        return elementsByTagName;
+    }
+}
diff --git a/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/CopyConfig.java b/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/CopyConfig.java
new file mode 100644 (file)
index 0000000..9f0f9d9
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2018 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.mdsal.connector.ops;
+
+import com.google.common.base.Optional;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
+import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
+import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public final class CopyConfig extends AbstractEdit {
+    private static final String OPERATION_NAME = "copy-config";
+    private static final String CONFIG_KEY = "config";
+    private static final String SOURCE_KEY = "source";
+
+    // Top-level "data" node without child nodes
+    private static final ContainerNode EMPTY_ROOT_NODE = Builders.containerBuilder()
+        .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(SchemaContext.NAME)).build();
+
+    private final TransactionProvider transactionProvider;
+
+    public CopyConfig(final String netconfSessionIdForReporting, final CurrentSchemaContext schemaContext,
+                      final TransactionProvider transactionProvider) {
+        super(netconfSessionIdForReporting, schemaContext);
+        this.transactionProvider = transactionProvider;
+    }
+
+    @Override
+    protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
+            throws DocumentedException {
+        final Datastore targetDatastore = extractTargetParameter(operationElement, OPERATION_NAME);
+        if (targetDatastore == Datastore.running) {
+            throw new DocumentedException("edit-config on running datastore is not supported",
+                    ErrorType.PROTOCOL,
+                    ErrorTag.OPERATION_NOT_SUPPORTED,
+                    ErrorSeverity.ERROR);
+        }
+        final XmlElement configElement = extractConfigParameter(operationElement);
+
+        // <copy-config>, unlike <edit-config>, always replaces entire configuration,
+        // so remove old configuration first:
+        final DOMDataReadWriteTransaction rwTx = transactionProvider.getOrCreateTransaction();
+        rwTx.put(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY, EMPTY_ROOT_NODE);
+
+        // Then create nodes present in the <config> element:
+        for (final XmlElement element : configElement.getChildElements()) {
+            final String ns = element.getNamespace();
+            final DataSchemaNode schemaNode = getSchemaNodeFromNamespace(ns, element);
+            final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
+            parseIntoNormalizedNode(schemaNode, element, ImmutableNormalizedNodeStreamWriter.from(resultHolder));
+            final NormalizedNode<?, ?> data = resultHolder.getResult();
+            final YangInstanceIdentifier path = YangInstanceIdentifier.create(data.getIdentifier());
+            // Doing merge instead of put to support top-level list:
+            rwTx.merge(LogicalDatastoreType.CONFIGURATION, path, data);
+        }
+        return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
+    }
+
+    private static XmlElement extractConfigParameter(final XmlElement operationElement) throws DocumentedException {
+        final XmlElement source = getElement(operationElement, SOURCE_KEY);
+        return getElement(source, CONFIG_KEY);
+    }
+
+    @Override
+    protected String getOperationName() {
+        return OPERATION_NAME;
+    }
+}
index cfb59b871f0df643b9c8febb89bb4591ca8b8aa5..2da085290e7c434588f6226569d51cf906d3a57f 100644 (file)
@@ -8,20 +8,12 @@
 
 package org.opendaylight.netconf.mdsal.connector.ops;
 
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableMap;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
-import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
-import javax.xml.transform.dom.DOMSource;
 import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
 import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
@@ -30,27 +22,20 @@ import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
 import org.opendaylight.netconf.mdsal.connector.ops.DataTreeChangeTracker.DataTreeChange;
-import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
-import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.ModifyAction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 import org.slf4j.Logger;
@@ -59,28 +44,25 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
-public class EditConfig extends AbstractSingletonNetconfOperation {
+public final class EditConfig extends AbstractEdit {
 
     private static final Logger LOG = LoggerFactory.getLogger(EditConfig.class);
 
     private static final String OPERATION_NAME = "edit-config";
     private static final String CONFIG_KEY = "config";
-    private static final String TARGET_KEY = "target";
     private static final String DEFAULT_OPERATION_KEY = "default-operation";
-    private final CurrentSchemaContext schemaContext;
     private final TransactionProvider transactionProvider;
 
     public EditConfig(final String netconfSessionIdForReporting, final CurrentSchemaContext schemaContext,
             final TransactionProvider transactionProvider) {
-        super(netconfSessionIdForReporting);
-        this.schemaContext = schemaContext;
+        super(netconfSessionIdForReporting, schemaContext);
         this.transactionProvider = transactionProvider;
     }
 
     @Override
     protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
             throws DocumentedException {
-        final Datastore targetDatastore = extractTargetParameter(operationElement);
+        final Datastore targetDatastore = extractTargetParameter(operationElement, OPERATION_NAME);
         if (targetDatastore == Datastore.running) {
             throw new DocumentedException("edit-config on running datastore is not supported",
                     ErrorType.PROTOCOL,
@@ -94,11 +76,10 @@ public class EditConfig extends AbstractSingletonNetconfOperation {
 
         for (final XmlElement element : configElement.getChildElements()) {
             final String ns = element.getNamespace();
-            final DataSchemaNode schemaNode = getSchemaNodeFromNamespace(ns, element).get();
-
+            final DataSchemaNode schemaNode = getSchemaNodeFromNamespace(ns, element);
             final DataTreeChangeTracker changeTracker = new DataTreeChangeTracker(defaultAction);
-
-            parseIntoNormalizedNode(schemaNode, element, changeTracker);
+            parseIntoNormalizedNode(schemaNode, element,
+                new EditOperationNormalizedNodeStreamWriter(new NormalizedNodeResult(), changeTracker));
             executeOperations(changeTracker);
         }
 
@@ -208,81 +189,6 @@ public class EditConfig extends AbstractSingletonNetconfOperation {
         }
     }
 
-    @SuppressWarnings("checkstyle:IllegalCatch")
-    private NormalizedNode<?, ?> parseIntoNormalizedNode(final DataSchemaNode schemaNode, final XmlElement element,
-            final DataTreeChangeTracker changeTracker) throws DocumentedException {
-        if (!(schemaNode instanceof ContainerSchemaNode) && !(schemaNode instanceof ListSchemaNode)) {
-            //this should never happen since edit-config on any other node type should not be possible nor makes sense
-            LOG.debug("DataNode from module is not ContainerSchemaNode nor ListSchemaNode, aborting..");
-            throw new UnsupportedOperationException("implement exception if parse fails");
-        }
-
-        final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
-        final NormalizedNodeStreamWriter writer = new EditOperationNormalizedNodeStreamWriter(resultHolder,
-                changeTracker);
-        final XmlParserStream xmlParser = XmlParserStream.create(writer, schemaContext.getCurrentContext(), schemaNode);
-        try {
-            xmlParser.traverse(new DOMSource(element.getDomElement()));
-        } catch (final Exception ex) {
-            throw new NetconfDocumentedException("Error parsing input: " + ex.getMessage(), ex, ErrorType.PROTOCOL,
-                    ErrorTag.MALFORMED_MESSAGE, ErrorSeverity.ERROR);
-        }
-
-        return resultHolder.getResult();
-    }
-
-    private Optional<DataSchemaNode> getSchemaNodeFromNamespace(final String namespace, final XmlElement element)
-            throws DocumentedException {
-        final Iterator<Module> it;
-        try {
-            // returns module with newest revision since findModuleByNamespace returns a set of modules and we only
-            // need the newest one
-            it = schemaContext.getCurrentContext().findModules(new URI(namespace)).iterator();
-        } catch (final URISyntaxException e) {
-            LOG.debug("Unable to create URI for namespace : {}", namespace);
-            return Optional.absent();
-        }
-
-        if (!it.hasNext()) {
-            // no module is present with this namespace
-            throw new NetconfDocumentedException("Unable to find module by namespace: " + namespace,
-                ErrorType.APPLICATION, ErrorTag.UNKNOWN_NAMESPACE, ErrorSeverity.ERROR);
-        }
-
-        final Module module = it.next();
-        final java.util.Optional<DataSchemaNode> schemaNode =
-                module.findDataChildByName(QName.create(module.getQNameModule(), element.getName()));
-        if (!schemaNode.isPresent()) {
-            if (schemaNode != null) {
-                throw new DocumentedException(
-                    "Unable to find node with namespace: " + namespace + "in module: " + module.toString(),
-                    ErrorType.APPLICATION,
-                    ErrorTag.UNKNOWN_NAMESPACE,
-                    ErrorSeverity.ERROR);
-            }
-        }
-
-        return Optional.fromJavaUtil(schemaNode);
-    }
-
-    private static Datastore extractTargetParameter(final XmlElement operationElement) throws DocumentedException {
-        final NodeList elementsByTagName = getElementsByTagName(operationElement, TARGET_KEY);
-        // Direct lookup instead of using XmlElement class due to performance
-        if (elementsByTagName.getLength() == 0) {
-            final Map<String, String> errorInfo = ImmutableMap.of("bad-attribute", TARGET_KEY, "bad-element",
-                OPERATION_NAME);
-            throw new DocumentedException("Missing target element", ErrorType.PROTOCOL, ErrorTag.MISSING_ATTRIBUTE,
-                ErrorSeverity.ERROR, errorInfo);
-        } else if (elementsByTagName.getLength() > 1) {
-            throw new DocumentedException("Multiple target elements", ErrorType.RPC, ErrorTag.UNKNOWN_ATTRIBUTE,
-                ErrorSeverity.ERROR);
-        } else {
-            final XmlElement targetChildNode =
-                    XmlElement.fromDomElement((Element) elementsByTagName.item(0)).getOnlyChildElement();
-            return Datastore.valueOf(targetChildNode.getName());
-        }
-    }
-
     private static ModifyAction getDefaultOperation(final XmlElement operationElement) throws DocumentedException {
         final NodeList elementsByTagName = getElementsByTagName(operationElement, DEFAULT_OPERATION_KEY);
         if (elementsByTagName.getLength() == 0) {
@@ -296,34 +202,6 @@ public class EditConfig extends AbstractSingletonNetconfOperation {
 
     }
 
-    private static XmlElement getElement(final XmlElement operationElement, final String elementName)
-            throws DocumentedException {
-        final Optional<XmlElement> childNode = operationElement.getOnlyChildElementOptionally(elementName);
-        if (!childNode.isPresent()) {
-            throw new DocumentedException(elementName + " element is missing",
-                    ErrorType.PROTOCOL,
-                    ErrorTag.MISSING_ELEMENT,
-                    ErrorSeverity.ERROR);
-        }
-
-        return childNode.get();
-    }
-
-    @VisibleForTesting
-    static NodeList getElementsByTagName(final XmlElement operationElement, final String key) throws
-            DocumentedException {
-        final Element element = operationElement.getDomElement();
-        final NodeList elementsByTagName;
-
-        if (Strings.isNullOrEmpty(element.getPrefix())) {
-            elementsByTagName = element.getElementsByTagName(key);
-        } else {
-            elementsByTagName = element.getElementsByTagNameNS(operationElement.getNamespace(), key);
-        }
-
-        return elementsByTagName;
-    }
-
     @Override
     protected String getOperationName() {
         return OPERATION_NAME;
diff --git a/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/AbstractNetconfOperationTest.java b/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/AbstractNetconfOperationTest.java
new file mode 100644 (file)
index 0000000..555f201
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+ * Copyright (c) 2018 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.mdsal.connector.ops;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.google.common.io.ByteSource;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
+import java.io.StringWriter;
+import java.util.EnumMap;
+import java.util.concurrent.ExecutorService;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import org.custommonkey.xmlunit.DetailedDiff;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Before;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.core.spi.data.DOMStore;
+import org.opendaylight.netconf.mapping.api.NetconfOperation;
+import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
+import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
+import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
+import org.opendaylight.netconf.mdsal.connector.ops.get.Get;
+import org.opendaylight.netconf.mdsal.connector.ops.get.GetConfig;
+import org.opendaylight.netconf.util.test.NetconfXmlUnitRecursiveQualifier;
+import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+abstract class AbstractNetconfOperationTest {
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfOperationTest.class);
+    protected static final String SESSION_ID_FOR_REPORTING = "netconf-test-session1";
+    private static final String RPC_REPLY_ELEMENT = "rpc-reply";
+    private static final String DATA_ELEMENT = "data";
+    protected static final Document RPC_REPLY_OK = getReplyOk();
+
+    private CurrentSchemaContext currentSchemaContext;
+    private TransactionProvider transactionProvider;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+
+        XMLUnit.setIgnoreWhitespace(true);
+        XMLUnit.setIgnoreAttributeOrder(true);
+
+        final SchemaContext schemaContext = getSchemaContext();
+        final SchemaService schemaService = new SchemaServiceStub(schemaContext);
+        final DOMStore operStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", schemaService);
+        final DOMStore configStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", schemaService);
+
+        currentSchemaContext = new CurrentSchemaContext(schemaService, sourceIdentifier -> {
+            final YangTextSchemaSource yangTextSchemaSource =
+                YangTextSchemaSource.delegateForByteSource(sourceIdentifier, ByteSource.wrap("module test".getBytes()));
+            return Futures.immediateCheckedFuture(yangTextSchemaSource);
+        });
+
+        final EnumMap<LogicalDatastoreType, DOMStore> datastores = new EnumMap<>(LogicalDatastoreType.class);
+        datastores.put(LogicalDatastoreType.CONFIGURATION, configStore);
+        datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
+
+        final ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
+            16, 16, "CommitFutures", CopyConfigTest.class);
+
+        final SerializedDOMDataBroker sdb = new SerializedDOMDataBroker(datastores,
+            MoreExecutors.listeningDecorator(listenableFutureExecutor));
+        this.transactionProvider = new TransactionProvider(sdb, SESSION_ID_FOR_REPORTING);
+    }
+
+    protected abstract SchemaContext getSchemaContext();
+
+    protected CurrentSchemaContext getCurrentSchemaContext() {
+        return currentSchemaContext;
+    }
+
+    protected TransactionProvider getTransactionProvider() {
+        return transactionProvider;
+    }
+
+    @SuppressWarnings("illegalCatch")
+    private static Document getReplyOk() {
+        Document doc;
+        try {
+            doc = XmlFileLoader.xmlFileToDocument("messages/mapping/rpc-reply_ok.xml");
+        } catch (final Exception e) {
+            LOG.debug("unable to load rpc reply ok.", e);
+            doc = XmlUtil.newDocument();
+        }
+        return doc;
+    }
+
+    protected Document commit() throws Exception {
+        final Commit commit = new Commit(SESSION_ID_FOR_REPORTING, transactionProvider);
+        return executeOperation(commit, "messages/mapping/commit.xml");
+    }
+
+    protected Document discardChanges() throws Exception {
+        final DiscardChanges discardOp = new DiscardChanges(SESSION_ID_FOR_REPORTING, transactionProvider);
+        return executeOperation(discardOp, "messages/mapping/discardChanges.xml");
+    }
+
+    protected Document edit(final String resource) throws Exception {
+        final EditConfig editConfig = new EditConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext,
+            transactionProvider);
+        return executeOperation(editConfig, resource);
+    }
+
+    protected Document get() throws Exception {
+        final Get get = new Get(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
+        return executeOperation(get, "messages/mapping/get.xml");
+    }
+
+    protected Document getWithFilter(final String resource) throws Exception {
+        final Get get = new Get(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
+        return executeOperation(get, resource);
+    }
+
+    protected Document getConfigRunning() throws Exception {
+        final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
+        return executeOperation(getConfig, "messages/mapping/getConfig.xml");
+    }
+
+    protected Document getConfigCandidate() throws Exception {
+        final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
+        return executeOperation(getConfig, "messages/mapping/getConfig_candidate.xml");
+    }
+
+    protected Document getConfigWithFilter(final String resource) throws Exception {
+        final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
+        return executeOperation(getConfig, resource);
+    }
+
+    protected static Document lock() throws Exception {
+        final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
+        return executeOperation(lock, "messages/mapping/lock.xml");
+    }
+
+    protected static Document unlock() throws Exception {
+        final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
+        return executeOperation(unlock, "messages/mapping/unlock.xml");
+    }
+
+    protected static Document lockWithoutTarget() throws Exception {
+        final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
+        return executeOperation(lock, "messages/mapping/lock_notarget.xml");
+    }
+
+    protected static Document unlockWithoutTarget() throws Exception {
+        final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
+        return executeOperation(unlock, "messages/mapping/unlock_notarget.xml");
+    }
+
+    protected static Document lockCandidate() throws Exception {
+        final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
+        return executeOperation(lock, "messages/mapping/lock_candidate.xml");
+    }
+
+    protected static Document unlockCandidate() throws Exception {
+        final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
+        return executeOperation(unlock, "messages/mapping/unlock_candidate.xml");
+    }
+
+    protected static Document executeOperation(final NetconfOperation op, final String filename) throws Exception {
+        final Document request = XmlFileLoader.xmlFileToDocument(filename);
+        final Document response = op.handle(request, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT);
+
+        LOG.debug("Got response {}", response);
+        return response;
+    }
+
+    protected static void assertEmptyDatastore(final Document response) {
+        final NodeList nodes = response.getChildNodes();
+        assertTrue(nodes.getLength() == 1);
+
+        assertEquals(nodes.item(0).getLocalName(), RPC_REPLY_ELEMENT);
+
+        final NodeList replyNodes = nodes.item(0).getChildNodes();
+        assertTrue(replyNodes.getLength() == 1);
+
+        final Node dataNode = replyNodes.item(0);
+        assertEquals(dataNode.getLocalName(), DATA_ELEMENT);
+        assertFalse(dataNode.hasChildNodes());
+    }
+
+    protected static void verifyResponse(final Document response, final Document template) throws Exception {
+        final DetailedDiff dd = new DetailedDiff(new Diff(response, template));
+        dd.overrideElementQualifier(new NetconfXmlUnitRecursiveQualifier());
+        if (!dd.similar()) {
+            LOG.warn("Actual response:");
+            printDocument(response);
+            LOG.warn("Expected response:");
+            printDocument(template);
+            fail("Differences found: " + dd.toString());
+        }
+    }
+
+    private static void printDocument(final Document doc) throws Exception {
+        final TransformerFactory tf = TransformerFactory.newInstance();
+        final Transformer transformer = tf.newTransformer();
+        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
+        transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+        transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
+
+        final StringWriter writer = new StringWriter();
+        transformer.transform(new DOMSource(doc),
+            new StreamResult(writer));
+        LOG.warn(writer.getBuffer().toString());
+    }
+}
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/CopyConfigTest.java b/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/CopyConfigTest.java
new file mode 100644 (file)
index 0000000..e634dc4
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2018 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.mdsal.connector.ops;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.opendaylight.yangtools.yang.test.util.YangParserTestUtils.parseYangResources;
+
+import org.junit.Test;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
+import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.w3c.dom.Document;
+
+public class CopyConfigTest extends AbstractNetconfOperationTest {
+
+    @Override
+    protected SchemaContext getSchemaContext() {
+        return parseYangResources(CopyConfigTest.class,
+            "/yang/mdsal-netconf-mapping-test.yang");
+    }
+
+
+    @Test
+    public void testTargetMissing() throws Exception {
+        try {
+            copyConfig("messages/mapping/copyConfigs/copyConfig_no_target.xml");
+            fail("Should have failed - <target> element is missing");
+        } catch (final DocumentedException e) {
+            assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
+            assertTrue(e.getErrorTag() == ErrorTag.MISSING_ATTRIBUTE);
+            assertTrue(e.getErrorType() == ErrorType.PROTOCOL);
+        }
+    }
+
+    @Test
+    public void testSourceMissing() throws Exception {
+        try {
+            copyConfig("messages/mapping/copyConfigs/copyConfig_no_source.xml");
+            fail("Should have fanode1iled - <source> element is missing");
+        } catch (final DocumentedException e) {
+            assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
+            assertTrue(e.getErrorTag() == ErrorTag.MISSING_ELEMENT);
+            assertTrue(e.getErrorType() == ErrorType.PROTOCOL);
+        }
+    }
+
+    @Test
+    public void testConfigMissing() throws Exception {
+        try {
+            copyConfig("messages/mapping/copyConfigs/copyConfig_no_config.xml");
+            fail("Should have failed - <config> element is missing");
+        } catch (final DocumentedException e) {
+            assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
+            assertTrue(e.getErrorTag() == ErrorTag.MISSING_ELEMENT);
+            assertTrue(e.getErrorType() == ErrorType.PROTOCOL);
+        }
+    }
+
+    @Test
+    public void testRunning() throws Exception {
+        try {
+            copyConfig("messages/mapping/copyConfigs/copyConfig_running.xml");
+            fail("Should have failed - copy config on running datastore is not supported");
+        } catch (final DocumentedException e) {
+            assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
+            assertTrue(e.getErrorTag() == ErrorTag.OPERATION_NOT_SUPPORTED);
+            assertTrue(e.getErrorType() == ErrorType.PROTOCOL);
+        }
+    }
+
+    @Test
+    public void testCandidateTransaction() throws Exception {
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_top_modules.xml"), RPC_REPLY_OK);
+        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_top_modules_control.xml"));
+        assertEmptyDatastore(getConfigRunning());
+
+        verifyResponse(discardChanges(), RPC_REPLY_OK);
+        assertEmptyDatastore(getConfigCandidate());
+    }
+
+    @Test
+    public void testWithCommit() throws Exception {
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_top_modules.xml"), RPC_REPLY_OK);
+        final Document expectedConfig = XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_top_modules_control.xml");
+        verifyResponse(getConfigCandidate(), expectedConfig);
+
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), expectedConfig);
+    }
+
+    @Test
+    public void testDeleteSubtree() throws Exception {
+        // Initialize datastore
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_delete_setup.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_delete_setup_control.xml"));
+
+        // Issue second copy-config, this time without top container
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_delete.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_delete_control.xml"));
+    }
+
+    @Test
+    public void testList() throws Exception {
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_list_setup.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_list_setup_control.xml"));
+
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_list_update.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_list_update_control.xml"));
+    }
+
+    @Test
+    public void testOrderedList() throws Exception {
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_ordered_list_setup.xml"),
+            RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_ordered_list_setup_control.xml"));
+
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_ordered_list_update.xml"),
+            RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_ordered_list_update_control.xml"));
+    }
+
+    @Test
+    public void testToplevelList() throws Exception {
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_toplevel_list_setup.xml"),
+            RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_toplevel_list_setup_control.xml"));
+
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_toplevel_list_update.xml"),
+            RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_toplevel_list_update_control.xml"));
+    }
+
+    @Test
+    public void testEmptyContainer() throws Exception {
+        // Check that empty non-presence container is removed.
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_empty_container.xml"),
+            RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_empty_container_control.xml"));
+    }
+
+    @Test
+    public void testEmptyPresenceContainer() throws Exception {
+        // Check that empty presence container is not removed.
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_empty_presence_container.xml"),
+            RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_empty_presence_container_control.xml"));
+    }
+
+    @Test
+    public void testAugmentations() throws Exception {
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_top_augmentation.xml"),
+            RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_top_augmentation_control.xml"));
+    }
+
+    @Test
+    public void testChoices() throws Exception {
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_choices1.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_choices2.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_choices3.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_choices4.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+            "messages/mapping/copyConfigs/copyConfig_choices_control.xml"));
+    }
+
+    private Document copyConfig(final String resource) throws Exception {
+        final CopyConfig copyConfig = new CopyConfig(SESSION_ID_FOR_REPORTING, getCurrentSchemaContext(),
+            getTransactionProvider());
+        return executeOperation(copyConfig, resource);
+    }
+}
\ No newline at end of file
index a514ca46dd763aaf8c02873500c2580d889c921e..a7709ecd0ebb6b9db70c610d6a620d5a0ef9f3ab 100644 (file)
@@ -9,75 +9,42 @@
 package org.opendaylight.netconf.mdsal.connector.ops;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doAnswer;
 
-import com.google.common.io.ByteSource;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.MoreExecutors;
 import java.io.StringWriter;
-import java.util.EnumMap;
-import java.util.concurrent.ExecutorService;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
-import org.custommonkey.xmlunit.DetailedDiff;
-import org.custommonkey.xmlunit.Diff;
-import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
-import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
 import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
 import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
 import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
-import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
-import org.opendaylight.netconf.mdsal.connector.ops.get.Get;
 import org.opendaylight.netconf.mdsal.connector.ops.get.GetConfig;
-import org.opendaylight.netconf.util.test.NetconfXmlUnitRecursiveQualifier;
 import org.opendaylight.netconf.util.test.XmlFileLoader;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-public class NetconfMDSalMappingTest {
+public class NetconfMDSalMappingTest extends AbstractNetconfOperationTest {
     private static final Logger LOG = LoggerFactory.getLogger(NetconfMDSalMappingTest.class);
 
     private static final String TARGET_KEY = "target";
-    private static final String RPC_REPLY_ELEMENT = "rpc-reply";
-    private static final String DATA_ELEMENT = "data";
     private static final String FILTER_NODE = "filter";
     private static final String GET_CONFIG = "get-config";
     private static final QName TOP = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "top");
@@ -101,63 +68,11 @@ public class NetconfMDSalMappingTest {
 
     private static final YangInstanceIdentifier AUGMENTED_CONTAINER_IN_MODULES =
             YangInstanceIdentifier.builder().node(TOP).node(MODULES).build();
-    private static final String SESSION_ID_FOR_REPORTING = "netconf-test-session1";
-    private static final Document RPC_REPLY_OK = NetconfMDSalMappingTest.getReplyOk();
 
-    private CurrentSchemaContext currentSchemaContext = null;
-    private SchemaContext schemaContext = null;
-    private TransactionProvider transactionProvider = null;
-
-    @Mock
-    private SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
-
-    @SuppressWarnings("illegalCatch")
-    private static Document getReplyOk() {
-        Document doc;
-        try {
-            doc = XmlFileLoader.xmlFileToDocument("messages/mapping/rpc-reply_ok.xml");
-        } catch (final Exception e) {
-            LOG.debug("unable to load rpc reply ok.", e);
-            doc = XmlUtil.newDocument();
-        }
-        return doc;
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
-        XMLUnit.setIgnoreWhitespace(true);
-        XMLUnit.setIgnoreAttributeOrder(true);
-
-        this.schemaContext = YangParserTestUtils.parseYangResources(NetconfMDSalMappingTest.class,
+    @Override
+    protected SchemaContext getSchemaContext() {
+        return YangParserTestUtils.parseYangResources(NetconfMDSalMappingTest.class,
             "/META-INF/yang/config@2013-04-05.yang", "/yang/mdsal-netconf-mapping-test.yang");
-        schemaContext.getModules();
-        final SchemaService schemaService = createSchemaService();
-
-        final DOMStore operStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", schemaService);
-        final DOMStore configStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", schemaService);
-
-        final EnumMap<LogicalDatastoreType, DOMStore> datastores = new EnumMap<>(LogicalDatastoreType.class);
-        datastores.put(LogicalDatastoreType.CONFIGURATION, configStore);
-        datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
-
-        final ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
-                16, 16, "CommitFutures", NetconfMDSalMappingTest.class);
-
-        final SerializedDOMDataBroker sdb = new SerializedDOMDataBroker(datastores,
-                MoreExecutors.listeningDecorator(listenableFutureExecutor));
-        this.transactionProvider = new TransactionProvider(sdb, SESSION_ID_FOR_REPORTING);
-
-        doAnswer(invocationOnMock -> {
-            final SourceIdentifier sId = (SourceIdentifier) invocationOnMock.getArguments()[0];
-            final YangTextSchemaSource yangTextSchemaSource =
-                    YangTextSchemaSource.delegateForByteSource(sId, ByteSource.wrap("module test".getBytes()));
-            return Futures.immediateFuture(yangTextSchemaSource);
-
-        }).when(sourceProvider).getSource(any(SourceIdentifier.class));
-
-        this.currentSchemaContext = new CurrentSchemaContext(schemaService, sourceProvider);
     }
 
     @Test
@@ -170,8 +85,8 @@ public class NetconfMDSalMappingTest {
     @Test
     public void testIncorrectGet() throws Exception {
         try {
-            executeOperation(new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider),
-                    "messages/mapping/bad_getConfig.xml");
+            executeOperation(new GetConfig(SESSION_ID_FOR_REPORTING, getCurrentSchemaContext(),
+                    getTransactionProvider()), "messages/mapping/bad_getConfig.xml");
             fail("Should have failed, this is an incorrect request");
         } catch (final DocumentedException e) {
             assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
@@ -180,8 +95,8 @@ public class NetconfMDSalMappingTest {
         }
 
         try {
-            executeOperation(new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider),
-                    "messages/mapping/bad_namespace_getConfig.xml");
+            executeOperation(new GetConfig(SESSION_ID_FOR_REPORTING, getCurrentSchemaContext(),
+                    getTransactionProvider()), "messages/mapping/bad_namespace_getConfig.xml");
             fail("Should have failed, this is an incorrect request");
         } catch (final DocumentedException e) {
             assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
@@ -692,8 +607,8 @@ public class NetconfMDSalMappingTest {
 
     private void verifyFilterIdentifier(final String resource, final YangInstanceIdentifier identifier)
             throws Exception {
-        final TestingGetConfig getConfig = new TestingGetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext,
-                transactionProvider);
+        final TestingGetConfig getConfig = new TestingGetConfig(SESSION_ID_FOR_REPORTING, getCurrentSchemaContext(),
+                getTransactionProvider());
         final Document request = XmlFileLoader.xmlFileToDocument(resource);
         final YangInstanceIdentifier iid = getConfig.getInstanceIdentifierFromDocument(request);
         assertEquals(identifier, iid);
@@ -719,148 +634,4 @@ public class NetconfMDSalMappingTest {
         verifyResponse(commit(), RPC_REPLY_OK);
         assertEmptyDatastore(getConfigRunning());
     }
-
-    private static void verifyResponse(final Document response, final Document template) throws Exception {
-        final DetailedDiff dd = new DetailedDiff(new Diff(response, template));
-        dd.overrideElementQualifier(new NetconfXmlUnitRecursiveQualifier());
-
-        printDocument(response);
-        printDocument(template);
-
-        assertTrue(dd.toString(), dd.similar());
-    }
-
-    private static void assertEmptyDatastore(final Document response) {
-        final NodeList nodes = response.getChildNodes();
-        assertTrue(nodes.getLength() == 1);
-
-        assertEquals(nodes.item(0).getLocalName(), RPC_REPLY_ELEMENT);
-
-        final NodeList replyNodes = nodes.item(0).getChildNodes();
-        assertTrue(replyNodes.getLength() == 1);
-
-        final Node dataNode = replyNodes.item(0);
-        assertEquals(dataNode.getLocalName(), DATA_ELEMENT);
-        assertFalse(dataNode.hasChildNodes());
-    }
-
-    private Document commit() throws Exception {
-        final Commit commit = new Commit(SESSION_ID_FOR_REPORTING, transactionProvider);
-        return executeOperation(commit, "messages/mapping/commit.xml");
-    }
-
-    private Document discardChanges() throws Exception {
-        final DiscardChanges discardOp = new DiscardChanges(SESSION_ID_FOR_REPORTING, transactionProvider);
-        return executeOperation(discardOp, "messages/mapping/discardChanges.xml");
-    }
-
-    private Document edit(final String resource) throws Exception {
-        final EditConfig editConfig = new EditConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext,
-                transactionProvider);
-        return executeOperation(editConfig, resource);
-    }
-
-    private Document get() throws Exception {
-        final Get get = new Get(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
-        return executeOperation(get, "messages/mapping/get.xml");
-    }
-
-    private Document getWithFilter(final String resource) throws Exception {
-        final Get get = new Get(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
-        return executeOperation(get, resource);
-    }
-
-    private Document getConfigRunning() throws Exception {
-        final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
-        return executeOperation(getConfig, "messages/mapping/getConfig.xml");
-    }
-
-    private Document getConfigCandidate() throws Exception {
-        final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
-        return executeOperation(getConfig, "messages/mapping/getConfig_candidate.xml");
-    }
-
-    private Document getConfigWithFilter(final String resource) throws Exception {
-        final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
-        return executeOperation(getConfig, resource);
-    }
-
-    private static Document lock() throws Exception {
-        final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
-        return executeOperation(lock, "messages/mapping/lock.xml");
-    }
-
-    private static Document unlock() throws Exception {
-        final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
-        return executeOperation(unlock, "messages/mapping/unlock.xml");
-    }
-
-    private static Document lockWithoutTarget() throws Exception {
-        final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
-        return executeOperation(lock, "messages/mapping/lock_notarget.xml");
-    }
-
-    private static Document unlockWithoutTarget() throws Exception {
-        final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
-        return executeOperation(unlock, "messages/mapping/unlock_notarget.xml");
-    }
-
-    private static Document lockCandidate() throws Exception {
-        final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
-        return executeOperation(lock, "messages/mapping/lock_candidate.xml");
-    }
-
-    private static Document unlockCandidate() throws Exception {
-        final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
-        return executeOperation(unlock, "messages/mapping/unlock_candidate.xml");
-    }
-
-    private static Document executeOperation(final NetconfOperation op, final String filename) throws Exception {
-        final Document request = XmlFileLoader.xmlFileToDocument(filename);
-        final Document response = op.handle(request, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT);
-
-        LOG.debug("Got response {}", response);
-        return response;
-    }
-
-    private SchemaService createSchemaService() {
-        return new SchemaService() {
-
-            @Override
-            public void addModule(final Module module) {
-            }
-
-            @Override
-            public void removeModule(final Module module) {
-
-            }
-
-            @Override
-            public SchemaContext getSessionContext() {
-                return schemaContext;
-            }
-
-            @Override
-            public SchemaContext getGlobalContext() {
-                return schemaContext;
-            }
-
-            @Override
-            public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
-                    final SchemaContextListener listener) {
-                listener.onGlobalContextUpdated(getGlobalContext());
-                return new ListenerRegistration<SchemaContextListener>() {
-                    @Override
-                    public void close() {
-
-                    }
-
-                    @Override
-                    public SchemaContextListener getInstance() {
-                        return listener;
-                    }
-                };
-            }
-        };
-    }
 }
diff --git a/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/SchemaServiceStub.java b/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/SchemaServiceStub.java
new file mode 100644 (file)
index 0000000..206beab
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2018 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.mdsal.connector.ops;
+
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+
+final class SchemaServiceStub implements SchemaService {
+    private final SchemaContext schemaContext;
+
+    SchemaServiceStub(SchemaContext schemaContext) {
+        this.schemaContext = schemaContext;
+    }
+
+    @Override
+    public void addModule(final Module module) {
+    }
+
+    @Override
+    public void removeModule(final Module module) {
+
+    }
+
+    @Override
+    public SchemaContext getSessionContext() {
+        return schemaContext;
+    }
+
+    @Override
+    public SchemaContext getGlobalContext() {
+        return schemaContext;
+    }
+
+    @Override
+    public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
+        final SchemaContextListener listener) {
+        listener.onGlobalContextUpdated(getGlobalContext());
+        return new ListenerRegistration<SchemaContextListener>() {
+            @Override
+            public void close() {
+            }
+
+            @Override
+            public SchemaContextListener getInstance() {
+                return listener;
+            }
+        };
+    }
+}
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices1.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices1.xml
new file mode 100644 (file)
index 0000000..2fc05cd
--- /dev/null
@@ -0,0 +1,22 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <text>some text</text>
+                </top>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices2.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices2.xml
new file mode 100644 (file)
index 0000000..2817458
--- /dev/null
@@ -0,0 +1,24 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <text-cont>
+                        <text>some text</text>
+                    </text-cont>
+                </top>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices3.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices3.xml
new file mode 100644 (file)
index 0000000..a2242fe
--- /dev/null
@@ -0,0 +1,22 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <augmented-case>augmented case text</augmented-case>
+                </top>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices4.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices4.xml
new file mode 100644 (file)
index 0000000..423b545
--- /dev/null
@@ -0,0 +1,24 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <choice-wrapper>
+                        <text2>some text</text2>
+                    </choice-wrapper>
+                </top>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_choices_control.xml
new file mode 100644 (file)
index 0000000..378417f
--- /dev/null
@@ -0,0 +1,17 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <top xmlns="urn:opendaylight:mdsal:mapping:test">
+            <choice-wrapper>
+                <text2>some text</text2>
+            </choice-wrapper>
+        </top>
+    </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete.xml
new file mode 100644 (file)
index 0000000..e9bdf41
--- /dev/null
@@ -0,0 +1,25 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <mapping-node>
+                        <id>node1</id>
+                        <content>content1</content>
+                    </mapping-node>
+                </mapping-nodes>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete_control.xml
new file mode 100644 (file)
index 0000000..0d177bc
--- /dev/null
@@ -0,0 +1,18 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+            <mapping-node>
+                <id>node1</id>
+                <content>content1</content>
+            </mapping-node>
+        </mapping-nodes>
+    </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete_setup.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete_setup.xml
new file mode 100644 (file)
index 0000000..68491b7
--- /dev/null
@@ -0,0 +1,43 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <mapping-node>
+                        <id>node1</id>
+                        <content>content1</content>
+                    </mapping-node>
+                </mapping-nodes>
+                <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <modules>
+                        <augmented-container>
+                            <identifier>augmented container</identifier>
+                        </augmented-container>
+                        <module>
+                            <id>module1</id>
+                            <type>type1</type>
+                            <desc>module1-desc</desc>
+                        </module>
+                        <module>
+                            <id>module2</id>
+                        </module>
+                        <module>
+                            <id>module3</id>
+                        </module>
+                    </modules>
+                </top>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete_setup_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_delete_setup_control.xml
new file mode 100644 (file)
index 0000000..9ec309a
--- /dev/null
@@ -0,0 +1,36 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+            <mapping-node>
+                <id>node1</id>
+                <content>content1</content>
+            </mapping-node>
+        </mapping-nodes>
+        <top xmlns="urn:opendaylight:mdsal:mapping:test">
+            <modules>
+                <augmented-container>
+                    <identifier>augmented container</identifier>
+                </augmented-container>
+                <module>
+                    <id>module1</id>
+                    <type>type1</type>
+                    <desc>module1-desc</desc>
+                </module>
+                <module>
+                    <id>module2</id>
+                </module>
+                <module>
+                    <id>module3</id>
+                </module>
+            </modules>
+        </top>
+    </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_container.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_container.xml
new file mode 100644 (file)
index 0000000..9249683
--- /dev/null
@@ -0,0 +1,21 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                </top>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_container_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_container_control.xml
new file mode 100644 (file)
index 0000000..34d9b31
--- /dev/null
@@ -0,0 +1,11 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data/>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_presence_container.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_presence_container.xml
new file mode 100644 (file)
index 0000000..df5c5ce
--- /dev/null
@@ -0,0 +1,20 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <top-with-presence xmlns="urn:opendaylight:mdsal:mapping:test" />
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_presence_container_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_empty_presence_container_control.xml
new file mode 100644 (file)
index 0000000..9bae4a6
--- /dev/null
@@ -0,0 +1,13 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <top-with-presence xmlns="urn:opendaylight:mdsal:mapping:test" />
+    </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_setup.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_setup.xml
new file mode 100644 (file)
index 0000000..14f9ea1
--- /dev/null
@@ -0,0 +1,33 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <mapping-node>
+                        <id>node1</id>
+                        <content>content1</content>
+                    </mapping-node>
+                    <mapping-node>
+                        <id>node2</id>
+                        <content>content2</content>
+                    </mapping-node>
+                    <mapping-node>
+                        <id>node3</id>
+                        <content>content3</content>
+                    </mapping-node>
+                </mapping-nodes>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_setup_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_setup_control.xml
new file mode 100644 (file)
index 0000000..b75333d
--- /dev/null
@@ -0,0 +1,26 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+            <mapping-node>
+                <id>node1</id>
+                <content>content1</content>
+            </mapping-node>
+            <mapping-node>
+                <id>node2</id>
+                <content>content2</content>
+            </mapping-node>
+            <mapping-node>
+                <id>node3</id>
+                <content>content3</content>
+            </mapping-node>
+        </mapping-nodes>
+    </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_update.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_update.xml
new file mode 100644 (file)
index 0000000..477a2fc
--- /dev/null
@@ -0,0 +1,33 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <mapping-node>
+                        <id>new_node</id>
+                        <content>new_node content</content>
+                    </mapping-node>
+                    <mapping-node>
+                        <id>node2</id>
+                        <content>content2</content>
+                    </mapping-node>
+                    <mapping-node>
+                        <id>node3</id>
+                        <content>updated content3</content>
+                    </mapping-node>
+                </mapping-nodes>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_update_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_list_update_control.xml
new file mode 100644 (file)
index 0000000..9ad53ba
--- /dev/null
@@ -0,0 +1,26 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+            <mapping-node>
+                <id>new_node</id>
+                <content>new_node content</content>
+            </mapping-node>
+            <mapping-node>
+                <id>node2</id>
+                <content>content2</content>
+            </mapping-node>
+            <mapping-node>
+                <id>node3</id>
+                <content>updated content3</content>
+            </mapping-node>
+        </mapping-nodes>
+    </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_no_config.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_no_config.xml
new file mode 100644 (file)
index 0000000..8149192
--- /dev/null
@@ -0,0 +1,17 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_no_source.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_no_source.xml
new file mode 100644 (file)
index 0000000..822977d
--- /dev/null
@@ -0,0 +1,15 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_no_target.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_no_target.xml
new file mode 100644 (file)
index 0000000..0a72ca3
--- /dev/null
@@ -0,0 +1,22 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <source>
+            <config>
+                <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <mapping-node>
+                        <id>node1-put</id>
+                        <content>put content</content>
+                    </mapping-node>
+                </mapping-nodes>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_setup.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_setup.xml
new file mode 100644 (file)
index 0000000..defe15c
--- /dev/null
@@ -0,0 +1,46 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <mapping-node>
+                        <id>id</id>
+                        <ordered-items>
+                            <ordered-item>
+                                <id>item1</id>
+                                <content>content1</content>
+                            </ordered-item>
+                            <ordered-item>
+                                <id>item2</id>
+                                <content>content2</content>
+                            </ordered-item>
+                            <ordered-item>
+                                <id>item3</id>
+                                <content>content3</content>
+                            </ordered-item>
+                            <ordered-item>
+                                <id>item4</id>
+                                <content>content4</content>
+                            </ordered-item>
+                            <ordered-item>
+                                <id>item5</id>
+                                <content>content5</content>
+                            </ordered-item>
+                        </ordered-items>
+                    </mapping-node>
+                </mapping-nodes>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_setup_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_setup_control.xml
new file mode 100644 (file)
index 0000000..3212491
--- /dev/null
@@ -0,0 +1,39 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+            <mapping-node>
+                <id>id</id>
+                <ordered-items>
+                    <ordered-item>
+                        <id>item1</id>
+                        <content>content1</content>
+                    </ordered-item>
+                    <ordered-item>
+                        <id>item2</id>
+                        <content>content2</content>
+                    </ordered-item>
+                    <ordered-item>
+                        <id>item3</id>
+                        <content>content3</content>
+                    </ordered-item>
+                    <ordered-item>
+                        <id>item4</id>
+                        <content>content4</content>
+                    </ordered-item>
+                    <ordered-item>
+                        <id>item5</id>
+                        <content>content5</content>
+                    </ordered-item>
+                </ordered-items>
+            </mapping-node>
+        </mapping-nodes>
+    </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_update.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_update.xml
new file mode 100644 (file)
index 0000000..4789895
--- /dev/null
@@ -0,0 +1,42 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <mapping-node>
+                        <id>id</id>
+                        <ordered-items>
+                            <ordered-item>
+                                <id>item1</id>
+                                <content>udated content1</content>
+                            </ordered-item>
+                            <ordered-item>
+                                <id>new_item</id>
+                                <content>new_item content</content>
+                            </ordered-item>
+                            <ordered-item>
+                                <id>item2</id>
+                                <content>content2</content>
+                            </ordered-item>
+                            <ordered-item>
+                                <id>item5</id>
+                                <content>content5</content>
+                            </ordered-item>
+                        </ordered-items>
+                    </mapping-node>
+                </mapping-nodes>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_update_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_ordered_list_update_control.xml
new file mode 100644 (file)
index 0000000..4cc2131
--- /dev/null
@@ -0,0 +1,35 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+            <mapping-node>
+                <id>id</id>
+                <ordered-items>
+                    <ordered-item>
+                        <id>item1</id>
+                        <content>udated content1</content>
+                    </ordered-item>
+                    <ordered-item>
+                        <id>new_item</id>
+                        <content>new_item content</content>
+                    </ordered-item>
+                    <ordered-item>
+                        <id>item2</id>
+                        <content>content2</content>
+                    </ordered-item>
+                    <ordered-item>
+                        <id>item5</id>
+                        <content>content5</content>
+                    </ordered-item>
+                </ordered-items>
+            </mapping-node>
+        </mapping-nodes>
+    </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_running.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_running.xml
new file mode 100644 (file)
index 0000000..2190a2d
--- /dev/null
@@ -0,0 +1,25 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <running/>
+        </target>
+        <source>
+            <config>
+                <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <mapping-node>
+                        <id>node1-put</id>
+                        <content>put content</content>
+                    </mapping-node>
+                </mapping-nodes>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_augmentation.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_augmentation.xml
new file mode 100644 (file)
index 0000000..b9769ac
--- /dev/null
@@ -0,0 +1,43 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <modules>
+                        <augmented-container>
+                            <identifier>augmented container</identifier>
+                        </augmented-container>
+                        <module>
+                            <id>module1</id>
+                            <type>type1</type>
+                            <desc>module1-desc</desc>
+                        </module>
+                    </modules>
+                    <mid-level>
+                        <low-level>
+                            <lowest-level>
+                                <note>note1</note>
+                                <note>note2</note>
+                            </lowest-level>
+                        </low-level>
+                        <low-level2>
+                            <note>note1</note>
+                            <note>note2</note>
+                        </low-level2>
+                    </mid-level>
+                </top>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_augmentation_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_augmentation_control.xml
new file mode 100644 (file)
index 0000000..bb09a7f
--- /dev/null
@@ -0,0 +1,36 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <top xmlns="urn:opendaylight:mdsal:mapping:test">
+            <modules>
+                <augmented-container>
+                    <identifier>augmented container</identifier>
+                </augmented-container>
+                <module>
+                    <id>module1</id>
+                    <type>type1</type>
+                    <desc>module1-desc</desc>
+                </module>
+            </modules>
+            <mid-level>
+                <low-level>
+                    <lowest-level>
+                        <note>note1</note>
+                        <note>note2</note>
+                    </lowest-level>
+                </low-level>
+                <low-level2>
+                    <note>note1</note>
+                    <note>note2</note>
+                </low-level2>
+            </mid-level>
+        </top>
+    </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_modules.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_modules.xml
new file mode 100644 (file)
index 0000000..2cecb4b
--- /dev/null
@@ -0,0 +1,29 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <modules>
+                        <module>
+                            <id>module1</id>
+                        </module>
+                        <module>
+                            <id>module2</id>
+                        </module>
+                    </modules>
+                </top>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_modules_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_top_modules_control.xml
new file mode 100644 (file)
index 0000000..3ab7eeb
--- /dev/null
@@ -0,0 +1,22 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <top xmlns="urn:opendaylight:mdsal:mapping:test">
+            <modules>
+                <module>
+                    <id>module1</id>
+                </module>
+                <module>
+                    <id>module2</id>
+                </module>
+            </modules>
+        </top>
+    </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_setup.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_setup.xml
new file mode 100644 (file)
index 0000000..f93dfda
--- /dev/null
@@ -0,0 +1,31 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <id>item1</id>
+                    <content>content1</content>
+                </toplevel-list>
+                <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <id>item2</id>
+                    <content>content2</content>
+                </toplevel-list>
+                <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <id>item3</id>
+                    <content>content3</content>
+                </toplevel-list>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_setup_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_setup_control.xml
new file mode 100644 (file)
index 0000000..08947b4
--- /dev/null
@@ -0,0 +1,24 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+            <id>item1</id>
+            <content>content1</content>
+        </toplevel-list>
+        <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+            <id>item2</id>
+            <content>content2</content>
+        </toplevel-list>
+        <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+            <id>item3</id>
+            <content>content3</content>
+        </toplevel-list>
+    </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_update.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_update.xml
new file mode 100644 (file)
index 0000000..0ce09fa
--- /dev/null
@@ -0,0 +1,27 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <copy-config>
+        <target>
+            <candidate/>
+        </target>
+        <source>
+            <config>
+                <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <id>new_item</id>
+                    <content>new_item content</content>
+                </toplevel-list>
+                <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+                    <id>item3</id>
+                    <content>updated content3</content>
+                </toplevel-list>
+            </config>
+        </source>
+    </copy-config>
+</rpc>
\ No newline at end of file
diff --git a/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_update_control.xml b/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/copyConfigs/copyConfig_toplevel_list_update_control.xml
new file mode 100644 (file)
index 0000000..014b45c
--- /dev/null
@@ -0,0 +1,20 @@
+<!--
+  ~ Copyright (c) 2018 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
+  -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+            <id>new_item</id>
+            <content>new_item content</content>
+        </toplevel-list>
+        <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+            <id>item3</id>
+            <content>updated content3</content>
+        </toplevel-list>
+    </data>
+</rpc-reply>
\ No newline at end of file
index 2557dbcc86f33bee9a16315ea43c228d950cd778..86fbc3481df0bf58b2bfd7bee8f352ef2edcc408 100644 (file)
@@ -210,4 +210,20 @@ module config {
             }
         }
     }
+
+    list toplevel-list {
+        key "id";
+        leaf id {
+            type string;
+        }
+
+        leaf content {
+            type string;
+        }
+    }
+
+    container top-with-presence {
+        presence "For testing presence containers";
+
+    }
 }
\ No newline at end of file