mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
fixes #873, add content type to /health
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user