1818
1919import static org .junit .Assert .assertEquals ;
2020
21+ import io .rsocket .RaceTestConstants ;
2122import io .rsocket .internal .subscriber .AssertSubscriber ;
2223import java .io .IOException ;
2324import java .time .Duration ;
@@ -60,7 +61,7 @@ public class ReconnectMonoTests {
6061 public void shouldExpireValueOnRacingDisposeAndNext () {
6162 Hooks .onErrorDropped (t -> {});
6263 Hooks .onNextDropped (System .out ::println );
63- for (int i = 0 ; i < 10000 ; i ++) {
64+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
6465 final int index = i ;
6566 final CoreSubscriber <? super String >[] monoSubscribers = new CoreSubscriber [1 ];
6667 Subscription mockSubscription = Mockito .mock (Subscription .class );
@@ -108,7 +109,7 @@ public void subscribe(CoreSubscriber<? super String> actual) {
108109 @ Test
109110 public void shouldNotifyAllTheSubscribersUnderRacingBetweenSubscribeAndComplete () {
110111 Hooks .onErrorDropped (t -> {});
111- for (int i = 0 ; i < 10000 ; i ++) {
112+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
112113 final TestPublisher <String > cold =
113114 TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
114115
@@ -151,7 +152,7 @@ public void shouldNotifyAllTheSubscribersUnderRacingBetweenSubscribeAndComplete(
151152 @ Test
152153 public void shouldNotExpireNewlyResolvedValueIfSubscribeIsRacingWithInvalidate () {
153154 Hooks .onErrorDropped (t -> {});
154- for (int i = 0 ; i < 10000 ; i ++) {
155+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
155156 final int index = i ;
156157 final TestPublisher <String > cold =
157158 TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
@@ -214,7 +215,7 @@ public void shouldNotExpireNewlyResolvedValueIfSubscribeIsRacingWithInvalidate()
214215 @ Test
215216 public void shouldNotExpireNewlyResolvedValueIfSubscribeIsRacingWithInvalidates () {
216217 Hooks .onErrorDropped (t -> {});
217- for (int i = 0 ; i < 10000 ; i ++) {
218+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
218219 final int index = i ;
219220 final TestPublisher <String > cold =
220221 TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
@@ -281,7 +282,7 @@ public void shouldNotExpireNewlyResolvedValueIfSubscribeIsRacingWithInvalidates(
281282 @ Test
282283 public void shouldNotExpireNewlyResolvedValueIfBlockIsRacingWithInvalidate () {
283284 Hooks .onErrorDropped (t -> {});
284- for (int i = 0 ; i < 10000 ; i ++) {
285+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
285286 final int index = i ;
286287 final Mono <String > source =
287288 Mono .fromSupplier (
@@ -347,7 +348,7 @@ public String get() {
347348
348349 @ Test
349350 public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribers () {
350- for (int i = 0 ; i < 10000 ; i ++) {
351+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
351352 final TestPublisher <String > cold = TestPublisher .createCold ();
352353 cold .next ("value" + i );
353354
@@ -394,7 +395,7 @@ public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribers() {
394395 @ Test
395396 public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribeAndBlock () {
396397 Duration timeout = Duration .ofMillis (100 );
397- for (int i = 0 ; i < 10000 ; i ++) {
398+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
398399 final TestPublisher <String > cold = TestPublisher .createCold ();
399400 cold .next ("value" + i );
400401
@@ -441,7 +442,7 @@ public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribeAndBlock() {
441442 @ Test
442443 public void shouldEstablishValueOnceInCaseOfRacingBetweenBlocks () {
443444 Duration timeout = Duration .ofMillis (100 );
444- for (int i = 0 ; i < 10000 ; i ++) {
445+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
445446 final TestPublisher <String > cold = TestPublisher .createCold ();
446447 cold .next ("value" + i );
447448
@@ -486,7 +487,7 @@ public void shouldEstablishValueOnceInCaseOfRacingBetweenBlocks() {
486487 @ Test
487488 public void shouldExpireValueOnRacingDisposeAndNoValueComplete () {
488489 Hooks .onErrorDropped (t -> {});
489- for (int i = 0 ; i < 10000 ; i ++) {
490+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
490491 final TestPublisher <String > cold =
491492 TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
492493
@@ -524,7 +525,7 @@ public void shouldExpireValueOnRacingDisposeAndNoValueComplete() {
524525 @ Test
525526 public void shouldExpireValueOnRacingDisposeAndComplete () {
526527 Hooks .onErrorDropped (t -> {});
527- for (int i = 0 ; i < 10000 ; i ++) {
528+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
528529 final TestPublisher <String > cold =
529530 TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
530531
@@ -564,7 +565,7 @@ public void shouldExpireValueOnRacingDisposeAndComplete() {
564565 public void shouldExpireValueOnRacingDisposeAndError () {
565566 Hooks .onErrorDropped (t -> {});
566567 RuntimeException runtimeException = new RuntimeException ("test" );
567- for (int i = 0 ; i < 10000 ; i ++) {
568+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
568569 final TestPublisher <String > cold =
569570 TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
570571
@@ -610,7 +611,7 @@ public void shouldExpireValueOnRacingDisposeAndError() {
610611 public void shouldExpireValueOnRacingDisposeAndErrorWithNoBackoff () {
611612 Hooks .onErrorDropped (t -> {});
612613 RuntimeException runtimeException = new RuntimeException ("test" );
613- for (int i = 0 ; i < 10000 ; i ++) {
614+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
614615 final TestPublisher <String > cold =
615616 TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
616617
@@ -886,19 +887,21 @@ public void shouldNotifyAllTheSubscribers() {
886887
887888 final ArrayList <MonoProcessor <String >> processors = new ArrayList <>(200 );
888889
889- for (int i = 0 ; i < 100 ; i ++) {
890+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
890891 final MonoProcessor <String > subA = MonoProcessor .create ();
891892 final MonoProcessor <String > subB = MonoProcessor .create ();
892893 processors .add (subA );
893894 processors .add (subB );
894895 RaceTestUtils .race (() -> reconnectMono .subscribe (subA ), () -> reconnectMono .subscribe (subB ));
895896 }
896897
897- Assertions .assertThat (reconnectMono .resolvingInner .subscribers ).hasSize (204 );
898+ Assertions .assertThat (reconnectMono .resolvingInner .subscribers )
899+ .hasSize (RaceTestConstants .REPEATS * 2 + 4 );
898900
899901 sub1 .dispose ();
900902
901- Assertions .assertThat (reconnectMono .resolvingInner .subscribers ).hasSize (203 );
903+ Assertions .assertThat (reconnectMono .resolvingInner .subscribers )
904+ .hasSize (RaceTestConstants .REPEATS * 2 + 3 );
902905
903906 publisher .next ("value" );
904907
@@ -917,7 +920,7 @@ public void shouldNotifyAllTheSubscribers() {
917920
918921 @ Test
919922 public void shouldExpireValueExactlyOnceOnRacingBetweenInvalidates () {
920- for (int i = 0 ; i < 10000 ; i ++) {
923+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
921924 final TestPublisher <String > cold = TestPublisher .createCold ();
922925 cold .next ("value" );
923926 final int timeout = 10 ;
@@ -959,7 +962,7 @@ public void shouldExpireValueExactlyOnceOnRacingBetweenInvalidates() {
959962
960963 @ Test
961964 public void shouldExpireValueExactlyOnceOnRacingBetweenInvalidateAndDispose () {
962- for (int i = 0 ; i < 10000 ; i ++) {
965+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
963966 final TestPublisher <String > cold = TestPublisher .createCold ();
964967 cold .next ("value" );
965968 final int timeout = 10000 ;
0 commit comments