HadoopFileSystem extends FileSystem<HadoopResourceId> { @Override protected HadoopResourceId matchNewResource(String singleResourceSpec, boolean isDirectory) { if (singleResourceSpec.endsWith("/") && !isDirectory) { throw new IllegalArgumentException( String.format("Expected file path but received directory path %s", singleResourceSpec)); } return !singleResourceSpec.endsWith("/") && isDirectory ? new HadoopResourceId(dropEmptyAuthority(singleResourceSpec + "/")) : new HadoopResourceId(dropEmptyAuthority(singleResourceSpec)); } HadoopFileSystem(String scheme, Configuration configuration);   }
@Test public void testMatchNewResource() { assertEquals(testPath("file"), fileSystem.matchNewResource(testPath("file").toString(), false)); assertEquals(testPath("dir/"), fileSystem.matchNewResource(testPath("dir").toString(), true)); assertEquals(testPath("dir/"), fileSystem.matchNewResource(testPath("dir/").toString(), true)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Expected file path but received directory path"); fileSystem.matchNewResource(testPath("dir/").toString(), false); }