Add more serialization assertions
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / persisted / ShardDataTreeSnapshotTest.java
index 333f3e9b247528a5d79805359f44c1965d7e9288..9327f6262fea5d000e0692c33c728ac2d2afd23b 100644 (file)
@@ -47,9 +47,12 @@ public class ShardDataTreeSnapshotTest {
             snapshot.serialize(out);
         }
 
+        final byte[] bytes = bos.toByteArray();
+        assertEquals(242, bytes.length);
+
         ShardDataTreeSnapshot deserialized;
-        try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()))) {
-            deserialized = ShardDataTreeSnapshot.deserialize(in);
+        try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes))) {
+            deserialized = ShardDataTreeSnapshot.deserialize(in).getSnapshot();
         }
 
         Optional<NormalizedNode<?, ?>> actualNode = deserialized.getRootNode();
@@ -73,9 +76,12 @@ public class ShardDataTreeSnapshotTest {
             snapshot.serialize(out);
         }
 
+        final byte[] bytes = bos.toByteArray();
+        assertEquals(390, bytes.length);
+
         ShardDataTreeSnapshot deserialized;
-        try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()))) {
-            deserialized = ShardDataTreeSnapshot.deserialize(in);
+        try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes))) {
+            deserialized = ShardDataTreeSnapshot.deserialize(in).getSnapshot();
         }
 
         Optional<NormalizedNode<?, ?>> actualNode = deserialized.getRootNode();
@@ -91,7 +97,7 @@ public class ShardDataTreeSnapshotTest {
 
         private final String data;
 
-        TestShardDataTreeSnapshotMetadata(String data) {
+        TestShardDataTreeSnapshotMetadata(final String data) {
             this.data = data;
         }
 
@@ -111,7 +117,7 @@ public class ShardDataTreeSnapshotTest {
         }
 
         @Override
-        public boolean equals(Object obj) {
+        public boolean equals(final Object obj) {
             return obj instanceof TestShardDataTreeSnapshotMetadata
                     && data.equals(((TestShardDataTreeSnapshotMetadata)obj).data);
         }
@@ -123,17 +129,17 @@ public class ShardDataTreeSnapshotTest {
             public Proxy() {
             }
 
-            Proxy(String data) {
+            Proxy(final String data) {
                 this.data = data;
             }
 
             @Override
-            public void writeExternal(ObjectOutput out) throws IOException {
+            public void writeExternal(final ObjectOutput out) throws IOException {
                 out.writeObject(data);
             }
 
             @Override
-            public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
                 data = (String) in.readObject();
             }