ResourceLoader { public static InputStream getResourceAsStream(String path) { return getResourceAsStream(path, getDefaultClassLoader(), null); }  static ClassLoader getDefaultClassLoader(); static void setDefaultClassLoader(ClassLoader defaultClassLoader); static URL getPackageResourceAsURL(Package ppackage, String name); static URL getPackageResourceAsURL(Package ppackage, String name, ClassLoader classLoader, AbstractFile rootPackageFile); static URL getResourceAsURL(String path); static URL getResourceAsURL(String path, ClassLoader classLoader, AbstractFile rootPackageFile); static InputStream getPackageResourceAsStream(Package ppackage, String name); static InputStream getPackageResourceAsStream(Package ppackage, String name, ClassLoader classLoader, AbstractFile rootPackageFile); static InputStream getResourceAsStream(String path); static InputStream getResourceAsStream(String path, ClassLoader classLoader, AbstractFile rootPackageFile); static AbstractFile getPackageResourceAsFile(Package ppackage, String name); static AbstractFile getPackageResourceAsFile(Package ppackage, String name, ClassLoader classLoader, AbstractFile rootPackageFile); static AbstractFile getResourceAsFile(String path); static AbstractFile getResourceAsFile(String path, ClassLoader classLoader, AbstractFile rootPackageFile); static AbstractFile getRootPackageAsFile(Class<?> aClass); static String getRelativePackagePath(Package ppackage); static String getRelativeClassPath(Class<?> cclass);  }
@Test public void testResourceAsStream() throws IOException { assertReadable(ResourceLoader.getResourceAsStream(getExistingResourcePath())); assertReadable(ResourceLoader.getResourceAsStream("/"+getExistingResourcePath())); assert ResourceLoader.getResourceAsStream(getNonExistingResourcePath()) == null; assertReadable(ResourceLoader.getResourceAsStream(getExistingResourcePath(), getThisClassLoader(), getRootPackageFile())); assertReadable(ResourceLoader.getResourceAsStream("/"+getExistingResourcePath(), getThisClassLoader(), getRootPackageFile())); assert ResourceLoader.getResourceAsStream(getNonExistingResourcePath(), getThisClassLoader(), getRootPackageFile()) == null; }