X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2Fstream%2FNormalizedNodeStreamReaderWriterTest.java;h=6528f2e4d2e6524f2f08acb750aae764c86dbc0b;hb=669ca536b9d889c65e91da66af61988f9d4271dd;hp=8854fc73b5ebffb656f07ea83b4a7443ba69d81e;hpb=47ad11bd477096d9ffcf568e071ba68baabdbe6e;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java index 8854fc73b5..6528f2e4d2 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java @@ -17,13 +17,17 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.util.TestModel; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; 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.api.schema.stream.NormalizedNodeWriter; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class NormalizedNodeStreamReaderWriterTest { @@ -31,7 +35,7 @@ public class NormalizedNodeStreamReaderWriterTest { @Test public void testNormalizedNodeStreamReaderWriter() throws IOException { - testNormalizedNodeStreamReaderWriter(TestModel.createTestContainer()); + testNormalizedNodeStreamReaderWriter(createTestContainer()); QName toaster = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","toaster"); QName darknessFactor = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","darknessFactor"); @@ -44,6 +48,34 @@ public class NormalizedNodeStreamReaderWriterTest { withChild(toasterNode).build()); } + private NormalizedNode createTestContainer() { + byte[] bytes1 = {1,2,3}; + LeafSetEntryNode entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)). + withValue(bytes1).build(); + + byte[] bytes2 = {}; + LeafSetEntryNode entry2 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)). + withValue(bytes2).build(); + + LeafSetEntryNode entry3 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, null)). + withValue(null).build(); + + + return TestModel.createBaseTestContainerBuilder(). + withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME)). + withChild(entry1).withChild(entry2).withChild(entry3).build()). + withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1,2,3,4})). + withChild(Builders.orderedMapBuilder(). + withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.ORDERED_LIST_QNAME)). + withChild(ImmutableNodes.mapEntry(TestModel.ORDERED_LIST_ENTRY_QNAME, + TestModel.ID_QNAME, 11)).build()). + build(); + } + private void testNormalizedNodeStreamReaderWriter(NormalizedNode input) throws IOException { byte[] byteData = null;