Add an explicit namespace sharing test 91/84691/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 24 Sep 2019 13:16:15 +0000 (15:16 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 25 Sep 2019 05:56:03 +0000 (07:56 +0200)
This adds a test to target QName/QNameModule/String reference
differentiation.

JIRA: CONTROLLER-1919
Change-Id: Iad736a81f627da4a04753b380acb530ccc8ba219
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/SerializationUtilsTest.java

index ad54834..3888426 100644 (file)
@@ -29,6 +29,7 @@ import org.junit.Test;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
@@ -116,6 +117,25 @@ public class SerializationUtilsTest {
         assertTrue(applierCalled.get());
     }
 
+    @Test
+    public void testSerializeDeserializeAugmentNoref() throws IOException {
+        final YangInstanceIdentifier expected = YangInstanceIdentifier.create(
+            AugmentationIdentifier.create(ImmutableSet.of(
+                QName.create("foo", "leaf1"),
+                QName.create("bar", "leaf2"))));
+
+        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        final DataOutput out = new DataOutputStream(bos);
+        SerializationUtils.writePath(out, expected);
+
+        final byte[] bytes = bos.toByteArray();
+        assertEquals(47, bytes.length);
+
+        final DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
+        final YangInstanceIdentifier read = SerializationUtils.readPath(in);
+        assertEquals(expected, read);
+    }
+
     private static NormalizedNode<?, ?> deserializeNormalizedNode(final byte[] bytes) throws IOException {
         return SerializationUtils.readNormalizedNode(new DataInputStream(new ByteArrayInputStream(bytes))).get();
     }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.