use of com.coreos.jetcd.Maintenance.Snapshot in project jetcd by coreos.
the class MaintenanceUnitTest method testWriteAfterClosed.
@Test(timeOut = 1000)
public void testWriteAfterClosed() throws IOException {
Snapshot snapshot = maintenanceCli.snapshot();
snapshot.close();
OutputStream out = new ByteArrayOutputStream();
assertThatThrownBy(() -> snapshot.write(out)).isInstanceOf(IOException.class).hasMessageContaining("Snapshot has closed");
}
use of com.coreos.jetcd.Maintenance.Snapshot in project jetcd by coreos.
the class MaintenanceUnitTest method testInterruptWrite.
@Test(timeOut = 1000)
public void testInterruptWrite() throws ExecutionException, InterruptedException {
Snapshot snapshot = maintenanceCli.snapshot();
OutputStream out = new ByteArrayOutputStream();
Future<?> done = executor.submit(() -> assertThatThrownBy(() -> snapshot.write(out)).isInstanceOf(IOException.class).hasMessageContaining("write is interrupted"));
Thread.sleep(50);
executor.shutdownNow();
done.get();
}
Aggregations