|
16 | 16 | import static com.rabbitmq.stream.Constants.CODE_MESSAGE_ENQUEUEING_FAILED;
|
17 | 17 | import static com.rabbitmq.stream.Constants.RESPONSE_CODE_OK;
|
18 | 18 | import static com.rabbitmq.stream.Constants.RESPONSE_CODE_STREAM_DOES_NOT_EXIST;
|
| 19 | +import static com.rabbitmq.stream.impl.Utils.defaultConnectionNamingStrategy; |
19 | 20 | import static com.rabbitmq.stream.impl.Utils.formatConstant;
|
20 | 21 | import static org.assertj.core.api.Assertions.assertThat;
|
21 | 22 | import static org.mockito.ArgumentMatchers.any;
|
|
26 | 27 | import static org.mockito.Mockito.when;
|
27 | 28 |
|
28 | 29 | import com.rabbitmq.stream.impl.Client.ClientParameters;
|
| 30 | +import com.rabbitmq.stream.impl.Utils.ClientConnectionType; |
29 | 31 | import com.rabbitmq.stream.impl.Utils.ClientFactory;
|
30 | 32 | import com.rabbitmq.stream.impl.Utils.ClientFactoryContext;
|
31 | 33 | import com.rabbitmq.stream.impl.Utils.ExactNodeRetryClientFactory;
|
32 | 34 | import java.time.Duration;
|
| 35 | +import java.util.function.Function; |
33 | 36 | import java.util.function.Predicate;
|
| 37 | +import java.util.stream.IntStream; |
34 | 38 | import org.junit.jupiter.api.Test;
|
35 | 39 |
|
36 | 40 | public class UtilsTest {
|
@@ -73,4 +77,16 @@ void exactNodeRetryClientFactoryShouldRetryUntilConditionOk() {
|
73 | 77 | verify(cf, times(3)).client(any());
|
74 | 78 | verify(client, times(2)).close();
|
75 | 79 | }
|
| 80 | + |
| 81 | + @Test |
| 82 | + void defaultConnectionNamingStrategyShouldIncrement() { |
| 83 | + Function<ClientConnectionType, String> strategy = defaultConnectionNamingStrategy(); |
| 84 | + for (ClientConnectionType type : ClientConnectionType.values()) { |
| 85 | + IntStream.range(0, 10) |
| 86 | + .forEach( |
| 87 | + i -> { |
| 88 | + assertThat(strategy.apply(type)).endsWith("-" + i); |
| 89 | + }); |
| 90 | + } |
| 91 | + } |
76 | 92 | }
|
0 commit comments