camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-8725: explainEndpointJson should order the options according to the given order from the endpoint
Date Fri, 01 May 2015 06:25:07 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x 0b9d33f11 -> c77d0f1c6
  refs/heads/master 7156cf717 -> 4fac6a0bc


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/4fac6a0b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4fac6a0b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4fac6a0b

Branch: refs/heads/master
Commit: 4fac6a0bcf0783598cba434a2ca8b07d189a708b
Parents: 7156cf7
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri May 1 08:28:19 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri May 1 08:28:19 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/4fac6a0b/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 bc5ca4f..17de821 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
@@ -1795,6 +1795,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);
@@ -1835,8 +1836,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
@@ -1859,11 +1860,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/4fac6a0b/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 3807dc0..f2fcf7f 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
@@ -260,6 +260,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, '}'));
 
@@ -267,7 +272,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\","
@@ -290,6 +295,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, '}'));
 
@@ -297,7 +307,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\","


Mime
View raw message