use of com.hotels.styx.spi.config.SpiExtension in project styx by ExpediaGroup.
the class PluginLoadingForStartup method loadPluginFactory.
private static ConfiguredPluginFactory loadPluginFactory(Pair<String, SpiExtension> pair) {
String pluginName = pair.key();
SpiExtension spiExtension = pair.value();
PluginFactory factory = new FileSystemPluginFactoryLoader().load(spiExtension);
return new ConfiguredPluginFactory(pluginName, factory, spiExtension::config);
}
use of com.hotels.styx.spi.config.SpiExtension in project styx by ExpediaGroup.
the class FileSystemPluginFactoryLoaderTest method pluginLoaderLoadsPluginFromJarFile.
@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"));
}
use of com.hotels.styx.spi.config.SpiExtension in project styx by ExpediaGroup.
the class FileSystemPluginFactoryLoaderTest method providesMeaningfulErrorMessageWhenConfiguredFactoryClassCannotBeLoaded.
@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" + "\\}\\}"));
}
Aggregations