You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/05/01 08:25:08 UTC

[2/2] camel git commit: CAMEL-8725: explainEndpointJson should order the options according to the given order from the endpoint

CAMEL-8725: explainEndpointJson should order the options according to the given order from the endpoint


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c77d0f1c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c77d0f1c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c77d0f1c

Branch: refs/heads/camel-2.15.x
Commit: c77d0f1c603454e2b0144fe72212c863c01ac57d
Parents: 0b9d33f
Author: Claus Ibsen <da...@apache.org>
Authored: Fri May 1 08:28:19 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri May 1 08:28:44 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/impl/DefaultCamelContext.java   | 19 +++++++++++++------
 .../management/ManagedCamelContextTest.java      | 14 ++++++++++++--
 2 files changed, 25 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c77d0f1c/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index a974b8f..99127f2 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -1667,6 +1667,7 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
 
             // selected rows to use for answer
             Map<String, String[]> selected = new LinkedHashMap<String, String[]>();
+            Map<String, String[]> uriOptions = new LinkedHashMap<String, String[]>();
 
             // insert values from uri
             Map<String, Object> options = URISupport.parseParameters(u);
@@ -1707,8 +1708,8 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
                     }
                 }
 
-                // add as selected row
-                selected.put(name, new String[]{name, kind, label, required, type, javaType, deprecated, value, defaultValue, description});
+                // remember this option from the uri
+                uriOptions.put(name, new String[]{name, kind, label, required, type, javaType, deprecated, value, defaultValue, description});
             }
 
             // include other rows
@@ -1731,11 +1732,17 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
                     value = URISupport.sanitizePath(value);
                 }
 
-                // always include path options
-                if (includeAllOptions || "path".equals(kind)) {
-                    // add as selected row
+                boolean isUriOption = uriOptions.containsKey(name);
+
+                // always include from uri or path options
+                if (includeAllOptions || isUriOption || "path".equals(kind)) {
                     if (!selected.containsKey(name)) {
-                        selected.put(name, new String[]{name, kind, label, required, type, javaType, deprecated, value, defaultValue, description});
+                        // add as selected row, but take the value from uri options if it was from there
+                        if (isUriOption) {
+                            selected.put(name, uriOptions.get(name));
+                        } else {
+                            selected.put(name, new String[]{name, kind, label, required, type, javaType, deprecated, value, defaultValue, description});
+                        }
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/c77d0f1c/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java b/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java
index c92eead..6d5f948 100644
--- a/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java
+++ b/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java
@@ -242,6 +242,11 @@ public class ManagedCamelContextTest extends ManagementTestSupport {
                 new String[]{"java.lang.String", "boolean"});
         assertNotNull(json);
 
+        // the loggerName option should come before the groupDelay option
+        int pos = json.indexOf("loggerName");
+        int pos2 = json.indexOf("groupDelay");
+        assertTrue("LoggerName should come before groupDelay", pos < pos2);
+
         assertEquals(8, StringHelper.countChar(json, '{'));
         assertEquals(8, StringHelper.countChar(json, '}'));
 
@@ -249,7 +254,7 @@ public class ManagedCamelContextTest extends ManagementTestSupport {
         assertTrue(json.contains("\"label\": \"core,monitoring\""));
 
         assertTrue(json.contains("\"groupDelay\": { \"kind\": \"parameter\", \"type\": \"integer\", \"javaType\": \"java.lang.Long\", \"deprecated\": \"false\", \"value\": \"2000\","
-                + " \"description\": \"Set the initial delay for stats (in millis)\" },"));
+                + " \"description\": \"Set the initial delay for stats (in millis)\" }"));
         assertTrue(json.contains("\"groupSize\": { \"kind\": \"parameter\", \"type\": \"integer\", \"javaType\": \"java.lang.Integer\", \"deprecated\": \"false\", \"value\": \"5\","
                 + " \"description\": \"An integer that specifies a group size for throughput logging.\" }"));
         assertTrue(json.contains("\"loggerName\": { \"kind\": \"path\", \"required\": \"true\", \"type\": \"string\", \"javaType\": \"java.lang.String\", \"deprecated\": \"false\","
@@ -272,6 +277,11 @@ public class ManagedCamelContextTest extends ManagementTestSupport {
                 new String[]{"java.lang.String", "boolean"});
         assertNotNull(json);
 
+        // the loggerName option should come before the groupDelay option
+        int pos = json.indexOf("loggerName");
+        int pos2 = json.indexOf("groupDelay");
+        assertTrue("LoggerName should come before groupDelay", pos < pos2);
+
         assertEquals(14, StringHelper.countChar(json, '{'));
         assertEquals(14, StringHelper.countChar(json, '}'));
 
@@ -279,7 +289,7 @@ public class ManagedCamelContextTest extends ManagementTestSupport {
         assertTrue(json.contains("\"label\": \"core,monitoring\""));
 
         assertTrue(json.contains("\"groupDelay\": { \"kind\": \"parameter\", \"type\": \"integer\", \"javaType\": \"java.lang.Long\", \"deprecated\": \"false\", \"value\": \"2000\","
-                + " \"description\": \"Set the initial delay for stats (in millis)\" },"));
+                + " \"description\": \"Set the initial delay for stats (in millis)\" }"));
         assertTrue(json.contains("\"groupSize\": { \"kind\": \"parameter\", \"type\": \"integer\", \"javaType\": \"java.lang.Integer\", \"deprecated\": \"false\", \"value\": \"5\","
                 + " \"description\": \"An integer that specifies a group size for throughput logging.\" }"));
         assertTrue(json.contains("\"loggerName\": { \"kind\": \"path\", \"required\": \"true\", \"type\": \"string\", \"javaType\": \"java.lang.String\", \"deprecated\": \"false\","