File tree 1 file changed +5
-7
lines changed
commandes/src/test/java/fr/duforat/demos/commandes/handler
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change 12
12
import org .springframework .web .reactive .socket .client .WebSocketClient ;
13
13
14
14
import fr .duforat .demos .commandes .CommandesApplication ;
15
+ import reactor .core .publisher .Flux ;
15
16
16
17
@ SpringBootTest (classes = CommandesApplication .class )
17
18
public class ReactiveWebSocketIntegrationTest {
@@ -21,9 +22,7 @@ public class ReactiveWebSocketIntegrationTest {
21
22
@ Test
22
23
public void testNotificationsOnUpdates () throws Exception {
23
24
24
- long durationInterval = 800 ;
25
- int countEmitedEvents = 2 ;
26
- long margin = 900 ;
25
+ int emitedEventsNumber = 2 ;
27
26
AtomicLong counter = new AtomicLong ();
28
27
URI uri = URI .create ("ws://localhost:7000/event-emitter" );
29
28
@@ -33,14 +32,13 @@ public void testNotificationsOnUpdates() throws Exception {
33
32
.receive ()
34
33
.map (WebSocketMessage ::getPayloadAsText )
35
34
.doOnNext (str -> counter .incrementAndGet ())
35
+ .zipWith (Flux .range (1 , emitedEventsNumber ))
36
36
.then ()
37
37
.log ();
38
38
39
- }).subscribe ();
39
+ }).block ();
40
40
41
- Thread .sleep (countEmitedEvents * durationInterval + margin );
42
-
43
- Assertions .assertThat (counter .get ()).isEqualTo (countEmitedEvents );
41
+ Assertions .assertThat (counter .get ()).isEqualTo (emitedEventsNumber );
44
42
}
45
43
46
44
}
You can’t perform that action at this time.
0 commit comments