use of io.pravega.storage.s3.S3StorageFactoryCreator in project pravega by pravega.
the class StorageFactoryTests method testS3StorageFactoryCreator.
private void testS3StorageFactoryCreator(S3StorageConfig config) {
StorageFactoryCreator factoryCreator = new S3StorageFactoryCreator();
val expected = new StorageFactoryInfo[] { StorageFactoryInfo.builder().name("S3").storageLayoutType(StorageLayoutType.CHUNKED_STORAGE).build() };
val factoryInfoList = factoryCreator.getStorageFactories();
Assert.assertEquals(1, factoryInfoList.length);
Assert.assertArrayEquals(expected, factoryInfoList);
// Simple Storage
ConfigSetup configSetup1 = mock(ConfigSetup.class);
when(configSetup1.getConfig(any())).thenReturn(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, config);
val factory1 = factoryCreator.createFactory(expected[0], configSetup1, executorService());
Assert.assertTrue(factory1 instanceof S3SimpleStorageFactory);
@Cleanup Storage storage1 = ((S3SimpleStorageFactory) factory1).createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executorService()));
Assert.assertTrue(storage1 instanceof ChunkedSegmentStorage);
Assert.assertTrue(((ChunkedSegmentStorage) storage1).getChunkStorage() instanceof S3ChunkStorage);
AssertExtensions.assertThrows("createStorageAdapter should throw UnsupportedOperationException.", () -> factory1.createStorageAdapter(), ex -> ex instanceof UnsupportedOperationException);
}
Aggregations