use of com.hotels.styx.api.configuration.Configuration in project styx by ExpediaGroup.
the class RetryPolicyFactoryTest method shouldCreateRetryPolicyAccordingToConfiguration.
@Test
public void shouldCreateRetryPolicyAccordingToConfiguration() {
Configuration configuration = new MapBackedConfiguration().set("count", 2);
RetryPolicy retryPolicy = new RetryPolicyFactory().create(environment, configuration);
assertThat(retryPolicy, is(instanceOf(RetryNTimes.class)));
assertThat(((RetryNTimes) retryPolicy).maxAttempts(), is(2));
}
use of com.hotels.styx.api.configuration.Configuration in project styx by ExpediaGroup.
the class FileBackedBackendServicesRegistryFactoryTest method requiresOriginsFileToBeNonEmpty.
@Test
public void requiresOriginsFileToBeNonEmpty() {
Configuration configuration = mockConfiguration(Optional.empty());
Exception e = assertThrows(ConfigurationException.class, () -> new FileBackedBackendServicesRegistry.Factory().create(environment, configuration));
assertTrue(e.getMessage().matches("missing .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 FileBackedBackendServicesRegistryFactoryTest method mockConfiguration.
private Configuration mockConfiguration(Optional<String> path) {
Configuration configuration = mock(Configuration.class);
when(configuration.get(eq("originsFile"), eq(String.class))).thenReturn(path);
return configuration;
}
use of com.hotels.styx.api.configuration.Configuration 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());
}
use of com.hotels.styx.api.configuration.Configuration 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)));
}
Aggregations