Merge pull request #14323 from panos-kakos/JAVA-22589

Java 22589
This commit is contained in:
Kasra Madadipouya 2023-07-09 20:30:49 +02:00 committed by GitHub
commit a795391cbc
2 changed files with 19 additions and 16 deletions

View File

@ -30,12 +30,12 @@
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot2</artifactId>
<version>2.0.2</version>
<version>${resilience4j-spring-boot2.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.14.2</version>
<version>${jackson-datatype-jsr310.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -45,9 +45,15 @@
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.35.0</version>
<version>${wiremock-jre8.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<wiremock-jre8.version>2.35.0</wiremock-jre8.version>
<resilience4j-spring-boot2.version>2.0.2</resilience4j-spring-boot2.version>
<jackson-datatype-jsr310.version>2.15.2</jackson-datatype-jsr310.version>
</properties>
</project>

View File

@ -8,12 +8,12 @@ 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.*;
@ -29,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());
@ -40,7 +42,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 +128,7 @@ class ResilientAppControllerIntegrationTest {
private List<CircuitBreakerEvent> 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 +173,7 @@ class ResilientAppControllerIntegrationTest {
private List<RetryEvent> 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,8 +197,7 @@ class ResilientAppControllerIntegrationTest {
private List<TimeLimiterEvent> 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();
@ -256,8 +255,7 @@ class ResilientAppControllerIntegrationTest {
private List<BulkheadEvent> 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<RateLimiterEvent> 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();