Browse Source

Adds test case for route specific actuator endpoint

pull/1190/head
Dennis Menge 5 years ago committed by Spencer Gibb
parent
commit
61f2a96c19
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 22
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/actuate/GatewayControllerEndpointTests.java

22
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/actuate/GatewayControllerEndpointTests.java

@ -27,7 +27,10 @@ import org.springframework.boot.SpringBootConfiguration; @@ -27,7 +27,10 @@ import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.cloud.gateway.test.PermitAllSecurityConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.reactive.server.WebTestClient;
@ -61,11 +64,28 @@ public class GatewayControllerEndpointTests { @@ -61,11 +64,28 @@ public class GatewayControllerEndpointTests {
});
}
@Test
public void testGetSpecificRoute() {
testClient.get().uri("http://localhost:" + port + "/actuator/gateway/routes/test-service")
.exchange().expectStatus().isOk().expectBodyList(Map.class)
.consumeWith(result -> {
List<Map> responseBody = result.getResponseBody();
assertThat(responseBody).isNotNull();
assertThat(responseBody.size()).isEqualTo(1);
assertThat(responseBody).isNotEmpty();
});
}
@SpringBootConfiguration
@EnableAutoConfiguration
@Import(PermitAllSecurityConfiguration.class)
static class TestConfig {
@Bean
RouteLocator testRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
return routeLocatorBuilder.routes()
.route("test-service", routePredicate -> routePredicate.path("/test-service/**").uri("lb://test-service"))
.build();
}
}
}

Loading…
Cancel
Save