Bug 7521: Convert Snapshot to store a State instance
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / test / java / org / opendaylight / controller / cluster / raft / SnapshotTest.java
index a0b9cd5ee1898b99ce0ab4fe26bedf49d970ce15..b4a8c27b7c9215e0f8ac1406c3fa7ab33ad5f110 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -24,12 +25,13 @@ import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload
  *
  * @author Thomas Pantelis
  */
+@Deprecated
 public class SnapshotTest {
 
     @Test
     public void testBackwardsCompatibleDeserializationFromLithium() throws Exception {
         Snapshot expSnapshot = newLithiumSnapshot();
-        try(FileInputStream fis = new FileInputStream("src/test/resources/lithium-serialized-Snapshot")) {
+        try (FileInputStream fis = new FileInputStream("src/test/resources/lithium-serialized-Snapshot")) {
             ObjectInputStream ois = new ObjectInputStream(fis);
 
             Snapshot snapshot = (Snapshot) ois.readObject();
@@ -39,7 +41,8 @@ public class SnapshotTest {
             assertEquals("lastTerm", expSnapshot.getLastTerm(), snapshot.getLastTerm());
             assertEquals("lastAppliedIndex", expSnapshot.getLastAppliedIndex(), snapshot.getLastAppliedIndex());
             assertEquals("lastAppliedTerm", expSnapshot.getLastAppliedTerm(), snapshot.getLastAppliedTerm());
-            assertEquals("unAppliedEntries size", expSnapshot.getUnAppliedEntries().size(), snapshot.getUnAppliedEntries().size());
+            assertEquals("unAppliedEntries size", expSnapshot.getUnAppliedEntries().size(),
+                    snapshot.getUnAppliedEntries().size());
             assertArrayEquals("state", expSnapshot.getState(), snapshot.getState());
             assertEquals("electionTerm", 0, snapshot.getElectionTerm());
             assertEquals("electionVotedFor", null, snapshot.getElectionVotedFor());
@@ -49,7 +52,8 @@ public class SnapshotTest {
     private static Snapshot newLithiumSnapshot() {
         byte[] state = {1, 2, 3, 4, 5};
         List<ReplicatedLogEntry> entries = new ArrayList<>();
-        entries.add(new ReplicatedLogImplEntry(6, 2, new MockPayload("payload")));
+        entries.add(new org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry(
+                6, 2, new MockPayload("payload")));
         long lastIndex = 6;
         long lastTerm = 2;
         long lastAppliedIndex = 5;
@@ -62,6 +66,7 @@ public class SnapshotTest {
      * Use this method to generate a file with a serialized Snapshot instance to be
      * used in tests that verify backwards compatible de-serialization.
      */
+    @SuppressWarnings("unused")
     private static void generateSerializedFile(Snapshot snapshot, String fileName) throws IOException {
         FileOutputStream fos = new FileOutputStream("src/test/resources/" + fileName);
         ObjectOutputStream oos = new ObjectOutputStream(fos);