BundleDelegatingClassLoader extends ClassLoader { @SuppressWarnings("unchecked") protected Enumeration findResources(String name) throws IOException { Enumeration resources = bundle.getResources(name); if (classLoader != null && (resources == null || !resources.hasMoreElements())) { resources = classLoader.getResources(name); } return resources; } BundleDelegatingClassLoader(Bundle bundle);  BundleDelegatingClassLoader(Bundle bundle, ClassLoader classLoader); Bundle getBundle(); @Override String toString();  }
@Test public void testFindResources() throws Exception { String resource = getClass().getName().replace('.', '/') + ".class"; Bundle bundle = mock(Bundle.class); BundleDelegatingClassLoader classLoader = new BundleDelegatingClassLoader(bundle, getClass().getClassLoader()); assertThat(classLoader.findResources(resource).hasMoreElements(), equalTo(true)); verify(bundle).getResources(eq(resource)); }