### Question:
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); static URL tidy(URL url); static String tidyFileUrl(String url); @Deprecated static String mergeFilePaths(String... items); @Deprecated static String tidyFilePath(String path); @Deprecated static String getProtocol(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); @Deprecated static String readFullyString(InputStream is); @Deprecated static byte[] readFullyBytes(InputStream is); @Deprecated static void copy(InputStream input, OutputStream output); @Deprecated static File mkdirs(File dir); @Deprecated static File writeToTempFile(InputStream is, String prefix, String suffix); @Deprecated static File writeToTempFile(InputStream is, File tempDir, String prefix, String suffix); @Deprecated static File writeToTempFile(Properties props, String prefix, String suffix); @Deprecated static File writeToTempFile(Properties props, File tempDir, String prefix, String suffix); @Deprecated static Thread addShutdownHook(final Runnable task); @Deprecated static boolean removeShutdownHook(Thread hook); @Deprecated static String mergePaths(String ...items);  }### Answer:
@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); }