use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class BackendServicesRouterTest method selectsApplicationBasedOnPathIfAppsAreProvidedInOppositeOrder.
@Test
public void selectsApplicationBasedOnPathIfAppsAreProvidedInOppositeOrder() throws Exception {
Registry.Changes<BackendService> changes = added(appB().newCopy().path("/appB/hotel/details.html").build(), appA().newCopy().path("/").build());
BackendServicesRouter router = new BackendServicesRouter(serviceClientFactory, environment, executor);
router.onChange(changes);
LiveHttpRequest request = get("/appB/hotel/details.html").build();
Optional<HttpHandler> route = router.route(request, context);
assertThat(proxyTo(route, request).header(ORIGIN_ID_DEFAULT), isValue(APP_B));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class BackendServicesRouterTest method throwsExceptionWhenNoApplicationMatches.
@Test
public void throwsExceptionWhenNoApplicationMatches() {
BackendServicesRouter router = new BackendServicesRouter(serviceClientFactory, environment, executor);
router.onChange(added(appB().newCopy().path("/appB/hotel/details.html").build()));
LiveHttpRequest request = get("/qwertyuiop").build();
assertThat(router.route(request, context), is(Optional.empty()));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class BackendServicesRouterTest method updatesRoutesOnBackendServicesChange.
@Test
public void updatesRoutesOnBackendServicesChange() throws Exception {
BackendServicesRouter router = new BackendServicesRouter(serviceClientFactory, environment, executor);
LiveHttpRequest request = get("/appB/").build();
router.onChange(added(appB()));
Optional<HttpHandler> route = router.route(request, context);
assertThat(proxyTo(route, request).header(ORIGIN_ID_DEFAULT), isValue(APP_B));
router.onChange(new Registry.Changes.Builder<BackendService>().build());
Optional<HttpHandler> route2 = router.route(request, context);
assertThat(proxyTo(route2, request).header(ORIGIN_ID_DEFAULT), isValue(APP_B));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class BackendServicesRouterTest method selectsServiceBasedOnPath.
@Test
public void selectsServiceBasedOnPath() throws Exception {
Registry.Changes<BackendService> changes = added(appA().newCopy().path("/").build(), appB().newCopy().path("/appB/hotel/details.html").build());
BackendServicesRouter router = new BackendServicesRouter(serviceClientFactory, environment, executor);
router.onChange(changes);
LiveHttpRequest request = get("/appB/hotel/details.html").build();
Optional<HttpHandler> route = router.route(request, context);
assertThat(proxyTo(route, request).header(ORIGIN_ID_DEFAULT), isValue(APP_B));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class BackendServicesRouterTest method selectsUsingSingleSlashPathIfAppsAreProvidedInOppositeOrder.
@Test
public void selectsUsingSingleSlashPathIfAppsAreProvidedInOppositeOrder() throws Exception {
Registry.Changes<BackendService> changes = added(appB().newCopy().path("/appB/hotel/details.html").build(), appA().newCopy().path("/").build());
BackendServicesRouter router = new BackendServicesRouter(serviceClientFactory, environment, executor);
router.onChange(changes);
LiveHttpRequest request = get("/").build();
Optional<HttpHandler> route = router.route(request, context);
assertThat(proxyTo(route, request).header(ORIGIN_ID_DEFAULT), isValue(APP_A));
}
Aggregations