NETCONF-529: add support for <copy-config> 05/69605/4
authorMarek Gradzki <mgradzki@cisco.com>
Wed, 14 Mar 2018 17:09:20 +0000 (18:09 +0100)
committerMarek Gradzki <mgradzki@cisco.com>
Wed, 28 Mar 2018 15:31:54 +0000 (17:31 +0200)
While <edit-config> is enough to configure any Netconf device,
<copy-config> is more user friendly in scenarios,
when entire configuration has to be written in single request, e.g.
there is no need for explicit delete of nodes that were present in DS.

This patch adds support for <copy-config> to mdsal-netconf-connector.
Only <candidate/> is supported.

To be included in subsequent patches:
- move common test code to AbstractNetconfOperationTest
- move common edit-config and copy-config code to AbstractEdit class

Change-Id: I4eb2d1d1c82e60acc1502b01265de5ec3aab4cd8
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
38 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/CopyConfig.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/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/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..89a9080
--- /dev/null
@@ -0,0 +1,213 @@
+/*
+ * 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.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.util.mapping.AbstractSingletonNetconfOperation;
+import org.opendaylight.yangtools.yang.common.QName;
+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.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.ImmutableNormalizedNodeStreamWriter;
+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.SchemaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class CopyConfig extends AbstractSingletonNetconfOperation {
+    private static final Logger LOG = LoggerFactory.getLogger(CopyConfig.class);
+
+    private static final String OPERATION_NAME = "copy-config";
+    private static final String CONFIG_KEY = "config";
+    private static final String TARGET_KEY = "target";
+    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 CurrentSchemaContext schemaContext;
+    private final TransactionProvider transactionProvider;
+
+    public CopyConfig(final String netconfSessionIdForReporting, final CurrentSchemaContext schemaContext,
+                      final TransactionProvider transactionProvider) {
+        super(netconfSessionIdForReporting);
+        this.schemaContext = schemaContext;
+        this.transactionProvider = transactionProvider;
+    }
+
+    @Override
+    protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
+            throws DocumentedException {
+        final Datastore targetDatastore = extractTargetParameter(operationElement);
+        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 NormalizedNode<?, ?> data = parseIntoNormalizedNode(schemaNode, element);
+            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());
+    }
+
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    private NormalizedNode<?, ?> parseIntoNormalizedNode(final DataSchemaNode schemaNode, final XmlElement element)
+        throws DocumentedException {
+        if (!(schemaNode instanceof ContainerSchemaNode) && !(schemaNode instanceof ListSchemaNode)) {
+            // this should never happen since copy-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 = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
+        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 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();
+    }
+
+    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.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT,
+                ErrorSeverity.ERROR);
+        } else {
+            final XmlElement targetChildNode =
+                    XmlElement.fromDomElement((Element) elementsByTagName.item(0)).getOnlyChildElement();
+            return Datastore.valueOf(targetChildNode.getName());
+        }
+    }
+
+    private static XmlElement extractConfigParameter(final XmlElement operationElement) throws DocumentedException {
+        final Optional<XmlElement> sourceNode = operationElement.getOnlyChildElementOptionally(SOURCE_KEY);
+        if (!sourceNode.isPresent()) {
+            throw new DocumentedException(SOURCE_KEY + " element is missing",
+                ErrorType.PROTOCOL,
+                ErrorTag.MISSING_ELEMENT,
+                ErrorSeverity.ERROR);
+        }
+        final Optional<XmlElement> configNode =
+            sourceNode.get().getOnlyChildElementOptionally(CONFIG_KEY);
+        if (!configNode.isPresent()) {
+            throw new DocumentedException(CONFIG_KEY + " element is missing",
+                ErrorType.PROTOCOL,
+                ErrorTag.MISSING_ELEMENT,
+                ErrorSeverity.ERROR);
+        }
+        return configNode.get();
+    }
+
+    private 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/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..914ac11
--- /dev/null
@@ -0,0 +1,353 @@
+/*
+ * 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 static org.opendaylight.yangtools.yang.test.util.YangParserTestUtils.parseYangResources;
+
+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.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier;
+import org.junit.Before;
+import org.junit.Test;
+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.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.GetConfig;
+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;
+
+public class CopyConfigTest {
+    private static final Logger LOG = LoggerFactory.getLogger(CopyConfigTest.class);
+    private 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";
+    private 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 = parseYangResources(CopyConfigTest.class,
+            "/yang/mdsal-netconf-mapping-test.yang");
+        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);
+    }
+
+    @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"));
+    }
+
+    @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;
+    }
+
+    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 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 copyConfig(final String resource) throws Exception {
+        final CopyConfig copyConfig = new CopyConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext,
+            transactionProvider);
+        return executeOperation(copyConfig, resource);
+    }
+
+    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 static void verifyResponse(final Document response, final Document template) throws Exception {
+        final DetailedDiff dd = new DetailedDiff(new Diff(response, template));
+        dd.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
+        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());
+    }
+
+    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());
+    }
+
+}
\ No newline at end of file
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