Search in sources :

Example 1 with Environment

use of com.hotels.styx.api.Environment in project styx by ExpediaGroup.

the class ServiceProvisionTest method loadsNewConfigurationFormat.

@Test
public void loadsNewConfigurationFormat() {
    Environment env = environmentWithConfig(yamlForServiceFactories);
    Map<String, StyxService> services = loadServices(env.configuration(), env, "multi", StyxService.class);
    assertThat(services.get("backendProvider"), instanceOf(BackendServiceProvider.class));
    assertThat(services.get("routingProvider"), instanceOf(RoutingObjectProvider.class));
}
Also used : Environment(com.hotels.styx.api.Environment) StyxService(com.hotels.styx.api.extension.service.spi.StyxService) AbstractStyxService(com.hotels.styx.api.extension.service.spi.AbstractStyxService) Test(org.junit.jupiter.api.Test)

Example 2 with Environment

use of com.hotels.styx.api.Environment in project styx by ExpediaGroup.

the class ServiceProvisionTest method isInstanceWorks.

@Test
public void isInstanceWorks() {
    Environment env = environmentWithConfig(yamlForServices);
    Map<String, StyxService> services = loadServices(env.configuration(), env, "multi", StyxService.class);
    assertThat(services.get("backendProvider"), instanceOf(BackendServiceProvider.class));
    assertThat(services.get("routingProvider"), instanceOf(RoutingObjectProvider.class));
}
Also used : Environment(com.hotels.styx.api.Environment) StyxService(com.hotels.styx.api.extension.service.spi.StyxService) AbstractStyxService(com.hotels.styx.api.extension.service.spi.AbstractStyxService) Test(org.junit.jupiter.api.Test)

Example 3 with Environment

use of com.hotels.styx.api.Environment in project styx by ExpediaGroup.

the class ServiceProvisionTest method throwsExceptionForInvalidSpiExtensionFactory.

@Test
public void throwsExceptionForInvalidSpiExtensionFactory() {
    String config = "" + "multi:\n" + "  factories:\n" + "    backendProvider:\n" + "      enabled: false\n" + "      factory:\n" + "        classPath: /path/to/jar\n" + "      config:\n" + "         attribute: x\n";
    Environment env = environmentWithConfig(config);
    Exception e = assertThrows(ConfigurationException.class, () -> loadServices(env.configuration(), env, "multi", StyxService.class));
    assertThat(e.getMessage(), matchesPattern("Unexpected configuration object 'services.factories.backendProvider', Configuration.*'"));
}
Also used : Environment(com.hotels.styx.api.Environment) StyxService(com.hotels.styx.api.extension.service.spi.StyxService) AbstractStyxService(com.hotels.styx.api.extension.service.spi.AbstractStyxService) ConfigurationException(com.hotels.styx.api.configuration.ConfigurationException) Test(org.junit.jupiter.api.Test)

Example 4 with Environment

use of com.hotels.styx.api.Environment in project styx by ExpediaGroup.

the class ServiceProvisionTest method throwsExceptionForInvalidServiceFactoryConfig.

@Test
public void throwsExceptionForInvalidServiceFactoryConfig() {
    String config = "" + "multi:\n" + "  factories:\n" + "    backendProvider:\n" + "      enabled: false\n" + "      config:\n" + "        stringValue: valueNumber1\n";
    Environment env = environmentWithConfig(config);
    Exception e = assertThrows(ConfigurationException.class, () -> loadServices(env.configuration(), env, "multi", StyxService.class));
    assertThat(e.getMessage(), matchesPattern("Unexpected configuration object 'services.factories.backendProvider', Configuration.*'"));
}
Also used : Environment(com.hotels.styx.api.Environment) StyxService(com.hotels.styx.api.extension.service.spi.StyxService) AbstractStyxService(com.hotels.styx.api.extension.service.spi.AbstractStyxService) ConfigurationException(com.hotels.styx.api.configuration.ConfigurationException) Test(org.junit.jupiter.api.Test)

Example 5 with Environment

use of com.hotels.styx.api.Environment in project styx by ExpediaGroup.

the class FileBackedBackendServicesRegistryFactoryTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    tempDir = createTempDirectory("");
    monitoredFile = Paths.get(tempDir.toString(), "origins.yml");
    write(monitoredFile, "content-v1");
    environment = new com.hotels.styx.Environment.Builder().registry(new MicrometerRegistry(new SimpleMeterRegistry())).build();
}
Also used : MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Environment(com.hotels.styx.api.Environment) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Environment (com.hotels.styx.api.Environment)8 AbstractStyxService (com.hotels.styx.api.extension.service.spi.AbstractStyxService)6 StyxService (com.hotels.styx.api.extension.service.spi.StyxService)6 Test (org.junit.jupiter.api.Test)6 ConfigurationException (com.hotels.styx.api.configuration.ConfigurationException)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 MicrometerRegistry (com.hotels.styx.api.MicrometerRegistry)1 Configuration (com.hotels.styx.api.configuration.Configuration)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 RetryPolicy (com.hotels.styx.api.extension.retrypolicy.spi.RetryPolicy)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 JsonNodeConfig (com.hotels.styx.infrastructure.configuration.yaml.JsonNodeConfig)1 UtilKt.iteratorToList (com.hotels.styx.javaconvenience.UtilKt.iteratorToList)1 ClassFactories.newInstance (com.hotels.styx.proxy.ClassFactories.newInstance)1 EXTENSION_OBJECT_FACTORY (com.hotels.styx.spi.ExtensionObjectFactory.EXTENSION_OBJECT_FACTORY)1