ResourceUtils { public String getClassLoaderDir() { if (contextObject==null) throw new IllegalArgumentException("No suitable context ("+context+") to auto-detect classloader dir"); Class<?> cc = contextObject instanceof Class ? (Class<?>)contextObject : contextObject.getClass(); return getClassLoaderDir(cc.getCanonicalName().replace('.', '/')+".class"); } ResourceUtils(ClassLoader loader, Object contextObject, String contextMessage);  ResourceUtils(BrooklynClassLoadingContext loader, Object contextObject, String contextMessage);  ResourceUtils(Object contextObject, String contextMessage);  ResourceUtils(Object contextObject); static final ResourceUtils create(ClassLoader loader, Object contextObject, String contextMessage); static final ResourceUtils create(BrooklynClassLoadingContext loader, Object contextObject, String contextMessage); static final ResourceUtils create(Object contextObject, String contextMessage); static final ResourceUtils create(Object contextObject); static final ResourceUtils create(); static void addClassLoaderProvider(Function<Object,BrooklynClassLoadingContext> provider); Iterable<URL> getResources(String name); InputStream getResourceFromUrl(String url,
            @Nullable org.apache.brooklyn.util.http.auth.Credentials credentials); InputStream getResourceFromUrl(String url); static URL tidy(URL url); static String tidyFileUrl(String url); String getResourceAsString(String url); String checkUrlExists(String url); String checkUrlExists(String url, String message); boolean doesUrlExist(String url); Optional<String> firstAvailableUrl(String ...urls); String getClassLoaderDir(); String getClassLoaderDir(String resourceInThatDir); static URL getContainerUrl(URL url, String resourceInThatDir);  }
@Test public void testClassLoaderDir() throws Exception { String d = utils.getClassLoaderDir(); log.info("Found resource "+this+" in: "+d); assertTrue(new File(d, "brooklyn/util/").exists()); }
@Test public void testClassLoaderDirFromJar() throws Exception { String d = utils.getClassLoaderDir("java/lang/Object.class"); log.info("Found Object in: "+d); assertTrue(d.toLowerCase().endsWith(".jar")); }
@Test public void testClassLoaderDirFromJarWithSlash() throws Exception { String d = utils.getClassLoaderDir("/java/lang/Object.class"); log.info("Found Object in: "+d); assertTrue(d.toLowerCase().endsWith(".jar")); }
@Test(expectedExceptions={NoSuchElementException.class}) public void testClassLoaderDirNotFound() throws Exception { String d = utils.getClassLoaderDir("/somewhere/not/found/XXX.xxx"); log.warn("Uh oh found imaginary resource in: "+d); }