X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2FNormalizedNodeToNodeCodecTest.java;h=c42865c659192e0584ebe93a147fee655ab284c4;hp=1b85d46fc6ebdfa9b13de079db728b9dadf2beac;hb=56a9f42fe2b4a62cd2fed644e5c71d7a21176c7f;hpb=c74d5c2399e500fe3e690edc8cee497b1cb6f867 diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java index 1b85d46fc6..c42865c659 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java @@ -13,9 +13,9 @@ package org.opendaylight.controller.cluster.datastore.node; import junit.framework.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory; import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeGetter; import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator; +import org.opendaylight.controller.cluster.datastore.node.utils.PathUtils; import org.opendaylight.controller.cluster.datastore.util.TestModel; import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container; import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node; @@ -24,7 +24,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import java.util.ArrayList; import java.util.List; import static junit.framework.Assert.assertEquals; @@ -43,21 +42,9 @@ public class NormalizedNodeToNodeCodecTest { } private YangInstanceIdentifier instanceIdentifierFromString(String s) { - - String[] ids = s.split("/"); - - List pathArguments = new ArrayList<>(); - for (String nodeId : ids) { - if (!"".equals(nodeId)) { - pathArguments.add(NodeIdentifierFactory.getArgument(nodeId)); - } - } - final YangInstanceIdentifier instanceIdentifier = - YangInstanceIdentifier.create(pathArguments); - return instanceIdentifier; + return PathUtils.toYangInstanceIdentifier(s); } - @Test public void testNormalizeNodeAttributesToProtoBuffNode() { final NormalizedNode documentOne = TestModel.createTestContainer(); @@ -69,7 +56,7 @@ public class NormalizedNodeToNodeCodecTest { NormalizedNodeGetter normalizedNodeGetter = new NormalizedNodeGetter(id); new NormalizedNodeNavigator(normalizedNodeGetter).navigate( - YangInstanceIdentifier.builder().build().toString(), documentOne); + PathUtils.toString(YangInstanceIdentifier.builder().build()), documentOne); // Validate the value of id can be retrieved from the normalized node NormalizedNode output = normalizedNodeGetter.getOutput(); @@ -78,8 +65,12 @@ public class NormalizedNodeToNodeCodecTest { NormalizedNodeToNodeCodec codec = new NormalizedNodeToNodeCodec(schemaContext); + long start = System.currentTimeMillis(); Container container = codec.encode(instanceIdentifierFromString(id), output); + long end = System.currentTimeMillis(); + + System.out.println("Timetaken to encode :"+(end-start)); assertNotNull(container); assertEquals(id, container.getParentPath() + "/" @@ -89,8 +80,12 @@ public class NormalizedNodeToNodeCodecTest { // first get the node representation of normalized node final Node node = container.getNormalizedNode(); + start = System.currentTimeMillis(); NormalizedNode normalizedNode = codec.decode(instanceIdentifierFromString(id), node); + end = System.currentTimeMillis(); + + System.out.println("Timetaken to decode :"+(end-start)); assertEquals(normalizedNode.getValue().toString(), output.getValue() .toString());