[JAVA-27546] Updated spring-cucumber to spring boot 3 (#15276)
This commit is contained in:
parent
a2acd64779
commit
8abd7a07b5
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-boot-2</artifactId>
|
<artifactId>parent-boot-3</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-2</relativePath>
|
<relativePath>../parent-boot-3</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -53,16 +53,17 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
|
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>${commons-io.version}</version>
|
<version>${commons-io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<!-- The main class to start by executing java -jar -->
|
||||||
|
<start-class>com.baeldung.SpringDemoApplication</start-class>
|
||||||
<cucumber.version>7.14.0</cucumber.version>
|
<cucumber.version>7.14.0</cucumber.version>
|
||||||
<commons-io.version>1.3.2</commons-io.version>
|
<junit-vintage-engine.version>5.10.1</junit-vintage-engine.version>
|
||||||
<junit-vintage-engine.version>5.10.0</junit-vintage-engine.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -3,6 +3,7 @@ package com.baeldung.cucumberoptions;
|
||||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.HttpStatusCode;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -11,12 +12,12 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
public class HealthCheckController {
|
public class HealthCheckController {
|
||||||
|
|
||||||
@GetMapping(path = "/v1/status", produces = APPLICATION_JSON_VALUE)
|
@GetMapping(path = "/v1/status", produces = APPLICATION_JSON_VALUE)
|
||||||
public HttpStatus getV1Status() {
|
public HttpStatusCode getV1Status() {
|
||||||
return ResponseEntity.ok().build().getStatusCode();
|
return ResponseEntity.ok().build().getStatusCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/v2/status", produces = APPLICATION_JSON_VALUE)
|
@GetMapping(path = "/v2/status", produces = APPLICATION_JSON_VALUE)
|
||||||
public HttpStatus getV2Status() {
|
public HttpStatusCode getV2Status() {
|
||||||
return ResponseEntity.ok().build().getStatusCode();
|
return ResponseEntity.ok().build().getStatusCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,6 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.HttpStatusCode;
|
||||||
import org.springframework.http.client.ClientHttpResponse;
|
import org.springframework.http.client.ClientHttpResponse;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.web.client.ResponseErrorHandler;
|
import org.springframework.web.client.ResponseErrorHandler;
|
||||||
|
@ -69,7 +71,7 @@ public class SpringIntegrationTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasError(ClientHttpResponse response) throws IOException {
|
public boolean hasError(ClientHttpResponse response) throws IOException {
|
||||||
hadError = response.getRawStatusCode() >= 400;
|
hadError = response.getStatusCode().value() >= 400;
|
||||||
return hadError;
|
return hadError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import io.cucumber.java.en.Given;
|
||||||
import io.cucumber.java.en.Then;
|
import io.cucumber.java.en.Then;
|
||||||
import io.cucumber.java.en.When;
|
import io.cucumber.java.en.When;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.HttpStatusCode;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
@ -29,7 +30,7 @@ public class StepDefsIntegrationTest extends SpringIntegrationTest {
|
||||||
|
|
||||||
@Then("^the client receives status code of (\\d+)$")
|
@Then("^the client receives status code of (\\d+)$")
|
||||||
public void the_client_receives_status_code_of(int statusCode) throws Throwable {
|
public void the_client_receives_status_code_of(int statusCode) throws Throwable {
|
||||||
final HttpStatus currentStatusCode = latestResponse.getTheResponse().getStatusCode();
|
final HttpStatusCode currentStatusCode = latestResponse.getTheResponse().getStatusCode();
|
||||||
assertThat("status code is incorrect : " + latestResponse.getBody(), currentStatusCode.value(), is(statusCode));
|
assertThat("status code is incorrect : " + latestResponse.getBody(), currentStatusCode.value(), is(statusCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@ package com.baeldung.cucumberoptions;
|
||||||
import io.cucumber.java.en.Then;
|
import io.cucumber.java.en.Then;
|
||||||
import io.cucumber.java.en.When;
|
import io.cucumber.java.en.When;
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
|
import org.springframework.http.HttpStatusCode;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ public class HealthCheckStepDefsIntegrationTest extends SpringIntegrationTest {
|
||||||
|
|
||||||
@Then("^the client receives (\\d+) status code$")
|
@Then("^the client receives (\\d+) status code$")
|
||||||
public void verifyStatusCode(int statusCode) throws Throwable {
|
public void verifyStatusCode(int statusCode) throws Throwable {
|
||||||
final HttpStatus currentStatusCode = statusResponse.getStatusCode();
|
final HttpStatusCode currentStatusCode = statusResponse.getStatusCode();
|
||||||
assertThat(currentStatusCode.value(), is(statusCode));
|
assertThat(currentStatusCode.value(), is(statusCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue