18
18
19
19
import static org .junit .Assert .assertEquals ;
20
20
21
+ import io .rsocket .RaceTestConstants ;
21
22
import io .rsocket .internal .subscriber .AssertSubscriber ;
22
23
import java .io .IOException ;
23
24
import java .time .Duration ;
@@ -60,7 +61,7 @@ public class ReconnectMonoTests {
60
61
public void shouldExpireValueOnRacingDisposeAndNext () {
61
62
Hooks .onErrorDropped (t -> {});
62
63
Hooks .onNextDropped (System .out ::println );
63
- for (int i = 0 ; i < 10000 ; i ++) {
64
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
64
65
final int index = i ;
65
66
final CoreSubscriber <? super String >[] monoSubscribers = new CoreSubscriber [1 ];
66
67
Subscription mockSubscription = Mockito .mock (Subscription .class );
@@ -108,7 +109,7 @@ public void subscribe(CoreSubscriber<? super String> actual) {
108
109
@ Test
109
110
public void shouldNotifyAllTheSubscribersUnderRacingBetweenSubscribeAndComplete () {
110
111
Hooks .onErrorDropped (t -> {});
111
- for (int i = 0 ; i < 10000 ; i ++) {
112
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
112
113
final TestPublisher <String > cold =
113
114
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
114
115
@@ -151,7 +152,7 @@ public void shouldNotifyAllTheSubscribersUnderRacingBetweenSubscribeAndComplete(
151
152
@ Test
152
153
public void shouldNotExpireNewlyResolvedValueIfSubscribeIsRacingWithInvalidate () {
153
154
Hooks .onErrorDropped (t -> {});
154
- for (int i = 0 ; i < 10000 ; i ++) {
155
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
155
156
final int index = i ;
156
157
final TestPublisher <String > cold =
157
158
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
@@ -214,7 +215,7 @@ public void shouldNotExpireNewlyResolvedValueIfSubscribeIsRacingWithInvalidate()
214
215
@ Test
215
216
public void shouldNotExpireNewlyResolvedValueIfSubscribeIsRacingWithInvalidates () {
216
217
Hooks .onErrorDropped (t -> {});
217
- for (int i = 0 ; i < 10000 ; i ++) {
218
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
218
219
final int index = i ;
219
220
final TestPublisher <String > cold =
220
221
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
@@ -281,7 +282,7 @@ public void shouldNotExpireNewlyResolvedValueIfSubscribeIsRacingWithInvalidates(
281
282
@ Test
282
283
public void shouldNotExpireNewlyResolvedValueIfBlockIsRacingWithInvalidate () {
283
284
Hooks .onErrorDropped (t -> {});
284
- for (int i = 0 ; i < 10000 ; i ++) {
285
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
285
286
final int index = i ;
286
287
final Mono <String > source =
287
288
Mono .fromSupplier (
@@ -347,7 +348,7 @@ public String get() {
347
348
348
349
@ Test
349
350
public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribers () {
350
- for (int i = 0 ; i < 10000 ; i ++) {
351
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
351
352
final TestPublisher <String > cold = TestPublisher .createCold ();
352
353
cold .next ("value" + i );
353
354
@@ -394,7 +395,7 @@ public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribers() {
394
395
@ Test
395
396
public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribeAndBlock () {
396
397
Duration timeout = Duration .ofMillis (100 );
397
- for (int i = 0 ; i < 10000 ; i ++) {
398
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
398
399
final TestPublisher <String > cold = TestPublisher .createCold ();
399
400
cold .next ("value" + i );
400
401
@@ -441,7 +442,7 @@ public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribeAndBlock() {
441
442
@ Test
442
443
public void shouldEstablishValueOnceInCaseOfRacingBetweenBlocks () {
443
444
Duration timeout = Duration .ofMillis (100 );
444
- for (int i = 0 ; i < 10000 ; i ++) {
445
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
445
446
final TestPublisher <String > cold = TestPublisher .createCold ();
446
447
cold .next ("value" + i );
447
448
@@ -486,7 +487,7 @@ public void shouldEstablishValueOnceInCaseOfRacingBetweenBlocks() {
486
487
@ Test
487
488
public void shouldExpireValueOnRacingDisposeAndNoValueComplete () {
488
489
Hooks .onErrorDropped (t -> {});
489
- for (int i = 0 ; i < 10000 ; i ++) {
490
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
490
491
final TestPublisher <String > cold =
491
492
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
492
493
@@ -524,7 +525,7 @@ public void shouldExpireValueOnRacingDisposeAndNoValueComplete() {
524
525
@ Test
525
526
public void shouldExpireValueOnRacingDisposeAndComplete () {
526
527
Hooks .onErrorDropped (t -> {});
527
- for (int i = 0 ; i < 10000 ; i ++) {
528
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
528
529
final TestPublisher <String > cold =
529
530
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
530
531
@@ -564,7 +565,7 @@ public void shouldExpireValueOnRacingDisposeAndComplete() {
564
565
public void shouldExpireValueOnRacingDisposeAndError () {
565
566
Hooks .onErrorDropped (t -> {});
566
567
RuntimeException runtimeException = new RuntimeException ("test" );
567
- for (int i = 0 ; i < 10000 ; i ++) {
568
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
568
569
final TestPublisher <String > cold =
569
570
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
570
571
@@ -610,7 +611,7 @@ public void shouldExpireValueOnRacingDisposeAndError() {
610
611
public void shouldExpireValueOnRacingDisposeAndErrorWithNoBackoff () {
611
612
Hooks .onErrorDropped (t -> {});
612
613
RuntimeException runtimeException = new RuntimeException ("test" );
613
- for (int i = 0 ; i < 10000 ; i ++) {
614
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
614
615
final TestPublisher <String > cold =
615
616
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
616
617
@@ -886,19 +887,21 @@ public void shouldNotifyAllTheSubscribers() {
886
887
887
888
final ArrayList <MonoProcessor <String >> processors = new ArrayList <>(200 );
888
889
889
- for (int i = 0 ; i < 100 ; i ++) {
890
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
890
891
final MonoProcessor <String > subA = MonoProcessor .create ();
891
892
final MonoProcessor <String > subB = MonoProcessor .create ();
892
893
processors .add (subA );
893
894
processors .add (subB );
894
895
RaceTestUtils .race (() -> reconnectMono .subscribe (subA ), () -> reconnectMono .subscribe (subB ));
895
896
}
896
897
897
- Assertions .assertThat (reconnectMono .resolvingInner .subscribers ).hasSize (204 );
898
+ Assertions .assertThat (reconnectMono .resolvingInner .subscribers )
899
+ .hasSize (RaceTestConstants .REPEATS * 2 + 4 );
898
900
899
901
sub1 .dispose ();
900
902
901
- Assertions .assertThat (reconnectMono .resolvingInner .subscribers ).hasSize (203 );
903
+ Assertions .assertThat (reconnectMono .resolvingInner .subscribers )
904
+ .hasSize (RaceTestConstants .REPEATS * 2 + 3 );
902
905
903
906
publisher .next ("value" );
904
907
@@ -917,7 +920,7 @@ public void shouldNotifyAllTheSubscribers() {
917
920
918
921
@ Test
919
922
public void shouldExpireValueExactlyOnceOnRacingBetweenInvalidates () {
920
- for (int i = 0 ; i < 10000 ; i ++) {
923
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
921
924
final TestPublisher <String > cold = TestPublisher .createCold ();
922
925
cold .next ("value" );
923
926
final int timeout = 10 ;
@@ -959,7 +962,7 @@ public void shouldExpireValueExactlyOnceOnRacingBetweenInvalidates() {
959
962
960
963
@ Test
961
964
public void shouldExpireValueExactlyOnceOnRacingBetweenInvalidateAndDispose () {
962
- for (int i = 0 ; i < 10000 ; i ++) {
965
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
963
966
final TestPublisher <String > cold = TestPublisher .createCold ();
964
967
cold .next ("value" );
965
968
final int timeout = 10000 ;
0 commit comments