Add sal-akka-raft serialization assertions 09/103509/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 2 Dec 2022 06:55:33 +0000 (07:55 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 2 Dec 2022 06:55:33 +0000 (07:55 +0100)
We need to be in control of serialized payload size. This patch adds the
assertions on sizes.

Change-Id: Ic73724d0acc51d7d7f28acb392fe569f719762c9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
16 files changed:
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/base/messages/TimeoutNowTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerIdentifierTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/client/messages/ShutdownTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesReplyTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/InstallSnapshotReplyTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/InstallSnapshotTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/RequestVoteReplyTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/RequestVoteTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/ApplyJournalEntriesTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/DeleteEntriesTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/EmptyStateTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/ServerConfigurationPayloadTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/SimpleReplicatedLogEntryTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/SnapshotTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/UpdateElectionTermTest.java

index 26cdb22d8ccc42569dc04bddf4d5ad9da7bb6cb9..375990e10609a3ee87c668463de55cf50085def1 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.raft.base.messages;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;
 
 import org.apache.commons.lang.SerializationUtils;
@@ -18,10 +19,11 @@ import org.junit.Test;
  * @author Thomas Pantelis
  */
 public class TimeoutNowTest {
-
     @Test
     public void test() {
-        TimeoutNow cloned = (TimeoutNow) SerializationUtils.clone(TimeoutNow.INSTANCE);
+        final var bytes = SerializationUtils.serialize(TimeoutNow.INSTANCE);
+        assertEquals(187, bytes.length);
+        final var cloned = SerializationUtils.deserialize(bytes);
         assertSame("Cloned instance", TimeoutNow.INSTANCE, cloned);
     }
 }
index a9305a6862f32f3737a194ad6ef601f6e77baff0..e0b7d61f0e4ce3ecb79c19c239591c18aa7a1d6a 100644 (file)
@@ -18,11 +18,12 @@ import org.junit.Test;
  * @author Thomas Pantelis
  */
 public class FollowerIdentifierTest {
-
     @Test
     public void testSerialization() {
-        FollowerIdentifier expected = new FollowerIdentifier("follower1");
-        FollowerIdentifier cloned = (FollowerIdentifier) SerializationUtils.clone(expected);
+        final var expected = new FollowerIdentifier("follower1");
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(109, bytes.length);
+        final var cloned = (FollowerIdentifier) SerializationUtils.deserialize(bytes);
         assertEquals("cloned", expected, cloned);
     }
 }
index 81b9fbbb860bd98767d0283379ce849526b13f1f..ea3bd7e4724c18038e551f180adeedee805d50c4 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.raft.client.messages;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;
 
 import org.apache.commons.lang.SerializationUtils;
@@ -18,10 +19,11 @@ import org.junit.Test;
  * @author Thomas Pantelis
  */
 public class ShutdownTest {
-
     @Test
     public void test() {
-        Shutdown cloned = (Shutdown) SerializationUtils.clone(Shutdown.INSTANCE);
+        final var bytes = SerializationUtils.serialize(Shutdown.INSTANCE);
+        assertEquals(187, bytes.length);
+        final var cloned = SerializationUtils.deserialize(bytes);
         assertSame("Cloned instance", Shutdown.INSTANCE, cloned);
     }
 }
index 8452a71c24a1b14faf5525b9513eebf80bda1722..8c09729e101ee8ccbf4634b645ae89add3e0408b 100644 (file)
@@ -19,12 +19,14 @@ import org.opendaylight.controller.cluster.raft.RaftVersions;
  * @author Thomas Pantelis
  */
 public class AppendEntriesReplyTest {
-
     @Test
     public void testSerialization() {
-        AppendEntriesReply expected = new AppendEntriesReply("follower", 5, true, 100, 4, (short)6, true, true,
-                RaftVersions.CURRENT_VERSION);
-        AppendEntriesReply cloned = (AppendEntriesReply) SerializationUtils.clone(expected);
+        final var expected = new AppendEntriesReply("follower", 5, true, 100, 4, (short)6, true, true,
+            RaftVersions.CURRENT_VERSION);
+
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(143, bytes.length);
+        final var cloned = (AppendEntriesReply) SerializationUtils.deserialize(bytes);
 
         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
         assertEquals("getFollowerId", expected.getFollowerId(), cloned.getFollowerId());
@@ -39,9 +41,12 @@ public class AppendEntriesReplyTest {
     @Test
     @Deprecated
     public void testPreFluorineSerialization() {
-        AppendEntriesReply expected = new AppendEntriesReply("follower", 5, true, 100, 4, (short)6, true, true,
-                RaftVersions.BORON_VERSION);
-        AppendEntriesReply cloned = (AppendEntriesReply) SerializationUtils.clone(expected);
+        final var expected = new AppendEntriesReply("follower", 5, true, 100, 4, (short)6, true, true,
+            RaftVersions.BORON_VERSION);
+
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(141, bytes.length);
+        final var cloned = (AppendEntriesReply) SerializationUtils.deserialize(bytes);
 
         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
         assertEquals("getFollowerId", expected.getFollowerId(), cloned.getFollowerId());
index a7c3c8b9d5e97bde0e4b6fb431e105545eea754b..bc9c6f1b87631705653f67391b8e36cf0e59d8f7 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.controller.cluster.raft.messages;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 
-import java.util.Arrays;
 import java.util.Iterator;
+import java.util.List;
 import org.apache.commons.lang.SerializationUtils;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload;
@@ -25,7 +25,6 @@ import org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEnt
  * @author Thomas Pantelis
  */
 public class AppendEntriesTest {
-
     @Test
     public void testSerialization() {
         ReplicatedLogEntry entry1 = new SimpleReplicatedLogEntry(1, 2, new MockPayload("payload1"));
@@ -36,19 +35,23 @@ public class AppendEntriesTest {
 
         // Without leader address
 
-        AppendEntries expected = new AppendEntries(5L, "node1", 7L, 8L, Arrays.asList(entry1, entry2), 10L,
-                -1, payloadVersion, RaftVersions.CURRENT_VERSION, null);
+        var expected = new AppendEntries(5L, "node1", 7L, 8L, List.of(entry1, entry2), 10L, -1, payloadVersion,
+            RaftVersions.CURRENT_VERSION, null);
 
-        AppendEntries cloned = (AppendEntries) SerializationUtils.clone(expected);
+        var bytes = SerializationUtils.serialize(expected);
+        assertEquals(355, bytes.length);
+        var cloned = (AppendEntries) SerializationUtils.deserialize(bytes);
 
         verifyAppendEntries(expected, cloned, RaftVersions.CURRENT_VERSION);
 
         // With leader address
 
-        expected = new AppendEntries(5L, "node1", 7L, 8L, Arrays.asList(entry1, entry2), 10L,
-                -1, payloadVersion, RaftVersions.CURRENT_VERSION, "leader address");
+        expected = new AppendEntries(5L, "node1", 7L, 8L, List.of(entry1, entry2), 10L, -1, payloadVersion,
+            RaftVersions.CURRENT_VERSION, "leader address");
 
-        cloned = (AppendEntries) SerializationUtils.clone(expected);
+        bytes = SerializationUtils.serialize(expected);
+        assertEquals(371, bytes.length);
+        cloned = (AppendEntries) SerializationUtils.deserialize(bytes);
 
         verifyAppendEntries(expected, cloned, RaftVersions.CURRENT_VERSION);
     }
@@ -62,15 +65,18 @@ public class AppendEntriesTest {
 
         short payloadVersion = 5;
 
-        AppendEntries expected = new AppendEntries(5L, "node1", 7L, 8L, Arrays.asList(entry1, entry2), 10L,
-                -1, payloadVersion, RaftVersions.BORON_VERSION, "leader address");
+        final var expected = new AppendEntries(5L, "node1", 7L, 8L, List.of(entry1, entry2), 10L, -1,
+            payloadVersion, RaftVersions.BORON_VERSION, "leader address");
 
-        AppendEntries cloned = (AppendEntries) SerializationUtils.clone(expected);
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(350, bytes.length);
+        final var cloned = (AppendEntries) SerializationUtils.deserialize(bytes);
 
         verifyAppendEntries(expected, cloned, RaftVersions.BORON_VERSION);
     }
 
-    private static void verifyAppendEntries(AppendEntries expected, AppendEntries actual, short recipientRaftVersion) {
+    private static void verifyAppendEntries(final AppendEntries expected, final AppendEntries actual,
+            final short recipientRaftVersion) {
         assertEquals("getLeaderId", expected.getLeaderId(), actual.getLeaderId());
         assertEquals("getTerm", expected.getTerm(), actual.getTerm());
         assertEquals("getLeaderCommit", expected.getLeaderCommit(), actual.getLeaderCommit());
@@ -94,7 +100,7 @@ public class AppendEntriesTest {
         }
     }
 
-    private static void verifyReplicatedLogEntry(ReplicatedLogEntry expected, ReplicatedLogEntry actual) {
+    private static void verifyReplicatedLogEntry(final ReplicatedLogEntry expected, final ReplicatedLogEntry actual) {
         assertEquals("getIndex", expected.getIndex(), actual.getIndex());
         assertEquals("getTerm", expected.getTerm(), actual.getTerm());
         assertEquals("getData", expected.getData().toString(), actual.getData().toString());
index 2841d989cf68772f82bb15a1023c4c2a24372d82..7ea8fb72000fe5c2d4536e11b8fd01a536d2d627 100644 (file)
@@ -18,11 +18,12 @@ import org.junit.Test;
  * @author Thomas Pantelis
  */
 public class InstallSnapshotReplyTest {
-
     @Test
     public void testSerialization() {
-        InstallSnapshotReply expected = new InstallSnapshotReply(5L, "follower", 1, true);
-        InstallSnapshotReply cloned = (InstallSnapshotReply) SerializationUtils.clone(expected);
+        final var expected = new InstallSnapshotReply(5L, "follower", 1, true);
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(126, bytes.length);
+        final var cloned = (InstallSnapshotReply) SerializationUtils.deserialize(bytes);
 
         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
         assertEquals("getFollowerId", expected.getFollowerId(), cloned.getFollowerId());
index c7fad2a19107e05332a873c5c2bad172854be3ab..b371ade4853d69ce8ad2b237fda815fa36098259 100644 (file)
@@ -45,12 +45,16 @@ public class InstallSnapshotTest {
         Object serialized = expected.toSerializable(RaftVersions.CURRENT_VERSION);
         assertEquals("Serialized type", InstallSnapshot.class, serialized.getClass());
 
-        InstallSnapshot actual = (InstallSnapshot) SerializationUtils.clone((Serializable) serialized);
+        var bytes = SerializationUtils.serialize((Serializable) serialized);
+        assertEquals(1302, bytes.length);
+        var actual = (InstallSnapshot) SerializationUtils.deserialize(bytes);
+
         verifyInstallSnapshot(expected, actual);
 
         expected = new InstallSnapshot(3L, "leaderId", 11L, 2L, data, 5, 6);
-        actual = (InstallSnapshot) SerializationUtils.clone((Serializable) expected.toSerializable(
-                RaftVersions.CURRENT_VERSION));
+        bytes = SerializationUtils.serialize((Serializable) expected.toSerializable(RaftVersions.CURRENT_VERSION));
+        assertEquals(1165, bytes.length);
+        actual = (InstallSnapshot) SerializationUtils.deserialize(bytes);
         verifyInstallSnapshot(expected, actual);
     }
 
index fa1bb5f15277d97cab4268bb3da6c0ac92e90feb..440c35f100b59c797a491ca196727cc10fdeff22 100644 (file)
@@ -18,11 +18,12 @@ import org.junit.Test;
  * @author Thomas Pantelis
  */
 public class RequestVoteReplyTest {
-
     @Test
     public void testSerialization() {
-        RequestVoteReply expected = new RequestVoteReply(5, true);
-        RequestVoteReply cloned = (RequestVoteReply) SerializationUtils.clone(expected);
+        final var expected = new RequestVoteReply(5, true);
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(105, bytes.length);
+        final var cloned = (RequestVoteReply) SerializationUtils.deserialize(bytes);
 
         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
         assertEquals("isVoteGranted", expected.isVoteGranted(), cloned.isVoteGranted());
index 6cb9179dedd3f4af8940dfcb1f6c615a89456700..e710685056cc64a377f7873cd16bb14f43f6cd6c 100644 (file)
@@ -18,11 +18,12 @@ import org.junit.Test;
  * @author Thomas Pantelis
  */
 public class RequestVoteTest {
-
     @Test
     public void testSerialization() {
-        RequestVote expected = new RequestVote(4, "candidateId", 3, 2);
-        RequestVote cloned = (RequestVote) SerializationUtils.clone(expected);
+        final var expected = new RequestVote(4, "candidateId", 3, 2);
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(131, bytes.length);
+        final var cloned = (RequestVote) SerializationUtils.deserialize(bytes);
 
         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
         assertEquals("getCandidateId", expected.getCandidateId(), cloned.getCandidateId());
index b7f152574bcbb478bf7951b1ef8f64aea12198db..2d9e7e3391a1098b8bfb38ae05cc57972ad52129 100644 (file)
@@ -18,11 +18,12 @@ import org.junit.Test;
  * @author Thomas Pantelis
  */
 public class ApplyJournalEntriesTest {
-
     @Test
     public void testSerialization() {
-        ApplyJournalEntries expected = new ApplyJournalEntries(5);
-        ApplyJournalEntries cloned = (ApplyJournalEntries) SerializationUtils.clone(expected);
+        final var expected = new ApplyJournalEntries(5);
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(108, bytes.length);
+        final var cloned = (ApplyJournalEntries) SerializationUtils.deserialize(bytes);
 
         assertEquals("getFromIndex", expected.getToIndex(), cloned.getToIndex());
     }
index 8334296ead188fd2263e855aeaeb164f36af839b..3254c899e61b8f7cacaa36c83ce4b0e6d42e6bd4 100644 (file)
@@ -18,11 +18,12 @@ import org.junit.Test;
  * @author Thomas Pantelis
  */
 public class DeleteEntriesTest {
-
     @Test
     public void testSerialization() {
-        DeleteEntries expected = new DeleteEntries(5);
-        DeleteEntries cloned = (DeleteEntries) SerializationUtils.clone(expected);
+        final var expected = new DeleteEntries(5);
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(102, bytes.length);
+        final var cloned = (DeleteEntries) SerializationUtils.deserialize(bytes);
 
         assertEquals("getFromIndex", expected.getFromIndex(), cloned.getFromIndex());
     }
index 963580cde4b04828cbe08b90bc70cebbaf4fd4ba..184b43b3c3e7a199dfdc977c8d65c9637f48fe0b 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.raft.persisted;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;
 
 import org.apache.commons.lang.SerializationUtils;
@@ -19,10 +20,11 @@ import org.junit.Test;
  *
  */
 public class EmptyStateTest {
-
     @Test
     public void testSerialization() {
-        EmptyState cloned = (EmptyState) SerializationUtils.clone(EmptyState.INSTANCE);
+        final var bytes = SerializationUtils.serialize(EmptyState.INSTANCE);
+        assertEquals(82, bytes.length);
+        final var cloned = SerializationUtils.deserialize(bytes);
         assertSame("cloned", EmptyState.INSTANCE, cloned);
     }
 }
index aa2fe90884540760fcd0dbd99b3f754dfa3f9412..82e7f8dbe4acc91bd82efa238f420a31dbc2ca44 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.controller.cluster.raft.persisted;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import java.util.Arrays;
+import java.util.List;
 import org.apache.commons.lang.SerializationUtils;
 import org.junit.Test;
 
@@ -20,19 +20,21 @@ import org.junit.Test;
  * @author Thomas Pantelis
  */
 public class ServerConfigurationPayloadTest {
-
     @Test
     public void testSerialization() {
-        ServerConfigurationPayload expected = new ServerConfigurationPayload(Arrays.asList(new ServerInfo("1", true),
-                new ServerInfo("2", false)));
-        ServerConfigurationPayload cloned = (ServerConfigurationPayload) SerializationUtils.clone(expected);
+        final var expected = new ServerConfigurationPayload(List.of(new ServerInfo("1", true),
+            new ServerInfo("2", false)));
+
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(125, bytes.length);
+        final var cloned = (ServerConfigurationPayload) SerializationUtils.deserialize(bytes);
 
         assertEquals("getServerConfig", expected.getServerConfig(), cloned.getServerConfig());
     }
 
     @Test
     public void testSize() {
-        ServerConfigurationPayload expected = new ServerConfigurationPayload(Arrays.asList(new ServerInfo("1", true)));
+        final var expected = new ServerConfigurationPayload(List.of(new ServerInfo("1", true)));
         assertTrue(expected.size() > 0);
     }
 }
index ec4a3689b2a4a109bb2c28d81aecbab214fe225f..9c0e8907dcbb82e5523d0582ae9ed8453372e59c 100644 (file)
@@ -19,12 +19,12 @@ import org.opendaylight.controller.cluster.raft.MockRaftActorContext;
  * @author Thomas Pantelis
  */
 public class SimpleReplicatedLogEntryTest {
-
     @Test
     public void testSerialization() {
-        SimpleReplicatedLogEntry expected = new SimpleReplicatedLogEntry(0, 1,
-                new MockRaftActorContext.MockPayload("A"));
-        SimpleReplicatedLogEntry cloned = (SimpleReplicatedLogEntry) SerializationUtils.clone(expected);
+        final var expected = new SimpleReplicatedLogEntry(0, 1, new MockRaftActorContext.MockPayload("A"));
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(260, bytes.length);
+        final var cloned = (SimpleReplicatedLogEntry) SerializationUtils.deserialize(bytes);
 
         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
         assertEquals("getIndex", expected.getIndex(), cloned.getIndex());
index 9f1f924252da9a9fd624973944f47ac42bb573b7..55d9d47376ddf4ad9cf0fa6319713d50d640a0eb 100644 (file)
@@ -9,8 +9,6 @@ package org.opendaylight.controller.cluster.raft.persisted;
 
 import static org.junit.Assert.assertEquals;
 
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import org.apache.commons.lang.SerializationUtils;
 import org.junit.Test;
@@ -23,27 +21,29 @@ import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
  * @author Thomas Pantelis
  */
 public class SnapshotTest {
-
     @Test
     public void testSerialization() {
-        testSerialization(new byte[]{1, 2, 3, 4, 5, 6, 7}, Arrays.asList(
-                new SimpleReplicatedLogEntry(6, 2, new MockPayload("payload"))));
-        testSerialization(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9}, Collections.emptyList());
+        testSerialization(new byte[]{1, 2, 3, 4, 5, 6, 7}, List.of(
+                new SimpleReplicatedLogEntry(6, 2, new MockPayload("payload"))), 548);
+        testSerialization(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9}, List.of(), 389);
     }
 
-    private static void testSerialization(final byte[] state, final List<ReplicatedLogEntry> unapplied) {
+    private static void testSerialization(final byte[] state, final List<ReplicatedLogEntry> unapplied,
+            final int expectedSize) {
         long lastIndex = 6;
         long lastTerm = 2;
         long lastAppliedIndex = 5;
         long lastAppliedTerm = 1;
         long electionTerm = 3;
         String electionVotedFor = "member-1";
-        ServerConfigurationPayload serverConfig = new ServerConfigurationPayload(Arrays.asList(
+        ServerConfigurationPayload serverConfig = new ServerConfigurationPayload(List.of(
                 new ServerInfo("1", true), new ServerInfo("2", false)));
 
-        Snapshot expected = Snapshot.create(ByteState.of(state), unapplied, lastIndex, lastTerm, lastAppliedIndex,
+        final var expected = Snapshot.create(ByteState.of(state), unapplied, lastIndex, lastTerm, lastAppliedIndex,
                 lastAppliedTerm, electionTerm, electionVotedFor, serverConfig);
-        Snapshot cloned = (Snapshot) SerializationUtils.clone(expected);
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(expectedSize, bytes.length);
+        final var cloned = (Snapshot) SerializationUtils.deserialize(bytes);
 
         assertEquals("lastIndex", expected.getLastIndex(), cloned.getLastIndex());
         assertEquals("lastTerm", expected.getLastTerm(), cloned.getLastTerm());
index de95125966405f1fb3af8d4357cae6218afb2032..f783c64be79196cb83bdd687eee06b6696202ff4 100644 (file)
@@ -18,11 +18,12 @@ import org.junit.Test;
  * @author Thomas Pantelis
  */
 public class UpdateElectionTermTest {
-
     @Test
     public void testSerialization() {
-        UpdateElectionTerm expected = new UpdateElectionTerm(5, "leader");
-        UpdateElectionTerm cloned = (UpdateElectionTerm) SerializationUtils.clone(expected);
+        final var expected = new UpdateElectionTerm(5, "leader");
+        final var bytes = SerializationUtils.serialize(expected);
+        assertEquals(116, bytes.length);
+        final var cloned = (UpdateElectionTerm) SerializationUtils.deserialize(bytes);
 
         assertEquals("getCurrentTerm", expected.getCurrentTerm(), cloned.getCurrentTerm());
         assertEquals("getVotedFor", expected.getVotedFor(), cloned.getVotedFor());