### Question:
FileSystemPluginFactoryLoader implements PluginFactoryLoader { @Override public PluginFactory load(SpiExtension spiExtension) { return newPluginFactory(spiExtension); }  @Override PluginFactory load(SpiExtension spiExtension);  }### Answer:
@Test public void pluginLoaderLoadsPluginFromJarFile() { SpiExtensionFactory factory = new SpiExtensionFactory("testgrp.TestPluginModule", pluginsPath.toString()); PluginFactory plugin = pluginFactoryLoader.load(new SpiExtension(factory, config, null)); assertThat(plugin, is(not(nullValue()))); assertThat(plugin.getClass().getName(), is("testgrp.TestPluginModule")); }
@Test public void providesMeaningfulErrorMessageWhenConfiguredFactoryClassCannotBeLoaded() { String jarFile = "/plugins/oneplugin/testPluginA-1.0-SNAPSHOT.jar"; Path pluginsPath = fixturesHome(FileSystemPluginFactoryLoader.class, jarFile); SpiExtensionFactory factory = new SpiExtensionFactory("incorrect.plugin.class.name.TestPluginModule", pluginsPath.toString()); SpiExtension spiExtension = new SpiExtension(factory, config, null); Exception e = assertThrows(ConfigurationException.class, () -> new FileSystemPluginFactoryLoader().load(spiExtension)); assertThat(e.getMessage(), matchesPattern("Could not load a plugin factory for configuration=SpiExtension\\{" + "factory=SpiExtensionFactory\\{" + "class=incorrect.plugin.class.name.TestPluginModule, " + "classPath=.*[\\\\/]components[\\\\/]proxy[\\\\/]target[\\\\/]test-classes[\\\\/]plugins[\\\\/]oneplugin[\\\\/]testPluginA-1.0-SNAPSHOT.jar" + "\\}\\}")); }