This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit dfef6cedd06d7cd1f1b4083a49f6bf31723461d4 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Jun 3 10:57:48 2020 +0200 CAMEL-15139: camel-health - Add API for readiness/liveness --- .../microprofile/health/AbstractCamelMicroProfileHealthCheck.java | 8 +++----- .../microprofile/health/CamelMicroProfileHealthCheckTest.java | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/components/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/AbstractCamelMicroProfileHealthCheck.java b/components/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/AbstractCamelMicroProfileHealthCheck.java index 0c3affd..bddb3e6 100644 --- a/components/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/AbstractCamelMicroProfileHealthCheck.java +++ b/components/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/AbstractCamelMicroProfileHealthCheck.java @@ -44,19 +44,17 @@ public abstract class AbstractCamelMicroProfileHealthCheck implements HealthChec public HealthCheckResponse call() { final HealthCheckResponseBuilder builder = HealthCheckResponse.builder(); builder.name(getHealthCheckName()); + builder.up(); if (camelContext != null) { Collection<Result> results = HealthCheckHelper.invoke(camelContext, (HealthCheckFilter) check -> // skip context as we have our own context check check.getId().equals("context") - // or that its either supposed to be only a livness or readness and the Camel health check is not + // or that its either supposed to be only a liveness or readiness and the Camel health check is not || (isLiveness() && !check.isLiveness() || isReadiness() && !check.isReadiness())); - if (!results.isEmpty()) { - builder.up(); - } - for (Result result: results) { + for (Result result : results) { Map<String, Object> details = result.getDetails(); boolean enabled = true; diff --git a/components/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java b/components/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java index c40f342..8781344 100644 --- a/components/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java +++ b/components/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java @@ -216,16 +216,16 @@ public class CamelMicroProfileHealthCheckTest extends CamelMicroProfileHealthTes SmallRyeHealth health = reporter.getHealth(); JsonObject healthObject = getHealthJson(health); - assertEquals(State.DOWN.name(), healthObject.getString("status")); + assertEquals(State.UP.name(), healthObject.getString("status")); JsonArray checks = healthObject.getJsonArray("checks"); assertEquals(2, checks.size()); - assertHealthCheckOutput("camel-readiness-checks", State.DOWN, checks.getJsonObject(0), jsonObject -> { + assertHealthCheckOutput("camel-readiness-checks", State.UP, checks.getJsonObject(0), jsonObject -> { assertNull(jsonObject); }); - assertHealthCheckOutput("camel-liveness-checks", State.DOWN, checks.getJsonObject(1), jsonObject -> { + assertHealthCheckOutput("camel-liveness-checks", State.UP, checks.getJsonObject(1), jsonObject -> { assertNull(jsonObject); }); }