use of org.springframework.cloud.client.discovery.DiscoveryClient in project spring-boot-admin by codecentric.
the class TurbineRouteLocatorTest method test_route_noservice.
@Test(expected = IllegalStateException.class)
public void test_route_noservice() {
ZuulRoute route = new ZuulRoute("/path/**", "turbine");
DiscoveryClient discovery = new NoopDiscoveryClient(null);
TurbineRouteLocator locator = new TurbineRouteLocator(route, "", new ZuulProperties(), discovery);
locator.getMatchingRoute("/path/foo");
}
use of org.springframework.cloud.client.discovery.DiscoveryClient in project spring-boot-admin by codecentric.
the class TurbineRouteLocatorTest method test_route_service_location.
@Test
public void test_route_service_location() {
ZuulRoute route = new ZuulRoute("/path/**", "turbine");
DiscoveryClient discovery = mock(DiscoveryClient.class);
when(discovery.getInstances("turbine")).thenReturn(Arrays.<ServiceInstance>asList(new DefaultServiceInstance("turbine", "example.com", 80, false)));
TurbineRouteLocator locator = new TurbineRouteLocator(route, "", new ZuulProperties(), discovery);
Route matchingRoute = locator.getMatchingRoute("/path/foo");
assertThat(matchingRoute.getLocation(), is("http://example.com:80"));
assertThat(matchingRoute.getPath(), is("/foo/turbine.stream"));
}
Aggregations