### Question:
PluginManager implements ContainerService { public void shutdown() { Collections.reverse(this.loadedPlugins); for (Plugin plugin : loadedPlugins) { PluginLifecycleListener listener = pluginLifecycleListenerMgr.getListener(plugin.getName()); if (listener != null) { try { ClassLoader originalCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( this.classLoaderManager.obtainPluginClassLoader(plugin.getName())); try { listener.shutdown(); } finally { Thread.currentThread().setContextClassLoader(originalCL); } } catch (Throwable t) { log.warn("Failed to get lifecycle listener to shutdown [" + plugin.getName() + "]. Cause: " + ThrowableUtil.getAllMessages(t)); } } } for (PluginEnvironment pluginEnvironment : this.loadedPluginEnvironments.values()) { pluginEnvironment.destroy(); } this.classLoaderManager.destroy(); this.loadedPluginEnvironments.clear(); this.loadedPlugins.clear(); pluginLifecycleListenerMgr.shutdown(); } PluginManager(PluginContainerConfiguration pluginContainerConfiguration,
        PluginLifecycleListenerManager pluginLifecycleListenerManager); void shutdown(); Collection<PluginEnvironment> getPlugins(); @Nullable PluginEnvironment getPlugin(String name); PluginMetadataManager getMetadataManager(); ClassLoaderManager getClassLoaderManager(); String getAmpsVersion(String pluginName);  }### Answer:
@Test public void pluginsShouldBeShutdownInCorrectOrder() throws Exception { PluginContainerConfiguration configuration = createConfiguration(); FakePluginLifecycleListenerManager pluginLifecycleListenerMgr = new FakePluginLifecycleListenerManager(); PluginManager pluginMgr = new PluginManager(configuration, pluginLifecycleListenerMgr); pluginMgr.shutdown(); verifyPluginsShutdownInCorrectOrder(pluginLifecycleListenerMgr); }