Search in sources :

Example 1 with StartupConfig

use of com.hotels.styx.StartupConfig in project styx by ExpediaGroup.

the class StartupConfigHandlerTest method outputsExpectedData.

@Test
public void outputsExpectedData() {
    StartupConfig startupConfig = newStartupConfigBuilder().styxHome("/foo").configFileLocation("/bar/configure-me.yml").logbackConfigLocation("/baz/logback-conf.xml").build();
    StartupConfigHandler handler = new StartupConfigHandler(startupConfig);
    HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block();
    assertThat(response.status(), is(OK));
    assertThat(response.bodyAs(UTF_8), matchesRegex("<html><body>" + "Styx Home='[/\\\\]foo'" + "<br />Config File Location='.*[/\\\\]bar[/\\\\]configure-me.yml'" + "<br />Log Config Location='.*[/\\\\]baz[/\\\\]logback-conf.xml'" + "</body></html>"));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) StartupConfig(com.hotels.styx.StartupConfig) Test(org.junit.jupiter.api.Test)

Example 2 with StartupConfig

use of com.hotels.styx.StartupConfig in project styx by ExpediaGroup.

the class LoggingConfigurationHandlerTest method showsLogConfigContent.

@Test
public void showsLogConfigContent() throws IOException {
    StartupConfig startupConfig = newStartupConfigBuilder().logbackConfigLocation(fixturesHome() + "/conf/environment/styx-config-test.yml").build();
    LoggingConfigurationHandler handler = new LoggingConfigurationHandler(startupConfig.logConfigLocation());
    HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block();
    String expected = Resources.load(new ClasspathResource("conf/environment/styx-config-test.yml", LoggingConfigurationHandlerTest.class));
    assertThat(response.status(), is(OK));
    assertThat(response.bodyAs(UTF_8), is(expected));
}
Also used : ClasspathResource(com.hotels.styx.common.io.ClasspathResource) HttpResponse(com.hotels.styx.api.HttpResponse) StartupConfig(com.hotels.styx.StartupConfig) Test(org.junit.jupiter.api.Test)

Example 3 with StartupConfig

use of com.hotels.styx.StartupConfig in project styx by ExpediaGroup.

the class LoggingConfigurationHandlerTest method showsErrorMessageInContentIfLogConfigFileDoesNotExist.

@Test
public void showsErrorMessageInContentIfLogConfigFileDoesNotExist() {
    StartupConfig startupConfig = newStartupConfigBuilder().logbackConfigLocation("/foo/bar").build();
    LoggingConfigurationHandler handler = new LoggingConfigurationHandler(startupConfig.logConfigLocation());
    HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block();
    assertThat(response.status(), is(OK));
    assertThat(response.bodyAs(UTF_8), matchesRegex("Could not load resource=.*foo[\\\\/]bar'"));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) StartupConfig(com.hotels.styx.StartupConfig) Test(org.junit.jupiter.api.Test)

Aggregations

StartupConfig (com.hotels.styx.StartupConfig)3 HttpResponse (com.hotels.styx.api.HttpResponse)3 Test (org.junit.jupiter.api.Test)3 ClasspathResource (com.hotels.styx.common.io.ClasspathResource)1