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));
}
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));
}
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;
}
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"));
}
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());
}
Aggregations