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 ;
@@ -59,7 +60,7 @@ public class ReconnectMonoTests {
59
60
public void shouldExpireValueOnRacingDisposeAndNext () {
60
61
Hooks .onErrorDropped (t -> {});
61
62
Hooks .onNextDropped (System .out ::println );
62
- for (int i = 0 ; i < 10000 ; i ++) {
63
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
63
64
final int index = i ;
64
65
final CoreSubscriber <? super String >[] monoSubscribers = new CoreSubscriber [1 ];
65
66
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 );
@@ -211,7 +212,7 @@ public void shouldNotExpireNewlyResolvedValueIfSubscribeIsRacingWithInvalidate()
211
212
@ Test
212
213
public void shouldNotExpireNewlyResolvedValueIfSubscribeIsRacingWithInvalidates () {
213
214
Hooks .onErrorDropped (t -> {});
214
- for (int i = 0 ; i < 10000 ; i ++) {
215
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
215
216
final int index = i ;
216
217
final TestPublisher <String > cold =
217
218
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
@@ -275,7 +276,7 @@ public void shouldNotExpireNewlyResolvedValueIfSubscribeIsRacingWithInvalidates(
275
276
@ Test
276
277
public void shouldNotExpireNewlyResolvedValueIfBlockIsRacingWithInvalidate () {
277
278
Hooks .onErrorDropped (t -> {});
278
- for (int i = 0 ; i < 10000 ; i ++) {
279
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
279
280
final int index = i ;
280
281
final Mono <String > source =
281
282
Mono .fromSupplier (
@@ -341,7 +342,7 @@ public String get() {
341
342
342
343
@ Test
343
344
public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribers () {
344
- for (int i = 0 ; i < 10000 ; i ++) {
345
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
345
346
final TestPublisher <String > cold = TestPublisher .createCold ();
346
347
cold .next ("value" + i );
347
348
@@ -388,7 +389,7 @@ public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribers() {
388
389
@ Test
389
390
public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribeAndBlock () {
390
391
Duration timeout = Duration .ofMillis (100 );
391
- for (int i = 0 ; i < 10000 ; i ++) {
392
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
392
393
final TestPublisher <String > cold = TestPublisher .createCold ();
393
394
cold .next ("value" + i );
394
395
@@ -436,7 +437,7 @@ public void shouldEstablishValueOnceInCaseOfRacingBetweenSubscribeAndBlock() {
436
437
@ Test
437
438
public void shouldEstablishValueOnceInCaseOfRacingBetweenBlocks () {
438
439
Duration timeout = Duration .ofMillis (100 );
439
- for (int i = 0 ; i < 10000 ; i ++) {
440
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
440
441
final TestPublisher <String > cold = TestPublisher .createCold ();
441
442
cold .next ("value" + i );
442
443
@@ -481,7 +482,7 @@ public void shouldEstablishValueOnceInCaseOfRacingBetweenBlocks() {
481
482
@ Test
482
483
public void shouldExpireValueOnRacingDisposeAndNoValueComplete () {
483
484
Hooks .onErrorDropped (t -> {});
484
- for (int i = 0 ; i < 10000 ; i ++) {
485
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
485
486
final TestPublisher <String > cold =
486
487
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
487
488
@@ -520,7 +521,7 @@ public void shouldExpireValueOnRacingDisposeAndNoValueComplete() {
520
521
@ Test
521
522
public void shouldExpireValueOnRacingDisposeAndComplete () {
522
523
Hooks .onErrorDropped (t -> {});
523
- for (int i = 0 ; i < 10000 ; i ++) {
524
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
524
525
final TestPublisher <String > cold =
525
526
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
526
527
@@ -561,7 +562,7 @@ public void shouldExpireValueOnRacingDisposeAndComplete() {
561
562
public void shouldExpireValueOnRacingDisposeAndError () {
562
563
Hooks .onErrorDropped (t -> {});
563
564
RuntimeException runtimeException = new RuntimeException ("test" );
564
- for (int i = 0 ; i < 10000 ; i ++) {
565
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
565
566
final TestPublisher <String > cold =
566
567
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
567
568
@@ -607,7 +608,7 @@ public void shouldExpireValueOnRacingDisposeAndError() {
607
608
public void shouldExpireValueOnRacingDisposeAndErrorWithNoBackoff () {
608
609
Hooks .onErrorDropped (t -> {});
609
610
RuntimeException runtimeException = new RuntimeException ("test" );
610
- for (int i = 0 ; i < 10000 ; i ++) {
611
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
611
612
final TestPublisher <String > cold =
612
613
TestPublisher .createNoncompliant (TestPublisher .Violation .REQUEST_OVERFLOW );
613
614
@@ -884,19 +885,21 @@ public void shouldNotifyAllTheSubscribers() {
884
885
885
886
final ArrayList <AssertSubscriber <String >> subscribers = new ArrayList <>(200 );
886
887
887
- for (int i = 0 ; i < 100 ; i ++) {
888
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
888
889
final AssertSubscriber <String > subA = new AssertSubscriber <>();
889
890
final AssertSubscriber <String > subB = new AssertSubscriber <>();
890
891
subscribers .add (subA );
891
892
subscribers .add (subB );
892
893
RaceTestUtils .race (() -> reconnectMono .subscribe (subA ), () -> reconnectMono .subscribe (subB ));
893
894
}
894
895
895
- Assertions .assertThat (reconnectMono .resolvingInner .subscribers ).hasSize (204 );
896
+ Assertions .assertThat (reconnectMono .resolvingInner .subscribers )
897
+ .hasSize (RaceTestConstants .REPEATS * 2 + 4 );
896
898
897
899
sub1 .cancel ();
898
900
899
- Assertions .assertThat (reconnectMono .resolvingInner .subscribers ).hasSize (203 );
901
+ Assertions .assertThat (reconnectMono .resolvingInner .subscribers )
902
+ .hasSize (RaceTestConstants .REPEATS * 2 + 3 );
900
903
901
904
publisher .next ("value" );
902
905
@@ -915,7 +918,7 @@ public void shouldNotifyAllTheSubscribers() {
915
918
916
919
@ Test
917
920
public void shouldExpireValueExactlyOnceOnRacingBetweenInvalidates () {
918
- for (int i = 0 ; i < 10000 ; i ++) {
921
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
919
922
final TestPublisher <String > cold = TestPublisher .createCold ();
920
923
cold .next ("value" );
921
924
cold .complete ();
@@ -963,7 +966,7 @@ public void shouldExpireValueExactlyOnceOnRacingBetweenInvalidates() {
963
966
964
967
@ Test
965
968
public void shouldExpireValueExactlyOnceOnRacingBetweenInvalidateAndDispose () {
966
- for (int i = 0 ; i < 10000 ; i ++) {
969
+ for (int i = 0 ; i < RaceTestConstants . REPEATS ; i ++) {
967
970
final TestPublisher <String > cold = TestPublisher .createCold ();
968
971
cold .next ("value" );
969
972
final int timeout = 10000 ;
0 commit comments