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=ac8fa418fcc65c61af21fa06735c66f06a047859;hp=a9f9c722deefd942f3259fea3f05a929d42aa827;hb=8ec73bf853a9b6708b455c0321a585992e02b125;hpb=36f7cda0765248e257702addbff6f50da7ab0dd6 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 a9f9c722de..ac8fa418fc 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 @@ -1,15 +1,17 @@ /* + * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. * - * Copyright (c) 2014 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 - * + * 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 */ package org.opendaylight.controller.cluster.datastore.node; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import java.util.List; import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeGetter; @@ -24,16 +26,7 @@ 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.List; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - public class NormalizedNodeToNodeCodecTest { - - - private SchemaContext schemaContext; @Before @@ -42,7 +35,7 @@ public class NormalizedNodeToNodeCodecTest { assertNotNull("Schema context must not be null.", schemaContext); } - private YangInstanceIdentifier instanceIdentifierFromString(String s) { + private static YangInstanceIdentifier instanceIdentifierFromString(String s) { return PathUtils.toYangInstanceIdentifier(s); } @@ -57,10 +50,10 @@ public class NormalizedNodeToNodeCodecTest { NormalizedNodeGetter normalizedNodeGetter = new NormalizedNodeGetter(id); new NormalizedNodeNavigator(normalizedNodeGetter).navigate( - PathUtils.toString(YangInstanceIdentifier.builder().build()), documentOne); + PathUtils.toString(YangInstanceIdentifier.EMPTY), documentOne); // Validate the value of id can be retrieved from the normalized node - NormalizedNode output = normalizedNodeGetter.getOutput(); + NormalizedNode output = normalizedNodeGetter.getOutput(); assertNotNull(output); @@ -68,15 +61,12 @@ public class NormalizedNodeToNodeCodecTest { new NormalizedNodeToNodeCodec(schemaContext); long start = System.currentTimeMillis(); Container container = - codec.encode(instanceIdentifierFromString(id), output); + codec.encode(output); long end = System.currentTimeMillis(); System.out.println("Timetaken to encode :"+(end-start)); assertNotNull(container); - assertEquals(id, container.getParentPath() + "/" - + NormalizedNodeSerializer.deSerialize(container.getNormalizedNode(), - container.getNormalizedNode().getPathArgument())); // Decode the normalized node from the ProtocolBuffer form // first get the node representation of normalized node @@ -84,7 +74,7 @@ public class NormalizedNodeToNodeCodecTest { start = System.currentTimeMillis(); NormalizedNode normalizedNode = - codec.decode(instanceIdentifierFromString(id), node); + codec.decode(node); end = System.currentTimeMillis(); System.out.println("Timetaken to decode :"+(end-start)); @@ -102,26 +92,18 @@ public class NormalizedNodeToNodeCodecTest { new NormalizedNodeToNodeCodec(schemaContext); Container container = - normalizedNodeToNodeCodec.encode(YangInstanceIdentifier.builder() - .build(), documentOne); + normalizedNodeToNodeCodec.encode(documentOne); final NormalizedNode decode = normalizedNodeToNodeCodec .decode( - instanceIdentifierFromString("/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"), container.getNormalizedNode()); assertNotNull(decode); // let us ensure that the return decode normalized node encode returns same container Container containerResult = - normalizedNodeToNodeCodec.encode(YangInstanceIdentifier.builder() - .build(), decode); - - assertEquals(container.getParentPath(), containerResult.getParentPath()); - - assertEquals(containerResult.getNormalizedNode().getChildCount(), - container.getNormalizedNode().getChildCount()); + normalizedNodeToNodeCodec.encode(decode); // check first level children are proper List childrenResult = @@ -174,11 +156,11 @@ public class NormalizedNodeToNodeCodecTest { NormalizedNodeToNodeCodec codec = new NormalizedNodeToNodeCodec(schemaContext); - Container encode = codec.encode(identifier, uno); + Container encode = codec.encode(uno); System.out.println(encode.getNormalizedNode()); - codec.decode(identifier, encode.getNormalizedNode()); + codec.decode(encode.getNormalizedNode()); } }