Merge branch 'eugenp:master' into JAVA-26380
This commit is contained in:
commit
e6e9224412
1
pom.xml
1
pom.xml
|
@ -1211,7 +1211,6 @@
|
|||
<module>gradle-modules/gradle/maven-to-gradle</module>
|
||||
<module>persistence-modules/spring-data-neo4j</module>
|
||||
<module>spring-actuator</module>
|
||||
<module>gcp-firebase</module>
|
||||
<module>spring-di-4</module>
|
||||
<module>spring-kafka-2</module>
|
||||
<!--<module>java-panama</module> Java-19 module-->
|
||||
|
|
|
@ -45,6 +45,12 @@
|
|||
<version>${cucumber.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<version>${junit-vintage-engine.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
@ -54,8 +60,9 @@
|
|||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<cucumber.version>6.8.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.0</junit-vintage-engine.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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<String> statusResponse;
|
||||
|
||||
private ResponseEntity<String> 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));
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
cucumber.filter.tags=not @v2
|
Loading…
Reference in New Issue