use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.
the class TestRangeStoreImpl method testPutMockStorageContainer.
@Test
public void testPutMockStorageContainer() throws Exception {
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
StorageContainerResponse response = createPutResponse(StatusCode.SUCCESS);
StorageContainerRequest request = createPutRequest(ROOT_STORAGE_CONTAINER_ID);
when(scStore.put(request)).thenReturn(CompletableFuture.completedFuture(response));
CompletableFuture<StorageContainerResponse> future = rangeStore.put(request);
verify(scStore, times(1)).put(eq(request));
assertTrue(response == future.get());
}
use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.
the class TestRangeStoreImpl method testGetStreamMockRootStorageContainerStore.
@Test
public void testGetStreamMockRootStorageContainerStore() throws Exception {
String colName = "test-get-namespace-no-root-storage-container-store";
String streamName = colName;
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
GetStreamResponse getResp = GetStreamResponse.newBuilder().setCode(StatusCode.STREAM_NOT_FOUND).build();
GetStreamRequest getReq = createGetStreamRequest(colName, streamName);
when(scStore.getStream(getReq)).thenReturn(CompletableFuture.completedFuture(getResp));
CompletableFuture<GetStreamResponse> getRespFuture = rangeStore.getStream(getReq);
verify(scStore, times(1)).getStream(getReq);
assertTrue(getResp == getRespFuture.get());
}
use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.
the class TestRangeStoreImpl method testDeleteMockStorageContainer.
@Test
public void testDeleteMockStorageContainer() throws Exception {
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
StorageContainerResponse response = createDeleteResponse(StatusCode.SUCCESS);
StorageContainerRequest request = createDeleteRequest(ROOT_STORAGE_CONTAINER_ID);
when(scStore.delete(request)).thenReturn(CompletableFuture.completedFuture(response));
CompletableFuture<StorageContainerResponse> future = rangeStore.delete(request);
verify(scStore, times(1)).delete(eq(request));
assertTrue(response == future.get());
}
use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.
the class TestRangeStoreImpl method testGetNamespaceMockRootStorageContainerStore.
@Test
public void testGetNamespaceMockRootStorageContainerStore() throws Exception {
String colName = "test-get-namespace-no-root-storage-container-store";
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
GetNamespaceResponse getResp = GetNamespaceResponse.newBuilder().setCode(StatusCode.NAMESPACE_NOT_FOUND).build();
GetNamespaceRequest request = createGetNamespaceRequest(colName);
when(scStore.getNamespace(request)).thenReturn(CompletableFuture.completedFuture(getResp));
CompletableFuture<GetNamespaceResponse> getRespFuture = rangeStore.getNamespace(request);
verify(scStore, times(1)).getNamespace(request);
assertTrue(getResp == getRespFuture.get());
}
use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.
the class TestRangeStoreImpl method testGetActiveRangesMockManager.
@Test
public void testGetActiveRangesMockManager() throws Exception {
long scId = System.currentTimeMillis();
StreamProperties props = StreamProperties.newBuilder(streamProps).setStorageContainerId(scId).build();
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(scId, scStore);
StorageContainerResponse resp = StorageContainerResponse.newBuilder().setCode(StatusCode.STREAM_NOT_FOUND).build();
StorageContainerRequest request = createGetActiveRangesRequest(scId, 34L);
when(scStore.getActiveRanges(request)).thenReturn(CompletableFuture.completedFuture(resp));
CompletableFuture<StorageContainerResponse> future = rangeStore.getActiveRanges(request);
verify(scStore, times(1)).getActiveRanges(request);
assertTrue(resp == future.get());
}
Aggregations