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 ;
@@ -49,6 +51,7 @@ class KeyCommandsTests {
49
51
50
52
private static final String PREFIX = KeyCommandsTests .class .getSimpleName ();
51
53
private static final String KEY_PATTERN = PREFIX + "*" ;
54
+ private final ExecutorService executor = Executors .newSingleThreadExecutor ();
52
55
53
56
@ Autowired ReactiveRedisConnectionFactory connectionFactory ;
54
57
@@ -103,13 +106,15 @@ void storeToListAndPop() {
103
106
104
107
private void generateRandomKeys (int nrKeys ) {
105
108
106
- var keyFlux = Flux .range (0 , nrKeys ).map (i -> (PREFIX + "-" + i ));
109
+ executor .execute (() -> {
110
+ var keyFlux = Flux .range (0 , nrKeys ).map (i -> (PREFIX + "-" + i ));
107
111
108
- var generator = keyFlux .map (String ::getBytes ).map (ByteBuffer ::wrap ) //
109
- .map (key -> SetCommand .set (key ) //
110
- .value (ByteBuffer .wrap (UUID .randomUUID ().toString ().getBytes ())));
112
+ var generator = keyFlux .map (String ::getBytes ).map (ByteBuffer ::wrap ) //
113
+ .map (key -> SetCommand .set (key ) //
114
+ .value (ByteBuffer .wrap (UUID .randomUUID ().toString ().getBytes ())));
111
115
112
- StepVerifier .create (connection .stringCommands ().set (generator )).expectNextCount (nrKeys ).verifyComplete ();
116
+ StepVerifier .create (connection .stringCommands ().set (generator )).expectNextCount (nrKeys ).verifyComplete ();
117
+ });
113
118
114
119
}
115
120
0 commit comments