Index: C:/java/hivemindsvn/framework/src/test/org/apache/hivemind/util/empty_fr =================================================================== Index: C:/java/hivemindsvn/framework/src/test/org/apache/hivemind/util/TestLocalizedContextResourceFinder.java =================================================================== --- C:/java/hivemindsvn/framework/src/test/org/apache/hivemind/util/TestLocalizedContextResourceFinder.java (revision 231226) +++ C:/java/hivemindsvn/framework/src/test/org/apache/hivemind/util/TestLocalizedContextResourceFinder.java (working copy) @@ -94,4 +94,24 @@ verifyControls(); } + + public void testExtensionlessResource() throws Exception + { + MockControl control = newControl(ServletContext.class); + ServletContext sc = (ServletContext) control.getMock(); + + sc.getResource("/foo/bar/baz"); + control.setReturnValue(new URL("http://foo.com")); + + replayControls(); + + LocalizedContextResourceFinder f = new LocalizedContextResourceFinder(sc); + + LocalizedResource lr = f.resolve("/foo/bar/baz", null); + + assertEquals("/foo/bar/baz", lr.getResourcePath()); + assertNull(lr.getResourceLocale()); + + verifyControls(); + } } \ No newline at end of file Index: C:/java/hivemindsvn/framework/src/test/org/apache/hivemind/util/TestFileResource.java =================================================================== --- C:/java/hivemindsvn/framework/src/test/org/apache/hivemind/util/TestFileResource.java (revision 231226) +++ C:/java/hivemindsvn/framework/src/test/org/apache/hivemind/util/TestFileResource.java (working copy) @@ -129,4 +129,17 @@ assertEquals(path, r.toString()); } + + public void testExtensionLess() + { + String path = getFrameworkPath(DIR); + // Remove the ./ at the beginning to remove any dot from the path + if (path.startsWith("./")) + path = path.substring(2); + + Resource r = new FileResource(path); + Resource localized = r.getLocalization(Locale.CHINA); + + assertSame(r, localized); + } } Index: C:/java/hivemindsvn/framework/src/test/org/apache/hivemind/util/TestClasspathResource.java =================================================================== --- C:/java/hivemindsvn/framework/src/test/org/apache/hivemind/util/TestClasspathResource.java (revision 231226) +++ C:/java/hivemindsvn/framework/src/test/org/apache/hivemind/util/TestClasspathResource.java (working copy) @@ -131,4 +131,13 @@ assertEquals(expected, actual); } + + public void testLocalizeExtensionless() + { + Resource l1 = new ClasspathResource(_resolver, "/org/apache/hivemind/util/empty"); + Resource expected = new ClasspathResource(_resolver, "/org/apache/hivemind/util/empty_fr"); + Resource actual = l1.getLocalization(Locale.FRENCH); + + assertEquals(expected, actual); + } } Index: C:/java/hivemindsvn/framework/src/java/org/apache/hivemind/util/LocalizedResourceFinder.java =================================================================== --- C:/java/hivemindsvn/framework/src/java/org/apache/hivemind/util/LocalizedResourceFinder.java (revision 231226) +++ C:/java/hivemindsvn/framework/src/java/org/apache/hivemind/util/LocalizedResourceFinder.java (working copy) @@ -49,8 +49,18 @@ public LocalizedResource resolve(String resourcePath, Locale locale) { int dotx = resourcePath.lastIndexOf('.'); - String basePath = resourcePath.substring(0, dotx); - String suffix = resourcePath.substring(dotx); + String basePath; + String suffix; + if (dotx >= 0) { + basePath = resourcePath.substring(0, dotx); + suffix = resourcePath.substring(dotx); + } + else + { + // Resource without extension + basePath = resourcePath; + suffix = ""; + } LocalizedNameGenerator generator = new LocalizedNameGenerator(basePath, locale, suffix); Index: C:/java/hivemindsvn/framework/src/java/org/apache/hivemind/util/LocalizedFileResourceFinder.java =================================================================== --- C:/java/hivemindsvn/framework/src/java/org/apache/hivemind/util/LocalizedFileResourceFinder.java (revision 231226) +++ C:/java/hivemindsvn/framework/src/java/org/apache/hivemind/util/LocalizedFileResourceFinder.java (working copy) @@ -30,7 +30,9 @@ { int dotx = path.lastIndexOf('.'); LocalizedNameGenerator g = - new LocalizedNameGenerator(path.substring(0, dotx), locale, path.substring(dotx)); + new LocalizedNameGenerator(dotx == -1 ? path : path.substring(0, dotx), + locale, + dotx == -1 ? "" : path.substring(dotx)); while (g.more()) { Index: C:/java/hivemindsvn/framework/src/java/org/apache/hivemind/util/LocalizedContextResourceFinder.java =================================================================== --- C:/java/hivemindsvn/framework/src/java/org/apache/hivemind/util/LocalizedContextResourceFinder.java (revision 231226) +++ C:/java/hivemindsvn/framework/src/java/org/apache/hivemind/util/LocalizedContextResourceFinder.java (working copy) @@ -49,8 +49,18 @@ public LocalizedResource resolve(String contextPath, Locale locale) { int dotx = contextPath.lastIndexOf('.'); - String basePath = contextPath.substring(0, dotx); - String suffix = contextPath.substring(dotx); + String basePath; + String suffix; + if (dotx >= 0) { + basePath = contextPath.substring(0, dotx); + suffix = contextPath.substring(dotx); + } + else + { + // Resource without extension + basePath = contextPath; + suffix = ""; + } LocalizedNameGenerator generator = new LocalizedNameGenerator(basePath, locale, suffix);