Add an explicit namespace sharing test
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / SerializationUtilsTest.java
index ad548340e398480e0e5b1ea3017521378ff1ed2d..388842661c2488dc84c33de61bb5da4b54895303 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();
     }