Skip to content

Commit 8abd7a0

Browse files
authored
[JAVA-27546] Updated spring-cucumber to spring boot 3 (#15276)
1 parent a2acd64 commit 8abd7a0

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

spring-cucumber/pom.xml

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
<parent>
1313
<groupId>com.baeldung</groupId>
14-
<artifactId>parent-boot-2</artifactId>
14+
<artifactId>parent-boot-3</artifactId>
1515
<version>0.0.1-SNAPSHOT</version>
16-
<relativePath>../parent-boot-2</relativePath>
16+
<relativePath>../parent-boot-3</relativePath>
1717
</parent>
1818

1919
<dependencies>
@@ -53,16 +53,17 @@
5353
</dependency>
5454
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
5555
<dependency>
56-
<groupId>org.apache.commons</groupId>
56+
<groupId>commons-io</groupId>
5757
<artifactId>commons-io</artifactId>
5858
<version>${commons-io.version}</version>
5959
</dependency>
6060
</dependencies>
6161

6262
<properties>
63+
<!-- The main class to start by executing java -jar -->
64+
<start-class>com.baeldung.SpringDemoApplication</start-class>
6365
<cucumber.version>7.14.0</cucumber.version>
64-
<commons-io.version>1.3.2</commons-io.version>
65-
<junit-vintage-engine.version>5.10.0</junit-vintage-engine.version>
66+
<junit-vintage-engine.version>5.10.1</junit-vintage-engine.version>
6667
</properties>
6768

6869
</project>

spring-cucumber/src/main/java/com/baeldung/cucumberoptions/HealthCheckController.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
44

55
import org.springframework.http.HttpStatus;
6+
import org.springframework.http.HttpStatusCode;
67
import org.springframework.http.ResponseEntity;
78
import org.springframework.web.bind.annotation.GetMapping;
89
import org.springframework.web.bind.annotation.RestController;
@@ -11,12 +12,12 @@
1112
public class HealthCheckController {
1213

1314
@GetMapping(path = "/v1/status", produces = APPLICATION_JSON_VALUE)
14-
public HttpStatus getV1Status() {
15+
public HttpStatusCode getV1Status() {
1516
return ResponseEntity.ok().build().getStatusCode();
1617
}
1718

1819
@GetMapping(path = "/v2/status", produces = APPLICATION_JSON_VALUE)
19-
public HttpStatus getV2Status() {
20+
public HttpStatusCode getV2Status() {
2021
return ResponseEntity.ok().build().getStatusCode();
2122
}
2223
}

spring-cucumber/src/test/java/com/baeldung/SpringIntegrationTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import org.springframework.boot.test.context.SpringBootTest;
1010
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
1111
import org.springframework.http.HttpMethod;
12+
import org.springframework.http.HttpStatus;
13+
import org.springframework.http.HttpStatusCode;
1214
import org.springframework.http.client.ClientHttpResponse;
1315
import org.springframework.test.context.ContextConfiguration;
1416
import org.springframework.web.client.ResponseErrorHandler;
@@ -69,7 +71,7 @@ private ResponseResults getResults() {
6971

7072
@Override
7173
public boolean hasError(ClientHttpResponse response) throws IOException {
72-
hadError = response.getRawStatusCode() >= 400;
74+
hadError = response.getStatusCode().value() >= 400;
7375
return hadError;
7476
}
7577

spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import io.cucumber.java.en.Then;
66
import io.cucumber.java.en.When;
77
import org.springframework.http.HttpStatus;
8+
import org.springframework.http.HttpStatusCode;
89

910
import static org.hamcrest.MatcherAssert.assertThat;
1011
import static org.hamcrest.Matchers.is;
@@ -29,7 +30,7 @@ public void the_client_issues_GET_version() throws Throwable {
2930

3031
@Then("^the client receives status code of (\\d+)$")
3132
public void the_client_receives_status_code_of(int statusCode) throws Throwable {
32-
final HttpStatus currentStatusCode = latestResponse.getTheResponse().getStatusCode();
33+
final HttpStatusCode currentStatusCode = latestResponse.getTheResponse().getStatusCode();
3334
assertThat("status code is incorrect : " + latestResponse.getBody(), currentStatusCode.value(), is(statusCode));
3435
}
3536

spring-cucumber/src/test/java/com/baeldung/cucumberoptions/HealthCheckStepDefsIntegrationTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import io.cucumber.java.en.Then;
44
import io.cucumber.java.en.When;
55

6-
import org.springframework.http.HttpStatus;
6+
7+
import org.springframework.http.HttpStatusCode;
78
import org.springframework.http.ResponseEntity;
89
import org.springframework.web.client.RestTemplate;
910

@@ -32,7 +33,7 @@ public void checkV2Status() throws Throwable {
3233

3334
@Then("^the client receives (\\d+) status code$")
3435
public void verifyStatusCode(int statusCode) throws Throwable {
35-
final HttpStatus currentStatusCode = statusResponse.getStatusCode();
36+
final HttpStatusCode currentStatusCode = statusResponse.getStatusCode();
3637
assertThat(currentStatusCode.value(), is(statusCode));
3738
}
3839
}

0 commit comments

Comments
 (0)