File tree Expand file tree Collapse file tree 6 files changed +94
-2
lines changed
resilience4j-reactor/src/test/java/io/github/resilience4j/reactor Expand file tree Collapse file tree 6 files changed +94
-2
lines changed Original file line number Diff line number Diff line change @@ -80,4 +80,16 @@ public void shouldEmitErrorWithCircuitBreakerOpenExceptionEvenWhenErrorDuringSub
80
80
).expectError (CircuitBreakerOpenException .class )
81
81
.verify (Duration .ofSeconds (1 ));
82
82
}
83
+
84
+ @ Test
85
+ public void shouldEmitErrorWithCircuitBreakerOpenExceptionEvenWhenErrorNotOnSubscribe () {
86
+ circuitBreaker .transitionToOpenState ();
87
+ StepVerifier .create (
88
+ Flux .error (new IOException ("BAM!" ), true )
89
+ .transform (CircuitBreakerOperator .of (circuitBreaker ))
90
+ .transform (BulkheadOperator .of (bulkhead , Schedulers .immediate ()))
91
+ .transform (RateLimiterOperator .of (rateLimiter , Schedulers .immediate ()))
92
+ ).expectError (CircuitBreakerOpenException .class )
93
+ .verify (Duration .ofSeconds (1 ));
94
+ }
83
95
}
Original file line number Diff line number Diff line change @@ -84,4 +84,18 @@ public void shouldEmitBulkheadFullExceptionEvenWhenErrorDuringSubscribe() {
84
84
85
85
assertThat (bulkhead .getMetrics ().getAvailableConcurrentCalls ()).isEqualTo (0 );
86
86
}
87
+
88
+ @ Test
89
+ public void shouldEmitBulkheadFullExceptionEvenWhenErrorNotOnSubscribe () {
90
+ bulkhead .isCallPermitted ();
91
+
92
+ StepVerifier .create (
93
+ Flux .error (new IOException ("BAM!" ), true )
94
+ .transform (BulkheadOperator .of (bulkhead , Schedulers .immediate ())))
95
+ .expectSubscription ()
96
+ .expectError (BulkheadFullException .class )
97
+ .verify (Duration .ofSeconds (1 ));
98
+
99
+ assertThat (bulkhead .getMetrics ().getAvailableConcurrentCalls ()).isEqualTo (0 );
100
+ }
87
101
}
Original file line number Diff line number Diff line change @@ -83,4 +83,18 @@ public void shouldEmitBulkheadFullExceptionEvenWhenErrorDuringSubscribe() {
83
83
84
84
assertThat (bulkhead .getMetrics ().getAvailableConcurrentCalls ()).isEqualTo (0 );
85
85
}
86
+
87
+ @ Test
88
+ public void shouldEmitBulkheadFullExceptionEvenWhenErrorNotOnSubscribe () {
89
+ bulkhead .isCallPermitted ();
90
+
91
+ StepVerifier .create (
92
+ Mono .error (new IOException ("BAM!" )).delayElement (Duration .ofMillis (1 ))
93
+ .transform (BulkheadOperator .of (bulkhead , Schedulers .immediate ())))
94
+ .expectSubscription ()
95
+ .expectError (BulkheadFullException .class )
96
+ .verify (Duration .ofSeconds (1 ));
97
+
98
+ assertThat (bulkhead .getMetrics ().getAvailableConcurrentCalls ()).isEqualTo (0 );
99
+ }
86
100
}
Original file line number Diff line number Diff line change @@ -47,6 +47,18 @@ public void shouldPropagateError() {
47
47
assertSingleFailedCall ();
48
48
}
49
49
50
+ @ Test
51
+ public void shouldEmitCircuitBreakerOpenExceptionEvenWhenErrorNotOnSubscribe () {
52
+ circuitBreaker .transitionToForcedOpenState ();
53
+ StepVerifier .create (
54
+ Mono .error (new IOException ("BAM!" )).delayElement (Duration .ofMillis (1 ))
55
+ .transform (CircuitBreakerOperator .of (circuitBreaker )))
56
+ .expectError (CircuitBreakerOpenException .class )
57
+ .verify (Duration .ofSeconds (1 ));
58
+
59
+ assertNoRegisteredCall ();
60
+ }
61
+
50
62
@ Test
51
63
public void shouldEmitCircuitBreakerOpenExceptionEvenWhenErrorDuringSubscribe () {
52
64
circuitBreaker .transitionToForcedOpenState ();
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ public void shouldPropagateError() {
51
51
}
52
52
53
53
@ Test
54
- public void shouldEmitErrorWithBulkheadFullException () {
54
+ public void shouldEmitRequestNotPermittedException () {
55
55
saturateRateLimiter ();
56
56
57
57
StepVerifier .create (
@@ -63,4 +63,32 @@ public void shouldEmitErrorWithBulkheadFullException() {
63
63
64
64
assertNoPermitLeft ();
65
65
}
66
+
67
+ @ Test
68
+ public void shouldEmitRequestNotPermittedExceptionEvenWhenErrorDuringSubscribe () {
69
+ saturateRateLimiter ();
70
+
71
+ StepVerifier .create (
72
+ Flux .error (new IOException ("BAM!" ))
73
+ .transform (RateLimiterOperator .of (rateLimiter )))
74
+ .expectSubscription ()
75
+ .expectError (RequestNotPermitted .class )
76
+ .verify (Duration .ofSeconds (1 ));
77
+
78
+ assertNoPermitLeft ();
79
+ }
80
+
81
+ @ Test
82
+ public void shouldEmitRequestNotPermittedExceptionEvenWhenErrorNotOnSubscribe () {
83
+ saturateRateLimiter ();
84
+
85
+ StepVerifier .create (
86
+ Flux .error (new IOException ("BAM!" ), true )
87
+ .transform (RateLimiterOperator .of (rateLimiter )))
88
+ .expectSubscription ()
89
+ .expectError (RequestNotPermitted .class )
90
+ .verify (Duration .ofSeconds (1 ));
91
+
92
+ assertNoPermitLeft ();
93
+ }
66
94
}
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ public void shouldEmitErrorWithBulkheadFullException() {
64
64
}
65
65
66
66
@ Test
67
- public void shouldEmitCircuitBreakerOpenExceptionEvenWhenErrorDuringSubscribe () {
67
+ public void shouldEmitRequestNotPermittedExceptionEvenWhenErrorDuringSubscribe () {
68
68
saturateRateLimiter ();
69
69
StepVerifier .create (
70
70
Mono .error (new IOException ("BAM!" ))
@@ -74,4 +74,16 @@ public void shouldEmitCircuitBreakerOpenExceptionEvenWhenErrorDuringSubscribe()
74
74
75
75
assertNoPermitLeft ();
76
76
}
77
+
78
+ @ Test
79
+ public void shouldEmitRequestNotPermittedExceptionEvenWhenErrorNotOnSubscribe () {
80
+ saturateRateLimiter ();
81
+ StepVerifier .create (
82
+ Mono .error (new IOException ("BAM!" )).delayElement (Duration .ofMillis (1 ))
83
+ .transform (RateLimiterOperator .of (rateLimiter , Schedulers .immediate ())))
84
+ .expectError (RequestNotPermitted .class )
85
+ .verify (Duration .ofSeconds (1 ));
86
+
87
+ assertNoPermitLeft ();
88
+ }
77
89
}
You can’t perform that action at this time.
0 commit comments