camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1102661 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/management/mbean/ test/java/org/apache/camel/management/
Date Fri, 13 May 2011 10:55:00 GMT
Author: davsclaus
Date: Fri May 13 10:54:59 2011
New Revision: 1102661

URL: http://svn.apache.org/viewvc?rev=1102661&view=rev
Log:
CAMEL-3973: Added operations to send message with headers to ManagedCamelContext.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextAutoStartupTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextSuspendResumeTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextSuspendStartTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAutoStartupTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java?rev=1102661&r1=1102660&r2=1102661&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
Fri May 13 10:54:59 2011
@@ -159,7 +159,7 @@ public class ManagedCamelContext {
     }
 
     @ManagedOperation(description = "Send body (in only)")
-    public void sendBody(String endpointUri, String body) throws Exception {
+    public void sendBody(String endpointUri, Object body) throws Exception {
         ProducerTemplate template = context.createProducerTemplate();
         try {
             template.sendBody(endpointUri, body);
@@ -168,8 +168,23 @@ public class ManagedCamelContext {
         }
     }
 
+    @ManagedOperation(description = "Send body (String type) (in only)")
+    public void sendStringBody(String endpointUri, String body) throws Exception {
+        sendBody(endpointUri, body);
+    }
+
+    @ManagedOperation(description = "Send body and headers (in only)")
+    public void sendBodyAndHeaders(String endpointUri, Object body, Map<String, Object>
headers) throws Exception {
+        ProducerTemplate template = context.createProducerTemplate();
+        try {
+            template.sendBodyAndHeaders(endpointUri, body, headers);
+        } finally {
+            template.stop();
+        }
+    }
+
     @ManagedOperation(description = "Request body (in out)")
-    public Object requestBody(String endpointUri, String body) throws Exception {
+    public Object requestBody(String endpointUri, Object body) throws Exception {
         ProducerTemplate template = context.createProducerTemplate();
         Object answer = null;
         try {
@@ -180,6 +195,23 @@ public class ManagedCamelContext {
         return answer;
     }
 
+    @ManagedOperation(description = "Request body (String type) (in out)")
+    public Object requestStringBody(String endpointUri, String body) throws Exception {
+        return requestBody(endpointUri, body);
+    }
+
+    @ManagedOperation(description = "Request body and headers (in out)")
+    public Object requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object>
headers) throws Exception {
+        ProducerTemplate template = context.createProducerTemplate();
+        Object answer = null;
+        try {
+            answer = template.requestBodyAndHeaders(endpointUri, body, headers);
+        } finally {
+            template.stop();
+        }
+        return answer;
+    }
+
     @ManagedOperation(description = "Dumps the routes as XML")
     public String dumpRoutesAsXml() throws Exception {
         List<RouteDefinition> routes = context.getRouteDefinitions();

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextAutoStartupTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextAutoStartupTest.java?rev=1102661&r1=1102660&r2=1102661&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextAutoStartupTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextAutoStartupTest.java
Fri May 13 10:54:59 2011
@@ -46,7 +46,7 @@ public class ManagedCamelContextAutoStar
         state = (String) mbeanServer.getAttribute(onRoute, "State");
         assertEquals("Started", state);
 
-        Object reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello
World"}, new String[]{"java.lang.String", "java.lang.String"});
+        Object reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello
World"}, new String[]{"java.lang.String", "java.lang.Object"});
         assertEquals("Bye World", reply);
 
         // stop Camel

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextSuspendResumeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextSuspendResumeTest.java?rev=1102661&r1=1102660&r2=1102661&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextSuspendResumeTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextSuspendResumeTest.java
Fri May 13 10:54:59 2011
@@ -46,7 +46,7 @@ public class ManagedCamelContextSuspendR
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
 
-        Object reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello
World"}, new String[]{"java.lang.String", "java.lang.String"});
+        Object reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello
World"}, new String[]{"java.lang.String", "java.lang.Object"});
         assertEquals("Bye World", reply);
 
         // suspend Camel
@@ -61,7 +61,7 @@ public class ManagedCamelContextSuspendR
         status = (String) mbeanServer.getAttribute(on, "State");
         assertEquals("Started", status);
 
-        reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello Camel"},
new String[]{"java.lang.String", "java.lang.String"});
+        reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello Camel"},
new String[]{"java.lang.String", "java.lang.Object"});
         assertEquals("Bye World", reply);
     }
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextSuspendStartTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextSuspendStartTest.java?rev=1102661&r1=1102660&r2=1102661&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextSuspendStartTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextSuspendStartTest.java
Fri May 13 10:54:59 2011
@@ -46,7 +46,7 @@ public class ManagedCamelContextSuspendS
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
 
-        Object reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello
World"}, new String[]{"java.lang.String", "java.lang.String"});
+        Object reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello
World"}, new String[]{"java.lang.String", "java.lang.Object"});
         assertEquals("Bye World", reply);
 
         // suspend Camel
@@ -61,7 +61,7 @@ public class ManagedCamelContextSuspendS
         status = (String) mbeanServer.getAttribute(on, "State");
         assertEquals("Started", status);
 
-        reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello Camel"},
new String[]{"java.lang.String", "java.lang.String"});
+        reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello Camel"},
new String[]{"java.lang.String", "java.lang.Object"});
         assertEquals("Bye World", reply);
     }
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java?rev=1102661&r1=1102660&r2=1102661&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java
Fri May 13 10:54:59 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.management;
 
+import java.util.HashMap;
+import java.util.Map;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
@@ -45,14 +47,37 @@ public class ManagedCamelContextTest ext
         // invoke operations
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
+        mbeanServer.invoke(on, "sendBody", new Object[]{"direct:start", "Hello World"}, new
String[]{"java.lang.String", "java.lang.Object"});
+        assertMockEndpointsSatisfied();
 
-        mbeanServer.invoke(on, "sendBody", new Object[]{"direct:start", "Hello World"}, new
String[]{"java.lang.String", "java.lang.String"});
-
+        resetMocks();
+        mock.expectedBodiesReceived("Hello World");
+        mbeanServer.invoke(on, "sendStringBody", new Object[]{"direct:start", "Hello World"},
new String[]{"java.lang.String", "java.lang.String"});
         assertMockEndpointsSatisfied();
 
-        Object reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello
World"}, new String[]{"java.lang.String", "java.lang.String"});
+        Object reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello
World"}, new String[]{"java.lang.String", "java.lang.Object"});
         assertEquals("Bye World", reply);
 
+        reply = mbeanServer.invoke(on, "requestStringBody", new Object[]{"direct:foo", "Hello
World"}, new String[]{"java.lang.String", "java.lang.String"});
+        assertEquals("Bye World", reply);
+
+        resetMocks();
+        mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+        mock.expectedHeaderReceived("foo", 123);
+        Map<String, Object> headers = new HashMap<String, Object>();
+        headers.put("foo", 123);
+        mbeanServer.invoke(on, "sendBodyAndHeaders", new Object[]{"direct:start", "Hello
World", headers}, new String[]{"java.lang.String", "java.lang.Object", "java.util.Map"});
+        assertMockEndpointsSatisfied();
+
+        resetMocks();
+        mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+        mock.expectedHeaderReceived("foo", 123);
+        reply = mbeanServer.invoke(on, "requestBodyAndHeaders", new Object[]{"direct:start",
"Hello World", headers}, new String[]{"java.lang.String", "java.lang.Object", "java.util.Map"});
+        assertEquals("Hello World", reply);
+        assertMockEndpointsSatisfied();
+
         // stop Camel
         mbeanServer.invoke(on, "stop", null, null);
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAutoStartupTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAutoStartupTest.java?rev=1102661&r1=1102660&r2=1102661&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAutoStartupTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAutoStartupTest.java
Fri May 13 10:54:59 2011
@@ -49,7 +49,7 @@ public class ManagedRouteAutoStartupTest
         state = (String) mbeanServer.getAttribute(onFoo, "State");
         assertEquals("Started", state);
 
-        Object reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello
World"}, new String[]{"java.lang.String", "java.lang.String"});
+        Object reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello
World"}, new String[]{"java.lang.String", "java.lang.Object"});
         assertEquals("Bye World", reply);
 
         // stop Camel



Mime
View raw message