|
26 | 26 | import org.junit.jupiter.api.Nested;
|
27 | 27 | import org.junit.jupiter.api.Test;
|
28 | 28 |
|
29 |
| -import org.springframework.core.task.SimpleAsyncTaskExecutor; |
| 29 | +import org.springframework.core.task.AsyncTaskExecutor; |
30 | 30 | import org.springframework.pulsar.core.PulsarConsumerFactory;
|
31 | 31 | import org.springframework.pulsar.listener.PulsarContainerProperties;
|
32 | 32 |
|
@@ -144,23 +144,23 @@ void defaultUsedWhenNotSetOnEndpointNorFactoryProps() {
|
144 | 144 | }
|
145 | 145 |
|
146 | 146 | @Nested
|
147 |
| - class ConsumerTaskExecutor { |
| 147 | + class ConsumerTaskExecutorFrom { |
148 | 148 |
|
149 | 149 | @Test
|
150 | 150 | @SuppressWarnings("unchecked")
|
151 |
| - void factoryValueCopiedWhenCreatingContainer() { |
152 |
| - final var factoryProps = new PulsarContainerProperties(); |
153 |
| - factoryProps.setConsumerTaskExecutor(new SimpleAsyncTaskExecutor()); |
154 |
| - final var containerFactory = new ConcurrentPulsarListenerContainerFactory<String>( |
| 151 | + void factoryPropsUsedWhenSpecified() { |
| 152 | + var factoryProps = new PulsarContainerProperties(); |
| 153 | + AsyncTaskExecutor executor = mock(); |
| 154 | + factoryProps.setConsumerTaskExecutor(executor); |
| 155 | + var containerFactory = new ConcurrentPulsarListenerContainerFactory<String>( |
155 | 156 | mock(PulsarConsumerFactory.class), factoryProps);
|
156 |
| - final var endpoint = mock(PulsarListenerEndpoint.class); |
157 |
| - // Mockito by default returns 0 for Integer |
158 |
| - when(endpoint.getConcurrency()).thenReturn(null); |
159 |
| - |
160 |
| - final var createdContainer = containerFactory.createRegisteredContainer(endpoint); |
| 157 | + var endpoint = mock(PulsarListenerEndpoint.class); |
| 158 | + when(endpoint.getConcurrency()).thenReturn(1); |
161 | 159 |
|
162 |
| - final var containerProperties = createdContainer.getContainerProperties(); |
163 |
| - assertThat(containerProperties.getConsumerTaskExecutor()).isEqualTo(factoryProps.getConsumerTaskExecutor()); |
| 160 | + var container = containerFactory.createRegisteredContainer(endpoint); |
| 161 | + assertThat(container.getContainerProperties()) |
| 162 | + .extracting(PulsarContainerProperties::getConsumerTaskExecutor) |
| 163 | + .isSameAs(executor); |
164 | 164 | }
|
165 | 165 |
|
166 | 166 | }
|
|
0 commit comments