Adds test for Supplier functions via config in server-webmvc
See gh-3646
This commit is contained in:
@@ -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<String> hello() {
|
||||
return () -> "hello";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user