Search in sources :

Example 1 with YamlConfig

use of com.hotels.styx.infrastructure.configuration.yaml.YamlConfig in project styx by ExpediaGroup.

the class AdminServerConfigTest method usesConfiguredPortIfPresent.

@Test
public void usesConfiguredPortIfPresent() {
    String yaml = "" + "admin:\n" + "  connectors:\n" + "    http:\n" + "      port: 1234\n";
    YamlConfig yamlConfig = new YamlConfig(yaml);
    Optional<AdminServerConfig> admin = yamlConfig.get("admin", AdminServerConfig.class);
    assertThat(admin.get().httpConnectorConfig().get().port(), is(1234));
}
Also used : YamlConfig(com.hotels.styx.infrastructure.configuration.yaml.YamlConfig) Test(org.junit.jupiter.api.Test)

Example 2 with YamlConfig

use of com.hotels.styx.infrastructure.configuration.yaml.YamlConfig in project styx by ExpediaGroup.

the class LoadBalancerFactoryProviderTest method errorsIfTheSpecifiedStrategyFactoryKeyClassIsMissing.

@Test
public void errorsIfTheSpecifiedStrategyFactoryKeyClassIsMissing() {
    String yaml = "" + "loadBalancing:\n" + "  strategy: noentry\n";
    Configuration configurations = new YamlConfig(yaml);
    assertThrows(MissingConfigurationException.class, () -> newProvider(configurations).get());
}
Also used : YamlConfig(com.hotels.styx.infrastructure.configuration.yaml.YamlConfig) Configuration(com.hotels.styx.api.configuration.Configuration) Test(org.junit.jupiter.api.Test)

Example 3 with YamlConfig

use of com.hotels.styx.infrastructure.configuration.yaml.YamlConfig in project styx by ExpediaGroup.

the class LoadBalancerFactoryProviderTest method errorsIfCannotFindTheFactoryClass.

@Test
public void errorsIfCannotFindTheFactoryClass() {
    String yaml = "" + "loadBalancing:\n" + "  strategy: awesome\n" + "  strategies:\n" + "    awesome:\n" + "      factory: {class: \"doesnot.really.exist\"}\n";
    Configuration configurations = new YamlConfig(yaml);
    assertThrows(RuntimeException.class, () -> newProvider(configurations).get());
}
Also used : YamlConfig(com.hotels.styx.infrastructure.configuration.yaml.YamlConfig) Configuration(com.hotels.styx.api.configuration.Configuration) Test(org.junit.jupiter.api.Test)

Example 4 with YamlConfig

use of com.hotels.styx.infrastructure.configuration.yaml.YamlConfig in project styx by ExpediaGroup.

the class LoadBalancerFactoryProviderTest method loadsTheConfiguredStrategy.

@Test
public void loadsTheConfiguredStrategy() {
    String yaml = "" + "loadBalancing:\n" + "  strategy: awesome\n" + "  strategies:\n" + "    awesome:\n" + "      factory: {class: \"com.hotels.styx.proxy.LoadBalancerFactoryProviderTest$NewAwesomeStrategy\"}\n";
    Configuration configuration = new YamlConfig(yaml);
    LoadBalancingStrategyFactoryProvider factoryProvider = newProvider(configuration);
    assertThat(factoryProvider.get(), is(instanceOf(NewAwesomeStrategy.class)));
}
Also used : YamlConfig(com.hotels.styx.infrastructure.configuration.yaml.YamlConfig) Configuration(com.hotels.styx.api.configuration.Configuration) Test(org.junit.jupiter.api.Test)

Example 5 with YamlConfig

use of com.hotels.styx.infrastructure.configuration.yaml.YamlConfig in project styx by ExpediaGroup.

the class AdminServerConfigTest method usesDefaultPortIfNoConnectors.

@Test
public void usesDefaultPortIfNoConnectors() {
    String yaml = "" + "admin:\n" + "  maxConnectionsCount: 123\n";
    YamlConfig yamlConfig = new YamlConfig(yaml);
    Optional<AdminServerConfig> admin = yamlConfig.get("admin", AdminServerConfig.class);
    assertThat(admin.get().httpConnectorConfig().get().port(), is(DEFAULT_ADMIN_PORT));
}
Also used : YamlConfig(com.hotels.styx.infrastructure.configuration.yaml.YamlConfig) Test(org.junit.jupiter.api.Test)

Aggregations

YamlConfig (com.hotels.styx.infrastructure.configuration.yaml.YamlConfig)5 Test (org.junit.jupiter.api.Test)5 Configuration (com.hotels.styx.api.configuration.Configuration)3