|
24 | 24 | import org.assertj.core.api.InstanceOfAssertFactories; |
25 | 25 | import org.assertj.core.api.ThrowingConsumer; |
26 | 26 | import org.junit.jupiter.api.Test; |
| 27 | +import org.mockito.InOrder; |
27 | 28 |
|
28 | 29 | import org.springframework.aot.hint.RuntimeHints; |
29 | 30 | import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; |
30 | 31 | import org.springframework.boot.autoconfigure.AutoConfigurations; |
31 | 32 | import org.springframework.boot.graphql.autoconfigure.GraphQlAutoConfiguration; |
32 | 33 | import org.springframework.boot.graphql.autoconfigure.GraphQlTestDataFetchers; |
33 | 34 | import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration; |
| 35 | +import org.springframework.boot.http.converter.autoconfigure.ServerHttpMessageConvertersCustomizer; |
34 | 36 | import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration; |
35 | 37 | import org.springframework.boot.test.context.runner.WebApplicationContextRunner; |
36 | 38 | import org.springframework.boot.testsupport.classpath.resources.WithResource; |
|
56 | 58 | import org.springframework.web.socket.server.support.WebSocketHandlerMapping; |
57 | 59 |
|
58 | 60 | import static org.assertj.core.api.Assertions.assertThat; |
| 61 | +import static org.mockito.ArgumentMatchers.any; |
| 62 | +import static org.mockito.Mockito.inOrder; |
| 63 | +import static org.mockito.Mockito.mock; |
59 | 64 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; |
60 | 65 |
|
61 | 66 | /** |
@@ -240,6 +245,22 @@ void shouldConfigureWebSocketBeans() { |
240 | 245 | }); |
241 | 246 | } |
242 | 247 |
|
| 248 | + @Test |
| 249 | + void shouldApplyJsonCustomizersInOrderB() { |
| 250 | + this.contextRunner.withPropertyValues("spring.graphql.websocket.path=/ws") |
| 251 | + .withUserConfiguration(CustomJsonConverterConfiguration.class) |
| 252 | + .run((context) -> { |
| 253 | + assertThat(context).hasSingleBean(GraphQlWebSocketHandler.class); |
| 254 | + ServerHttpMessageConvertersCustomizer before = context.getBean("before", |
| 255 | + ServerHttpMessageConvertersCustomizer.class); |
| 256 | + ServerHttpMessageConvertersCustomizer after = context.getBean("after", |
| 257 | + ServerHttpMessageConvertersCustomizer.class); |
| 258 | + InOrder ordered = inOrder(before, after); |
| 259 | + ordered.verify(before).customize(any()); |
| 260 | + ordered.verify(after).customize(any()); |
| 261 | + }); |
| 262 | + } |
| 263 | + |
243 | 264 | @Test |
244 | 265 | void shouldConfigureWebSocketProperties() { |
245 | 266 | this.contextRunner |
@@ -314,6 +335,23 @@ WebGraphQlInterceptor customWebGraphQlInterceptor() { |
314 | 335 |
|
315 | 336 | } |
316 | 337 |
|
| 338 | + @Configuration(proxyBeanMethods = false) |
| 339 | + static class CustomJsonConverterConfiguration { |
| 340 | + |
| 341 | + @Bean |
| 342 | + @Order(1) |
| 343 | + ServerHttpMessageConvertersCustomizer after() { |
| 344 | + return mock(); |
| 345 | + } |
| 346 | + |
| 347 | + @Bean |
| 348 | + @Order(-1) |
| 349 | + ServerHttpMessageConvertersCustomizer before() { |
| 350 | + return mock(); |
| 351 | + } |
| 352 | + |
| 353 | + } |
| 354 | + |
317 | 355 | @Configuration |
318 | 356 | static class CustomRouterFunctions { |
319 | 357 |
|
|
0 commit comments