You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ra...@apache.org on 2013/09/01 19:44:03 UTC

git commit: camel-mongodb: Add a test for basic operations with Spring DSL

Updated Branches:
  refs/heads/master 617eab1c3 -> 8e2fb690c


camel-mongodb: Add a test for basic operations with Spring DSL


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

Branch: refs/heads/master
Commit: 8e2fb690c96321b3691d5ee4bf48c272f3e8e370
Parents: 617eab1
Author: Raúl Kripalani <ra...@apache.org>
Authored: Sun Sep 1 18:42:18 2013 +0100
Committer: Raúl Kripalani <ra...@apache.org>
Committed: Sun Sep 1 18:42:18 2013 +0100

----------------------------------------------------------------------
 .../mongodb/MongoDbSpringDslOperationsTest.java | 43 +++++++++++
 .../mongodb/mongoBasicOperationsTest.xml        | 75 ++++++++++++++++++++
 2 files changed, 118 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8e2fb690/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbSpringDslOperationsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbSpringDslOperationsTest.java b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbSpringDslOperationsTest.java
new file mode 100644
index 0000000..0e4bb20
--- /dev/null
+++ b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbSpringDslOperationsTest.java
@@ -0,0 +1,43 @@
+/**
+ * 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.component.mongodb;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.SpringCamelContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class MongoDbSpringDslOperationsTest extends MongoDbOperationsTest {
+    
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/component/mongodb/mongoBasicOperationsTest.xml");
+        CamelContext ctx = SpringCamelContext.springCamelContext(applicationContext);
+        return ctx;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // Nothing, all routes are initialized by the Spring DSL context file
+            }
+        };
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8e2fb690/components/camel-mongodb/src/test/resources/org/apache/camel/component/mongodb/mongoBasicOperationsTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/test/resources/org/apache/camel/component/mongodb/mongoBasicOperationsTest.xml b/components/camel-mongodb/src/test/resources/org/apache/camel/component/mongodb/mongoBasicOperationsTest.xml
new file mode 100644
index 0000000..03df4b6
--- /dev/null
+++ b/components/camel-mongodb/src/test/resources/org/apache/camel/component/mongodb/mongoBasicOperationsTest.xml
@@ -0,0 +1,75 @@
+<?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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+  <bean id="myDb" class="com.mongodb.Mongo">
+    <constructor-arg index="0" value="localhost"/>
+  </bean>
+  
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+  
+    <propertyPlaceholder id="properties" location="mongodb.test.properties"/>
+  
+    <route>
+        <from uri="direct:count" />
+        <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=count&amp;dynamicity=true" />
+    </route>
+
+    <route>
+        <from uri="direct:insert" />
+        <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=insert&amp;writeConcern=SAFE" />
+    </route>
+    
+    <route>
+        <from uri="direct:save" />
+        <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=save&amp;writeConcern=SAFE" />
+    </route>
+    
+    <route>
+        <from uri="direct:update" />
+        <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=update&amp;writeConcern=SAFE" />
+    </route>
+    
+    <route>
+        <from uri="direct:remove" />
+        <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=remove&amp;writeConcern=SAFE" />
+    </route>
+
+    <route>
+        <from uri="direct:aggregate" />
+        <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=aggregate&amp;writeConcern=SAFE" />
+    </route>
+
+    <route>
+        <from uri="direct:getDbStats" />
+        <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=getDbStats" />
+    </route>
+    
+    <route>
+        <from uri="direct:getColStats" />
+        <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=getColStats" />
+    </route>
+  
+  </camelContext>
+
+</beans>