@Test public void testNormalizeClassPathResourcePath() throws Exception { assertEquals("/my/package", ClassPathResourceProvider.normalizeClassPathResourcePath("my.package")); assertEquals("/my/package", ClassPathResourceProvider.normalizeClassPathResourcePath("/my/package/")); assertEquals("/my/package", ClassPathResourceProvider.normalizeClassPathResourcePath("my/package")); assertEquals("/my/package", ClassPathResourceProvider.normalizeClassPathResourcePath("/my/package")); }
@VisibleForTesting static String normalizeClassPathResourcePath(String basePackage) { if (!basePackage.contains("/") && basePackage.contains(".")) { basePackage = basePackage.replaceAll("\\.", "/"); } if (!basePackage.startsWith("/")) { basePackage = "/" + basePackage; } if (basePackage.endsWith("/")) { basePackage = basePackage.substring(0, basePackage.length() - 1); } return basePackage; }
ClassPathResourceProvider implements ResourceProvider { @VisibleForTesting static String normalizeClassPathResourcePath(String basePackage) { if (!basePackage.contains("/") && basePackage.contains(".")) { basePackage = basePackage.replaceAll("\\.", "/"); } if (!basePackage.startsWith("/")) { basePackage = "/" + basePackage; } if (basePackage.endsWith("/")) { basePackage = basePackage.substring(0, basePackage.length() - 1); } return basePackage; } }
ClassPathResourceProvider implements ResourceProvider { @VisibleForTesting static String normalizeClassPathResourcePath(String basePackage) { if (!basePackage.contains("/") && basePackage.contains(".")) { basePackage = basePackage.replaceAll("\\.", "/"); } if (!basePackage.startsWith("/")) { basePackage = "/" + basePackage; } if (basePackage.endsWith("/")) { basePackage = basePackage.substring(0, basePackage.length() - 1); } return basePackage; } ClassPathResourceProvider(String basePackage); }
ClassPathResourceProvider implements ResourceProvider { @VisibleForTesting static String normalizeClassPathResourcePath(String basePackage) { if (!basePackage.contains("/") && basePackage.contains(".")) { basePackage = basePackage.replaceAll("\\.", "/"); } if (!basePackage.startsWith("/")) { basePackage = "/" + basePackage; } if (basePackage.endsWith("/")) { basePackage = basePackage.substring(0, basePackage.length() - 1); } return basePackage; } ClassPathResourceProvider(String basePackage); @Override Resource getResource(String servletPath, String relativeResourcePath, String sessionId); }
ClassPathResourceProvider implements ResourceProvider { @VisibleForTesting static String normalizeClassPathResourcePath(String basePackage) { if (!basePackage.contains("/") && basePackage.contains(".")) { basePackage = basePackage.replaceAll("\\.", "/"); } if (!basePackage.startsWith("/")) { basePackage = "/" + basePackage; } if (basePackage.endsWith("/")) { basePackage = basePackage.substring(0, basePackage.length() - 1); } return basePackage; } ClassPathResourceProvider(String basePackage); @Override Resource getResource(String servletPath, String relativeResourcePath, String sessionId);  }