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 ac2cb1949eaeca5505ba3ac8ba7d20abb7cade6b
Author: Tomohisa Igarashi <tm.igara...@gmail.com>
AuthorDate: Fri Mar 23 12:25:14 2018 -0400

    CAMEL-12373: Allow route dump only when !read-only
---
 .../spring/boot/actuate/endpoint/CamelRoutesEndpoint.java   |  6 +++++-
 .../boot/actuate/endpoint/CamelRoutesEndpointTest.java      | 13 +++----------
 .../endpoint/CamelRoutesEndpointWriteOperationTest.java     | 12 ++++++++++++
 3 files changed, 20 insertions(+), 11 deletions(-)

diff --git 
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
 
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
index 9a061f1..e9f8a53 100644
--- 
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
+++ 
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
@@ -104,8 +104,12 @@ public class CamelRoutesEndpoint {
         }
     }
 
-    @ReadOperation
+    @WriteOperation
     public String getRouteDump(@Selector String id) {
+        if (this.isReadOnly()) {
+            throw new IllegalArgumentException("Read only: route dump is not 
permitted in read-only mode");
+        }
+
         RouteDefinition route = camelContext.getRouteDefinition(id);
         if (route != null) {
             try {
diff --git 
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointTest.java
 
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointTest.java
index 1878336..8e75ec5 100644
--- 
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointTest.java
+++ 
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointTest.java
@@ -62,16 +62,9 @@ public class CamelRoutesEndpointTest extends Assert {
         assertTrue(routes.stream().anyMatch(r -> 
"foo-route".equals(r.getId())));
     }
 
-    @Test
-    public void testRouteDump() throws Exception {
-        String dump = endpoint.getRouteDump("foo-route");
-        assertNotNull(dump);
-        assertTrue(dump, dump.contains("<route "));
-        assertTrue(dump, dump.contains("<from "));
-        assertTrue(dump, dump.contains("uri=\"timer:foo\""));
-        assertTrue(dump, dump.contains("<to "));
-        assertTrue(dump, dump.contains("uri=\"log:foo\""));
-        assertTrue(dump, dump.contains("</route>"));
+    @Test(expected = IllegalArgumentException.class)
+    public void testRouteDumpReadOnly() throws Exception {
+        endpoint.getRouteDump("foo-route");
     }
 
     @Test
diff --git 
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointWriteOperationTest.java
 
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointWriteOperationTest.java
index 779de02..24a024b 100644
--- 
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointWriteOperationTest.java
+++ 
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpointWriteOperationTest.java
@@ -70,4 +70,16 @@ public class CamelRoutesEndpointWriteOperationTest extends 
Assert {
         Assert.assertTrue(status.isStarted());
     }
 
+    @Test
+    public void testRouteDump() throws Exception {
+        String dump = endpoint.getRouteDump("foo-route");
+        assertNotNull(dump);
+        assertTrue(dump, dump.contains("<route "));
+        assertTrue(dump, dump.contains("<from "));
+        assertTrue(dump, dump.contains("uri=\"timer:foo\""));
+        assertTrue(dump, dump.contains("<to "));
+        assertTrue(dump, dump.contains("uri=\"log:foo\""));
+        assertTrue(dump, dump.contains("</route>"));
+    }
+
 }

-- 
To stop receiving notification emails like this one, please contact
davscl...@apache.org.

Reply via email to