fixes #873, add content type to /health

This commit is contained in:
Michal Szynkiewicz
2019-02-15 09:45:35 +01:00
parent 80de0ed921
commit f5fadc88ac
3 changed files with 7 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ All submissions, including submissions by project members, need to be reviewed b
### Continuous Integration
Because we are all humans, the project use a continuous integration approach and each pull request triggers a full build.
Because we are all humans, the project uses a continuous integration approach and each pull request triggers a full build.
Please make sure to monitor the output of the build and act accordingly.
### Tests and documentation are not optional

View File

@@ -43,6 +43,8 @@ public class SmallRyeHealthServlet extends HttpServlet {
if (health.isDown()) {
resp.setStatus(503);
}
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8");
reporter.reportHealth(resp.getOutputStream(), health);
}
}

View File

@@ -19,21 +19,22 @@ package org.jboss.shamrock.example.test;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.is;
import io.restassured.http.ContentType;
import org.hamcrest.Matchers;
import org.jboss.shamrock.test.junit.ShamrockTest;
import org.junit.jupiter.api.Test;
import io.restassured.RestAssured;
import io.restassured.parsing.Parser;
@ShamrockTest
public class HealthTestCase {
@Test
public void testHealthCheck() {
// the health check does not set a content type so we need to force the parser
try {
RestAssured.defaultParser = Parser.JSON;
RestAssured.when().get("/health").then()
.contentType(ContentType.JSON)
.header("Content-Type", Matchers.containsString("charset=UTF-8"))
.body("outcome", is("UP"),
"checks.state", contains("UP"),
"checks.name", contains("basic"));