use of com.hotels.styx.api.extension.service.spi.StyxService 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));
}
use of com.hotels.styx.api.extension.service.spi.StyxService 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));
}
use of com.hotels.styx.api.extension.service.spi.StyxService in project styx by ExpediaGroup.
the class StyxServerComponentsTest method loadsServices.
@Test
public void loadsServices() {
StyxServerComponents components = new StyxServerComponents.Builder().registry(new MicrometerRegistry(new CompositeMeterRegistry())).styxConfig(new StyxConfig()).services((env, routeDb) -> Map.of("service1", mock(StyxService.class), "service2", mock(StyxService.class))).build();
Map<String, StyxService> services = components.services();
assertThat(services.keySet(), containsInAnyOrder("service1", "service2"));
}
use of com.hotels.styx.api.extension.service.spi.StyxService in project styx by ExpediaGroup.
the class StyxServerTest method serverDoesNotStartIfServiceFails.
@Test
public void serverDoesNotStartIfServiceFails() {
StyxServer styxServer = null;
try {
StyxService testService = registryThatFailsToStart();
styxServer = styxServerWithBackendServiceRegistry(testService);
Service serverService = styxServer.startAsync();
eventually(() -> assertThat(serverService.state(), is(FAILED)));
assertThat(styxServer.state(), is(FAILED));
} finally {
stopIfRunning(styxServer);
}
}
use of com.hotels.styx.api.extension.service.spi.StyxService in project styx by ExpediaGroup.
the class ServiceProviderHandlerTest method createTestStore.
private StyxObjectStore<StyxObjectRecord<StyxService>> createTestStore() throws IOException {
ObjectMapper mapper = new ObjectMapper();
StyxService mockService = mock(StyxService.class);
StyxObjectStore<StyxObjectRecord<StyxService>> store = new StyxObjectStore<>();
JsonNode config1 = mapper.readTree("{\"setting1\" : \"A\", \"setting2\" : \"A\"}");
StyxObjectRecord<StyxService> rec1 = new StyxObjectRecord<>("Type1", new HashSet<>(Arrays.asList("this=that", "truth=false")), config1, mockService);
store.insert("object1", rec1);
JsonNode config2 = mapper.readTree("{\"setting1\" : \"B\", \"setting2\" : \"B\"}");
StyxObjectRecord<StyxService> rec2 = new StyxObjectRecord<>("Type2", new HashSet<>(Arrays.asList("up=down", "weakness=strength")), config2, mockService);
store.insert("object2", rec2);
JsonNode config3 = mapper.readTree("{\"setting1\" : \"C\", \"setting2\" : \"C\"}");
StyxObjectRecord<StyxService> rec3 = new StyxObjectRecord<>("Type3", new HashSet<>(Arrays.asList("black=white", "left=right")), config3, mockService);
store.insert("object3", rec3);
return store;
}
Aggregations