MetadataResourceResolver { static String getDirname(String path) { String pathNormalized = path.replace('\\', '/'); int i = pathNormalized.lastIndexOf('/'); if (i > 0) { return pathNormalized.substring(0, i); } return ""; } MetadataResourceResolver(SimpleFileSystem simpleFileSystem); SortedMap<String, String> getSourceMetadataPaths(String sourcePath); TargetResourceInfo getTargetName(String templatePath, String targetPath); static final String VELOCITY_TEMPLATE_EXTENSION; }
@Test public void testDirname() throws Exception { assertEquals("", MetadataResourceResolver.getDirname("foo.txt")); assertEquals("", MetadataResourceResolver.getDirname("/foo.txt")); assertEquals(".", MetadataResourceResolver.getDirname("./foo.txt")); assertEquals("bar", MetadataResourceResolver.getDirname("bar/foo.txt")); assertEquals("/bar", MetadataResourceResolver.getDirname("/bar/foo.txt")); assertEquals("", MetadataResourceResolver.getDirname("\\foo.txt")); assertEquals(".", MetadataResourceResolver.getDirname(".\\foo.txt")); assertEquals("bar", MetadataResourceResolver.getDirname("bar\\foo.txt")); assertEquals("C:/bar", MetadataResourceResolver.getDirname("C:\\bar\\foo.txt")); }