use of com.hotels.styx.proxy.plugin.NamedPlugin in project styx by ExpediaGroup.
the class StyxServerComponentsTest method loadsPlugins.
@Test
public void loadsPlugins() {
ConfiguredPluginFactory f1 = new ConfiguredPluginFactory("plugin1", any -> stubPlugin("MyResponse1"));
ConfiguredPluginFactory f2 = new ConfiguredPluginFactory("plugin2", any -> stubPlugin("MyResponse2"));
StyxServerComponents components = new StyxServerComponents.Builder().registry(new MicrometerRegistry(new CompositeMeterRegistry())).styxConfig(new StyxConfig()).pluginFactories(List.of(f1, f2)).build();
List<NamedPlugin> plugins = components.plugins();
List<String> names = plugins.stream().map(NamedPlugin::name).collect(toList());
assertThat(names, contains("plugin1", "plugin2"));
}
use of com.hotels.styx.proxy.plugin.NamedPlugin in project styx by ExpediaGroup.
the class StaticPipelineBuilderTest method appliesPluginsInOrderTheyAreConfigured.
@Test
public void appliesPluginsInOrderTheyAreConfigured() throws Exception {
Iterable<NamedPlugin> plugins = List.of(interceptor("Test-A", appendResponseHeader("X-From-Plugin", "A")), interceptor("Test-B", appendResponseHeader("X-From-Plugin", "B")));
HttpHandler handler = new StaticPipelineFactory(clientFactory, environment, registry, plugins, executor, false).build();
LiveHttpResponse response = Mono.from(handler.handle(get("/foo").build(), requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(response.headers("X-From-Plugin"), hasItems("B", "A"));
}
use of com.hotels.styx.proxy.plugin.NamedPlugin in project styx by ExpediaGroup.
the class PluginLoadingForStartupTest method suppliesConfiguredPlugin.
@Test
public void suppliesConfiguredPlugin() {
String yaml = "" + "plugins:\n" + " active: myPlugin\n" + " all:\n" + " myPlugin:\n" + " factory:\n" + " class: com.hotels.styx.startup.extensions.PluginLoadingForStartupTest$MyPluginFactory\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n" + " config:\n" + " testConfiguration: test-foo-bar\n";
List<NamedPlugin> plugins = PluginLoadingForStartup.loadPlugins(environment(yaml));
NamedPlugin plugin = plugins.get(0);
assertThat(plugin.originalPlugin(), is(instanceOf(MyPlugin.class)));
assertThat(plugin.name(), is("myPlugin"));
assertThat(((MyPlugin) plugin.originalPlugin()).myPluginConfig, is(new MyPluginConfig("test-foo-bar")));
}
Aggregations