### Question:
ClassLoaders { public static Set<URL> findUrls(final ClassLoader classLoader) throws IOException { if (classLoader == null || (SYSTEM.getParent() != null && classLoader == SYSTEM.getParent())) { return Collections.emptySet(); } final Set<URL> urls = new HashSet<URL>(); if (URLClassLoader.class.isInstance(classLoader) && !DONT_USE_GET_URLS) { if (!isSurefire(classLoader)) { for (final Collection<URL> item : Arrays.asList( Arrays.asList(URLClassLoader.class.cast(classLoader).getURLs()), findUrls(classLoader.getParent()))) { for (final URL url : item) { addIfNotSo(urls, url); } } } else { urls.addAll(fromClassPath()); } } if (urls.size() <= 1) { final Set<URL> urlFromResources = findUrlFromResources(classLoader); if (!urls.isEmpty()) { final URL theUrl = urls.iterator().next(); if ("file".equals(theUrl.getProtocol())) { urlFromResources.remove(new URL("jar:" + theUrl.toExternalForm() + "!/")); } } urls.addAll(urlFromResources); } return urls; } private  ClassLoaders(); static Set<URL> findUrls(final ClassLoader classLoader); static boolean isNative(final URL url); static Set<URL> findUrlFromResources(final ClassLoader classLoader);  }### Answer:
@Test public void singleUrl() throws IOException { final File metaInf = new File("target/ClassLoadersTest/singleUrl/META-INF"); metaInf.getParentFile().mkdirs(); final URL url = metaInf.getParentFile().toURI().toURL(); final ClassLoader loader = new URLClassLoader(new URL[] {url}, new ClassLoader() { @Override protected Class<?> loadClass(final String name, final boolean resolve) throws ClassNotFoundException { throw new ClassNotFoundException(); } @Override public Enumeration<URL> getResources(final String name) throws IOException { return EmptyEnumeration.EMPTY_ENUMERATION; } }) { @Override public Enumeration<URL> getResources(final String name) throws IOException { if ("META-INF".equals(name)) { return EmptyEnumeration.EMPTY_ENUMERATION; } return enumeration(singleton(new URL("jar:file:/tmp/app.jar!/"))); } @Override public URL[] getURLs() { try { return new URL[] { new URL("file:/tmp/app.jar") }; } catch (final MalformedURLException e) { fail(); throw new IllegalStateException(e); } } }; assertEquals(1, ClassLoaders.findUrls(loader).size()); }