Search in sources :

Example 36 with BackendService

use of com.hotels.styx.api.extension.service.BackendService in project styx by ExpediaGroup.

the class MemoryBackedRegistryTest method updatesResources.

@Test
public void updatesResources() {
    BackendService landing = backendService("landing", 9091);
    MemoryBackedRegistry<BackendService> registry = new MemoryBackedRegistry<>();
    registry.add(backendService("shopping", 9090));
    registry.add(landing);
    registry.addListener(listener);
    BackendService shopping = backendService("shopping", 9091);
    registry.add(shopping);
    assertThat(registry.get(), containsInAnyOrder(landing, shopping));
    verify(listener).onChange(eq(updated(shopping)));
}
Also used : BackendService(com.hotels.styx.api.extension.service.BackendService) Test(org.junit.jupiter.api.Test)

Example 37 with BackendService

use of com.hotels.styx.api.extension.service.BackendService in project styx by ExpediaGroup.

the class MemoryBackedRegistryTest method removesResources.

@Test
public void removesResources() {
    BackendService shopping = backendService("shopping", 9090);
    BackendService landing = backendService("landing", 9091);
    MemoryBackedRegistry<BackendService> registry = new MemoryBackedRegistry<>();
    registry.add(shopping);
    registry.add(landing);
    registry.addListener(listener);
    registry.removeById(id("shopping"));
    assertThat(registry.get(), contains(landing));
    verify(listener).onChange(eq(removed(shopping)));
}
Also used : BackendService(com.hotels.styx.api.extension.service.BackendService) Test(org.junit.jupiter.api.Test)

Aggregations

BackendService (com.hotels.styx.api.extension.service.BackendService)37 Test (org.junit.jupiter.api.Test)36 Registry (com.hotels.styx.api.extension.service.spi.Registry)11 JustATestException (com.hotels.styx.support.JustATestException)8 LiveHttpRequest (com.hotels.styx.api.LiveHttpRequest)7 MicrometerRegistry (com.hotels.styx.api.MicrometerRegistry)7 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)7 MeterRegistry (com.hotels.styx.api.MeterRegistry)6 Resource (com.hotels.styx.api.Resource)6 MemoryBackedRegistry (com.hotels.styx.infrastructure.MemoryBackedRegistry)6 IOException (java.io.IOException)6 HttpHandler (com.hotels.styx.api.HttpHandler)5 ReloadResult (com.hotels.styx.api.extension.service.spi.Registry.ReloadResult)5 ReloadResult.reloaded (com.hotels.styx.api.extension.service.spi.Registry.ReloadResult.reloaded)5 ReloadResult.unchanged (com.hotels.styx.api.extension.service.spi.Registry.ReloadResult.unchanged)5 StyxFutures.await (com.hotels.styx.common.StyxFutures.await)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)5 List (java.util.List)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5