### Question:
BundleClassloaderWrapper extends ClassLoader { @Override public URL getResource( String name ) { return ( parent == null ) ? findResource( name ) : super.getResource( name ); } BundleClassloaderWrapper( Bundle bundle );  BundleClassloaderWrapper( Bundle bundle, ClassLoader parent ); @Override Enumeration<URL> findResources( String name ); @Override URL findResource( String name ); @Override Class<?> findClass( String name ); @Override URL getResource( String name ); Bundle getBundle();  }### Answer:
@Test public void testGetResourceNoParent() throws MalformedURLException { URL result = new URL( "http: String resource = "RESOURCE"; when( bundle.getResource( resource ) ).thenReturn( result ); BundleClassloaderWrapper bundleClassloaderWrapper = new BundleClassloaderWrapper( bundle ); assertEquals( result, bundleClassloaderWrapper.getResource( resource ) ); }
@Test public void testGetResourceParent() throws MalformedURLException { URL result = new URL( "http: String resource = "RESOURCE"; when( bundle.getResource( resource ) ).thenReturn( result ); BundleClassloaderWrapper bundleClassloaderWrapper = new BundleClassloaderWrapper( bundle, parent ); assertEquals( result, bundleClassloaderWrapper.getResource( resource ) ); }