### Question:
PluginsClassLoader extends AbstractClassLoader { @Override protected URL findResource(final String name) { final Plugin indexedPlugin; synchronized (this) { indexedPlugin = pluginResourceIndex.get(name); } final URL result; if (isPluginEnabled(indexedPlugin)) { result = indexedPlugin.getClassLoader().getResource(name); } else { result = getResourceFromPlugins(name); } if (log.isDebugEnabled()) { log.debug("Find resource [ " + name + " ], found [ " + result + " ]"); } return result; } 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 testFindResourceWhenIndexed() { final StubClassLoader stubClassLoader = new StubClassLoader(); loadPluginResource(stubClassLoader); assertTrue(stubClassLoader.getFindResourceNames().contains(TEST_RESOURCE)); stubClassLoader.clear(); mockPlugin.expectAndReturn("getKey", PLUGIN_KEY); mockPluginAccessor.matchAndReturn("isPluginEnabled", C.args(C.eq(PLUGIN_KEY)), Boolean.TRUE); mockPlugin.expectAndReturn("getClassLoader", stubClassLoader); pluginsClassLoader.findResource(TEST_RESOURCE); assertTrue(stubClassLoader.getFindResourceNames().contains(TEST_RESOURCE)); }
@Test public void testFindResourceWhenIndexedAndPluginDisabled() { final StubClassLoader stubClassLoader = new StubClassLoader(); loadPluginResource(stubClassLoader); assertTrue(stubClassLoader.getFindResourceNames().contains(TEST_RESOURCE)); stubClassLoader.clear(); mockPluginAccessor.expectAndReturn("getEnabledPlugins", Collections.emptyList()); mockPlugin.expectAndReturn("getKey", PLUGIN_KEY); mockPluginAccessor.matchAndReturn("isPluginEnabled", C.args(C.eq(PLUGIN_KEY)), Boolean.FALSE); pluginsClassLoader.findResource(TEST_RESOURCE); assertFalse(stubClassLoader.getFindResourceNames().contains(TEST_RESOURCE)); }