FileSystems { @VisibleForTesting static Map<String, FileSystem> verifySchemesAreUnique( PipelineOptions options, Set<FileSystemRegistrar> registrars) { Multimap<String, FileSystem> fileSystemsBySchemes = TreeMultimap.create(Ordering.<String>natural(), Ordering.arbitrary()); for (FileSystemRegistrar registrar : registrars) { for (FileSystem fileSystem : registrar.fromOptions(options)) { fileSystemsBySchemes.put(fileSystem.getScheme(), fileSystem); } } for (Entry<String, Collection<FileSystem>> entry : fileSystemsBySchemes.asMap().entrySet()) { if (entry.getValue().size() > 1) { String conflictingFileSystems = Joiner.on(", ") .join( FluentIterable.from(entry.getValue()) .transform(input -> input.getClass().getName()) .toSortedList(Ordering.natural())); throw new IllegalStateException( String.format( "Scheme: [%s] has conflicting filesystems: [%s]", entry.getKey(), conflictingFileSystems)); } } ImmutableMap.Builder<String, FileSystem> schemeToFileSystem = ImmutableMap.builder(); for (Entry<String, FileSystem> entry : fileSystemsBySchemes.entries()) { schemeToFileSystem.put(entry.getKey(), entry.getValue()); } return schemeToFileSystem.build(); }  static boolean hasGlobWildcard(String spec); static List<MatchResult> match(List<String> specs); static List<MatchResult> match(List<String> specs, EmptyMatchTreatment emptyMatchTreatment); static MatchResult match(String spec); static MatchResult match(String spec, EmptyMatchTreatment emptyMatchTreatment); static Metadata matchSingleFileSpec(String spec); static List<MatchResult> matchResources(List<ResourceId> resourceIds); static WritableByteChannel create(ResourceId resourceId, String mimeType); static WritableByteChannel create(ResourceId resourceId, CreateOptions createOptions); static ReadableByteChannel open(ResourceId resourceId); static void copy(
      List<ResourceId> srcResourceIds, List<ResourceId> destResourceIds, MoveOptions... moveOptions); static void rename(
      List<ResourceId> srcResourceIds, List<ResourceId> destResourceIds, MoveOptions... moveOptions); static void delete(Collection<ResourceId> resourceIds, MoveOptions... moveOptions); @Internal static void setDefaultPipelineOptions(PipelineOptions options); static ResourceId matchNewResource(String singleResourceSpec, boolean isDirectory); static final String DEFAULT_SCHEME; }
@Test public void testVerifySchemesAreUnique() throws Exception { thrown.expect(RuntimeException.class); thrown.expectMessage("Scheme: [file] has conflicting filesystems"); FileSystems.verifySchemesAreUnique( PipelineOptionsFactory.create(), Sets.newHashSet(new LocalFileSystemRegistrar(), new LocalFileSystemRegistrar())); }