PluginManager { public Plugin installPlugin(File pluginFile) throws IOException { PluginInfo pluginInfo = pluginLoader.loadPluginInfoFrom(pluginFile, Collections.<JarClassLoader>emptySet()); if (findInstalledVersionOf(pluginInfo) != null && !overwriteConfirmed(pluginInfo)) { return null; } File destinationFile = new File(pluginDirectory, pluginFile.getName()); if (destinationFile.exists()) { destinationFile = createNonExistingFileName(destinationFile); } fileOperations.copyFile(pluginFile, destinationFile); resolver.addPlugin(pluginInfo, destinationFile); if (uninstallPlugin(pluginInfo, true)) { return doInstallPlugin(destinationFile, findDependentClassLoaders(destinationFile)); } else { return null; } } PluginManager(SoapUIFactoryRegistry factoryRegistry,
                         SoapUIActionRegistry actionRegistry, ListenerRegistry listenerRegistry); PluginLoader getPluginLoader(); static ForkJoinPool getForkJoinPool(); void loadPlugins(); Plugin installPlugin(File pluginFile); boolean uninstallPlugin(Plugin plugin); boolean uninstallPlugin(PluginInfo pluginInfo, boolean silent); Collection<Plugin> getInstalledPlugins(); void addPluginListener(PluginListener listener); void removePluginListener(PluginListener listener); void installPlugins(List<File> pluginFilesToInstall); Collection<Plugin> getDependentPlugins(Plugin selectedPlugin);  }
@Test public void installsAndReturnsPlugin() throws Exception { assertThat(pluginManager.installPlugin(pluginFile), is(plugin)); verify(pluginLoader).loadPlugin(pluginFile, java.util.Collections.<JarClassLoader>emptySet()); verify(fileOperations).copyFile(eq(pluginFile), any(File.class)); }
@Test public void loadsNothingFromPluginWhenUserDeclinesOverwrite() throws Exception { pluginManager.installPlugin(pluginFile); when(pluginLoader.loadPluginInfoFrom(secondPluginFile, java.util.Collections.<JarClassLoader>emptySet())).thenReturn(upgradedAndUninstallablePlugin.getInfo()); stubbedDialogs.mockConfirmWithReturnValue(false); pluginManager.installPlugin(secondPluginFile); verify(pluginLoader, never()).loadPlugin(secondPluginFile, java.util.Collections.<JarClassLoader>emptySet()); }
@Test public void displaysVersionNumbersWhenPromptingForOverwriteConfirmation() throws Exception { pluginManager.installPlugin(pluginFile); stubbedDialogs.mockConfirmWithReturnValue(false); pluginManager.installPlugin(secondPluginFile); String confirmationQuestion = stubbedDialogs.getConfirmations().get(0).question; assertThat(confirmationQuestion, containsString("0.1")); assertThat(confirmationQuestion, containsString("0.2")); }