Skip to content

Commit f71ace7

Browse files
authored
Update to use Spring Boot 4.0.0 without updating to Jackson 3 (#266)
1 parent b29a620 commit f71ace7

File tree

6 files changed

+32
-17
lines changed

6 files changed

+32
-17
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<maven.compiler.release>17</maven.compiler.release>
5353
<spotless.version>3.1.0</spotless.version>
5454
<josdk.version>5.2.0</josdk.version>
55-
<spring-boot.version>3.5.8</spring-boot.version>
55+
<spring-boot.version>4.0.0</spring-boot.version>
5656
<surefire.version>3.5.4</surefire.version>
5757
<fabric8-client.version>7.3.1</fabric8-client.version>
5858
<jenvtest.version>0.9.7</jenvtest.version>

starter-test/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@
8282
<artifactId>spring-boot-starter-test</artifactId>
8383
<scope>test</scope>
8484
</dependency>
85+
<dependency>
86+
<groupId>org.springframework.boot</groupId>
87+
<artifactId>spring-boot-starter-webmvc-test</artifactId>
88+
<scope>test</scope>
89+
</dependency>
8590
<dependency>
8691
<groupId>org.awaitility</groupId>
8792
<artifactId>awaitility</artifactId>

starter-test/src/main/java/io/javaoperatorsdk/operator/springboot/starter/test/EnableMockOperator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.lang.annotation.Retention;
44
import java.lang.annotation.RetentionPolicy;
55

6-
import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
6+
import org.springframework.boot.test.context.PropertyMapping;
77
import org.springframework.context.annotation.Import;
88

99
@Retention(RetentionPolicy.RUNTIME)

starter-test/src/test/java/io/javaoperatorsdk/operator/springboot/starter/test/HealthIndicatorTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@
33
import org.junit.jupiter.api.Test;
44
import org.springframework.beans.factory.annotation.Autowired;
55
import org.springframework.boot.test.context.SpringBootTest;
6-
import org.springframework.boot.test.web.client.TestRestTemplate;
7-
import org.springframework.http.HttpStatus;
8-
import org.springframework.http.ResponseEntity;
6+
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
7+
import org.springframework.test.web.servlet.MockMvc;
98

10-
import static org.assertj.core.api.Assertions.assertThat;
9+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
10+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
11+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
1112

1213
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {
1314
"management.endpoint.health.enabled=true", "management.endpoint.health.show-details=always"})
1415
@EnableMockOperator(crdPaths = "classpath:crd.yml")
16+
@AutoConfigureMockMvc
1517
class HealthIndicatorTest {
1618

1719
@Autowired
18-
private TestRestTemplate restTemplate;
20+
private MockMvc mockMvc;
1921

2022
@Test
21-
void testOperatorHealthIndicator() {
22-
ResponseEntity<String> entity =
23-
this.restTemplate.getForEntity("/actuator/health", String.class);
24-
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
25-
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
26-
assertThat(entity.getBody())
27-
.contains(
28-
"\"operator\":{\"status\":\"UP\",\"details\":{\"customservicereconciler\":\"OK\"}}");
23+
void testOperatorHealthIndicator() throws Exception {
24+
mockMvc.perform(get("/actuator/health"))
25+
.andExpect(status().isOk())
26+
.andExpect(jsonPath("$.status").value("UP"))
27+
.andExpect(jsonPath("$.components.operator.status").value("UP"))
28+
.andExpect(jsonPath("$.components.operator.details.customservicereconciler").value("OK"));
2929
}
3030

3131
}

starter/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@
5757
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
5858
<optional>true</optional>
5959
</dependency>
60+
<dependency>
61+
<groupId>org.springframework.boot</groupId>
62+
<artifactId>spring-boot-health</artifactId>
63+
<optional>true</optional>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.springframework.boot</groupId>
67+
<artifactId>spring-boot-jackson2</artifactId>
68+
<optional>true</optional>
69+
</dependency>
6070
<!-- without this, the app exits after 1 minute -->
6171
<dependency>
6272
<groupId>org.springframework.boot</groupId>

starter/src/main/java/io/javaoperatorsdk/operator/springboot/starter/OperatorHealthIndicator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
5-
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
6-
import org.springframework.boot.actuate.health.Health;
5+
import org.springframework.boot.health.contributor.AbstractHealthIndicator;
6+
import org.springframework.boot.health.contributor.Health;
77
import org.springframework.stereotype.Component;
88
import org.springframework.util.Assert;
99

0 commit comments

Comments
 (0)