ImageDirectoryLocator { public static File locateImagesDirectoryInExplodedClassPath(String parentImagesPackageResourceLocation) { log.info("parentImagesPackageResourceLocation = {}", parentImagesPackageResourceLocation); final URL parentImagesPackageResourceUrl; final ClassLoader classLoader = ImageDirectoryLocator.class.getClassLoader(); parentImagesPackageResourceUrl = classLoader.getResource(parentImagesPackageResourceLocation); log.info("parentImagesPackageResourceUrl = {}", parentImagesPackageResourceUrl); if (parentImagesPackageResourceUrl == null) { throw new IllegalStateException("Resource not found : " + parentImagesPackageResourceLocation); } final File imagesDirectory = new File(parentImagesPackageResourceUrl.getFile()); log.info("imagesDirectory = {}", imagesDirectory.getAbsolutePath()); checkImageDirectory(imagesDirectory); return imagesDirectory; }  static File locateImagesDirectoryInUnpackedDistDirectory(String parentImagesPackageResourceLocation); static File locateImagesDirectoryInExplodedClassPath(String parentImagesPackageResourceLocation);  }
@Test void canLocateImagesDirectoryInExplodedClassPath() { final String pathName = "data/common/default"; final File result = ImageDirectoryLocator.locateImagesDirectoryInExplodedClassPath(pathName); assert (result.getAbsolutePath().contains("data" + FILESEPARATOR + "common" + FILESEPARATOR + "default")); }