@Test public void attemptsToLoadAllPluginsEvenIfSomePluginFactoriesCannotBeLoaded() { LoggingTestSupport log = new LoggingTestSupport(FailureHandling.class); String yaml = "" + "plugins:\n" + " active: myPlugin1,myPlugin2,myPlugin3\n" + " all:\n" + " myPlugin1:\n" + " factory:\n" + " class: BadClassName\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n" + " myPlugin2:\n" + " factory:\n" + " class: BadClassName\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n" + " myPlugin3:\n" + " factory:\n" + " class: BadClassName\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n"; Exception e = assertThrows(RuntimeException.class, () -> PluginLoadingForStartup.loadPlugins(environment(yaml))); assertThat(e.getMessage(), matchesPattern("3 plugin\\(s\\) could not be loaded: failedPlugins=\\[myPlugin1, myPlugin2, myPlugin3\\]; failureCauses=\\[" + "myPlugin1: com.hotels.styx.api.configuration.ConfigurationException: Could not load a plugin factory.*, " + "myPlugin2: com.hotels.styx.api.configuration.ConfigurationException: Could not load a plugin factory.*, " + "myPlugin3: com.hotels.styx.api.configuration.ConfigurationException: Could not load a plugin factory.*\\]")); assertThat(log.log(), hasItem(loggingEvent(ERROR, "Could not load plugin: pluginName=myPlugin1; factoryClass=.*", ConfigurationException.class, "Could not load a plugin factory for.*"))); log.stop(); }
public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private  PluginLoadingForStartup(); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private  PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories); static List<NamedPlugin> loadPlugins(Environment environment); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private  PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories); static List<NamedPlugin> loadPlugins(Environment environment);  }