[
https://issues.apache.org/jira/browse/CAMEL-12113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16309517#comment-16309517
]
ASF GitHub Bot commented on CAMEL-12113:
----------------------------------------
davsclaus closed pull request #2161: CAMEL-12113: Camel healthcheck spring-boot
actuators don't honor endp…
URL: https://github.com/apache/camel/pull/2161
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelHealthCheckEndpointAutoConfiguration.java
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelHealthCheckEndpointAutoConfiguration.java
index 72b856911b0..a005cf27fc8 100644
---
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelHealthCheckEndpointAutoConfiguration.java
+++
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelHealthCheckEndpointAutoConfiguration.java
@@ -18,12 +18,14 @@
import org.apache.camel.CamelContext;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.util.GroupCondition;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
/**
@@ -33,6 +35,7 @@
@ConditionalOnClass(CamelHealthCheckEndpoint.class)
@ConditionalOnBean(CamelAutoConfiguration.class)
@AutoConfigureAfter(CamelAutoConfiguration.class)
+@Conditional(CamelHealthCheckEndpointAutoConfiguration.Condition.class)
public class CamelHealthCheckEndpointAutoConfiguration {
@Bean
@ConditionalOnBean(CamelContext.class)
@@ -48,4 +51,17 @@ public CamelHealthCheckEndpoint
healthChecksEndpoint(CamelContext camelContext)
public CamelHealthCheckMvcEndpoint
healthChecksMvcEndpoint(CamelHealthCheckEndpoint delegate) {
return new CamelHealthCheckMvcEndpoint(delegate);
}
+
+ // ***************************************
+ // Condition
+ // ***************************************
+
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super(
+ "endpoints",
+ "endpoints." + CamelHealthCheckEndpoint.ENDPOINT_ID
+ );
+ }
+ }
}
diff --git
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointAutoConfiguration.java
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointAutoConfiguration.java
index ca75ed4b908..44d5f1ea68a 100644
---
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointAutoConfiguration.java
+++
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointAutoConfiguration.java
@@ -18,12 +18,14 @@
import org.apache.camel.CamelContext;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.util.GroupCondition;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
/**
@@ -33,6 +35,7 @@
@ConditionalOnClass({CamelRouteControllerEndpoint.class})
@ConditionalOnBean(CamelAutoConfiguration.class)
@AutoConfigureAfter(CamelAutoConfiguration.class)
+@Conditional(CamelRouteControllerEndpointAutoConfiguration.Condition.class)
public class CamelRouteControllerEndpointAutoConfiguration {
@Bean
@ConditionalOnClass(CamelContext.class)
@@ -48,4 +51,17 @@ public CamelRouteControllerEndpoint
routeControllerEndpoint(CamelContext camelCo
public CamelRouteControllerMvcEndpoint
routeControllerMvcEndpoint(CamelRouteControllerEndpoint delegate) {
return new CamelRouteControllerMvcEndpoint(delegate);
}
+
+ // ***************************************
+ // Condition
+ // ***************************************
+
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super(
+ "endpoints",
+ "endpoints." + CamelRouteControllerEndpoint.ENDPOINT_ID
+ );
+ }
+ }
}
diff --git
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java
index fdf49f08624..85070dd4253 100644
---
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java
+++
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointAutoConfiguration.java
@@ -18,12 +18,14 @@
import org.apache.camel.CamelContext;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.util.GroupCondition;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
/**
@@ -33,6 +35,7 @@
@ConditionalOnClass({CamelRoutesEndpoint.class})
@ConditionalOnBean(CamelAutoConfiguration.class)
@AutoConfigureAfter(CamelAutoConfiguration.class)
+@Conditional(CamelRoutesEndpointAutoConfiguration.Condition.class)
public class CamelRoutesEndpointAutoConfiguration {
@Bean
@ConditionalOnClass(CamelContext.class)
@@ -48,4 +51,17 @@ public CamelRoutesEndpoint camelEndpoint(CamelContext
camelContext) {
public CamelRoutesMvcEndpoint camelMvcEndpoint(CamelRoutesEndpoint
delegate) {
return new CamelRoutesMvcEndpoint(delegate);
}
+
+ // ***************************************
+ // Condition
+ // ***************************************
+
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super(
+ "endpoints",
+ "endpoints." + CamelRoutesEndpoint.ENDPOINT_ID
+ );
+ }
+ }
}
diff --git
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/ActuatorTestRoute.java
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/ActuatorTestRoute.java
index 599f94037b9..96b4c0a9858 100644
---
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/ActuatorTestRoute.java
+++
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/ActuatorTestRoute.java
@@ -16,7 +16,9 @@
*/
package org.apache.camel.spring.boot.actuate.endpoint;
+import org.apache.camel.Route;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.SupervisingRouteController;
import org.springframework.stereotype.Component;
@Component
@@ -24,6 +26,8 @@
@Override
public void configure() throws Exception {
+// SupervisingRouteController src = new SupervisingRouteController();
+// src.addFilter(route -> new
SupervisingRouteController.FilterResult(true, "Catch all Filter"));
from("timer:foo").routeId("foo-route").to("log:foo");
}
diff --git
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelEndpointsGloballyDisabledTest.java
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelEndpointsGloballyDisabledTest.java
new file mode 100644
index 00000000000..430fcabc981
--- /dev/null
+++
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelEndpointsGloballyDisabledTest.java
@@ -0,0 +1,64 @@
+/**
+ * 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.endpoint;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@DirtiesContext
+@RunWith(SpringRunner.class)
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ CamelHealthCheckEndpointAutoConfiguration.class
+ },
+ properties = {
+ "endpoints.enabled = false"
+ }
+)
+public class CamelEndpointsGloballyDisabledTest {
+ @Autowired(required = false)
+ private CamelHealthCheckEndpoint healthCheckEndpoint;
+
+ @Autowired(required = false)
+ private CamelRouteControllerEndpoint routeControllerEndpoint;
+
+ @Autowired(required = false)
+ private CamelRouteControllerMvcEndpoint routeControllerMvcEndpoint;
+
+ @Autowired(required = false)
+ private CamelRoutesEndpoint routesEndpoint;
+
+ @Autowired(required = false)
+ private CamelRoutesMvcEndpoint routesMvcEndpoint;
+
+ @Test
+ public void testHealthCheckEndpointNotPresent() throws Exception {
+ Assert.assertNull(healthCheckEndpoint);
+ Assert.assertNull(routeControllerEndpoint);
+ Assert.assertNull(routeControllerMvcEndpoint);
+ Assert.assertNull(routesEndpoint);
+ Assert.assertNull(routesMvcEndpoint);
+ }
+}
diff --git
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelHealthCheckEndpointDisabledTest.java
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelHealthCheckEndpointDisabledTest.java
new file mode 100644
index 00000000000..39b397aeb12
--- /dev/null
+++
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelHealthCheckEndpointDisabledTest.java
@@ -0,0 +1,48 @@
+/**
+ * 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.endpoint;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@DirtiesContext
+@RunWith(SpringRunner.class)
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ CamelHealthCheckEndpointAutoConfiguration.class
+ },
+ properties = {
+ "endpoints.camelhealthcheck.enabled = false"
+ }
+)
+public class CamelHealthCheckEndpointDisabledTest {
+ @Autowired(required = false)
+ private CamelHealthCheckEndpoint endpoint;
+
+ @Test
+ public void testHealthCheckEndpointNotPresent() throws Exception {
+ Assert.assertNull(endpoint);
+ }
+}
diff --git
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelHealthCheckEndpointGloballyDisabledAndReenabledTest.java
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelHealthCheckEndpointGloballyDisabledAndReenabledTest.java
new file mode 100644
index 00000000000..506e9d17412
--- /dev/null
+++
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelHealthCheckEndpointGloballyDisabledAndReenabledTest.java
@@ -0,0 +1,49 @@
+/**
+ * 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.endpoint;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@DirtiesContext
+@RunWith(SpringRunner.class)
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ CamelHealthCheckEndpointAutoConfiguration.class
+ },
+ properties = {
+ "endpoints.enabled = false",
+ "endpoints.camelhealthcheck.enabled = true"
+ }
+)
+public class CamelHealthCheckEndpointGloballyDisabledAndReenabledTest {
+ @Autowired
+ private CamelHealthCheckEndpoint endpoint;
+
+ @Test
+ public void testHealthCheckEndpointPresent() throws Exception {
+ Assert.assertNotNull(endpoint);
+ }
+}
diff --git
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointDisabledTest.java
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointDisabledTest.java
new file mode 100644
index 00000000000..75ccc33fa05
--- /dev/null
+++
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointDisabledTest.java
@@ -0,0 +1,59 @@
+/**
+ * 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.endpoint;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * Test for the {@link CamelRoutesEndpoint} actuator endpoint.
+ */
+@DirtiesContext
+@RunWith(SpringRunner.class)
+@EnableAutoConfiguration
+@SpringBootApplication
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
CamelRoutesEndpointAutoConfiguration.class, ActuatorTestRoute.class},
+ properties = {
+ "endpoints.camelroutecontroller.enabled = false"
+ })
+public class CamelRouteControllerEndpointDisabledTest extends Assert {
+
+ @Autowired(required = false)
+ CamelRouteControllerEndpoint routeControllerEndpoint;
+
+ @Autowired(required = false)
+ CamelRouteControllerMvcEndpoint routeControllerMvcEndpoint;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Test
+ public void testRoutesEndpointNotPresent() throws Exception {
+ Assert.assertNull(routeControllerEndpoint);
+ Assert.assertNull(routeControllerMvcEndpoint);
+ }
+
+}
diff --git
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointGloballyDisabledAndReenabledTest.java
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointGloballyDisabledAndReenabledTest.java
new file mode 100644
index 00000000000..ff00296f660
--- /dev/null
+++
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointGloballyDisabledAndReenabledTest.java
@@ -0,0 +1,60 @@
+/**
+ * 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.endpoint;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * Test for the {@link CamelRoutesEndpoint} actuator endpoint.
+ */
+@DirtiesContext
+@RunWith(SpringRunner.class)
+@EnableAutoConfiguration
+@SpringBootApplication
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
CamelRoutesEndpointAutoConfiguration.class, ActuatorTestRoute.class},
+ properties = {
+ "endpoints.enabled = false",
+ "endpoints.camelroutecontroller.enabled = true"
+ })
+public class CamelRouteControllerEndpointGloballyDisabledAndReenabledTest
extends Assert {
+
+ @Autowired
+ CamelRouteControllerEndpoint routeControllerEndpoint;
+
+ @Autowired
+ CamelRouteControllerMvcEndpoint routeControllerMvcEndpoint;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Test
+ public void testRoutesEndpointPresent() throws Exception {
+ Assert.assertNotNull(routeControllerEndpoint);
+ Assert.assertNotNull(routeControllerMvcEndpoint);
+ }
+
+}
diff --git
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointTest.java
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointTest.java
new file mode 100644
index 00000000000..67eb14e35db
--- /dev/null
+++
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointTest.java
@@ -0,0 +1,62 @@
+/**
+ * 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.endpoint;
+
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+import org.springframework.test.context.junit4.SpringRunner;
+
+
+/**
+ * Test for the {@link CamelRouteControllerEndpoint} actuator endpoint.
+ */
+@DirtiesContext
+@RunWith(SpringRunner.class)
+@EnableAutoConfiguration
+@SpringBootApplication
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
CamelRouteControllerEndpointAutoConfiguration.class, ActuatorTestRoute.class},
+ properties = {
+ "camel.supervising.controller.enabled = true"
+ })
+public class CamelRouteControllerEndpointTest extends Assert {
+
+ @Autowired
+ CamelRouteControllerEndpoint endpoint;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Test
+ public void testRouteControllerEndpoint() throws Exception {
+ List<String> routesId = endpoint.invoke();
+
+ assertFalse(routesId.isEmpty());
+ assertEquals(routesId.size(), camelContext.getRoutes().size());
+ assertTrue(routesId.stream().anyMatch(r -> "foo-route".equals(r)));
+ }
+
+}
diff --git
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerMvcEndpointTest.java
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerMvcEndpointTest.java
new file mode 100644
index 00000000000..25f839ce90a
--- /dev/null
+++
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerMvcEndpointTest.java
@@ -0,0 +1,65 @@
+/**
+ * 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.endpoint;
+
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.model.RouteDetailsInfo;
+import org.apache.camel.spring.boot.model.RouteInfo;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+import org.springframework.test.context.junit4.SpringRunner;
+
+
+/**
+ * Test for the {@link CamelRouteControllerMvcEndpoint} actuator endpoint.
+ */
+@DirtiesContext
+@RunWith(SpringRunner.class)
+@EnableAutoConfiguration
+@SpringBootApplication
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
CamelRouteControllerEndpointAutoConfiguration.class, ActuatorTestRoute.class},
+ properties = {
+ "camel.supervising.controller.enabled = true"
+ })
+public class CamelRouteControllerMvcEndpointTest extends Assert {
+
+ @Autowired
+ CamelRouteControllerMvcEndpoint endpoint;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Test
+ public void testRouteControllerEndpoint() throws Exception {
+ List<String> routesId = (List<String>)endpoint.invoke();
+
+ assertFalse(routesId.isEmpty());
+ assertEquals(routesId.size(), camelContext.getRoutes().size());
+ assertTrue(routesId.stream().anyMatch(r -> "foo-route".equals(r)));
+ }
+
+
+}
diff --git
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointDisabledTest.java
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointDisabledTest.java
new file mode 100644
index 00000000000..681baa5859c
--- /dev/null
+++
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointDisabledTest.java
@@ -0,0 +1,63 @@
+/**
+ * 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.endpoint;
+
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.model.RouteInfo;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+import org.springframework.test.context.junit4.SpringRunner;
+
+
+/**
+ * Test for the {@link CamelRoutesEndpoint} actuator endpoint.
+ */
+@DirtiesContext
+@RunWith(SpringRunner.class)
+@EnableAutoConfiguration
+@SpringBootApplication
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
CamelRoutesEndpointAutoConfiguration.class, ActuatorTestRoute.class},
+ properties = {
+ "endpoints.camelroutes.enabled = false"
+ })
+public class CamelRoutesEndpointDisabledTest extends Assert {
+
+ @Autowired(required = false)
+ CamelRoutesEndpoint routesEndpoint;
+
+ @Autowired(required = false)
+ CamelRoutesMvcEndpoint routesMvcEndpoint;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Test
+ public void testRoutesEndpointNotPresent() throws Exception {
+ Assert.assertNull(routesEndpoint);
+ Assert.assertNull(routesMvcEndpoint);
+ }
+
+}
diff --git
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointGloballyDisabledAndReenabledTest.java
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointGloballyDisabledAndReenabledTest.java
new file mode 100644
index 00000000000..c0f8537a536
--- /dev/null
+++
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointGloballyDisabledAndReenabledTest.java
@@ -0,0 +1,60 @@
+/**
+ * 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.endpoint;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * Test for the {@link CamelRoutesEndpoint} actuator endpoint.
+ */
+@DirtiesContext
+@RunWith(SpringRunner.class)
+@EnableAutoConfiguration
+@SpringBootApplication
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
CamelRoutesEndpointAutoConfiguration.class, ActuatorTestRoute.class},
+ properties = {
+ "endpoints.enabled = false",
+ "endpoints.camelroutes.enabled = true"
+ })
+public class CamelRoutesEndpointGloballyDisabledAndReenabledTest extends
Assert {
+
+ @Autowired
+ CamelRoutesEndpoint routesEndpoint;
+
+ @Autowired
+ CamelRoutesMvcEndpoint routesMvcEndpoint;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Test
+ public void testRoutesEndpointPresent() throws Exception {
+ Assert.assertNotNull(routesEndpoint);
+ Assert.assertNotNull(routesMvcEndpoint);
+ }
+
+}
diff --git
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/health/CamelHealthDisabledTest.java
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/health/CamelHealthDisabledTest.java
new file mode 100644
index 00000000000..649fb652603
--- /dev/null
+++
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/health/CamelHealthDisabledTest.java
@@ -0,0 +1,49 @@
+/**
+ * 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 org.apache.camel.CamelContext;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@EnableAutoConfiguration
+@SpringBootApplication
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
CamelHealthAutoConfiguration.class, MyCamelRoute.class},
+ properties = {
+ "camel.health.enabled = false"
+ })
+public class CamelHealthDisabledTest extends Assert {
+ @Autowired(required = false)
+ CamelHealthIndicator indicator;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Test
+ public void shouldNotHaveHealth() throws Exception {
+ assertNull(indicator);
+ }
+
+}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Camel healthcheck spring-boot actuators don't honor "endpoints.*.enabled"
> property
> -----------------------------------------------------------------------------------
>
> Key: CAMEL-12113
> URL: https://issues.apache.org/jira/browse/CAMEL-12113
> Project: Camel
> Issue Type: Improvement
> Components: camel-spring-boot
> Affects Versions: 2.20.0
> Reporter: Andrea Tarocchi
> Assignee: Claus Ibsen
> Fix For: 2.20.2, 2.21.0
>
>
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)