### Question:
Classpaths { public static List<String> listFromClassLoader(ClassLoader loader, String resource) { final List<URL> resourceURLs = Classpaths.classpathResources( loader, resource ); final List<String> resourcePaths = Lists.list( String.class ); final Map<URI, FileSystem> pathToZipFileSystems = new HashMap<>(); for ( URL resourceURL : resourceURLs ) { if ( resourceURL.getProtocol().equals( "jar" ) ) { resourcesFromJar( resourcePaths, resourceURL, pathToZipFileSystems ); } else { resourcesFromFileSystem( resourcePaths, resourceURL ); } } return resourcePaths; }  static List<URL> classpathResources( ClassLoader loader, String resource ); static List<URL> classpathResources( Class<?> clazz, String resource ); static List<String> resources( Class<?> clazz, String resource ); static List<Path> paths( Class<?> clazz, String resource ); static List<String> listFromClassLoader(ClassLoader loader, String resource); static List<Path> pathsFromClassLoader(ClassLoader loader, String resource);  }### Answer:
@Test public void testDirectory() throws Exception { String someResource = "/org/node/"; File file = new File( "files/node-1.0-SNAPSHOT.jar" ); URL url1 = file.getAbsoluteFile().toURI().toURL(); URL url2 = new File( "files/invoke-1.0-SNAPSHOT.jar" ).getAbsoluteFile().toURI().toURL(); URLClassLoader loader = new URLClassLoader( new URL[]{ url1, url2 } ); final List<String> resourcePaths = Classpaths.listFromClassLoader(loader, someResource); int directoryCount = 0; for ( String path : resourcePaths ) { if ( !Files.isDirectory( IO.path(path) ) ) { die(); } else { directoryCount++; } } boolean ok = true; }
@Test public void testFileResources() throws Exception { String someResource = "/org/node/resource.txt"; File file = new File( "files/node-1.0-SNAPSHOT.jar" ); URL url1 = file.getAbsoluteFile().toURI().toURL(); URL url2 = new File( "files/invoke-1.0-SNAPSHOT.jar" ).getAbsoluteFile().toURI().toURL(); URLClassLoader loader = new URLClassLoader( new URL[]{ url1, url2 } ); final List<String> resourcePaths = Classpaths.listFromClassLoader(loader, someResource); int fileCount = 0; int dirCount = 0; for ( String path : resourcePaths ) { if ( !Files.isDirectory( IO.path(path) ) ) { fileCount++; } else { dirCount++; } } boolean ok = true; ok |= dirCount == 0 || die(); }