|
15 | 15 | */
|
16 | 16 | package io.github.resilience4j.retry;
|
17 | 17 |
|
18 |
| -import static org.assertj.core.api.Assertions.assertThat; |
19 |
| - |
20 |
| -import java.io.IOException; |
21 |
| -import java.util.Map; |
22 |
| -import java.util.concurrent.CompletionStage; |
23 |
| -import java.util.concurrent.ExecutionException; |
24 |
| -import java.util.concurrent.TimeUnit; |
25 |
| -import java.util.concurrent.TimeoutException; |
26 |
| - |
27 | 18 | import org.junit.Test;
|
28 | 19 | import org.junit.runner.RunWith;
|
29 | 20 | import org.springframework.beans.factory.annotation.Autowired;
|
30 | 21 | import org.springframework.boot.test.context.SpringBootTest;
|
31 | 22 | import org.springframework.boot.test.web.client.TestRestTemplate;
|
32 | 23 | import org.springframework.http.ResponseEntity;
|
| 24 | +import org.springframework.test.annotation.DirtiesContext; |
33 | 25 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
34 | 26 |
|
| 27 | +import java.io.IOException; |
| 28 | +import java.util.Map; |
| 29 | +import java.util.concurrent.CompletionStage; |
| 30 | +import java.util.concurrent.ExecutionException; |
| 31 | +import java.util.concurrent.TimeUnit; |
| 32 | +import java.util.concurrent.TimeoutException; |
| 33 | + |
35 | 34 | import io.github.resilience4j.circuitbreaker.IgnoredException;
|
36 | 35 | import io.github.resilience4j.retry.autoconfigure.RetryProperties;
|
37 | 36 | import io.github.resilience4j.retry.configure.RetryAspect;
|
|
40 | 39 | import io.github.resilience4j.service.test.RetryDummyService;
|
41 | 40 | import io.github.resilience4j.service.test.TestApplication;
|
42 | 41 |
|
| 42 | +import static org.assertj.core.api.Assertions.assertThat; |
| 43 | + |
43 | 44 | @RunWith(SpringJUnit4ClassRunner.class)
|
44 | 45 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
45 | 46 | classes = TestApplication.class)
|
@@ -68,6 +69,7 @@ public class RetryAutoConfigurationTest {
|
68 | 69 | * that the Retry logic is properly handled
|
69 | 70 | */
|
70 | 71 | @Test
|
| 72 | + @DirtiesContext |
71 | 73 | public void testRetryAutoConfiguration() throws IOException {
|
72 | 74 | assertThat(retryRegistry).isNotNull();
|
73 | 75 | assertThat(retryProperties).isNotNull();
|
@@ -116,6 +118,7 @@ public void testRetryAutoConfiguration() throws IOException {
|
116 | 118 | * that the Async Retry logic is properly handled
|
117 | 119 | */
|
118 | 120 | @Test
|
| 121 | + @DirtiesContext |
119 | 122 | public void testRetryAutoConfigurationAsync() throws Throwable {
|
120 | 123 | assertThat(asyncRetryRegistry).isNotNull();
|
121 | 124 |
|
@@ -150,10 +153,10 @@ public void testRetryAutoConfigurationAsync() throws Throwable {
|
150 | 153 |
|
151 | 154 | // expect retry-event actuator endpoint recorded both events
|
152 | 155 | ResponseEntity<RetryEventsEndpointResponse> retryEventList = restTemplate.getForEntity("/actuator/retryevents", RetryEventsEndpointResponse.class);
|
153 |
| - assertThat(retryEventList.getBody().getRetryEvents()).hasSize(6); |
| 156 | + assertThat(retryEventList.getBody().getRetryEvents()).hasSize(3); |
154 | 157 |
|
155 | 158 | retryEventList = restTemplate.getForEntity("/actuator/retryevents/retryBackendA", RetryEventsEndpointResponse.class);
|
156 |
| - assertThat(retryEventList.getBody().getRetryEvents()).hasSize(6); |
| 159 | + assertThat(retryEventList.getBody().getRetryEvents()).hasSize(3); |
157 | 160 |
|
158 | 161 | assertThat(retry.getRetryConfig().getExceptionPredicate().test(new IOException())).isTrue();
|
159 | 162 | assertThat(retry.getRetryConfig().getExceptionPredicate().test(new IgnoredException())).isFalse();
|
|
0 commit comments