|
24 | 24 | import java.time.Duration; |
25 | 25 | import java.util.Collections; |
26 | 26 | import java.util.UUID; |
| 27 | +import java.util.concurrent.ExecutorService; |
| 28 | +import java.util.concurrent.Executors; |
27 | 29 |
|
28 | 30 | import org.junit.jupiter.api.BeforeEach; |
29 | 31 | import org.junit.jupiter.api.Test; |
|
42 | 44 | * {@link ReactiveRedisConnectionFactory}. |
43 | 45 | * |
44 | 46 | * @author Mark Paluch |
| 47 | + * @author Arooba Shahoor |
45 | 48 | */ |
46 | 49 | @SpringBootTest(classes = RedisTestConfiguration.class) |
47 | 50 | @EnabledOnRedisAvailable |
48 | 51 | class KeyCommandsTests { |
49 | 52 |
|
50 | 53 | private static final String PREFIX = KeyCommandsTests.class.getSimpleName(); |
51 | 54 | private static final String KEY_PATTERN = PREFIX + "*"; |
| 55 | + private final ExecutorService executor = Executors.newSingleThreadExecutor(); |
52 | 56 |
|
53 | 57 | @Autowired ReactiveRedisConnectionFactory connectionFactory; |
54 | 58 |
|
@@ -103,13 +107,15 @@ void storeToListAndPop() { |
103 | 107 |
|
104 | 108 | private void generateRandomKeys(int nrKeys) { |
105 | 109 |
|
106 | | - var keyFlux = Flux.range(0, nrKeys).map(i -> (PREFIX + "-" + i)); |
| 110 | + executor.execute(() -> { |
| 111 | + var keyFlux = Flux.range(0, nrKeys).map(i -> (PREFIX + "-" + i)); |
107 | 112 |
|
108 | | - var generator = keyFlux.map(String::getBytes).map(ByteBuffer::wrap) // |
109 | | - .map(key -> SetCommand.set(key) // |
110 | | - .value(ByteBuffer.wrap(UUID.randomUUID().toString().getBytes()))); |
| 113 | + var generator = keyFlux.map(String::getBytes).map(ByteBuffer::wrap) // |
| 114 | + .map(key -> SetCommand.set(key) // |
| 115 | + .value(ByteBuffer.wrap(UUID.randomUUID().toString().getBytes()))); |
111 | 116 |
|
112 | | - StepVerifier.create(connection.stringCommands().set(generator)).expectNextCount(nrKeys).verifyComplete(); |
| 117 | + StepVerifier.create(connection.stringCommands().set(generator)).expectNextCount(nrKeys).verifyComplete(); |
| 118 | + }); |
113 | 119 |
|
114 | 120 | } |
115 | 121 |
|
|
0 commit comments