final NormalizedNodeStreamWriter nnStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter,
schemaContext.getCurrentContext(), getSchemaPath(dataRoot));
- final NormalizedNodeWriter nnWriter = NormalizedNodeWriter.forStreamWriter(nnStreamWriter);
+ final NormalizedNodeWriter nnWriter = NormalizedNodeWriter.forStreamWriter(nnStreamWriter, true);
writeRootElement(xmlWriter, nnWriter, (ContainerNode) data);
return result.getNode();
}
+ @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 {
--- /dev/null
+<!--
+ ~ Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+<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
--- /dev/null
+<!--
+ ~ Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<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
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 {