PluginLoader extends LoaderBase { InstalledPluginRecord loadPlugin(File pluginFile, Collection<JarClassLoader> dependencyClassLoaders) throws IOException { ReflectionsAndClassLoader tuple = makeJarFileScanner(pluginFile, dependencyClassLoaders); Class<?> pluginClass = readPluginConfigurationClasses(pluginFile, tuple.reflections); Plugin plugin = loadPlugin(pluginClass, tuple.reflections); return new InstalledPluginRecord(plugin, tuple.jarClassLoader); } PluginLoader(SoapUIFactoryRegistry factoryRegistry,
                        SoapUIActionRegistry actionRegistry, ListenerRegistry listenerRegistry); void unloadPlugin(Plugin plugin); PluginInfo loadPluginInfoFrom(File pluginFile, Collection<JarClassLoader> dependencyClassLoaders); static Logger log; }
@Test public void installsPluginFromFile() throws IOException { File pluginFile = new File(PluginLoaderTest.class.getResource("plugin-example-1.0.jar").getPath()); Plugin loadedPlugin = pluginLoader.loadPlugin(pluginFile, java.util.Collections.<JarClassLoader>emptySet()).plugin; assertThat(loadedPlugin.getInfo().getId().getName(), is("Example plugin")); assertThat(defaultSoapUICore.getActionRegistry().getAction("ExampleAction"), is(notNullValue())); assertThat(defaultSoapUICore.getFactoryRegistry().getFactories(RequestTransportFactory.class), is(aCollectionWithSize(1))); assertThat(defaultSoapUICore.getListenerRegistry().getListeners(WorkspaceListener.class), is(aCollectionWithSize(1))); }
@Test public void installsBarePluginFromFile() throws IOException { File pluginFile = new File(PluginLoaderTest.class.getResource("bare-plugin.jar").getPath()); Plugin loadedPlugin = pluginLoader.loadPlugin(pluginFile, java.util.Collections.<JarClassLoader>emptySet()).plugin; assertThat(loadedPlugin.getInfo().getId().getName(), is("NonAdapterPlugin")); }
@Test(expected = InvalidPluginException.class) public void rejectsPluginThatRequiresHigherReadyApiVersion() throws Exception { pluginLoader.loadPlugin(ScienceFictionPlugin.class, null); }
@Test public void acceptsPluginThatDoesNotRequireAHigherReadyApiVersion() throws Exception { pluginLoader.loadPlugin(VanillaPlugin.class, null); }
@Test public void setsPluginInPluginAwareComponents() throws Exception { Plugin plugin = pluginLoader.loadPlugin(AwarenessPlugin.class, null); AwareAction action = (AwareAction)plugin.getActions().get(0); AwareFactory factory = (AwareFactory)plugin.getFactories().iterator().next(); assertThat(action.plugin, is(plugin)); assertThat(factory.plugin, is(plugin)); }