Search in sources :

Example 1 with Configuration

use of com.hotels.styx.api.configuration.Configuration in project styx by ExpediaGroup.

the class FileBackedBackendServicesRegistryFactoryTest method fileMonitorIsTurnedOffByDefault.

@Test
public void fileMonitorIsTurnedOffByDefault() {
    Configuration configuration = mockConfiguration(Optional.of("/styx/config/path/origins.yml"), Optional.empty());
    FileBackedBackendServicesRegistry registry = (FileBackedBackendServicesRegistry) new FileBackedBackendServicesRegistry.Factory().create(environment, configuration);
    assertThat(registry.monitor(), is(FileMonitor.DISABLED));
}
Also used : Configuration(com.hotels.styx.api.configuration.Configuration) Test(org.junit.jupiter.api.Test)

Example 2 with Configuration

use of com.hotels.styx.api.configuration.Configuration in project styx by ExpediaGroup.

the class FileBackedBackendServicesRegistryFactoryTest method createsWithFileChangeMonitor.

@Test
public void createsWithFileChangeMonitor() {
    Configuration configuration = mockConfiguration(Optional.of(monitoredFile.toString()), Optional.of(new FileMonitorSettings(true)));
    FileBackedBackendServicesRegistry registry = (FileBackedBackendServicesRegistry) new FileBackedBackendServicesRegistry.Factory().create(environment, configuration);
    assertThat(registry.monitor(), instanceOf(FileChangeMonitor.class));
}
Also used : Configuration(com.hotels.styx.api.configuration.Configuration) FileMonitorSettings(com.hotels.styx.proxy.backends.file.FileChangeMonitor.FileMonitorSettings) Test(org.junit.jupiter.api.Test)

Example 3 with Configuration

use of com.hotels.styx.api.configuration.Configuration in project styx by ExpediaGroup.

the class FileBackedBackendServicesRegistryFactoryTest method mockConfiguration.

private Configuration mockConfiguration(Optional<String> path, Optional<FileMonitorSettings> monitorSettings) {
    Configuration configuration = mock(Configuration.class);
    when(configuration.get(eq("originsFile"), eq(String.class))).thenReturn(path);
    when(configuration.get(eq("monitor"), eq(FileMonitorSettings.class))).thenReturn(monitorSettings);
    return configuration;
}
Also used : Configuration(com.hotels.styx.api.configuration.Configuration) FileMonitorSettings(com.hotels.styx.proxy.backends.file.FileChangeMonitor.FileMonitorSettings)

Example 4 with Configuration

use of com.hotels.styx.api.configuration.Configuration in project styx by ExpediaGroup.

the class FileBackedBackendServicesRegistryFactoryTest method requiresOriginsFileToBeSet.

@Test
public void requiresOriginsFileToBeSet() {
    Configuration configuration = mockConfiguration(Optional.of(""));
    Exception e = assertThrows(ConfigurationException.class, () -> new FileBackedBackendServicesRegistry.Factory().create(environment, configuration));
    assertTrue(e.getMessage().matches("empty .services.registry.factory.config.originsFile. config value for factory class FileBackedBackendServicesRegistry.Factory"));
}
Also used : Configuration(com.hotels.styx.api.configuration.Configuration) ConfigurationException(com.hotels.styx.api.configuration.ConfigurationException) Test(org.junit.jupiter.api.Test)

Example 5 with Configuration

use of com.hotels.styx.api.configuration.Configuration 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)

Aggregations

Configuration (com.hotels.styx.api.configuration.Configuration)13 Test (org.junit.jupiter.api.Test)9 ConfigurationException (com.hotels.styx.api.configuration.ConfigurationException)3 YamlConfig (com.hotels.styx.infrastructure.configuration.yaml.YamlConfig)3 MapBackedConfiguration (com.hotels.styx.api.configuration.Configuration.MapBackedConfiguration)2 RetryPolicy (com.hotels.styx.api.extension.retrypolicy.spi.RetryPolicy)2 FileMonitorSettings (com.hotels.styx.proxy.backends.file.FileChangeMonitor.FileMonitorSettings)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Environment (com.hotels.styx.Environment)1 StyxConfig (com.hotels.styx.StyxConfig)1 AdminServerConfig (com.hotels.styx.admin.AdminServerConfig)1 Environment (com.hotels.styx.api.Environment)1 MicrometerRegistry (com.hotels.styx.api.MicrometerRegistry)1 ServiceFactory (com.hotels.styx.api.configuration.ServiceFactory)1 ActiveOrigins (com.hotels.styx.api.extension.ActiveOrigins)1 LoadBalancer (com.hotels.styx.api.extension.loadbalancing.spi.LoadBalancer)1 LoadBalancerFactory (com.hotels.styx.api.extension.loadbalancing.spi.LoadBalancerFactory)1 RetryPolicyFactory (com.hotels.styx.api.extension.retrypolicy.spi.RetryPolicyFactory)1 Pair (com.hotels.styx.common.Pair)1 Pair.pair (com.hotels.styx.common.Pair.pair)1