Add netconf test to verify key ordering in output 57/30257/1
authorMaros Marsalek <mmarsale@cisco.com>
Thu, 26 Nov 2015 16:00:08 +0000 (17:00 +0100)
committerMaros Marsalek <mmarsale@cisco.com>
Thu, 26 Nov 2015 16:00:17 +0000 (17:00 +0100)
Change-Id: Ife737433c720ea5da4ff35e849644d7df8237c70
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/NetconfMDSalMappingTest.java
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_keys_1.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_keys_1_control.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/yang/mdsal-netconf-mapping-test.yang

index 06c4c48d140bb70bd9e9c035ad48188ea63cbfb2..a392bbbba844af89dfe01af1b64c4c88d24b7a2b 100644 (file)
@@ -209,6 +209,25 @@ public class NetconfMDSalMappingTest {
 
     }
 
+    @Test
+    public void testKeyOrder() throws Exception {
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_keys_1.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+        final Document configRunning = getConfigRunning();
+        final String responseAsString = XmlUtil.toString(configRunning);
+        verifyResponse(configRunning, XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_keys_1_control.xml"));
+
+        final int key3 = responseAsString.indexOf("key3");
+        final int key1 = responseAsString.indexOf("key1");
+        final int key2 = responseAsString.indexOf("key2");
+
+        assertTrue(String.format("Key ordering invalid, should be key3(%d) < key1(%d) < key2(%d)", key3, key1, key2),
+            key3 < key1 && key1 < key2);
+
+        deleteDatastore();
+    }
+
+
     @Test
     public void testMultipleEditsWithMerge() throws Exception {
 
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_keys_1.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_keys_1.xml
new file mode 100644 (file)
index 0000000..6b9ce73
--- /dev/null
@@ -0,0 +1,30 @@
+<!--
+  ~ Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+  ~
+  ~ This program and the accompanying materials are made available under the
+  ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+  ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+  -->
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <edit-config>
+        <target>
+            <candidate/>
+        </target>
+        <test-option>
+            set
+        </test-option>
+        <default-operation>merge</default-operation>
+        <config>
+            <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+                <multiple-keys>
+                    <!-- We can handle keys out of order -->
+                    <value2>22</value2>
+                    <key2>2</key2>
+                    <key1>1</key1>
+                    <value1>11</value1>
+                    <key3>3</key3>
+                </multiple-keys>
+            </mapping-nodes>
+        </config>
+    </edit-config>
+</rpc>
\ No newline at end of file
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_keys_1_control.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_keys_1_control.xml
new file mode 100644 (file)
index 0000000..01a8661
--- /dev/null
@@ -0,0 +1,21 @@
+<!--
+  ~ Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+  ~
+  ~ This program and the accompanying materials are made available under the
+  ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+  ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+  -->
+
+<rpc-reply id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+        <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+            <multiple-keys>
+                <key3>3</key3>
+                <key1>1</key1>
+                <key2>2</key2>
+                <value2>22</value2>
+                <value1>11</value1>
+            </multiple-keys>
+        </mapping-nodes>
+    </data>
+</rpc-reply>
\ No newline at end of file
index 399ae4b3bc423976353856de4eb2a9c8d9c92d2b..50c975e0b37efccd7cab639b4c10d319ed19329d 100644 (file)
@@ -7,6 +7,30 @@ module config {
 
     container mapping-nodes {
 
+        list multiple-keys {
+            key "key3 key1 key2";
+
+            leaf value1 {
+                type string;
+            }
+
+            leaf key1 {
+                type string;
+            }
+
+            leaf value2 {
+                type string;
+            }
+
+            leaf key2 {
+                type string;
+            }
+
+            leaf key3 {
+                type string;
+            }
+        }
+        
         list mapping-node{
             key "id";
             leaf id {