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