camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/7] git commit: CAMEL-5828 Added OSGi related tests of camel-disruptor
Date Wed, 22 May 2013 10:48:39 GMT
Updated Branches:
  refs/heads/master 839ec5698 -> 2cce9b0c4


CAMEL-5828 Added OSGi related tests of camel-disruptor


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

Branch: refs/heads/master
Commit: 881dfc620ee1b4a6b75278a609cb5bfea29d8422
Parents: 6d05326
Author: Willem Jiang <ningjiang@apache.org>
Authored: Wed May 22 18:15:19 2013 +0800
Committer: Willem Jiang <ningjiang@apache.org>
Committed: Wed May 22 18:46:26 2013 +0800

----------------------------------------------------------------------
 tests/camel-itest-osgi/pom.xml                     |    5 +
 .../camel/itest/osgi/disruptor/DisruptorTest.java  |   66 +++++++++++++++
 .../itest/osgi/disruptor/vm/DisruptorVmTest.java   |   60 +++++++++++++
 3 files changed, 131 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/881dfc62/tests/camel-itest-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/pom.xml b/tests/camel-itest-osgi/pom.xml
index fc5fa20..9307e7c 100644
--- a/tests/camel-itest-osgi/pom.xml
+++ b/tests/camel-itest-osgi/pom.xml
@@ -396,6 +396,11 @@
           <scope>test</scope>
       </dependency>
       <dependency>
+          <groupId>org.apache.camel</groupId>
+          <artifactId>camel-disruptor</artifactId>
+          <scope>test</scope>
+      </dependency>
+      <dependency>
         <groupId>org.apache.derby</groupId>
         <artifactId>derby</artifactId>
         <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/camel/blob/881dfc62/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/DisruptorTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/DisruptorTest.java
b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/DisruptorTest.java
new file mode 100644
index 0000000..aa11f4f
--- /dev/null
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/DisruptorTest.java
@@ -0,0 +1,66 @@
+/**
+ * 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.itest.osgi.disruptor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+/**
+ * @version 
+ */
+@RunWith(JUnit4TestRunner.class)
+public class DisruptorTest extends OSGiIntegrationTestSupport {
+    
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("disruptor:foo").to("mock:bar");
+            }
+        };
+    }
+
+    @Test
+    public void testSendMessage() throws Exception {
+        MockEndpoint mock =  getMandatoryEndpoint("mock:bar", MockEndpoint.class);
+        assertNotNull("The mock endpoint should not be null", mock);
+        
+        mock.expectedBodiesReceived("Hello World");
+        template.sendBody("disruptor:foo", "Hello World");
+        assertMockEndpointsSatisfied();        
+    }
+    
+    @Test
+    public void testCamelContextName() throws Exception {
+        // should get the context name with osgi bundle id
+        String name1 = context.getName();
+
+        CamelContext context2 = createCamelContext();
+        String name2 = context2.getName();
+
+        assertNotSame(name1, name2);
+
+        String id = "" + bundleContext.getBundle().getBundleId();
+        assertTrue(name1.startsWith(id));
+        assertTrue(name2.startsWith(id));
+    }
+   
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/881dfc62/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/vm/DisruptorVmTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/vm/DisruptorVmTest.java
b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/vm/DisruptorVmTest.java
new file mode 100644
index 0000000..36b0a84
--- /dev/null
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/vm/DisruptorVmTest.java
@@ -0,0 +1,60 @@
+/**
+ * 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.itest.osgi.disruptor.vm;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+/**
+ * @version 
+ */
+@RunWith(JUnit4TestRunner.class)
+public class DisruptorVmTest extends OSGiIntegrationTestSupport {
+    
+    @Override
+    protected RouteBuilder[] createRouteBuilders() throws Exception {
+        RouteBuilder[] routeBuilders = new RouteBuilder[2];
+        routeBuilders[0] = new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("disruptor-vm:foo");
+            }
+        };
+        routeBuilders[1] = new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("disruptor-vm:foo?concurrentConsumers=5")
+                    .to("mock:result");
+            }
+        };
+        
+        return routeBuilders;
+    }
+
+    @Test
+    public void testSendMessage() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+        
+        template.sendBody("direct:start", "Hello World");
+        
+        assertMockEndpointsSatisfied();        
+    }
+}
\ No newline at end of file


Mime
View raw message