diff --git a/pom.xml b/pom.xml index 17a914d619..07b9d6d842 100644 --- a/pom.xml +++ b/pom.xml @@ -1211,7 +1211,6 @@ gradle-modules/gradle/maven-to-gradle persistence-modules/spring-data-neo4j spring-actuator - gcp-firebase spring-di-4 spring-kafka-2 diff --git a/spring-cucumber/pom.xml b/spring-cucumber/pom.xml index c6c163d7d1..042e81971f 100644 --- a/spring-cucumber/pom.xml +++ b/spring-cucumber/pom.xml @@ -45,6 +45,12 @@ ${cucumber.version} test + + org.junit.vintage + junit-vintage-engine + ${junit-vintage-engine.version} + test + org.apache.commons @@ -54,8 +60,9 @@ - 6.8.0 + 7.14.0 1.3.2 + 5.10.0 \ No newline at end of file diff --git a/spring-cucumber/src/main/java/com/baeldung/cucumberoptions/CucumberOptionsApplication.java b/spring-cucumber/src/main/java/com/baeldung/cucumberoptions/CucumberOptionsApplication.java new file mode 100644 index 0000000000..03082128b3 --- /dev/null +++ b/spring-cucumber/src/main/java/com/baeldung/cucumberoptions/CucumberOptionsApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.cucumberoptions; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CucumberOptionsApplication { + + public static void main(String[] args) { + SpringApplication.run(CucumberOptionsApplication.class, args); + } + +} \ No newline at end of file diff --git a/spring-cucumber/src/main/java/com/baeldung/cucumberoptions/HealthCheckController.java b/spring-cucumber/src/main/java/com/baeldung/cucumberoptions/HealthCheckController.java new file mode 100644 index 0000000000..637dbdb540 --- /dev/null +++ b/spring-cucumber/src/main/java/com/baeldung/cucumberoptions/HealthCheckController.java @@ -0,0 +1,22 @@ +package com.baeldung.cucumberoptions; + +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HealthCheckController { + + @GetMapping(path = "/v1/status", produces = APPLICATION_JSON_VALUE) + public HttpStatus getV1Status() { + return ResponseEntity.ok().build().getStatusCode(); + } + + @GetMapping(path = "/v2/status", produces = APPLICATION_JSON_VALUE) + public HttpStatus getV2Status() { + return ResponseEntity.ok().build().getStatusCode(); + } +} \ No newline at end of file diff --git a/spring-cucumber/src/test/java/com/baeldung/cucumberoptions/HealthCheckStepDefsIntegrationTest.java b/spring-cucumber/src/test/java/com/baeldung/cucumberoptions/HealthCheckStepDefsIntegrationTest.java new file mode 100644 index 0000000000..999adadbef --- /dev/null +++ b/spring-cucumber/src/test/java/com/baeldung/cucumberoptions/HealthCheckStepDefsIntegrationTest.java @@ -0,0 +1,38 @@ +package com.baeldung.cucumberoptions; + +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import com.baeldung.SpringIntegrationTest; + +public class HealthCheckStepDefsIntegrationTest extends SpringIntegrationTest { + + private ResponseEntity statusResponse; + + private ResponseEntity doGet(String url) { + return new RestTemplate().getForEntity(url, String.class); + } + + @When("^the client calls /v1/status") + public void checkV1Status() throws Throwable { + statusResponse = doGet("http://localhost:8082/v1/status"); + } + + @When("^the client calls /v2/status") + public void checkV2Status() throws Throwable { + statusResponse = doGet("http://localhost:8082/v2/status"); + } + + @Then("^the client receives (\\d+) status code$") + public void verifyStatusCode(int statusCode) throws Throwable { + final HttpStatus currentStatusCode = statusResponse.getStatusCode(); + assertThat(currentStatusCode.value(), is(statusCode)); + } +} \ No newline at end of file diff --git a/spring-cucumber/src/test/resources/com/baeldung/cucumberoptions/healthcheck.feature b/spring-cucumber/src/test/resources/com/baeldung/cucumberoptions/healthcheck.feature new file mode 100644 index 0000000000..33e07c1add --- /dev/null +++ b/spring-cucumber/src/test/resources/com/baeldung/cucumberoptions/healthcheck.feature @@ -0,0 +1,11 @@ +Feature: healthcheck endpoints can be verified + + @v1 + Scenario: v1 status is healthy + When the client calls /v1/status + Then the client receives 200 status code + + @v2 + Scenario: v2 status is healthy + When the client calls /v2/status + Then the client receives 200 status code diff --git a/spring-cucumber/src/test/resources/cucumber.properties b/spring-cucumber/src/test/resources/cucumber.properties new file mode 100644 index 0000000000..22c3379201 --- /dev/null +++ b/spring-cucumber/src/test/resources/cucumber.properties @@ -0,0 +1 @@ +cucumber.filter.tags=not @v2 \ No newline at end of file