mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '4.0.x'
Closes gh-50914
This commit is contained in:
+1
-1
@@ -203,7 +203,7 @@ public final class GraphQlWebMvcAutoConfiguration {
|
||||
private HttpMessageConverter<Object> getJsonConverter(
|
||||
ObjectProvider<ServerHttpMessageConvertersCustomizer> customizers) {
|
||||
ServerBuilder serverBuilder = HttpMessageConverters.forServer().registerDefaults();
|
||||
customizers.forEach((customizer) -> customizer.customize(serverBuilder));
|
||||
customizers.orderedStream().forEach((customizer) -> customizer.customize(serverBuilder));
|
||||
for (HttpMessageConverter<?> converter : serverBuilder.build()) {
|
||||
if (canReadJsonMap(converter)) {
|
||||
return asObjectHttpMessageConverter(converter);
|
||||
|
||||
+38
@@ -24,6 +24,7 @@ import graphql.schema.idl.TypeRuntimeWiring;
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.assertj.core.api.ThrowingConsumer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InOrder;
|
||||
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||
@@ -31,6 +32,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.graphql.autoconfigure.GraphQlAutoConfiguration;
|
||||
import org.springframework.boot.graphql.autoconfigure.GraphQlTestDataFetchers;
|
||||
import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.http.converter.autoconfigure.ServerHttpMessageConvertersCustomizer;
|
||||
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.classpath.resources.WithResource;
|
||||
@@ -56,6 +58,9 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
|
||||
import org.springframework.web.socket.server.support.WebSocketHandlerMapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
|
||||
/**
|
||||
@@ -240,6 +245,22 @@ class GraphQlWebMvcAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldApplyJsonCustomizersInOrderB() {
|
||||
this.contextRunner.withPropertyValues("spring.graphql.websocket.path=/ws")
|
||||
.withUserConfiguration(CustomJsonConverterConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(GraphQlWebSocketHandler.class);
|
||||
ServerHttpMessageConvertersCustomizer before = context.getBean("before",
|
||||
ServerHttpMessageConvertersCustomizer.class);
|
||||
ServerHttpMessageConvertersCustomizer after = context.getBean("after",
|
||||
ServerHttpMessageConvertersCustomizer.class);
|
||||
InOrder ordered = inOrder(before, after);
|
||||
ordered.verify(before).customize(any());
|
||||
ordered.verify(after).customize(any());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldConfigureWebSocketProperties() {
|
||||
this.contextRunner
|
||||
@@ -314,6 +335,23 @@ class GraphQlWebMvcAutoConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class CustomJsonConverterConfiguration {
|
||||
|
||||
@Bean
|
||||
@Order(1)
|
||||
ServerHttpMessageConvertersCustomizer after() {
|
||||
return mock();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Order(-1)
|
||||
ServerHttpMessageConvertersCustomizer before() {
|
||||
return mock();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class CustomRouterFunctions {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user