use of io.etcd.jetcd.api.SnapshotResponse in project jetcd by etcd-io.
the class MaintenanceUnitTest method setUp.
@BeforeEach
public void setUp() throws IOException, URISyntaxException {
observerQueue = new LinkedBlockingQueue<>();
executor = Executors.newFixedThreadPool(2);
serviceRegistry = new MutableHandlerRegistry();
serviceRegistry.addService(new MaintenanceImplBase() {
@Override
public void snapshot(SnapshotRequest request, StreamObserver<SnapshotResponse> observer) {
try {
observerQueue.put(observer);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
});
fakeServer = NettyServerBuilder.forPort(TestUtil.findNextAvailablePort()).fallbackHandlerRegistry(serviceRegistry).directExecutor().build().start();
client = Client.builder().endpoints(new URI("http://127.0.0.1:" + fakeServer.getPort())).build();
maintenance = client.getMaintenanceClient();
}
use of io.etcd.jetcd.api.SnapshotResponse in project jetcd by coreos.
the class MaintenanceUnitTest method testWrite.
@Test
public void testWrite() throws Exception {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final ByteString blob = ByteString.copyFromUtf8("blob");
final CompletableFuture<Long> answer = maintenance.snapshot(out);
StreamObserver<SnapshotResponse> observer = observerQueue.take();
observer.onNext(SnapshotResponse.newBuilder().setBlob(blob).setRemainingBytes(0).build());
observer.onCompleted();
answer.get();
assertThat(out.toByteArray()).isEqualTo(blob.toByteArray());
}
use of io.etcd.jetcd.api.SnapshotResponse in project jetcd by coreos.
the class MaintenanceUnitTest method setUp.
@BeforeEach
public void setUp() throws IOException, URISyntaxException {
observerQueue = new LinkedBlockingQueue<>();
executor = Executors.newFixedThreadPool(2);
serviceRegistry = new MutableHandlerRegistry();
serviceRegistry.addService(new MaintenanceImplBase() {
@Override
public void snapshot(SnapshotRequest request, StreamObserver<SnapshotResponse> observer) {
try {
observerQueue.put(observer);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
});
fakeServer = NettyServerBuilder.forPort(TestUtil.findNextAvailablePort()).fallbackHandlerRegistry(serviceRegistry).directExecutor().build().start();
client = Client.builder().endpoints(new URI("http://127.0.0.1:" + fakeServer.getPort())).build();
maintenance = client.getMaintenanceClient();
}
use of io.etcd.jetcd.api.SnapshotResponse in project jetcd by etcd-io.
the class MaintenanceUnitTest method testWrite.
@Test
public void testWrite() throws Exception {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final ByteString blob = ByteString.copyFromUtf8("blob");
final CompletableFuture<Long> answer = maintenance.snapshot(out);
StreamObserver<SnapshotResponse> observer = observerQueue.take();
observer.onNext(SnapshotResponse.newBuilder().setBlob(blob).setRemainingBytes(0).build());
observer.onCompleted();
answer.get();
assertThat(out.toByteArray()).isEqualTo(blob.toByteArray());
}
Aggregations