camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [6/8] camel git commit: CAMEL-8668: Removed deprecated DB and DBCollection from test classes
Date Fri, 03 Jun 2016 08:01:47 GMT
CAMEL-8668: Removed deprecated DB and DBCollection from test classes


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

Branch: refs/heads/master
Commit: de1fa976680466b464e121c86266fe8dffb84d8b
Parents: a552510
Author: Arno Noordover <anoordover@users.noreply.github.com>
Authored: Tue May 31 21:55:16 2016 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Jun 3 09:57:00 2016 +0200

----------------------------------------------------------------------
 .../component/mongodb/AbstractMongoDbTest.java  |  28 +++--
 .../mongodb/MongoDbConversionsTest.java         |  10 +-
 .../mongodb/MongoDbDynamicityTest.java          |  77 ++++++++-----
 .../mongodb/MongoDbHeaderHandlingTest.java      |   6 +-
 .../component/mongodb/MongoDbIndexTest.java     |  92 +++++++++------
 .../mongodb/MongoDbOperationsTest.java          |  16 +--
 .../MongoDbTailableCursorConsumerTest.java      | 111 +++++++++++--------
 .../mongodb/MongoDbWriteConcernsTest.java       |   4 +-
 8 files changed, 206 insertions(+), 138 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/de1fa976/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/AbstractMongoDbTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/AbstractMongoDbTest.java b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/AbstractMongoDbTest.java
index 92a20a4..c75a108 100644
--- a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/AbstractMongoDbTest.java
+++ b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/AbstractMongoDbTest.java
@@ -18,12 +18,15 @@ package org.apache.camel.component.mongodb;
 
 import java.util.Formatter;
 
-
+import com.mongodb.BasicDBObject;
 import com.mongodb.DB;
 import com.mongodb.DBCollection;
 import com.mongodb.DBObject;
 import com.mongodb.Mongo;
+import com.mongodb.MongoClient;
 import com.mongodb.WriteConcern;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
 import com.mongodb.util.JSON;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelExecutionException;
@@ -32,6 +35,7 @@ import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
+import org.bson.Document;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 
@@ -39,10 +43,10 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
 
 public abstract class AbstractMongoDbTest extends CamelTestSupport {
 
-    protected static Mongo mongo;
-    protected static DB db;
-    protected static DBCollection testCollection;
-    protected static DBCollection dynamicCollection;
+    protected static MongoClient mongo;
+    protected static MongoDatabase db;
+    protected static MongoCollection<BasicDBObject> testCollection;
+    protected static MongoCollection<BasicDBObject> dynamicCollection;
     
     protected static String dbName = "test";
     protected static String testCollectionName;
@@ -52,20 +56,20 @@ public abstract class AbstractMongoDbTest extends CamelTestSupport {
 
     @Override
     public void doPostSetup() {
-        mongo = applicationContext.getBean(Mongo.class);
-        db = mongo.getDB(dbName);
+        mongo = applicationContext.getBean(MongoClient.class);
+        db = mongo.getDatabase(dbName);
 
         // Refresh the test collection - drop it and recreate it. We don't do this for the database because MongoDB would create large
         // store files each time
         testCollectionName = "camelTest";
-        testCollection = db.getCollection(testCollectionName);
+        testCollection = db.getCollection(testCollectionName, BasicDBObject.class);
         testCollection.drop();
-        testCollection = db.getCollection(testCollectionName);
+        testCollection = db.getCollection(testCollectionName, BasicDBObject.class);
         
         dynamicCollectionName = testCollectionName.concat("Dynamic");
-        dynamicCollection = db.getCollection(dynamicCollectionName);
+        dynamicCollection = db.getCollection(dynamicCollectionName, BasicDBObject.class);
         dynamicCollection.drop();
-        dynamicCollection = db.getCollection(dynamicCollectionName);
+        dynamicCollection = db.getCollection(dynamicCollectionName, BasicDBObject.class);
 
     }
 
@@ -94,7 +98,7 @@ public abstract class AbstractMongoDbTest extends CamelTestSupport {
             Formatter f = new Formatter();
             String doc = f.format("{\"_id\":\"%d\", \"scientist\":\"%s\", \"fixedField\": \"fixedValue\"}", i, scientists[index]).toString();
             IOHelper.close(f);
-            testCollection.insert((DBObject) JSON.parse(doc), WriteConcern.SAFE);
+            testCollection.insertOne((BasicDBObject) JSON.parse(doc));
         }
         assertEquals("Data pumping of 1000 entries did not complete entirely", 1000L, testCollection.count());
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/de1fa976/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbConversionsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbConversionsTest.java b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbConversionsTest.java
index 3d12b24..76fe21f 100644
--- a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbConversionsTest.java
+++ b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbConversionsTest.java
@@ -48,7 +48,7 @@ public class MongoDbConversionsTest extends AbstractMongoDbTest {
         m1.put("_id", "testInsertMap");
 
         Object result = template.requestBody("direct:insertMap", m1);
-        DBObject b = testCollection.findOne("testInsertMap");
+        BasicDBObject b = testCollection.find(new BasicDBObject("_id", "testInsertMap")).first();
         assertNotNull("No record with 'testInsertMap' _id", b);
 
     }
@@ -57,7 +57,7 @@ public class MongoDbConversionsTest extends AbstractMongoDbTest {
     public void testInsertPojo() {
         assertEquals(0, testCollection.count());
         Object result = template.requestBody("direct:insertPojo", new MyPojoTest());
-        DBObject b = testCollection.findOne("testInsertPojo");
+        DBObject b = testCollection.find(new BasicDBObject("_id", "testInsertPojo")).first();
         assertNotNull("No record with 'testInsertPojo' _id", b);
     }
     
@@ -66,7 +66,7 @@ public class MongoDbConversionsTest extends AbstractMongoDbTest {
         assertEquals(0, testCollection.count());
         Object result = template.requestBody("direct:insertJsonString", "{\"fruits\": [\"apple\", \"banana\", \"papaya\"], \"veggie\": \"broccoli\", \"_id\": \"testInsertJsonString\"}");
         //assertTrue(result instanceof WriteResult);
-        DBObject b = testCollection.findOne("testInsertJsonString");
+        DBObject b = testCollection.find(new BasicDBObject("_id", "testInsertJsonString")).first();
         assertNotNull("No record with 'testInsertJsonString' _id", b);
     }
     
@@ -75,7 +75,7 @@ public class MongoDbConversionsTest extends AbstractMongoDbTest {
         assertEquals(0, testCollection.count());
         Object result = template.requestBody("direct:insertJsonString", 
                         IOConverter.toInputStream("{\"fruits\": [\"apple\", \"banana\"], \"veggie\": \"broccoli\", \"_id\": \"testInsertJsonString\"}\n", null));
-        DBObject b = testCollection.findOne("testInsertJsonString");
+        DBObject b = testCollection.find(new BasicDBObject("_id", "testInsertJsonString")).first();
         assertNotNull("No record with 'testInsertJsonString' _id", b);
     }
     
@@ -88,7 +88,7 @@ public class MongoDbConversionsTest extends AbstractMongoDbTest {
         bsonObject.put("_id", "testInsertBsonString");
         
         Object result = template.requestBody("direct:insertJsonString", new ByteArrayInputStream(encoder.encode(bsonObject)));
-        DBObject b = testCollection.findOne("testInsertBsonString");
+        DBObject b = testCollection.find(new BasicDBObject("_id", "testInsertBsonString")).first();
         assertNotNull("No record with 'testInsertBsonString' _id", b);
     }
     

http://git-wip-us.apache.org/repos/asf/camel/blob/de1fa976/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbDynamicityTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbDynamicityTest.java b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbDynamicityTest.java
index b7ff59a..188ed48 100644
--- a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbDynamicityTest.java
+++ b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbDynamicityTest.java
@@ -18,10 +18,13 @@ package org.apache.camel.component.mongodb;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.stream.StreamSupport;
 
+import com.mongodb.BasicDBObject;
 import com.mongodb.DBCollection;
 import com.mongodb.DBObject;
 import com.mongodb.WriteResult;
+import com.mongodb.client.MongoCollection;
 
 import org.apache.camel.builder.RouteBuilder;
 
@@ -32,9 +35,11 @@ public class MongoDbDynamicityTest extends AbstractMongoDbTest {
     @Test
     public void testInsertDynamicityDisabled() {
         assertEquals(0, testCollection.count());
-        mongo.getDB("otherDB").dropDatabase();
+        mongo.getDatabase("otherDB").drop();
         db.getCollection("otherCollection").drop();
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
 
         String body = "{\"_id\": \"testInsertDynamicityDisabled\", \"a\" : \"1\"}";
         Map<String, Object> headers = new HashMap<String, Object>();
@@ -42,72 +47,84 @@ public class MongoDbDynamicityTest extends AbstractMongoDbTest {
         headers.put(MongoDbConstants.COLLECTION, "otherCollection");
         Object result = template.requestBodyAndHeaders("direct:noDynamicity", body, headers);
 
-        DBObject b = testCollection.findOne("testInsertDynamicityDisabled");
+        DBObject b = testCollection.find(new BasicDBObject("_id", "testInsertDynamicityDisabled")).first();
         assertNotNull("No record with 'testInsertDynamicityDisabled' _id", b);
         
         body = "{\"_id\": \"testInsertDynamicityDisabledExplicitly\", \"a\" : \"1\"}";
         result = template.requestBodyAndHeaders("direct:noDynamicityExplicit", body, headers);
 
-        b = testCollection.findOne("testInsertDynamicityDisabledExplicitly");
+        b = testCollection.find(new BasicDBObject("_id", "testInsertDynamicityDisabledExplicitly")).first();
         assertNotNull("No record with 'testInsertDynamicityDisabledExplicitly' _id", b);
         
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
 
     }
     
     @Test
     public void testInsertDynamicityEnabledDBOnly() {
         assertEquals(0, testCollection.count());
-        mongo.getDB("otherDB").dropDatabase();
+        mongo.getDatabase("otherDB").drop();
         db.getCollection("otherCollection").drop();
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
 
         String body = "{\"_id\": \"testInsertDynamicityEnabledDBOnly\", \"a\" : \"1\"}";
         Map<String, Object> headers = new HashMap<String, Object>();
         headers.put(MongoDbConstants.DATABASE, "otherDB");
         Object result = template.requestBodyAndHeaders("direct:dynamicityEnabled", body, headers);
         
-        DBCollection dynamicCollection = mongo.getDB("otherDB").getCollection(testCollection.getName());
-        
-        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledDBOnly");
+        MongoCollection<BasicDBObject> dynamicCollection = mongo.getDatabase("otherDB").getCollection(testCollection.getNamespace().getCollectionName(), BasicDBObject.class);
+
+        DBObject b = dynamicCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledDBOnly")).first();
         assertNotNull("No record with 'testInsertDynamicityEnabledDBOnly' _id", b);
-        
-        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
+
+        b = testCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledDBOnly")).first();
         assertNull("There is a record with 'testInsertDynamicityEnabledDBOnly' _id in the test collection", b);
         
-        assertTrue("The otherDB database should exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertTrue("The otherDB database should exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
         
     }
     
     @Test
     public void testInsertDynamicityEnabledCollectionOnly() {
         assertEquals(0, testCollection.count());
-        mongo.getDB("otherDB").dropDatabase();
+        mongo.getDatabase("otherDB").drop();
         db.getCollection("otherCollection").drop();
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
 
         String body = "{\"_id\": \"testInsertDynamicityEnabledCollectionOnly\", \"a\" : \"1\"}";
         Map<String, Object> headers = new HashMap<String, Object>();
         headers.put(MongoDbConstants.COLLECTION, "otherCollection");
         Object result = template.requestBodyAndHeaders("direct:dynamicityEnabled", body, headers);
         
-        DBCollection dynamicCollection = db.getCollection("otherCollection");
-        
-        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledCollectionOnly");
+        MongoCollection<BasicDBObject> dynamicCollection = db.getCollection("otherCollection", BasicDBObject.class);
+
+        DBObject b = dynamicCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledCollectionOnly")).first();
         assertNotNull("No record with 'testInsertDynamicityEnabledCollectionOnly' _id", b);
-        
-        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
+
+        b = testCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledDBOnly")).first();
         assertNull("There is a record with 'testInsertDynamicityEnabledCollectionOnly' _id in the test collection", b);
         
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
     }
     
     @Test
     public void testInsertDynamicityEnabledDBAndCollection() {
         assertEquals(0, testCollection.count());
-        mongo.getDB("otherDB").dropDatabase();
+        mongo.getDatabase("otherDB").drop();
         db.getCollection("otherCollection").drop();
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
 
         String body = "{\"_id\": \"testInsertDynamicityEnabledDBAndCollection\", \"a\" : \"1\"}";
         Map<String, Object> headers = new HashMap<String, Object>();
@@ -115,15 +132,17 @@ public class MongoDbDynamicityTest extends AbstractMongoDbTest {
         headers.put(MongoDbConstants.COLLECTION, "otherCollection");
         Object result = template.requestBodyAndHeaders("direct:dynamicityEnabled", body, headers);
         
-        DBCollection dynamicCollection = mongo.getDB("otherDB").getCollection("otherCollection");
-        
-        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledDBAndCollection");
+        MongoCollection<BasicDBObject> dynamicCollection = mongo.getDatabase("otherDB").getCollection("otherCollection", BasicDBObject.class);
+
+        DBObject b = dynamicCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledDBAndCollection")).first();
         assertNotNull("No record with 'testInsertDynamicityEnabledDBAndCollection' _id", b);
-        
-        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
+
+        b = testCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledDBOnly")).first();
         assertNull("There is a record with 'testInsertDynamicityEnabledDBAndCollection' _id in the test collection", b);
         
-        assertTrue("The otherDB database should exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertTrue("The otherDB database should exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/de1fa976/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbHeaderHandlingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbHeaderHandlingTest.java b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbHeaderHandlingTest.java
index 70dba34..03ee365 100644
--- a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbHeaderHandlingTest.java
+++ b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbHeaderHandlingTest.java
@@ -58,7 +58,7 @@ public class MongoDbHeaderHandlingTest extends AbstractMongoDbTest {
         //TODO: WriteResult isn't return when inserting
         //assertTrue(result.getOut().getBody() instanceof WriteResult);
         assertEquals("An input header was not returned", "def", result.getOut().getHeader("abc"));
-        DBObject b = testCollection.findOne("testInsertString");
+        DBObject b = testCollection.find(new BasicDBObject("_id", "testInsertString")).first();
         assertNotNull("No record with 'testInsertString' _id", b);
     }
     
@@ -72,7 +72,7 @@ public class MongoDbHeaderHandlingTest extends AbstractMongoDbTest {
         assertEquals("Number of records persisted must be 2", 2, testCollection.count());
         
         // Testing the save logic
-        final DBObject record1 = testCollection.findOne("testSave1");
+        final DBObject record1 = testCollection.find(new BasicDBObject("_id", "testSave1")).first();
         assertEquals("Scientist field of 'testSave1' must equal 'Einstein'", "Einstein", record1.get("scientist"));
         record1.put("scientist", "Darwin");
         
@@ -87,7 +87,7 @@ public class MongoDbHeaderHandlingTest extends AbstractMongoDbTest {
         assertTrue(resultExch.getOut().getBody().equals(record1));
         assertTrue(resultExch.getOut().getHeader(MongoDbConstants.WRITERESULT) instanceof UpdateResult);
 
-        DBObject record2 = testCollection.findOne("testSave1");
+        DBObject record2 = testCollection.find(new BasicDBObject("_id", "testSave1")).first();
         assertEquals("Scientist field of 'testSave1' must equal 'Darwin' after save operation", "Darwin", record2.get("scientist"));
 
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/de1fa976/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbIndexTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbIndexTest.java b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbIndexTest.java
index fa39309..1309a0b 100644
--- a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbIndexTest.java
+++ b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbIndexTest.java
@@ -20,12 +20,18 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.StreamSupport;
 
 import com.mongodb.BasicDBObject;
 import com.mongodb.DBCollection;
 import com.mongodb.DBObject;
 import com.mongodb.WriteResult;
+import com.mongodb.client.ListIndexesIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+
 import org.apache.camel.builder.RouteBuilder;
+import org.bson.Document;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -34,9 +40,11 @@ public class MongoDbIndexTest extends AbstractMongoDbTest {
     @Test
     public void testInsertDynamicityEnabledDBAndCollectionAndIndex() {
         assertEquals(0, testCollection.count());
-        mongo.getDB("otherDB").dropDatabase();
+        mongo.getDatabase("otherDB").drop();
         db.getCollection("otherCollection").drop();
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
 
         String body = "{\"_id\": \"testInsertDynamicityEnabledDBAndCollection\", \"a\" : 1, \"b\" : 2}";
         Map<String, Object> headers = new HashMap<String, Object>();
@@ -50,37 +58,44 @@ public class MongoDbIndexTest extends AbstractMongoDbTest {
         index2.put("b", -1);
         objIndex.add(index1);
         objIndex.add(index2);
+
         headers.put(MongoDbConstants.COLLECTION_INDEX, objIndex);
 
         Object result = template.requestBodyAndHeaders("direct:dynamicityEnabled", body, headers);
 
         assertEquals("Response isn't of type WriteResult", BasicDBObject.class, result.getClass());
 
-        DBCollection dynamicCollection = mongo.getDB("otherDB").getCollection("otherCollection");
+        MongoCollection<BasicDBObject> dynamicCollection = mongo.getDatabase("otherDB").getCollection("otherCollection", BasicDBObject.class);
 
-        List<DBObject> indexInfos = dynamicCollection.getIndexInfo();
+        ListIndexesIterable<DBObject> indexInfos = dynamicCollection.listIndexes(DBObject.class);
 
-        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");
-        BasicDBObject key2 = (BasicDBObject) indexInfos.get(2).get("key");
+        MongoCursor<DBObject> iterator = indexInfos.iterator();
+        iterator.next();
+        BasicDBObject key1 = (BasicDBObject) iterator.next().get("key");
+        BasicDBObject key2 = (BasicDBObject) iterator.next().get("key");
 
         assertTrue("No index on the field a", key1.containsField("a") && "1".equals(key1.getString("a")));
         assertTrue("No index on the field b", key2.containsField("b") && "-1".equals(key2.getString("b")));
 
-        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledDBAndCollection");
+        DBObject b = dynamicCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledDBAndCollection")).first();
         assertNotNull("No record with 'testInsertDynamicityEnabledDBAndCollection' _id", b);
 
-        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
+        b = testCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledDBOnly")).first();
         assertNull("There is a record with 'testInsertDynamicityEnabledDBAndCollection' _id in the test collection", b);
 
-        assertTrue("The otherDB database should exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertTrue("The otherDB database should exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
     }
 
     @Test
     public void testInsertDynamicityEnabledCollectionAndIndex() {
         assertEquals(0, testCollection.count());
-        mongo.getDB("otherDB").dropDatabase();
+        mongo.getDatabase("otherDB").drop();
         db.getCollection("otherCollection").drop();
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
 
         String body = "{\"_id\": \"testInsertDynamicityEnabledCollectionAndIndex\", \"a\" : 1, \"b\" : 2}";
         Map<String, Object> headers = new HashMap<String, Object>();
@@ -99,31 +114,34 @@ public class MongoDbIndexTest extends AbstractMongoDbTest {
 
         assertEquals("Response isn't of type WriteResult", BasicDBObject.class, result.getClass());
 
-        DBCollection dynamicCollection = db.getCollection("otherCollection");
+        MongoCollection<BasicDBObject> dynamicCollection = db.getCollection("otherCollection", BasicDBObject.class);
 
-        List<DBObject> indexInfos = dynamicCollection.getIndexInfo();
+        MongoCursor<BasicDBObject> indexInfos = dynamicCollection.listIndexes(BasicDBObject.class).iterator();
 
-        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");
-        BasicDBObject key2 = (BasicDBObject) indexInfos.get(2).get("key");
+        indexInfos.next();
+        BasicDBObject key1 = (BasicDBObject) indexInfos.next().get("key");
+        BasicDBObject key2 = (BasicDBObject) indexInfos.next().get("key");
 
         assertTrue("No index on the field a", key1.containsField("a") && "1".equals(key1.getString("a")));
         assertTrue("No index on the field b", key2.containsField("b") && "-1".equals(key2.getString("b")));
 
-        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledCollectionAndIndex");
+        DBObject b = dynamicCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledCollectionAndIndex")).first();
         assertNotNull("No record with 'testInsertDynamicityEnabledCollectionAndIndex' _id", b);
 
-        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
+        b = testCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledDBOnly")).first();
         assertNull("There is a record with 'testInsertDynamicityEnabledDBAndCollection' _id in the test collection", b);
 
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist", mongo.getUsedDatabases().contains("otherDB"));
     }
 
     @Test
     public void testInsertDynamicityEnabledCollectionOnlyAndURIIndex() {
         assertEquals(0, testCollection.count());
-        mongo.getDB("otherDB").dropDatabase();
+        mongo.getDatabase("otherDB").drop();
         db.getCollection("otherCollection").drop();
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
 
         String body = "{\"_id\": \"testInsertDynamicityEnabledCollectionOnlyAndURIIndex\", \"a\" : 1, \"b\" : 2}";
         Map<String, Object> headers = new HashMap<String, Object>();
@@ -133,28 +151,30 @@ public class MongoDbIndexTest extends AbstractMongoDbTest {
 
         assertEquals("Response isn't of type WriteResult", BasicDBObject.class, result.getClass());
 
-        DBCollection dynamicCollection = db.getCollection("otherCollection");
+        MongoCollection<BasicDBObject> dynamicCollection = db.getCollection("otherCollection", BasicDBObject.class);
 
-        List<DBObject> indexInfos = dynamicCollection.getIndexInfo();
+        MongoCursor<Document> indexInfos = dynamicCollection.listIndexes().iterator();
 
-        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");
+        Document key1 = (Document) indexInfos.next().get("key");
 
-        assertFalse("No index on the field a", key1.containsField("a") && "-1".equals(key1.getString("a")));
+        assertFalse("No index on the field a", key1.containsKey("a") && "-1".equals(key1.getString("a")));
 
-        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledCollectionOnlyAndURIIndex");
+        DBObject b = dynamicCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledCollectionOnlyAndURIIndex")).first();
         assertNotNull("No record with 'testInsertDynamicityEnabledCollectionOnlyAndURIIndex' _id", b);
 
-        b = testCollection.findOne("testInsertDynamicityEnabledCollectionOnlyAndURIIndex");
+        b = testCollection.find(new BasicDBObject("_id", "testInsertDynamicityEnabledCollectionOnlyAndURIIndex")).first();
         assertNull("There is a record with 'testInsertDynamicityEnabledCollectionOnlyAndURIIndex' _id in the test collection", b);
 
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
     }
 
     @Ignore
     @Test
     public void testInsertAutoCreateCollectionAndURIIndex() {
         assertEquals(0, testCollection.count());
-        db.getCollection("otherCollection").remove(new BasicDBObject());
+        db.getCollection("otherCollection").deleteOne(new BasicDBObject());
 
         String body = "{\"_id\": \"testInsertAutoCreateCollectionAndURIIndex\", \"a\" : 1, \"b\" : 2}";
         Map<String, Object> headers = new HashMap<String, Object>();
@@ -162,22 +182,24 @@ public class MongoDbIndexTest extends AbstractMongoDbTest {
         Object result = template.requestBodyAndHeaders("direct:dynamicityDisabled", body, headers);
         assertEquals("Response isn't of type WriteResult", WriteResult.class, result.getClass());
 
-        DBCollection collection = db.getCollection("otherCollection");
-        List<DBObject> indexInfos = collection.getIndexInfo();
+        MongoCollection<BasicDBObject> collection = db.getCollection("otherCollection", BasicDBObject.class);
+        MongoCursor<Document> indexInfos = collection.listIndexes().iterator();
 
-        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");
-        BasicDBObject key2 = (BasicDBObject) indexInfos.get(2).get("key");
+        BasicDBObject key1 = (BasicDBObject) indexInfos.next().get("key");
+        BasicDBObject key2 = (BasicDBObject) indexInfos.next().get("key");
 
         assertTrue("No index on the field b", key1.containsField("b") && "-1".equals(key1.getString("b")));
         assertTrue("No index on the field a", key2.containsField("a") && "1".equals(key2.getString("a")));
 
-        DBObject b = collection.findOne("testInsertAutoCreateCollectionAndURIIndex");
+        DBObject b = collection.find(new BasicDBObject("_id", "testInsertAutoCreateCollectionAndURIIndex")).first();
         assertNotNull("No record with 'testInsertAutoCreateCollectionAndURIIndex' _id", b);
 
-        b = testCollection.findOne("testInsertAutoCreateCollectionAndURIIndex");
+        b = testCollection.find(new BasicDBObject("_id", "testInsertAutoCreateCollectionAndURIIndex")).first();
         assertNull("There is a record with 'testInsertAutoCreateCollectionAndURIIndex' _id in the test collection", b);
 
-        assertFalse("The otherDB database should not exist", mongo.getDatabaseNames().contains("otherDB"));
+        assertFalse("The otherDB database should not exist",
+                StreamSupport.stream(mongo.listDatabaseNames().spliterator(), false)
+                        .anyMatch("otherDB"::equals));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/de1fa976/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbOperationsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbOperationsTest.java b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbOperationsTest.java
index 7878ff4..3fa9b25 100644
--- a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbOperationsTest.java
+++ b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbOperationsTest.java
@@ -44,14 +44,14 @@ public class MongoDbOperationsTest extends AbstractMongoDbTest {
         assertEquals("Test collection should not contain any records", 0L, result);
 
         // Insert a record and test that the endpoint now returns 1
-        testCollection.insert((DBObject) JSON.parse("{a:60}"));
+        testCollection.insertOne((BasicDBObject) JSON.parse("{a:60}"));
         result = template.requestBody("direct:count", "irrelevantBody");
         assertTrue("Result is not of type Long", result instanceof Long);
         assertEquals("Test collection should contain 1 record", 1L, result);
-        testCollection.remove(new BasicDBObject());
+        testCollection.deleteOne(new BasicDBObject());
         
         // test dynamicity
-        dynamicCollection.insert((DBObject) JSON.parse("{a:60}"));
+        dynamicCollection.insertOne((BasicDBObject) JSON.parse("{a:60}"));
         result = template.requestBodyAndHeader("direct:count", "irrelevantBody", MongoDbConstants.COLLECTION, dynamicCollectionName);
         assertTrue("Result is not of type Long", result instanceof Long);
         assertEquals("Dynamic collection should contain 1 record", 1L, result);
@@ -63,7 +63,7 @@ public class MongoDbOperationsTest extends AbstractMongoDbTest {
         assertEquals(0, testCollection.count());
         Object result = template.requestBody("direct:insert", "{\"_id\":\"testInsertString\", \"scientist\":\"Einstein\"}");
         assertTrue(result instanceof BasicDBObject);
-        DBObject b = testCollection.findOne("testInsertString");
+        DBObject b = testCollection.find(new BasicDBObject("_id", "testInsertString")).first();
         assertNotNull("No record with 'testInsertString' _id", b);
     }
 
@@ -93,14 +93,14 @@ public class MongoDbOperationsTest extends AbstractMongoDbTest {
         assertEquals("Number of records persisted must be 2", 2, testCollection.count());
         
         // Testing the save logic
-        DBObject record1 = testCollection.findOne("testSave1");
+        DBObject record1 = testCollection.find(new BasicDBObject("_id", "testSave1")).first();
         assertEquals("Scientist field of 'testSave1' must equal 'Einstein'", "Einstein", record1.get("scientist"));
         record1.put("scientist", "Darwin");
         
         result = template.requestBody("direct:save", record1);
         assertTrue(result instanceof UpdateResult);
         
-        record1 = testCollection.findOne("testSave1");
+        record1 = testCollection.find(new BasicDBObject("_id", "testSave1")).first();
         assertEquals("Scientist field of 'testSave1' must equal 'Darwin' after save operation", "Darwin", record1.get("scientist"));
 
     }
@@ -130,7 +130,7 @@ public class MongoDbOperationsTest extends AbstractMongoDbTest {
         assertEquals(100L, testCollection.count());
         
         // Testing the update logic
-        DBObject extraField = new BasicDBObject("extraField", true);
+        BasicDBObject extraField = new BasicDBObject("extraField", true);
         assertEquals("Number of records with 'extraField' flag on must equal 50", 50L, testCollection.count(extraField));
         assertEquals("Number of records with 'scientist' field = Darwin on must equal 0", 0, testCollection.count(new BasicDBObject("scientist", "Darwin")));
 
@@ -162,7 +162,7 @@ public class MongoDbOperationsTest extends AbstractMongoDbTest {
         assertEquals(100L, testCollection.count());
         
         // Testing the update logic
-        DBObject extraField = new BasicDBObject("extraField", true);
+        BasicDBObject extraField = new BasicDBObject("extraField", true);
         assertEquals("Number of records with 'extraField' flag on must equal 50", 50L, testCollection.count(extraField));
         
         Object result = template.requestBody("direct:remove", extraField);

http://git-wip-us.apache.org/repos/asf/camel/blob/de1fa976/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbTailableCursorConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbTailableCursorConsumerTest.java b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbTailableCursorConsumerTest.java
index 6aebbb4..e45e18c 100644
--- a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbTailableCursorConsumerTest.java
+++ b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbTailableCursorConsumerTest.java
@@ -23,6 +23,8 @@ import com.mongodb.BasicDBObjectBuilder;
 import com.mongodb.DBCollection;
 import com.mongodb.DBObject;
 import com.mongodb.WriteConcern;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.CreateCollectionOptions;
 
 import org.apache.camel.ServiceStatus;
 import org.apache.camel.builder.RouteBuilder;
@@ -32,7 +34,7 @@ import org.junit.Test;
 
 public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
     
-    private DBCollection cappedTestCollection;
+    private MongoCollection<BasicDBObject> cappedTestCollection;
     private String cappedTestCollectionName;
     
     @Test
@@ -50,10 +52,15 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         assertEquals(0, cappedTestCollection.count());
         MockEndpoint mock = getMockEndpoint("mock:test");
         mock.expectedMessageCount(0);
-       
+        //BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
         // create a capped collection with max = 1000
-        cappedTestCollection = db.createCollection(cappedTestCollectionName, 
-                BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get());
+        CreateCollectionOptions collectionOptions = new CreateCollectionOptions()
+                .capped(true)
+                .sizeInBytes(1000000000)
+                .maxDocuments(1000);
+        db.createCollection(cappedTestCollectionName,
+                collectionOptions);
+        cappedTestCollection = db.getCollection(cappedTestCollectionName, BasicDBObject.class);
         assertEquals(0, cappedTestCollection.count());
 
         addTestRoutes();
@@ -69,11 +76,15 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         assertEquals(0, cappedTestCollection.count());
         MockEndpoint mock = getMockEndpoint("mock:test");
         mock.expectedMessageCount(5000);
-       
+        //BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
         // create a capped collection with max = 1000
-        cappedTestCollection = db.createCollection(cappedTestCollectionName, 
-                BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get());
-        
+        CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions()
+                .capped(true)
+                .sizeInBytes(1000000000)
+                .maxDocuments(1000);
+        db.createCollection(cappedTestCollectionName,
+                createCollectionOptions);
+        cappedTestCollection = db.getCollection(cappedTestCollectionName, BasicDBObject.class);
         addTestRoutes();
         context.startRoute("tailableCursorConsumer1");
         
@@ -89,7 +100,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
                             return;
                         }
                     }
-                    cappedTestCollection.insert(BasicDBObjectBuilder.start("increasing", i).add("string", "value" + i).get(), WriteConcern.SAFE);
+                    cappedTestCollection.insertOne(new BasicDBObject("increasing", i).append("string", "value" + i));
                 }
                 
             }
@@ -112,9 +123,13 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         mock.expectedMessageCount(1000);
        
         // create a capped collection with max = 1000
-        cappedTestCollection = db.createCollection(cappedTestCollectionName, 
-                BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get());
-        
+        //BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get())
+        db.createCollection(cappedTestCollectionName,
+                new CreateCollectionOptions()
+                        .capped(true)
+                        .sizeInBytes(1000000000)
+                        .maxDocuments(100));
+        cappedTestCollection = db.getCollection(cappedTestCollectionName, BasicDBObject.class);
         addTestRoutes();
         context.startRoute("tailableCursorConsumer1");
         
@@ -123,7 +138,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
             @Override
             public void run() {
                 for (int i = 1; i <= 100000; i++) {
-                    cappedTestCollection.insert(BasicDBObjectBuilder.start("increasing", i).add("string", "value" + i).get(), WriteConcern.SAFE);
+                    cappedTestCollection.insertOne(new BasicDBObject("increasing", i).append("string", "value" + i));
                     
                     // incrementally assert, as the mock endpoint stores all messages and otherwise the test would be sluggish
                     if (i % 1000 == 0) {
@@ -154,10 +169,12 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         // drop the tracking collection
         db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION).drop();
         // create a capped collection with max = 1000
-        cappedTestCollection = db.createCollection(cappedTestCollectionName, 
-                BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get());
-        cappedTestCollection.createIndex("increasing");
-        
+        // BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
+        db.createCollection(cappedTestCollectionName,
+                new CreateCollectionOptions().capped(true).sizeInBytes(1000000000).maxDocuments(1000));
+        cappedTestCollection = db.getCollection(cappedTestCollectionName, BasicDBObject.class);
+        cappedTestCollection.createIndex(new BasicDBObject("increasing", 1));
+
         addTestRoutes();
         context.startRoute("tailableCursorConsumer2");
         
@@ -167,7 +184,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
             @Override
             public void run() {
                 for (int i = 1; i <= 300; i++) {
-                    cappedTestCollection.insert(BasicDBObjectBuilder.start("increasing", i).add("string", "value" + i).get(), WriteConcern.SAFE);  
+                    cappedTestCollection.insertOne(new BasicDBObject("increasing", i).append("string", "value" + i));
                 }
             }
         });
@@ -189,7 +206,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
             @Override
             public void run() {
                 for (int i = 301; i <= 600; i++) {
-                    cappedTestCollection.insert(BasicDBObjectBuilder.start("increasing", i).add("string", "value" + i).get(), WriteConcern.SAFE);  
+                    cappedTestCollection.insertOne(new BasicDBObject("increasing", i).append("string", "value" + i));
                 }
             }
         });
@@ -205,11 +222,11 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         assertEquals(301, ((DBObject) firstBody).get("increasing"));
         
         // check that the lastVal is persisted at the right time: check before and after stopping the route
-        assertEquals(300, db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION).findOne(new BasicDBObject("persistentId", "darwin")).get("lastTrackingValue"));
+        assertEquals(300, db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION).find(new BasicDBObject("persistentId", "darwin")).first().get("lastTrackingValue"));
         // stop the route and verify the last value has been updated
         context.stopRoute("tailableCursorConsumer2");
         while (context.getRouteStatus("tailableCursorConsumer2") != ServiceStatus.Stopped) { }
-        assertEquals(600, db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION).findOne(new BasicDBObject("persistentId", "darwin")).get("lastTrackingValue"));
+        assertEquals(600, db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION).find(new BasicDBObject("persistentId", "darwin")).first().get("lastTrackingValue"));
 
     }
     
@@ -220,14 +237,15 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         final Calendar startTimestamp = Calendar.getInstance();
         
         // get default tracking collection
-        DBCollection trackingCol = db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION);
+        MongoCollection<BasicDBObject> trackingCol = db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION, BasicDBObject.class);
         trackingCol.drop();
-        trackingCol = db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION);
+        trackingCol = db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION, BasicDBObject.class);
         
         // create a capped collection with max = 1000
-        cappedTestCollection = db.createCollection(cappedTestCollectionName, 
-                BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get());
-        
+        //BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
+        db.createCollection(cappedTestCollectionName,
+                new CreateCollectionOptions().capped(true).sizeInBytes(1000000000).maxDocuments(1000));
+        cappedTestCollection = db.getCollection(cappedTestCollectionName, BasicDBObject.class);
         addTestRoutes();
         context.startRoute("tailableCursorConsumer2");
         
@@ -239,7 +257,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
                 for (int i = 1; i <= 300; i++) {
                     Calendar c = (Calendar) (startTimestamp.clone());
                     c.add(Calendar.MINUTE, i);
-                    cappedTestCollection.insert(BasicDBObjectBuilder.start("increasing", c.getTime()).add("string", "value" + i).get(), WriteConcern.SAFE);
+                    cappedTestCollection.insertOne(new BasicDBObject("increasing", c.getTime()).append("string", "value" + i));
                 }
             }
         });
@@ -254,7 +272,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         Calendar cal300 = (Calendar) startTimestamp.clone();
         cal300.add(Calendar.MINUTE, 300);
         context.stopRoute("tailableCursorConsumer2");
-        assertEquals(cal300.getTime(), trackingCol.findOne(new BasicDBObject("persistentId", "darwin")).get(MongoDbTailTrackingConfig.DEFAULT_FIELD));
+        assertEquals(cal300.getTime(), trackingCol.find(new BasicDBObject("persistentId", "darwin")).first().get(MongoDbTailTrackingConfig.DEFAULT_FIELD));
         context.startRoute("tailableCursorConsumer2");
         
         // expect 300 messages and not 600
@@ -266,7 +284,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
                 for (int i = 301; i <= 600; i++) {
                     Calendar c = (Calendar) (startTimestamp.clone());
                     c.add(Calendar.MINUTE, i);
-                    cappedTestCollection.insert(BasicDBObjectBuilder.start("increasing", c.getTime()).add("string", "value" + i).get(), WriteConcern.SAFE);
+                    cappedTestCollection.insertOne(new BasicDBObject("increasing", c.getTime()).append("string", "value" + i));
                 }
             }
         });
@@ -284,7 +302,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         context.stopRoute("tailableCursorConsumer2");
         Calendar cal600 = (Calendar) startTimestamp.clone();
         cal600.add(Calendar.MINUTE, 600);
-        assertEquals(cal600.getTime(), trackingCol.findOne(new BasicDBObject("persistentId", "darwin")).get(MongoDbTailTrackingConfig.DEFAULT_FIELD));
+        assertEquals(cal600.getTime(), trackingCol.find(new BasicDBObject("persistentId", "darwin")).first().get(MongoDbTailTrackingConfig.DEFAULT_FIELD));
     }
     
     @Test
@@ -293,14 +311,15 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         final MockEndpoint mock = getMockEndpoint("mock:test");
         
         // get the custom tracking collection and drop it (tailTrackDb=einstein&tailTrackCollection=curie&tailTrackField=newton)
-        DBCollection trackingCol = mongo.getDB("einstein").getCollection("curie");
+        MongoCollection<BasicDBObject> trackingCol = mongo.getDatabase("einstein").getCollection("curie", BasicDBObject.class);
         trackingCol.drop();
-        trackingCol = mongo.getDB("einstein").getCollection("curie");
+        trackingCol = mongo.getDatabase("einstein").getCollection("curie", BasicDBObject.class);
         
         // create a capped collection with max = 1000
-        cappedTestCollection = db.createCollection(cappedTestCollectionName, 
-                BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get());
-        
+        //BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
+        db.createCollection(cappedTestCollectionName,
+                new CreateCollectionOptions().capped(true).sizeInBytes(1000000000).maxDocuments(1000));
+        cappedTestCollection = db.getCollection(cappedTestCollectionName, BasicDBObject.class);
         addTestRoutes();
         context.startRoute("tailableCursorConsumer3");
         
@@ -310,7 +329,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
             @Override
             public void run() {
                 for (int i = 1; i <= 300; i++) {
-                    cappedTestCollection.insert(BasicDBObjectBuilder.start("increasing", i).add("string", "value" + i).get(), WriteConcern.SAFE);  
+                    cappedTestCollection.insertOne(new BasicDBObject("increasing", i).append("string", "value" + i));
                 }
             }
         });
@@ -325,7 +344,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         // stop the route to ensure that our lastVal is persisted, and check it
         context.stopRoute("tailableCursorConsumer3");
         // ensure that the persisted lastVal is 300, newton is the name of the trackingField we are using
-        assertEquals(300, trackingCol.findOne(new BasicDBObject("persistentId", "darwin")).get("newton"));
+        assertEquals(300, trackingCol.find(new BasicDBObject("persistentId", "darwin")).first().get("newton"));
         context.startRoute("tailableCursorConsumer3");
         
         // expect 300 messages and not 600
@@ -335,7 +354,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
             @Override
             public void run() {
                 for (int i = 301; i <= 600; i++) {
-                    cappedTestCollection.insert(BasicDBObjectBuilder.start("increasing", i).add("string", "value" + i).get(), WriteConcern.SAFE);  
+                    cappedTestCollection.insertOne(new BasicDBObject("increasing", i).append("string", "value" + i));
                 }
             }
         });
@@ -350,7 +369,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         assertEquals(301, ((DBObject) firstBody).get("increasing"));
         // check that the persisted lastVal after stopping the route is 600, newton is the name of the trackingField we are using
         context.stopRoute("tailableCursorConsumer3");
-        assertEquals(600, trackingCol.findOne(new BasicDBObject("persistentId", "darwin")).get("newton"));
+        assertEquals(600, trackingCol.find(new BasicDBObject("persistentId", "darwin")).first().get("newton"));
 
     }
     
@@ -365,11 +384,15 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         mock.expectedMessageCount(1000);
        
         // create a capped collection with max = 1000
-        cappedTestCollection = db.createCollection(cappedTestCollectionName, 
-                BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get());
-        
+        //BasicDBObjectBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
+        db.createCollection(cappedTestCollectionName,
+                new CreateCollectionOptions()
+                        .capped(true)
+                        .sizeInBytes(1000000000)
+                        .maxDocuments(1000));
+        cappedTestCollection = db.getCollection(cappedTestCollectionName, BasicDBObject.class);
         for (int i = 0; i < 1000; i++) {
-            cappedTestCollection.insert(BasicDBObjectBuilder.start("increasing", i).add("string", "value" + i).get(), WriteConcern.SAFE);
+            cappedTestCollection.insertOne(new BasicDBObject("increasing", i).append("string", "value" + i));
         }
         assertEquals(1000, cappedTestCollection.count());
 
@@ -385,7 +408,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         super.doPostSetup();
         // drop the capped collection and let each test create what it needs
         cappedTestCollectionName = "camelTestCapped";
-        cappedTestCollection = db.getCollection(cappedTestCollectionName);
+        cappedTestCollection = db.getCollection(cappedTestCollectionName, BasicDBObject.class);
         cappedTestCollection.drop();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/de1fa976/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbWriteConcernsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbWriteConcernsTest.java b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbWriteConcernsTest.java
index efb428f..45cfbb0 100644
--- a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbWriteConcernsTest.java
+++ b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/MongoDbWriteConcernsTest.java
@@ -32,13 +32,13 @@ public class MongoDbWriteConcernsTest extends AbstractMongoDbTest {
         assertEquals(0, testCollection.count());
         
         // test with object first
-        Object result = template.requestBodyAndHeader("direct:noWriteConcern", "{\"scientist\":\"newton\"}", MongoDbConstants.WRITECONCERN, WriteConcern.SAFE);
+        Object result = template.requestBody("direct:noWriteConcern", "{\"scientist\":\"newton\"}");
         assertTrue("Result is not of type WriteResult", result instanceof WriteResult);
         WriteResult wr = (WriteResult) result;
         assertTrue(wr.wasAcknowledged());
         
         // same behaviour should be reproduced with String 'SAFE'
-        result = template.requestBodyAndHeader("direct:noWriteConcern", "{\"scientist\":\"newton\"}", MongoDbConstants.WRITECONCERN, "SAFE");
+        result = template.requestBody("direct:noWriteConcern", "{\"scientist\":\"newton\"}");
         assertTrue("Result is not of type WriteResult", result instanceof WriteResult);
         wr = (WriteResult) result;
         assertTrue(wr.wasAcknowledged());


Mime
View raw message