Search in sources :

Example 1 with ZuulProperties

use of org.springframework.cloud.netflix.zuul.filters.ZuulProperties 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");
}
Also used : ZuulRoute(org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute) ZuulProperties(org.springframework.cloud.netflix.zuul.filters.ZuulProperties) DiscoveryClient(org.springframework.cloud.client.discovery.DiscoveryClient) NoopDiscoveryClient(org.springframework.cloud.client.discovery.noop.NoopDiscoveryClient) NoopDiscoveryClient(org.springframework.cloud.client.discovery.noop.NoopDiscoveryClient) Test(org.junit.Test)

Example 2 with ZuulProperties

use of org.springframework.cloud.netflix.zuul.filters.ZuulProperties 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"));
}
Also used : DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) ZuulRoute(org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute) ZuulProperties(org.springframework.cloud.netflix.zuul.filters.ZuulProperties) DiscoveryClient(org.springframework.cloud.client.discovery.DiscoveryClient) NoopDiscoveryClient(org.springframework.cloud.client.discovery.noop.NoopDiscoveryClient) Route(org.springframework.cloud.netflix.zuul.filters.Route) ZuulRoute(org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute) Test(org.junit.Test)

Example 3 with ZuulProperties

use of org.springframework.cloud.netflix.zuul.filters.ZuulProperties in project spring-boot-admin by codecentric.

the class TurbineRouteLocatorTest method test_route_http_location.

@Test
public void test_route_http_location() {
    ZuulRoute route = new ZuulRoute("/path/**", "http://example.com/target");
    TurbineRouteLocator locator = new TurbineRouteLocator(route, "", new ZuulProperties(), null);
    assertThat(locator.getRoutes().size(), is(1));
    assertThat(locator.getRoutes().get(0).getPath(), is("/**"));
    assertThat(locator.getRoutes().get(0).getPrefix(), is("/path"));
    assertThat(locator.getRoutes().get(0).getLocation(), is("http://example.com/target"));
    Route matchingRoute = locator.getMatchingRoute("/path/foo");
    assertThat(matchingRoute.getLocation(), is("http://example.com/target"));
    assertThat(matchingRoute.getPath(), is("/foo/turbine.stream"));
    assertThat(locator.getMatchingRoute("/404/foo"), nullValue());
}
Also used : ZuulRoute(org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute) ZuulProperties(org.springframework.cloud.netflix.zuul.filters.ZuulProperties) Route(org.springframework.cloud.netflix.zuul.filters.Route) ZuulRoute(org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 ZuulProperties (org.springframework.cloud.netflix.zuul.filters.ZuulProperties)3 ZuulRoute (org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute)3 DiscoveryClient (org.springframework.cloud.client.discovery.DiscoveryClient)2 NoopDiscoveryClient (org.springframework.cloud.client.discovery.noop.NoopDiscoveryClient)2 Route (org.springframework.cloud.netflix.zuul.filters.Route)2 DefaultServiceInstance (org.springframework.cloud.client.DefaultServiceInstance)1