Move byte-based serialization method 89/82389/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 3 Jun 2019 18:52:36 +0000 (20:52 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 4 Jun 2019 00:08:15 +0000 (02:08 +0200)
This is only used in testing, move the method out to testing class.

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

index 3a04347..7e0de62 100644 (file)
@@ -9,11 +9,9 @@ package org.opendaylight.controller.cluster.datastore.node.utils.stream;
 
 import com.google.common.base.Preconditions;
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.DataInput;
 import java.io.DataInputStream;
 import java.io.DataOutput;
-import java.io.DataOutputStream;
 import java.io.IOException;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -116,12 +114,6 @@ public final class SerializationUtils {
         }
     }
 
-    public static byte [] serializeNormalizedNode(NormalizedNode<?, ?> node) {
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        serializeNormalizedNode(node, new DataOutputStream(bos));
-        return bos.toByteArray();
-    }
-
     public static void serializePath(YangInstanceIdentifier path, DataOutput out) {
         Preconditions.checkNotNull(path);
         try {
index 50d06ad..25b4f2a 100644 (file)
@@ -49,7 +49,7 @@ public class SerializationUtilsTest {
     @Test
     public void testSerializeDeserializeNodes() {
         final NormalizedNode<?, ?> normalizedNode = createNormalizedNode();
-        final byte[] bytes = SerializationUtils.serializeNormalizedNode(normalizedNode);
+        final byte[] bytes = serializeNormalizedNode(normalizedNode);
         Assert.assertEquals(normalizedNode, SerializationUtils.deserializeNormalizedNode(bytes));
 
     }
@@ -63,7 +63,7 @@ public class SerializationUtilsTest {
                 .withNodeIdentifier(id("anyXmlNode"))
                 .withValue(new DOMSource(parse))
                 .build();
-        final byte[] bytes = SerializationUtils.serializeNormalizedNode(anyXmlNode);
+        final byte[] bytes = serializeNormalizedNode(anyXmlNode);
         final NormalizedNode<?, ?> deserialized = SerializationUtils.deserializeNormalizedNode(bytes);
         final DOMSource value = (DOMSource) deserialized.getValue();
         final Diff diff = XMLUnit.compareXML((Document) anyXmlNode.getValue().getNode(),
@@ -104,6 +104,12 @@ public class SerializationUtilsTest {
         Assert.assertTrue(applierCalled.get());
     }
 
+    private static byte[] serializeNormalizedNode(final NormalizedNode<?, ?> node) {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        SerializationUtils.serializeNormalizedNode(node, new DataOutputStream(bos));
+        return bos.toByteArray();
+    }
+
     private static NormalizedNode<?, ?> createNormalizedNode() {
         final LeafSetNode<Object> leafSetNode = Builders.leafSetBuilder()
                 .withNodeIdentifier(id("leafSetNode"))

©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.