### Question:
PluginsClassLoader extends AbstractClassLoader { public Plugin getPluginForClass(String className) { Plugin indexedPlugin; synchronized (this) { indexedPlugin = pluginClassIndex.get(className); } if (isPluginEnabled(indexedPlugin)) { return indexedPlugin; } if (isSystemClass(className)) { return null; } Class clazz = loadClassFromPlugins(className); if (clazz == null) { return null; } synchronized (this) { indexedPlugin = pluginClassIndex.get(className); } return indexedPlugin; } 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 testGetPluginForClass() throws Exception { final MockPluginAccessor mockPluginAccessor = new MockPluginAccessor(); PluginsClassLoader pluginsClassLoader = new PluginsClassLoader(mockPluginAccessor); MockClassLoader mockClassLoaderA = new MockClassLoader(); mockClassLoaderA.register("com.acme.Ant", String.class); mockClassLoaderA.register("com.acme.Clash", String.class); MockPlugin pluginA = new MockPlugin("A", mockClassLoaderA); mockPluginAccessor.addPlugin(pluginA); MockClassLoader mockClassLoaderB = new MockClassLoader(); mockClassLoaderB.register("com.acme.Bat", String.class); mockClassLoaderB.register("com.acme.Clash", String.class); MockPlugin pluginB = new MockPlugin("B", mockClassLoaderB); mockPluginAccessor.addPlugin(pluginB); assertEquals(null, pluginsClassLoader.getPluginForClass("com.acme.Ant")); assertEquals(null, pluginsClassLoader.getPluginForClass("com.acme.Bat")); assertEquals(null, pluginsClassLoader.getPluginForClass("com.acme.Clash")); assertEquals(null, pluginsClassLoader.getPluginForClass("java.lang.String")); pluginB.enable(); pluginsClassLoader.notifyPluginOrModuleEnabled(); assertEquals(null, pluginsClassLoader.getPluginForClass("com.acme.Ant")); assertEquals(pluginB, pluginsClassLoader.getPluginForClass("com.acme.Bat")); assertEquals(pluginB, pluginsClassLoader.getPluginForClass("com.acme.Clash")); assertEquals(null, pluginsClassLoader.getPluginForClass("java.lang.String")); pluginA.enable(); pluginsClassLoader.notifyPluginOrModuleEnabled(); assertEquals(pluginA, pluginsClassLoader.getPluginForClass("com.acme.Ant")); assertEquals(pluginB, pluginsClassLoader.getPluginForClass("com.acme.Bat")); assertEquals(pluginB, pluginsClassLoader.getPluginForClass("com.acme.Clash")); assertEquals(null, pluginsClassLoader.getPluginForClass("java.lang.String")); pluginsClassLoader.notifyUninstallPlugin(pluginB); assertEquals(pluginA, pluginsClassLoader.getPluginForClass("com.acme.Ant")); assertEquals(pluginB, pluginsClassLoader.getPluginForClass("com.acme.Bat")); assertEquals(pluginA, pluginsClassLoader.getPluginForClass("com.acme.Clash")); assertEquals(null, pluginsClassLoader.getPluginForClass("java.lang.String")); }