use of com.hotels.styx.Environment in project styx by ExpediaGroup.
the class StyxServerComponentsTest method createsEnvironment.
@Test
public void createsEnvironment() {
Configuration config = new Configuration.MapBackedConfiguration().set("foo", "abc").set("bar", "def");
StyxServerComponents components = new StyxServerComponents.Builder().registry(new MicrometerRegistry(new CompositeMeterRegistry())).styxConfig(new StyxConfig(config)).build();
Environment environment = components.environment();
assertThat(environment.configuration().get("foo", String.class), isValue("abc"));
assertThat(environment.configuration().get("bar", String.class), isValue("def"));
assertThat(environment.eventBus(), is(notNullValue()));
assertThat(environment.metricRegistry(), is(notNullValue()));
}
use of com.hotels.styx.Environment in project styx by ExpediaGroup.
the class PluginLoadingForStartupTest method appliesDefaultMetricsScopeForPlugins.
@Test
public void appliesDefaultMetricsScopeForPlugins() {
String yaml = "" + "plugins:\n" + " active: myPlugin, myAnotherPlugin\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" + " myAnotherPlugin:\n" + " factory:\n" + " class: com.hotels.styx.startup.extensions.PluginLoadingForStartupTest$MyPluginFactory\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n" + " config:\n" + " testConfiguration: test-foo-bar\n";
Environment environment = environment(yaml);
PluginLoadingForStartup.loadPlugins(environment);
assertThat(environment.meterRegistry().get("plugin.internal.myplugin.initialised").counter().count(), is(1D));
assertThat(environment.meterRegistry().get("plugin.internal.myanotherplugin.initialised").counter().count(), is(1D));
assertThat(environment.meterRegistry().get("plugin.internal.myPlugin.legacy").tags(Tags.of("attribute", "count", "metricSource", "dropwizard")).gauge().value(), is(1D));
assertThat(environment.meterRegistry().get("plugin.internal.myAnotherPlugin.legacy").tags(Tags.of("attribute", "count", "metricSource", "dropwizard")).gauge().value(), is(1D));
assertThat(environment.metricRegistry().counter("plugin.internal.myPlugin.legacy").getCount(), is(1L));
assertThat(environment.metricRegistry().counter("plugin.internal.myAnotherPlugin.legacy").getCount(), is(1L));
}
use of com.hotels.styx.Environment in project styx by ExpediaGroup.
the class StaticPipelineBuilderTest method staticPipelineBuilderTest.
@BeforeEach
public void staticPipelineBuilderTest() {
environment = new Environment.Builder().registry(new MicrometerRegistry(new SimpleMeterRegistry())).build();
clientFactory = (backendService, originsInventory, originStatsFactory) -> (request, context) -> Mono.just(response(OK).build());
registry = backendRegistry(newBackendServiceBuilder().origins(newOriginBuilder("localhost", 0).build()).path("/foo").build());
}
Aggregations