|
16 | 16 |
|
17 | 17 | package org.springframework.boot.autoconfigure.rsocket; |
18 | 18 |
|
| 19 | +import org.assertj.core.api.InstanceOfAssertFactories; |
19 | 20 | import org.junit.jupiter.api.Test; |
20 | 21 |
|
21 | 22 | import org.springframework.boot.autoconfigure.AutoConfigurations; |
22 | 23 | import org.springframework.boot.test.context.runner.ApplicationContextRunner; |
23 | 24 | import org.springframework.context.annotation.Bean; |
24 | 25 | import org.springframework.context.annotation.Configuration; |
| 26 | +import org.springframework.messaging.rsocket.RSocketConnectorConfigurer; |
25 | 27 | import org.springframework.messaging.rsocket.RSocketRequester; |
26 | 28 |
|
| 29 | +import static org.assertj.core.api.Assertions.as; |
27 | 30 | import static org.assertj.core.api.Assertions.assertThat; |
28 | 31 | import static org.mockito.Mockito.mock; |
29 | 32 |
|
30 | 33 | /** |
31 | 34 | * Tests for {@link RSocketRequesterAutoConfiguration} |
32 | 35 | * |
33 | 36 | * @author Brian Clozel |
| 37 | + * @author Nguyen Bao Sach |
34 | 38 | */ |
35 | 39 | class RSocketRequesterAutoConfigurationTests { |
36 | 40 |
|
@@ -59,6 +63,21 @@ void shouldNotCreateBuilderIfAlreadyPresent() { |
59 | 63 | }); |
60 | 64 | } |
61 | 65 |
|
| 66 | + @Test |
| 67 | + void rSocketConnectorConfigurersArePickedUp() { |
| 68 | + RSocketConnectorConfigurer first = mock(RSocketConnectorConfigurer.class); |
| 69 | + RSocketConnectorConfigurer second = mock(RSocketConnectorConfigurer.class); |
| 70 | + this.contextRunner.withBean("firstRSocketConnectorConfigurer", RSocketConnectorConfigurer.class, () -> first) |
| 71 | + .withBean("secondRSocketConnectorConfigurer", RSocketConnectorConfigurer.class, () -> second) |
| 72 | + .run((context) -> { |
| 73 | + assertThat(context).getBeans(RSocketConnectorConfigurer.class).hasSize(2); |
| 74 | + |
| 75 | + RSocketRequester.Builder builder = context.getBean(RSocketRequester.Builder.class); |
| 76 | + assertThat(builder).extracting("rsocketConnectorConfigurers", as(InstanceOfAssertFactories.LIST)) |
| 77 | + .containsExactly(first, second); |
| 78 | + }); |
| 79 | + } |
| 80 | + |
62 | 81 | @Configuration(proxyBeanMethods = false) |
63 | 82 | static class CustomRSocketRequesterBuilder { |
64 | 83 |
|
|
0 commit comments