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 2014/03/24 08:29:33 UTC
[2/2] git commit: CAMEL-7323: createRouteStatisticEndpointJson -
Returns invalid json if no routes
CAMEL-7323: createRouteStatisticEndpointJson - Returns invalid json if no routes
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b9a1bbe7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b9a1bbe7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b9a1bbe7
Branch: refs/heads/camel-2.13.x
Commit: b9a1bbe7c2e6851d8e40ee5e954a7487f8c5d049
Parents: a3cb8d3
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Mar 24 08:31:53 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Mar 24 08:32:17 2014 +0100
----------------------------------------------------------------------
.../apache/camel/impl/DefaultCamelContext.java | 4 +-
.../ManagedCamelContextEmptyRouteTest.java | 65 ++++++++++++++++++++
.../management/ManagedCamelContextTest.java | 3 +
3 files changed, 71 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b9a1bbe7/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 d339805..801c991 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
@@ -1109,7 +1109,9 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
}
buffer.append("\n ]");
}
- buffer.append("\n }");
+ if (!firstRoute) {
+ buffer.append("\n }");
+ }
buffer.append("\n }\n}\n");
return buffer.toString();
http://git-wip-us.apache.org/repos/asf/camel/blob/b9a1bbe7/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextEmptyRouteTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextEmptyRouteTest.java b/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextEmptyRouteTest.java
new file mode 100644
index 0000000..99574ff
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextEmptyRouteTest.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.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.StringHelper;
+
+/**
+ * @version
+ */
+public class ManagedCamelContextEmptyRouteTest extends ManagementTestSupport {
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = super.createCamelContext();
+ // to force a different management name than the camel id
+ context.getManagementNameStrategy().setNamePattern("20-#name#");
+ return context;
+ }
+
+ public void testManagedCamelContextCreateRouteStaticEndpointJson() throws Exception {
+ // JMX tests dont work well on AIX CI servers (hangs them)
+ if (isPlatform("aix")) {
+ return;
+ }
+
+ MBeanServer mbeanServer = getMBeanServer();
+ ObjectName on = ObjectName.getInstance("org.apache.camel:context=20-camel-1,type=context,name=\"camel-1\"");
+
+ // get the json
+ String json = (String) mbeanServer.invoke(on, "createRouteStaticEndpointJson", null, null);
+ assertNotNull(json);
+ assertEquals(2, StringHelper.countChar(json, '{'));
+ assertEquals(2, StringHelper.countChar(json, '}'));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // no routes
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9a1bbe7/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 66cc4f7..9ee8d57 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
@@ -25,6 +25,7 @@ import javax.management.ObjectName;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.util.StringHelper;
/**
* @version
@@ -214,6 +215,8 @@ public class ManagedCamelContextTest extends ManagementTestSupport {
// get the json
String json = (String) mbeanServer.invoke(on, "createRouteStaticEndpointJson", null, null);
assertNotNull(json);
+ assertEquals(7, StringHelper.countChar(json, '{'));
+ assertEquals(7, StringHelper.countChar(json, '}'));
assertTrue(json.contains("{ \"uri\": \"direct:start\" }"));
assertTrue(json.contains("{ \"uri\": \"direct:foo\" }"));
}