Notify listeners on applySnapshot
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / DatastoreSnapshotRestoreTest.java
index aa67e53faa02debdc3b427f672b02efbfdc9efbe..9f0b1b5341ff861f07954f6dc133e21d1e21de29 100644 (file)
@@ -65,22 +65,21 @@ public class DatastoreSnapshotRestoreTest {
             SerializationUtils.serialize(snapshotList, fos);
         }
 
-        DatastoreSnapshotRestore.createInstance(restoreDirectoryPath);
+        DatastoreSnapshotRestore instance = DatastoreSnapshotRestore.instance(restoreDirectoryPath);
 
-        verifySnapshot(configSnapshot, DatastoreSnapshotRestore.instance().getAndRemove("config"));
-        verifySnapshot(operSnapshot, DatastoreSnapshotRestore.instance().getAndRemove("oper"));
+        verifySnapshot(configSnapshot, instance.getAndRemove("config"));
+        verifySnapshot(operSnapshot, instance.getAndRemove("oper"));
 
-        assertNull("DatastoreSnapshot was not removed", DatastoreSnapshotRestore.instance().getAndRemove("config"));
+        assertNull("DatastoreSnapshot was not removed", instance.getAndRemove("config"));
 
         assertFalse(backupFile + " was not deleted", backupFile.exists());
 
-        DatastoreSnapshotRestore.removeInstance();
-        DatastoreSnapshotRestore.createInstance("target/does-not-exist");
-        assertNull("Expected null DatastoreSnapshot", DatastoreSnapshotRestore.instance().getAndRemove("config"));
-        assertNull("Expected null DatastoreSnapshot", DatastoreSnapshotRestore.instance().getAndRemove("oper"));
+        instance = DatastoreSnapshotRestore.instance(restoreDirectoryPath);
+        assertNull("Expected null DatastoreSnapshot", instance.getAndRemove("config"));
+        assertNull("Expected null DatastoreSnapshot", instance.getAndRemove("oper"));
     }
 
-    private void verifySnapshot(DatastoreSnapshot expected, DatastoreSnapshot actual) {
+    private static void verifySnapshot(DatastoreSnapshot expected, DatastoreSnapshot actual) {
         assertNotNull("DatastoreSnapshot is null", actual);
         assertEquals("getType", expected.getType(), actual.getType());
         assertTrue("ShardManager snapshots don't match", Objects.deepEquals(expected.getShardManagerSnapshot(),