### Question:
BundleClassloaderWrapper extends ClassLoader { @Override protected Class<?> loadClass( String name, boolean resolve ) throws ClassNotFoundException { Class<?> clazz = ( parent == null ) ? findClass( name ) : super.loadClass( name, false ); if ( resolve ) { super.resolveClass( clazz ); } return clazz; } 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 testLoadClassNoParentNoResolve() throws ClassNotFoundException { Class result = Map.class; String name = "RESOURCE"; when( bundle.loadClass( name ) ).thenReturn( result ); BundleClassloaderWrapper bundleClassloaderWrapper = new BundleClassloaderWrapper( bundle ); assertEquals( result, bundleClassloaderWrapper.loadClass( name, false ) ); }
@Test public void testLoadClassNoParentResolve() throws ClassNotFoundException { Class result = Map.class; String name = "RESOURCE"; when( bundle.loadClass( name ) ).thenReturn( result ); BundleClassloaderWrapper bundleClassloaderWrapper = new BundleClassloaderWrapper( bundle ); assertEquals( result, bundleClassloaderWrapper.loadClass( name, true ) ); }
@Test public void testLoadClassParentNoResolve() throws ClassNotFoundException { Class result = Map.class; String name = "RESOURCE"; when( bundle.loadClass( name ) ).thenReturn( result ); BundleClassloaderWrapper bundleClassloaderWrapper = new BundleClassloaderWrapper( bundle, parent ); assertEquals( result, bundleClassloaderWrapper.loadClass( name, false ) ); }
@Test public void testLoadClassParentResolve() throws ClassNotFoundException { Class result = Map.class; String name = "RESOURCE"; when( bundle.loadClass( name ) ).thenReturn( result ); BundleClassloaderWrapper bundleClassloaderWrapper = new BundleClassloaderWrapper( bundle, parent ); assertEquals( result, bundleClassloaderWrapper.loadClass( name, true ) ); }