Search in sources :

Example 1 with FileSystemRegistrar

use of org.apache.beam.sdk.io.FileSystemRegistrar in project beam by apache.

the class HadoopFileSystemRegistrarTest method testServiceLoader.

@Test
public void testServiceLoader() {
    HadoopFileSystemOptions options = PipelineOptionsFactory.as(HadoopFileSystemOptions.class);
    options.setHdfsConfiguration(ImmutableList.of(configuration));
    for (FileSystemRegistrar registrar : Lists.newArrayList(ServiceLoader.load(FileSystemRegistrar.class).iterator())) {
        if (registrar instanceof HadoopFileSystemRegistrar) {
            Iterable<FileSystem<?>> fileSystems = registrar.fromOptions(options);
            assertEquals(hdfsClusterBaseUri.getScheme(), ((HadoopFileSystem) Iterables.getOnlyElement(fileSystems)).getScheme());
            return;
        }
    }
    fail("Expected to find " + HadoopFileSystemRegistrar.class);
}
Also used : FileSystemRegistrar(org.apache.beam.sdk.io.FileSystemRegistrar) FileSystem(org.apache.beam.sdk.io.FileSystem) Test(org.junit.Test)

Example 2 with FileSystemRegistrar

use of org.apache.beam.sdk.io.FileSystemRegistrar in project beam by apache.

the class GcsFileSystemRegistrarTest method testServiceLoader.

@Test
public void testServiceLoader() {
    for (FileSystemRegistrar registrar : Lists.newArrayList(ServiceLoader.load(FileSystemRegistrar.class).iterator())) {
        if (registrar instanceof GcsFileSystemRegistrar) {
            Iterable<FileSystem<?>> fileSystems = registrar.fromOptions(PipelineOptionsFactory.create());
            assertThat(fileSystems, contains(instanceOf(GcsFileSystem.class)));
            return;
        }
    }
    fail("Expected to find " + GcsFileSystemRegistrar.class);
}
Also used : FileSystemRegistrar(org.apache.beam.sdk.io.FileSystemRegistrar) FileSystem(org.apache.beam.sdk.io.FileSystem) Test(org.junit.Test)

Aggregations

FileSystem (org.apache.beam.sdk.io.FileSystem)2 FileSystemRegistrar (org.apache.beam.sdk.io.FileSystemRegistrar)2 Test (org.junit.Test)2