use of io.atomix.utils.time.WallClockTimestamp in project atomix by atomix.
the class FileSnapshotStoreTest method testPersistLoadSnapshot.
/**
* Tests persisting and loading snapshots.
*/
@Test
public void testPersistLoadSnapshot() {
SnapshotStore store = createSnapshotStore();
Snapshot snapshot = store.newTemporarySnapshot(2, new WallClockTimestamp());
try (SnapshotWriter writer = snapshot.openWriter()) {
writer.writeLong(10);
}
snapshot = snapshot.persist();
assertNull(store.getSnapshot(2));
snapshot.complete();
assertNotNull(store.getSnapshot(2));
try (SnapshotReader reader = snapshot.openReader()) {
assertEquals(reader.readLong(), 10);
}
store.close();
store = createSnapshotStore();
assertNotNull(store.getSnapshot(2));
assertEquals(store.getSnapshot(2).index(), 2);
snapshot = store.getSnapshot(2);
try (SnapshotReader reader = snapshot.openReader()) {
assertEquals(reader.readLong(), 10);
}
}
Aggregations