Added isMockEndpointUnit test accroding the mailing list question

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

Branch: refs/heads/master
Commit: 8c5769fe143f3c22e08c340fae0b7ef6f54b744b
Parents: adc9b89
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Thu Oct 30 09:55:05 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Thu Oct 30 10:33:50 2014 +0800

----------------------------------------------------------------------
 .../blueprint/IsMockEndpointJUnit4Test.java     | 76 ++++++++++++++++++++
 .../camel/test/blueprint/IsMockEndpoints.xml    | 46 ++++++++++++
 2 files changed, 122 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8c5769fe/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/IsMockEndpointJUnit4Test.java
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/IsMockEndpointJUnit4Test.java
 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/IsMockEndpointJUnit4Test.java
new file mode 100644
index 0000000..a403c90
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/IsMockEndpointJUnit4Test.java
@@ -0,0 +1,76 @@
+/**
+ * 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.test.blueprint;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+public class IsMockEndpointJUnit4Test extends CamelBlueprintTestSupport {
+   
+    @EndpointInject (uri = "mock:seda:result", context = "IsMockEndpoints")
+    private MockEndpoint mockSeda;
+
+    @EndpointInject (uri = "mock:bar", context = "IsMockEndpoints")
+    private MockEndpoint mockBar;
+
+    @EndpointInject (uri = "mock:baz", context = "IsMockEndpoints")
+    private MockEndpoint mockBaz;
+    
+    @Override
+    protected String getBlueprintDescriptor() {
+        return "org/apache/camel/test/blueprint/IsMockEndpoints.xml";
+    }
+
+    @Override
+    public String isMockEndpoints() {
+        return "*";
+    }
+
+
+    @Test
+    public void testMockAllEndpoints() throws Exception {
+        mockSeda.expectedBodiesReceived("bar");
+        mockBar.expectedBodiesReceived("bar");
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertNotNull(context.hasEndpoint("mock:seda:result"));
+        assertNotNull(context.hasEndpoint("mock:baz"));
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testMockBar() throws Exception {
+        mockBar.expectedBodiesReceived("bar");
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertNotNull(context.hasEndpoint("mock:bar"));
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testMockBaz() throws Exception {
+        mockBaz.expectedBodiesReceived("baz");
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertNotNull(context.hasEndpoint("mock:baz"));
+        assertMockEndpointsSatisfied();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/8c5769fe/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/IsMockEndpoints.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/IsMockEndpoints.xml
 
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/IsMockEndpoints.xml
new file mode 100644
index 0000000..269aaa4
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/IsMockEndpoints.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"; 
xmlns:camel="http://camel.apache.org/schema/blueprint"; 
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="
+       http://www.osgi.org/xmlns/blueprint/v1.0.0
+       http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd       
+       http://camel.apache.org/schema/blueprint 
+       http://camel.apache.org/schema/blueprint/camel-blueprint.xsd";>
+
+       <camelContext id="IsMockEndpoints" trace="false" 
xmlns="http://camel.apache.org/schema/blueprint";>
+
+               <route id="IsMockEndpointsRoute">
+                       <from uri="direct:foo" />
+                       <setBody>
+                               <simple>bar</simple>
+                       </setBody>
+                       <to uri="seda:result" />
+                       <to uri="mock:bar" />
+               </route>
+               <route>
+                       <from uri="seda:result" />
+                       <setBody>
+                               <simple>baz</simple>
+                       </setBody>
+                       <to uri="mock:baz" />
+               </route>
+
+       </camelContext>
+
+</blueprint>

Reply via email to