import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
*
* @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();
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());
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;
* 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);