### Question:
PluginsClassLoader extends AbstractClassLoader { @Override protected Class<?> findClass(final String className) throws ClassNotFoundException { final Plugin indexedPlugin; synchronized (this) { indexedPlugin = pluginClassIndex.get(className); } final Class<?> result; if (isPluginEnabled(indexedPlugin)) { result = indexedPlugin.getClassLoader().loadClass(className); } else { result = loadClassFromPlugins(className); } if (log.isDebugEnabled()) { log.debug("Find class [ " + className + " ], found [ " + result + " ]"); } if (result != null) { return result; } else { throw new ClassNotFoundException(className); } } PluginsClassLoader(final PluginAccessor pluginAccessor);  PluginsClassLoader(final ClassLoader parent, final PluginAccessor pluginAccessor);  PluginsClassLoader(final ClassLoader parent, final PluginAccessor pluginAccessor, PluginEventManager pluginEventManager); synchronized void notifyUninstallPlugin(final Plugin plugin); Plugin getPluginForClass(String className); @PluginEventListener void onPluginEnabled(PluginEnabledEvent event); @PluginEventListener void onPluginModuleEnabled(PluginModuleEnabledEvent event); synchronized void notifyPluginOrModuleEnabled();  }### Answer:
@Test public void testFindClassWhenIndexed() throws Exception { final StubClassLoader stubClassLoader = new StubClassLoader(); loadPluginClass(stubClassLoader); assertTrue(stubClassLoader.getFindClassNames().contains(TEST_CLASS)); stubClassLoader.clear(); mockPlugin.expectAndReturn("getKey", PLUGIN_KEY); mockPluginAccessor.matchAndReturn("isPluginEnabled", C.args(C.eq(PLUGIN_KEY)), Boolean.TRUE); mockPlugin.expectAndReturn("getClassLoader", stubClassLoader); pluginsClassLoader.findClass(TEST_CLASS); assertTrue(stubClassLoader.getFindClassNames().contains(TEST_CLASS)); }
@Test public void testFindClassWhenIndexedAndPluginDisabled() throws Exception { final StubClassLoader stubClassLoader = new StubClassLoader(); loadPluginClass(stubClassLoader); assertTrue(stubClassLoader.getFindClassNames().contains(TEST_CLASS)); stubClassLoader.clear(); mockPluginAccessor.expectAndReturn("getEnabledPlugins", Collections.emptyList()); mockPlugin.expectAndReturn("getKey", PLUGIN_KEY); mockPluginAccessor.matchAndReturn("isPluginEnabled", C.args(C.eq(PLUGIN_KEY)), Boolean.FALSE); try { pluginsClassLoader.findClass(TEST_CLASS); fail("Plugin is disabled so its ClassLoader should throw ClassNotFoundException"); } catch (ClassNotFoundException e) { } }