|
19 | 19 | import java.time.Duration; |
20 | 20 | import java.util.Collections; |
21 | 21 | import java.util.UUID; |
| 22 | +import java.util.concurrent.ExecutorService; |
| 23 | +import java.util.concurrent.Executors; |
22 | 24 |
|
23 | 25 | import example.springdata.redis.RedisTestConfiguration; |
24 | 26 | import org.junit.jupiter.api.BeforeEach; |
|
39 | 41 | * {@link ReactiveRedisConnectionFactory}. |
40 | 42 | * |
41 | 43 | * @author Mark Paluch |
| 44 | + * @author Arooba Shahoor |
42 | 45 | */ |
43 | 46 | @SpringBootTest(classes = RedisTestConfiguration.class) |
44 | 47 | class KeyCommandsTests { |
45 | 48 |
|
46 | 49 | private static final String PREFIX = KeyCommandsTests.class.getSimpleName(); |
47 | 50 | private static final String KEY_PATTERN = PREFIX + "*"; |
| 51 | + private final ExecutorService executor = Executors.newSingleThreadExecutor(); |
48 | 52 |
|
49 | 53 | @Autowired ReactiveRedisConnectionFactory connectionFactory; |
50 | 54 |
|
@@ -99,15 +103,16 @@ void storeToListAndPop() { |
99 | 103 |
|
100 | 104 | private void generateRandomKeys(int nrKeys) { |
101 | 105 |
|
102 | | - var keyFlux = Flux.range(0, nrKeys).map(i -> (PREFIX + "-" + i)); |
| 106 | + executor.execute(() -> { |
| 107 | + var keyFlux = Flux.range(0, nrKeys).map(i -> (PREFIX + "-" + i)); |
103 | 108 |
|
104 | | - var generator = keyFlux.map(String::getBytes).map(ByteBuffer::wrap) // |
105 | | - .map(key -> SetCommand.set(key) // |
106 | | - .value(ByteBuffer.wrap(UUID.randomUUID().toString().getBytes()))); |
| 109 | + var generator = keyFlux.map(String::getBytes).map(ByteBuffer::wrap) // |
| 110 | + .map(key -> SetCommand.set(key) // |
| 111 | + .value(ByteBuffer.wrap(UUID.randomUUID().toString().getBytes()))); |
107 | 112 |
|
108 | | - connection.stringCommands().set(generator).as(StepVerifier::create) // |
| 113 | + connection.stringCommands().set(generator).as(StepVerifier::create) // |
109 | 114 | .expectNextCount(nrKeys) // |
110 | | - .verifyComplete(); |
| 115 | + .verifyComplete();}); |
111 | 116 |
|
112 | 117 | } |
113 | 118 |
|
|
0 commit comments