HadoopFileSystem extends FileSystem<HadoopResourceId> { @Override protected void delete(Collection<HadoopResourceId> resourceIds) throws IOException { for (HadoopResourceId resourceId : resourceIds) { final Path resourcePath = resourceId.toPath(); resourcePath.getFileSystem(configuration).delete(resourceId.toPath(), false); } } HadoopFileSystem(String scheme, Configuration configuration);   }
@Test public void testDelete() throws Exception { create("testFileA", "testDataA".getBytes(StandardCharsets.UTF_8)); create("testFileB", "testDataB".getBytes(StandardCharsets.UTF_8)); create("testFileC", "testDataC".getBytes(StandardCharsets.UTF_8)); assertArrayEquals("testDataA".getBytes(StandardCharsets.UTF_8), read("testFileA", 0)); assertArrayEquals("testDataB".getBytes(StandardCharsets.UTF_8), read("testFileB", 0)); assertArrayEquals("testDataC".getBytes(StandardCharsets.UTF_8), read("testFileC", 0)); fileSystem.delete(ImmutableList.of(testPath("testFileA"), testPath("testFileC"))); List<MatchResult> results = fileSystem.match(ImmutableList.of(testPath("testFile*").toString())); assertThat( results, contains( MatchResult.create( Status.OK, ImmutableList.of( Metadata.builder() .setResourceId(testPath("testFileB")) .setIsReadSeekEfficient(true) .setSizeBytes("testDataB".getBytes(StandardCharsets.UTF_8).length) .setLastModifiedMillis(lastModified("testFileB")) .build())))); }
@Test public void testDeleteNonExisting() throws Exception { fileSystem.delete(ImmutableList.of(testPath("MissingFile"))); }