Merge branch '4.0.x'
This commit is contained in:
@@ -96,8 +96,8 @@ public class AbstractGatewayControllerEndpoint implements ApplicationEventPublis
|
||||
List<GlobalFilter> globalFilters, List<GatewayFilterFactory> gatewayFilters,
|
||||
List<RoutePredicateFactory> routePredicates, RouteDefinitionWriter routeDefinitionWriter,
|
||||
RouteLocator routeLocator) {
|
||||
this(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates,
|
||||
routeDefinitionWriter, routeLocator, new WebEndpointProperties());
|
||||
this(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates, routeDefinitionWriter,
|
||||
routeLocator, new WebEndpointProperties());
|
||||
}
|
||||
|
||||
public AbstractGatewayControllerEndpoint(RouteDefinitionLocator routeDefinitionLocator,
|
||||
@@ -126,8 +126,7 @@ public class AbstractGatewayControllerEndpoint implements ApplicationEventPublis
|
||||
.collectList();
|
||||
}
|
||||
|
||||
private List<GatewayEndpointInfo> mergeEndpoints(List<GatewayEndpointInfo> listA,
|
||||
List<GatewayEndpointInfo> listB) {
|
||||
private List<GatewayEndpointInfo> mergeEndpoints(List<GatewayEndpointInfo> listA, List<GatewayEndpointInfo> listB) {
|
||||
Map<String, List<String>> mergedMap = new HashMap<>();
|
||||
|
||||
Stream.concat(listA.stream(), listB.stream()).forEach(e -> mergedMap
|
||||
|
||||
@@ -50,8 +50,8 @@ public class GatewayControllerEndpoint extends AbstractGatewayControllerEndpoint
|
||||
List<RoutePredicateFactory> routePredicates, RouteDefinitionWriter routeDefinitionWriter,
|
||||
RouteLocator routeLocator, RouteDefinitionLocator routeDefinitionLocator,
|
||||
WebEndpointProperties webEndpointProperties) {
|
||||
super(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates,
|
||||
routeDefinitionWriter, routeLocator, webEndpointProperties);
|
||||
super(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates, routeDefinitionWriter,
|
||||
routeLocator, webEndpointProperties);
|
||||
}
|
||||
|
||||
@GetMapping("/routedefinitions")
|
||||
|
||||
@@ -151,7 +151,7 @@ public interface ShortcutConfigurable {
|
||||
// strip boolean flag if last entry is true or false
|
||||
int lastIdx = values.size() - 1;
|
||||
String lastValue = values.get(lastIdx);
|
||||
if (lastValue.equalsIgnoreCase("true") || lastValue.equalsIgnoreCase("false")) {
|
||||
if ("true".equalsIgnoreCase(lastValue) || "false".equalsIgnoreCase(lastValue) || lastValue == null) {
|
||||
values = values.subList(0, lastIdx);
|
||||
map.put(fieldOrder.get(1), getValue(parser, beanFactory, lastValue));
|
||||
}
|
||||
|
||||
@@ -70,29 +70,21 @@ public class GatewayControllerEndpointTests {
|
||||
|
||||
@Test
|
||||
public void testEndpoints() {
|
||||
testClient.get().uri("http://localhost:" + port + "/actuator/gateway").exchange()
|
||||
.expectStatus().isOk().expectBodyList(Map.class).consumeWith(result -> {
|
||||
testClient.get().uri("http://localhost:" + port + "/actuator/gateway").exchange().expectStatus().isOk()
|
||||
.expectBodyList(Map.class).consumeWith(result -> {
|
||||
List<Map> responseBody = result.getResponseBody();
|
||||
assertThat(responseBody).isNotEmpty();
|
||||
assertThat(responseBody).contains(
|
||||
Map.of("href", "/actuator/gateway/", "methods",
|
||||
List.of("GET")),
|
||||
Map.of("href", "/actuator/gateway/globalfilters", "methods",
|
||||
List.of("GET")),
|
||||
Map.of("href", "/actuator/gateway/refresh", "methods",
|
||||
List.of("POST")),
|
||||
Map.of("href", "/actuator/gateway/routedefinitions",
|
||||
"methods", List.of("GET")),
|
||||
Map.of("href", "/actuator/gateway/routefilters", "methods",
|
||||
List.of("GET")),
|
||||
Map.of("href", "/actuator/gateway/routepredicates", "methods",
|
||||
List.of("GET")),
|
||||
Map.of("href", "/actuator/gateway/routes", "methods",
|
||||
List.of("POST", "GET")),
|
||||
Map.of("href", "/actuator/gateway/routes/test-service",
|
||||
"methods", List.of("POST", "DELETE", "GET")),
|
||||
Map.of("href", "/actuator/gateway/routes/route_with_metadata",
|
||||
"methods", List.of("POST", "DELETE", "GET")));
|
||||
assertThat(responseBody).contains(Map.of("href", "/actuator/gateway/", "methods", List.of("GET")),
|
||||
Map.of("href", "/actuator/gateway/globalfilters", "methods", List.of("GET")),
|
||||
Map.of("href", "/actuator/gateway/refresh", "methods", List.of("POST")),
|
||||
Map.of("href", "/actuator/gateway/routedefinitions", "methods", List.of("GET")),
|
||||
Map.of("href", "/actuator/gateway/routefilters", "methods", List.of("GET")),
|
||||
Map.of("href", "/actuator/gateway/routepredicates", "methods", List.of("GET")),
|
||||
Map.of("href", "/actuator/gateway/routes", "methods", List.of("POST", "GET")),
|
||||
Map.of("href", "/actuator/gateway/routes/test-service", "methods",
|
||||
List.of("POST", "DELETE", "GET")),
|
||||
Map.of("href", "/actuator/gateway/routes/route_with_metadata", "methods",
|
||||
List.of("POST", "DELETE", "GET")));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +182,32 @@ public class ShortcutConfigurableTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNormalizeGatherListTailFlagFlagIsNull() {
|
||||
parser = new SpelExpressionParser();
|
||||
ShortcutConfigurable shortcutConfigurable = new ShortcutConfigurable() {
|
||||
@Override
|
||||
public List<String> shortcutFieldOrder() {
|
||||
return Arrays.asList("values", "flag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShortcutType shortcutType() {
|
||||
return ShortcutType.GATHER_LIST_TAIL_FLAG;
|
||||
}
|
||||
};
|
||||
Map<String, String> args = new HashMap<>();
|
||||
args.put("1", "val0");
|
||||
args.put("2", "val1");
|
||||
args.put("3", "val2");
|
||||
args.put("4", null);
|
||||
Map<String, Object> map = ShortcutType.GATHER_LIST_TAIL_FLAG.normalize(args, shortcutConfigurable, parser,
|
||||
this.beanFactory);
|
||||
assertThat(map).isNotNull().containsKey("values");
|
||||
assertThat((List) map.get("values")).containsExactly("val0", "val1", "val2");
|
||||
assertThat(map.get("flag")).isNull();
|
||||
}
|
||||
|
||||
@SpringBootConfiguration
|
||||
protected static class TestConfig {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user