diff --git a/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/config/FunctionHandlerConfigTests.java b/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/config/FunctionHandlerConfigTests.java index 21fe10f2..779bc5bd 100644 --- a/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/config/FunctionHandlerConfigTests.java +++ b/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/config/FunctionHandlerConfigTests.java @@ -18,6 +18,7 @@ package org.springframework.cloud.gateway.server.mvc.config; import java.util.Locale; import java.util.function.Function; +import java.util.function.Supplier; import org.junit.jupiter.api.Test; @@ -63,6 +64,18 @@ public class FunctionHandlerConfigTests { .isEqualTo("HELLO"); } + @Test + public void testSupplierFunctionWorks() { + restClient.get() + .uri("/supplierfunction") + .accept(MediaType.TEXT_PLAIN) + .exchange() + .expectStatus() + .isOk() + .expectBody(String.class) + .isEqualTo("hello"); + } + @SpringBootConfiguration @EnableAutoConfiguration protected static class TestConfiguration { @@ -72,6 +85,11 @@ public class FunctionHandlerConfigTests { return s -> s.toUpperCase(Locale.ROOT); } + @Bean + Supplier hello() { + return () -> "hello"; + } + } } diff --git a/spring-cloud-gateway-server-mvc/src/test/resources/application-functionhandlerconfigtests.yml b/spring-cloud-gateway-server-mvc/src/test/resources/application-functionhandlerconfigtests.yml index 0690e34b..c7430ca4 100644 --- a/spring-cloud-gateway-server-mvc/src/test/resources/application-functionhandlerconfigtests.yml +++ b/spring-cloud-gateway-server-mvc/src/test/resources/application-functionhandlerconfigtests.yml @@ -10,7 +10,11 @@ spring.cloud.gateway.mvc: predicates: - Path=/templatedfunction/{fnName} - Method=POST - + testsupplierfunction: + uri: fn:hello + predicates: + - Path=/supplierfunction + - Method=GET logging: level: org.springframework.cloud.gateway.server.mvc: TRACE