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