camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [5/6] camel git commit: CAMEL-9389: camel-metrics - Allow to capture message history easily
Date Sat, 05 Dec 2015 08:29:28 GMT
CAMEL-9389: camel-metrics - Allow to capture message history easily


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

Branch: refs/heads/master
Commit: 31e988c348fc265a873550f3a4f305f50f7411e3
Parents: 13f953f
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Dec 5 09:10:45 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Dec 5 09:10:45 2015 +0100

----------------------------------------------------------------------
 .../messagehistory/ManagedMessageHistoryTest.java  |  1 +
 .../messagehistory/MetricsMessageHistoryTest.java  | 17 ++++++++++++++---
 .../SpringMetricsMessageHistoryTest.java           | 11 +++++++++++
 .../SpringMetricsMessageHistoryTest.xml            |  6 +++---
 4 files changed, 29 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/31e988c3/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/ManagedMessageHistoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/ManagedMessageHistoryTest.java
b/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/ManagedMessageHistoryTest.java
index faafc84..cb62393 100644
--- a/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/ManagedMessageHistoryTest.java
+++ b/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/ManagedMessageHistoryTest.java
@@ -85,6 +85,7 @@ public class ManagedMessageHistoryTest extends CamelTestSupport {
         Set<ObjectName> set = getMBeanServer().queryNames(new ObjectName("org.apache.camel.metrics:*"),
null);
         assertEquals(3, set.size());
 
+        // get the message history service using JMX
         String name = String.format("org.apache.camel:context=%s,type=services,name=MetricsMessageHistoryService",
context.getManagementName());
         ObjectName on = ObjectName.getInstance(name);
         String json = (String) getMBeanServer().invoke(on, "dumpStatisticsAsJson", null,
null);

http://git-wip-us.apache.org/repos/asf/camel/blob/31e988c3/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/MetricsMessageHistoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/MetricsMessageHistoryTest.java
b/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/MetricsMessageHistoryTest.java
index 0467812..664137b 100644
--- a/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/MetricsMessageHistoryTest.java
+++ b/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/MetricsMessageHistoryTest.java
@@ -56,6 +56,17 @@ public class MetricsMessageHistoryTest extends CamelTestSupport {
 
         // there should be 3 names
         assertEquals(3, registry.getNames().size());
+
+        // get the message history service
+        MetricsMessageHistoryService service = context.hasService(MetricsMessageHistoryService.class);
+        assertNotNull(service);
+        String json = service.dumpStatisticsAsJson();
+        assertNotNull(json);
+        log.info(json);
+
+        assertTrue(json.contains("foo.history"));
+        assertTrue(json.contains("bar.history"));
+        assertTrue(json.contains("baz.history"));
     }
 
     @Override
@@ -64,11 +75,11 @@ public class MetricsMessageHistoryTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {
                 from("seda:foo")
-                    .to("mock:foo");
+                    .to("mock:foo").id("foo");
 
                 from("seda:bar")
-                    .to("mock:bar")
-                    .to("mock:baz");
+                    .to("mock:bar").id("bar")
+                    .to("mock:baz").id("baz");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/31e988c3/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/SpringMetricsMessageHistoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/SpringMetricsMessageHistoryTest.java
b/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/SpringMetricsMessageHistoryTest.java
index a57ffe0..d6d1ab9 100644
--- a/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/SpringMetricsMessageHistoryTest.java
+++ b/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/messagehistory/SpringMetricsMessageHistoryTest.java
@@ -48,6 +48,17 @@ public class SpringMetricsMessageHistoryTest extends CamelSpringTestSupport
{
         // there should be 3 names
         MetricRegistry registry = context.getRegistry().findByType(MetricRegistry.class).iterator().next();
         assertEquals(3, registry.getNames().size());
+
+        // get the message history service
+        MetricsMessageHistoryService service = context.hasService(MetricsMessageHistoryService.class);
+        assertNotNull(service);
+        String json = service.dumpStatisticsAsJson();
+        assertNotNull(json);
+        log.info(json);
+
+        assertTrue(json.contains("foo.history"));
+        assertTrue(json.contains("bar.history"));
+        assertTrue(json.contains("baz.history"));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/31e988c3/components/camel-metrics/src/test/resources/org/apache/camel/component/metrics/messagehistory/SpringMetricsMessageHistoryTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-metrics/src/test/resources/org/apache/camel/component/metrics/messagehistory/SpringMetricsMessageHistoryTest.xml
b/components/camel-metrics/src/test/resources/org/apache/camel/component/metrics/messagehistory/SpringMetricsMessageHistoryTest.xml
index d3694cb..11854e8 100644
--- a/components/camel-metrics/src/test/resources/org/apache/camel/component/metrics/messagehistory/SpringMetricsMessageHistoryTest.xml
+++ b/components/camel-metrics/src/test/resources/org/apache/camel/component/metrics/messagehistory/SpringMetricsMessageHistoryTest.xml
@@ -34,12 +34,12 @@
   <camelContext xmlns="http://camel.apache.org/schema/spring">
     <route>
       <from uri="seda:foo"/>
-      <to uri="mock:foo"/>
+      <to uri="mock:foo" id="foo"/>
     </route>
     <route>
       <from uri="seda:bar"/>
-      <to uri="mock:bar"/>
-      <to uri="mock:baz"/>
+      <to uri="mock:bar" id="bar"/>
+      <to uri="mock:baz" id="baz"/>
     </route>
   </camelContext>
 


Mime
View raw message