This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new afedf71  CAMEL-17587: camel-health - Make Health Check API simpler
afedf71 is described below

commit afedf718376fa0bc3fe090323aab2fbc84dbf846
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Wed Feb 9 11:32:47 2022 +0100

    CAMEL-17587: camel-health - Make Health Check API simpler
---
 .../springboot/catalog/components/aws2-ses.json    |  4 ++
 .../src/main/docs/aws2-ses.json                    | 12 ++++
 .../ses/springboot/Ses2ComponentConfiguration.java | 26 ++++++++
 .../src/main/docs/spring-boot.json                 | 39 +++--------
 .../health/CamelHealthCheckAutoConfiguration.java  | 47 ++++---------
 .../CamelHealthCheckConfigurationProperties.java   | 69 ++++---------------
 .../health/CamelHealthCheckConfigurationTest.java  | 78 ----------------------
 7 files changed, 80 insertions(+), 195 deletions(-)

diff --git 
a/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/aws2-ses.json
 
b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/aws2-ses.json
index 627be91..a5a1cab 100644
--- 
a/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/aws2-ses.json
+++ 
b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/aws2-ses.json
@@ -23,6 +23,8 @@
   },
   "componentProperties": {
     "amazonSESClient": { "kind": "property", "displayName": "Amazon 
SESClient", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": "software.amazon.awssdk.services.ses.SesClient", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", 
"configurationField": "configuration", "description": "To use the 
AmazonSimpleEmailService as the client" },
+    "bcc": { "kind": "property", "displayName": "Bcc", "group": "producer", 
"label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", 
"configurationField": "configuration", "description": "List of comma separated 
destination blind carbon copy (bcc) email address. Can be overriden with 
'CamelAwsSesBcc' header." },
+    "cc": { "kind": "property", "displayName": "Cc", "group": "producer", 
"label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", 
"configurationField": "configuration", "description": "List of comma separated 
destination carbon copy (cc) email address. Can be overriden with 
'CamelAwsSesCc' header." },
     "configuration": { "kind": "property", "displayName": "Configuration", 
"group": "producer", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.aws2.ses.Ses2Configuration", 
"deprecated": false, "autowired": false, "secret": false, "description": 
"component configuration" },
     "configurationSet": { "kind": "property", "displayName": "Configuration 
Set", "group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": 
"configuration", "description": "Set the configuration set to send with every 
request. Override it with 'CamelAwsSesConfigurationSet' header." },
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start 
Producer", "group": "producer", "label": "producer", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "Whether the producer 
should be started lazy (on the first message). By starting lazy you can use 
this to allow CamelContext and routes to startup in situations where a producer 
may otherwise fail during star [...]
@@ -45,6 +47,8 @@
   "properties": {
     "from": { "kind": "path", "displayName": "From", "group": "producer", 
"label": "", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": 
"configuration", "description": "The sender's email address." },
     "amazonSESClient": { "kind": "parameter", "displayName": "Amazon 
SESClient", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": "software.amazon.awssdk.services.ses.SesClient", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", 
"configurationField": "configuration", "description": "To use the 
AmazonSimpleEmailService as the client" },
+    "bcc": { "kind": "parameter", "displayName": "Bcc", "group": "producer", 
"label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", 
"configurationField": "configuration", "description": "List of comma separated 
destination blind carbon copy (bcc) email address. Can be overriden with 
'CamelAwsSesBcc' header." },
+    "cc": { "kind": "parameter", "displayName": "Cc", "group": "producer", 
"label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", 
"configurationField": "configuration", "description": "List of comma separated 
destination carbon copy (cc) email address. Can be overriden with 
'CamelAwsSesCc' header." },
     "configurationSet": { "kind": "parameter", "displayName": "Configuration 
Set", "group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": 
"configuration", "description": "Set the configuration set to send with every 
request. Override it with 'CamelAwsSesConfigurationSet' header." },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start 
Producer", "group": "producer", "label": "producer", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "Whether the producer 
should be started lazy (on the first message). By starting lazy you can use 
this to allow CamelContext and routes to startup in situations where a producer 
may otherwise fail during sta [...]
     "overrideEndpoint": { "kind": "parameter", "displayName": "Override 
Endpoint", "group": "producer", "label": "", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "configurationClass": 
"org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": 
"configuration", "description": "Set the need for overidding the endpoint. This 
option needs to be used in combination with uriEndpo [...]
diff --git 
a/components-starter/camel-aws2-ses-starter/src/main/docs/aws2-ses.json 
b/components-starter/camel-aws2-ses-starter/src/main/docs/aws2-ses.json
index df77c81..b7b7998 100644
--- a/components-starter/camel-aws2-ses-starter/src/main/docs/aws2-ses.json
+++ b/components-starter/camel-aws2-ses-starter/src/main/docs/aws2-ses.json
@@ -33,6 +33,18 @@
       "defaultValue": true
     },
     {
+      "name": "camel.component.aws2-ses.bcc",
+      "type": "java.lang.String",
+      "description": "List of comma separated destination blind carbon copy 
(bcc) email address. Can be overriden with 'CamelAwsSesBcc' header.",
+      "sourceType": 
"org.apache.camel.component.aws2.ses.springboot.Ses2ComponentConfiguration"
+    },
+    {
+      "name": "camel.component.aws2-ses.cc",
+      "type": "java.lang.String",
+      "description": "List of comma separated destination carbon copy (cc) 
email address. Can be overriden with 'CamelAwsSesCc' header.",
+      "sourceType": 
"org.apache.camel.component.aws2.ses.springboot.Ses2ComponentConfiguration"
+    },
+    {
       "name": "camel.component.aws2-ses.configuration",
       "type": "org.apache.camel.component.aws2.ses.Ses2Configuration",
       "description": "component configuration. The option is a 
org.apache.camel.component.aws2.ses.Ses2Configuration type.",
diff --git 
a/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentConfiguration.java
 
b/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentConfiguration.java
index f5a9ffe..131d8d7 100644
--- 
a/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentConfiguration.java
+++ 
b/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentConfiguration.java
@@ -46,6 +46,16 @@ public class Ses2ComponentConfiguration
      */
     private SesClient amazonSESClient;
     /**
+     * List of comma separated destination blind carbon copy (bcc) email
+     * address. Can be overriden with 'CamelAwsSesBcc' header.
+     */
+    private String bcc;
+    /**
+     * List of comma separated destination carbon copy (cc) email address. Can
+     * be overriden with 'CamelAwsSesCc' header.
+     */
+    private String cc;
+    /**
      * component configuration. The option is a
      * org.apache.camel.component.aws2.ses.Ses2Configuration type.
      */
@@ -150,6 +160,22 @@ public class Ses2ComponentConfiguration
         this.amazonSESClient = amazonSESClient;
     }
 
+    public String getBcc() {
+        return bcc;
+    }
+
+    public void setBcc(String bcc) {
+        this.bcc = bcc;
+    }
+
+    public String getCc() {
+        return cc;
+    }
+
+    public void setCc(String cc) {
+        this.cc = cc;
+    }
+
     public Ses2Configuration getConfiguration() {
         return configuration;
     }
diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json 
b/core/camel-spring-boot/src/main/docs/spring-boot.json
index 7409d1e..cb4b964 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -79,11 +79,6 @@
       "sourceType": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
     },
     {
-      "name": "camel.health.config",
-      "type": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties$HealthCheckConfigurationProperties",
-      "sourceType": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties$HealthCheckConfigurationProperties"
-    },
-    {
       "name": "camel.language",
       "type": "org.apache.camel.spring.boot.LanguageConfigurationProperties",
       "sourceType": 
"org.apache.camel.spring.boot.LanguageConfigurationProperties"
@@ -395,51 +390,39 @@
       "defaultValue": true
     },
     {
-      "name": "camel.health.config",
-      "type": 
"java.util.Map<java.lang.String,org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties$HealthCheckConfigurationProperties>",
-      "description": "Additional health check properties for fine-grained 
configuration of health checks.",
-      "sourceType": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
-    },
-    {
-      "name": "camel.health.config.enabled",
-      "type": "java.lang.Boolean",
-      "description": "Set if the check associated to this configuration is 
enabled or not. Is default enabled.",
-      "sourceType": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties$HealthCheckConfigurationProperties"
-    },
-    {
-      "name": "camel.health.config.parent",
-      "type": "java.lang.String",
-      "description": "The id of the health check such as routes or registry 
(can use * as wildcard)",
-      "sourceType": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties$HealthCheckConfigurationProperties"
-    },
-    {
       "name": "camel.health.consumers-enabled",
       "type": "java.lang.Boolean",
-      "description": "Whether consumers health check is enabled. Is default 
enabled",
+      "description": "Whether consumers health check is enabled. <p> Is 
default enabled",
       "sourceType": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
     },
     {
       "name": "camel.health.context-enabled",
       "type": "java.lang.Boolean",
-      "description": "Whether context health check is enabled. Is default 
enabled",
+      "description": "Whether context health check is enabled. <p> Is default 
enabled",
       "sourceType": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
     },
     {
       "name": "camel.health.enabled",
       "type": "java.lang.Boolean",
-      "description": "Whether health check is enabled globally. Is default 
enabled",
+      "description": "Whether health check is enabled globally. <p> Is default 
enabled",
+      "sourceType": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
+    },
+    {
+      "name": "camel.health.exclude-pattern",
+      "type": "java.lang.String",
+      "description": "Pattern to exclude health checks from being invoked by 
Camel when checking healths. Multiple patterns can be separated by comma.",
       "sourceType": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
     },
     {
       "name": "camel.health.registry-enabled",
       "type": "java.lang.Boolean",
-      "description": "Whether registry health check is enabled. Is default 
enabled",
+      "description": "Whether registry health check is enabled. <p> Is default 
enabled",
       "sourceType": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
     },
     {
       "name": "camel.health.routes-enabled",
       "type": "java.lang.Boolean",
-      "description": "Whether routes health check is enabled. Is default 
enabled",
+      "description": "Whether routes health check is enabled. <p> Is default 
enabled",
       "sourceType": 
"org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
     },
     {
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckAutoConfiguration.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckAutoConfiguration.java
index 9edac6d..0966197 100644
--- 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckAutoConfiguration.java
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckAutoConfiguration.java
@@ -66,19 +66,25 @@ public class CamelHealthCheckAutoConfiguration {
             // lets signal we are integrated with spring boot
             hcr.setId("camel-spring-boot");
 
-            // configure camel health check
+            if (config.getEnabled() != null) {
+                hcr.setEnabled(config.getEnabled());
+            }
+            if (config.getExcludePattern() != null) {
+                hcr.setExcludePattern(config.getExcludePattern());
+            }
+
             // context is enabled by default
-            if (!config.getConfig().containsKey("context") || 
config.getContextEnabled() != null) {
+            if (hcr.isEnabled()) {
                 HealthCheck hc = (HealthCheck) hcr.resolveById("context");
                 if (hc != null) {
                     if (config.getContextEnabled() != null) {
-                        
hc.getConfiguration().setEnabled(config.getContextEnabled());
+                        hc.setEnabled(config.getContextEnabled());
                     }
                     hcr.register(hc);
                 }
             }
             // routes are enabled by default
-            if (hcr.isEnabled() && (!config.getConfig().containsKey("routes") 
|| config.getRoutesEnabled() != null)) {
+            if (hcr.isEnabled()) {
                 HealthCheckRepository hc = 
hcr.getRepository("routes").orElse((HealthCheckRepository) 
hcr.resolveById("routes"));
                 if (hc != null) {
                     if (config.getRoutesEnabled() != null) {
@@ -88,8 +94,9 @@ public class CamelHealthCheckAutoConfiguration {
                 }
             }
             // consumers are enabled by default
-            if (hcr.isEnabled() && 
(!config.getConfig().containsKey("consumers") || config.getConsumersEnabled() 
!= null)) {
-                HealthCheckRepository hc = 
hcr.getRepository("consumers").orElse((HealthCheckRepository) 
hcr.resolveById("consumers"));
+            if (hcr.isEnabled()) {
+                HealthCheckRepository hc
+                        = 
hcr.getRepository("consumers").orElse((HealthCheckRepository) 
hcr.resolveById("consumers"));
                 if (hc != null) {
                     if (config.getConsumersEnabled() != null) {
                         hc.setEnabled(config.getConsumersEnabled());
@@ -98,7 +105,7 @@ public class CamelHealthCheckAutoConfiguration {
                 }
             }
             // registry are enabled by default
-            if (hcr.isEnabled() && 
(!config.getConfig().containsKey("registry") || config.getRegistryEnabled() != 
null)) {
+            if (hcr.isEnabled()) {
                 HealthCheckRepository hc
                         = 
hcr.getRepository("registry").orElse((HealthCheckRepository) 
hcr.resolveById("registry"));
                 if (hc != null) {
@@ -109,32 +116,6 @@ public class CamelHealthCheckAutoConfiguration {
                 }
             }
 
-            // configure health checks configurations
-            for (String id : config.getConfig().keySet()) {
-                
CamelHealthCheckConfigurationProperties.HealthCheckConfigurationProperties hcc 
= config.getConfig().get(id);
-                String parent = hcc.getParent();
-                if (parent == null) {
-                    throw new IllegalArgumentException("HealthCheck with id: " 
+ id + " must have parent configured");
-                }
-                // lookup health check by id
-                Object hc = hcr.getCheck(id).orElse(null);
-                if (hc == null) {
-                    hc = hcr.resolveById(parent);
-                    if (hc == null) {
-                        LOG.warn("Cannot resolve HealthCheck with id: " + 
parent + " from classpath.");
-                        continue;
-                    }
-                    hcr.register(hc);
-                }
-
-                if (hc instanceof HealthCheck) {
-                    ((HealthCheck) 
hc).getConfiguration().setParent(hcc.getParent());
-                    ((HealthCheck) 
hc).getConfiguration().setEnabled(hcc.getEnabled() != null ? hcc.getEnabled() : 
true);
-                } else if (hc instanceof HealthCheckRepository) {
-                    ((HealthCheckRepository) hc).addConfiguration(id, 
hcc.toHealthCheckConfiguration());
-                }
-            }
-
             return new CamelHealthCheckIndicator(camelContext);
         }
     }
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckConfigurationProperties.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckConfigurationProperties.java
index 5ab08b8..8a3d604 100644
--- 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckConfigurationProperties.java
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckConfigurationProperties.java
@@ -16,10 +16,6 @@
  */
 package org.apache.camel.spring.boot.actuate.health;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.camel.health.HealthCheckConfiguration;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
 @ConfigurationProperties(prefix = "camel.health")
@@ -27,43 +23,44 @@ public class CamelHealthCheckConfigurationProperties {
 
     /**
      * Whether health check is enabled globally.
-     *
+     * <p>
      * Is default enabled
      */
     private Boolean enabled;
 
     /**
      * Whether context health check is enabled.
-     *
+     * <p>
      * Is default enabled
      */
     private Boolean contextEnabled;
 
     /**
      * Whether routes health check is enabled.
-     *
+     * <p>
      * Is default enabled
      */
     private Boolean routesEnabled;
 
     /**
      * Whether consumers health check is enabled.
-     *
+     * <p>
      * Is default enabled
      */
     private Boolean consumersEnabled;
 
     /**
      * Whether registry health check is enabled.
-     *
+     * <p>
      * Is default enabled
      */
     private Boolean registryEnabled;
 
     /**
-     * Additional health check properties for fine-grained configuration of 
health checks.
+     * Pattern to exclude health checks from being invoked by Camel when 
checking healths. Multiple patterns can be
+     * separated by comma.
      */
-    private Map<String, HealthCheckConfigurationProperties> config = new 
HashMap<>();
+    private String excludePattern;
 
     public Boolean getEnabled() {
         return enabled;
@@ -105,54 +102,14 @@ public class CamelHealthCheckConfigurationProperties {
         this.registryEnabled = registryEnabled;
     }
 
-    public Map<String, HealthCheckConfigurationProperties> getConfig() {
-        return config;
-    }
-
-    public void setConfig(Map<String, HealthCheckConfigurationProperties> 
config) {
-        this.config = config;
+    public String getExcludePattern() {
+        return excludePattern;
     }
 
-    @ConfigurationProperties(prefix = "camel.health.config")
-    public static class HealthCheckConfigurationProperties {
-
-        /**
-         * The id of the health check such as routes or registry (can use * as 
wildcard)
-         */
-        private String parent;
-
-        /**
-         * Set if the check associated to this configuration is enabled or not.
-         *
-         * Is default enabled.
-         */
-        private Boolean enabled;
-
-        public String getParent() {
-            return parent;
-        }
-
-        public void setParent(String parent) {
-            this.parent = parent;
-        }
-
-        public Boolean getEnabled() {
-            return enabled;
-        }
-
-        public void setEnabled(Boolean enabled) {
-            this.enabled = enabled;
-        }
-
-        public HealthCheckConfiguration toHealthCheckConfiguration() {
-            HealthCheckConfiguration answer = new HealthCheckConfiguration();
-            answer.setParent(parent);
-            if (enabled != null) {
-                answer.setEnabled(enabled);
-            }
-            return answer;
-        }
+    public void setExcludePattern(String excludePattern) {
+        this.excludePattern = excludePattern;
     }
 }
 
 
+
diff --git 
a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckConfigurationTest.java
 
b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckConfigurationTest.java
deleted file mode 100644
index c3b475f..0000000
--- 
a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckConfigurationTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.boot.actuate.health;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.health.HealthCheckRegistry;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.actuate.health.Health;
-import org.springframework.boot.actuate.health.Status;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.annotation.DirtiesContext;
-
-@CamelSpringBootTest
-@EnableAutoConfiguration
-@SpringBootApplication
-@DirtiesContext
-@SpringBootTest(
-    classes = {CamelAutoConfiguration.class, 
CamelHealthCheckAutoConfiguration.class, DownRoute.class, MyCamelRoute.class},
-    properties = 
{"camel.health.config[consumer\\:down-route].parent=consumers",
-                  "camel.health.config[consumer\\:down-route].enabled=false"})
-class CamelHealthCheckConfigurationTest {
-
-    @Autowired
-    CamelHealthCheckIndicator indicator;
-
-    @Autowired
-    CamelContext camelContext;
-
-    @Test
-    void shouldBeHealth() throws Exception {
-        // 'down-route' is DOWN, but health check for this consumer should be 
disabled by configuration
-        final Health health = indicator.health();
-        assertThat(health)
-            .as("Has health")
-            .isNotNull()
-            .as("Should be UP")
-            .matches(h -> h.getStatus() == Status.UP);
-    }
-
-    @Test
-    void shouldNotDisableAllConsumersHealthChecks() {
-        @SuppressWarnings("resource")
-        final HealthCheckRegistry registry = 
camelContext.getExtension(HealthCheckRegistry.class);
-
-        assertThat(registry.getCheck("consumer:down-route"))
-            .as("'down-route' health check is disabled")
-            .isPresent()
-            .get()
-            .matches(hc -> !hc.getConfiguration().isEnabled());
-
-        assertThat(registry.getCheck("consumer:foo-route"))
-            .as("other route health check is enabled")
-            .isPresent()
-            .get()
-            .matches(hc -> hc.getConfiguration().isEnabled());
-    }
-}

Reply via email to