From 862de9617b84a2e8bdaafb9d1addb87f4652da7b Mon Sep 17 00:00:00 2001 From: panos-kakos Date: Tue, 27 Jun 2023 11:43:54 +0300 Subject: [PATCH 1/3] [JAVA-22589] Clean up --- spring-boot-modules/spring-boot-resilience4j/pom.xml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spring-boot-modules/spring-boot-resilience4j/pom.xml b/spring-boot-modules/spring-boot-resilience4j/pom.xml index 609bc7fc49..0acb8ad7cb 100644 --- a/spring-boot-modules/spring-boot-resilience4j/pom.xml +++ b/spring-boot-modules/spring-boot-resilience4j/pom.xml @@ -30,12 +30,12 @@ io.github.resilience4j resilience4j-spring-boot2 - 2.0.2 + ${resilience4j-spring-boot2.version} com.fasterxml.jackson.datatype jackson-datatype-jsr310 - 2.14.2 + 2.15.2 org.springframework.boot @@ -45,9 +45,14 @@ com.github.tomakehurst wiremock-jre8 - 2.35.0 + ${wiremock-jre8.version} test + + 2.35.0 + 2.0.2 + + \ No newline at end of file From 2485d2514036ffb04aaba30ee109d83686dab20c Mon Sep 17 00:00:00 2001 From: panos-kakos Date: Thu, 29 Jun 2023 00:18:06 +0300 Subject: [PATCH 2/3] [JAVA-22589] Disabled test case --- .../spring-boot-resilience4j/pom.xml | 3 ++- ...ResilientAppControllerIntegrationTest.java | 23 ++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/spring-boot-modules/spring-boot-resilience4j/pom.xml b/spring-boot-modules/spring-boot-resilience4j/pom.xml index 0acb8ad7cb..355ef8f92d 100644 --- a/spring-boot-modules/spring-boot-resilience4j/pom.xml +++ b/spring-boot-modules/spring-boot-resilience4j/pom.xml @@ -35,7 +35,7 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 - 2.15.2 + ${jackson-datatype-jsr310.version} org.springframework.boot @@ -53,6 +53,7 @@ 2.35.0 2.0.2 + 2.15.2 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java b/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java index d1951218de..a666b90ab9 100644 --- a/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java +++ b/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java @@ -8,17 +8,18 @@ import static org.springframework.http.HttpStatus.*; import com.baeldung.resilience4j.eventendpoints.model.*; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JSR310Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.github.tomakehurst.wiremock.junit5.WireMockExtension; import java.net.URI; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; import java.util.concurrent.*; import java.util.stream.IntStream; import org.apache.commons.io.IOUtils; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.slf4j.Logger; @@ -40,7 +41,7 @@ class ResilientAppControllerIntegrationTest { @LocalServerPort private Integer port; private static final ObjectMapper objectMapper = - new ObjectMapper().registerModule(new JSR310Module()); + new ObjectMapper().registerModule(new JavaTimeModule()); @RegisterExtension static WireMockExtension EXTERNAL_SERVICE = @@ -126,8 +127,7 @@ class ResilientAppControllerIntegrationTest { private List getCircuitBreakerEvents() throws Exception { String jsonEventsList = IOUtils.toString( - new URI("http://localhost:" + port + "/actuator/circuitbreakerevents"), - Charset.forName("UTF-8")); + new URI("http://localhost:" + port + "/actuator/circuitbreakerevents"), StandardCharsets.UTF_8); CircuitBreakerEvents circuitBreakerEvents = objectMapper.readValue(jsonEventsList, CircuitBreakerEvents.class); return circuitBreakerEvents.getCircuitBreakerEvents(); @@ -172,8 +172,7 @@ class ResilientAppControllerIntegrationTest { private List getRetryEvents() throws Exception { String jsonEventsList = IOUtils.toString( - new URI("http://localhost:" + port + "/actuator/retryevents"), - Charset.forName("UTF-8")); + new URI("http://localhost:" + port + "/actuator/retryevents"), StandardCharsets.UTF_8); RetryEvents retryEvents = objectMapper.readValue(jsonEventsList, RetryEvents.class); return retryEvents.getRetryEvents(); } @@ -197,13 +196,13 @@ class ResilientAppControllerIntegrationTest { private List getTimeLimiterEvents() throws Exception { String jsonEventsList = IOUtils.toString( - new URI("http://localhost:" + port + "/actuator/timelimiterevents"), - Charset.forName("UTF-8")); + new URI("http://localhost:" + port + "/actuator/timelimiterevents"), StandardCharsets.UTF_8); TimeLimiterEvents timeLimiterEvents = objectMapper.readValue(jsonEventsList, TimeLimiterEvents.class); return timeLimiterEvents.getTimeLimiterEvents(); } + @Disabled @Test void testBulkheadEvents() throws Exception { EXTERNAL_SERVICE.stubFor(WireMock.get("/api/external").willReturn(ok())); @@ -256,8 +255,7 @@ class ResilientAppControllerIntegrationTest { private List getBulkheadEvents() throws Exception { String jsonEventsList = IOUtils.toString( - new URI("http://localhost:" + port + "/actuator/bulkheadevents"), - Charset.forName("UTF-8")); + new URI("http://localhost:" + port + "/actuator/bulkheadevents"), StandardCharsets.UTF_8); BulkheadEvents bulkheadEvents = objectMapper.readValue(jsonEventsList, BulkheadEvents.class); return bulkheadEvents.getBulkheadEvents(); } @@ -310,8 +308,7 @@ class ResilientAppControllerIntegrationTest { private List getRateLimiterEvents() throws Exception { String jsonEventsList = IOUtils.toString( - new URI("http://localhost:" + port + "/actuator/ratelimiterevents"), - Charset.forName("UTF-8")); + new URI("http://localhost:" + port + "/actuator/ratelimiterevents"), StandardCharsets.UTF_8); RateLimiterEvents rateLimiterEvents = objectMapper.readValue(jsonEventsList, RateLimiterEvents.class); return rateLimiterEvents.getRateLimiterEvents(); From c305321a42b81ddd7ab7f76a9da5b3ae3aceda21 Mon Sep 17 00:00:00 2001 From: panos-kakos Date: Mon, 3 Jul 2023 17:15:45 +0300 Subject: [PATCH 3/3] [JAVA-22589] Added @DirtiesContext and re-enabled test case --- .../eventendpoints/ResilientAppControllerIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java b/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java index a666b90ab9..b4378a9248 100644 --- a/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java +++ b/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java @@ -19,7 +19,6 @@ import java.util.Map; import java.util.concurrent.*; import java.util.stream.IntStream; import org.apache.commons.io.IOUtils; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.slf4j.Logger; @@ -30,8 +29,10 @@ import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.test.annotation.DirtiesContext; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) class ResilientAppControllerIntegrationTest { private final Logger LOGGER = LoggerFactory.getLogger(getClass()); @@ -202,7 +203,6 @@ class ResilientAppControllerIntegrationTest { return timeLimiterEvents.getTimeLimiterEvents(); } - @Disabled @Test void testBulkheadEvents() throws Exception { EXTERNAL_SERVICE.stubFor(WireMock.get("/api/external").willReturn(ok()));