storageBackup = new StorageBackupImpl(delegate, clock, config);
}
@Test
public void testBackup() throws Exception {
Snapshot snapshot = makeSnapshot();
expect(delegate.createSnapshot()).andReturn(snapshot).times(3);
control.replay();
assertEquals(snapshot, storageBackup.createSnapshot());
assertBackupCount(0);
clock.advance(Amount.of(INTERVAL.as(Time.MILLISECONDS) - 1, Time.MILLISECONDS));
assertEquals(snapshot, storageBackup.createSnapshot());
assertBackupCount(0);
clock.advance(Amount.of(1L, Time.MILLISECONDS));
assertEquals(snapshot, storageBackup.createSnapshot());
assertBackupCount(1);
assertEquals(1, storageBackup.getSuccesses().get());
Snapshot restored = ThriftBinaryCodec.decode(
Snapshot.class,
Files.toByteArray(config.getDir().listFiles()[0]));
assertEquals(snapshot, restored);
}