You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2016/12/18 09:07:24 UTC

[08/13] camel git commit: CAMEL-10554 - Camel Mongodb evolution to driver 3. Fixed CS

http://git-wip-us.apache.org/repos/asf/camel/blob/5715fce7/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbOutputTypeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbOutputTypeTest.java b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbOutputTypeTest.java
index 7ac2af9..a2a0c9a 100644
--- a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbOutputTypeTest.java
+++ b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbOutputTypeTest.java
@@ -16,24 +16,23 @@
  */
 package org.apache.camel.component.mongodb3;
 
-import static org.apache.camel.component.mongodb3.MongoDbConstants.MONGO_ID;
-
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.mongodb.client.MongoIterable;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mongodb3.MongoDbConstants;
 import org.apache.commons.lang3.ObjectUtils;
 import org.bson.Document;
 import org.junit.Test;
 
-import com.mongodb.client.MongoIterable;
+import static org.apache.camel.component.mongodb3.MongoDbConstants.MONGO_ID;
 
 public class MongoDbOutputTypeTest extends AbstractMongoDbTest {
 
-	@Test
+    @Test
     public void testFindAllDBCursor() {
         // Test that the collection has 0 documents in it
         assertEquals(0, testCollection.count());
@@ -49,7 +48,7 @@ public class MongoDbOutputTypeTest extends AbstractMongoDbTest {
             assertTrue("Result is not of type MongoIterable", result instanceof MongoIterable);
 
             @SuppressWarnings("unchecked")
-			MongoIterable<Document> resultCursor = (MongoIterable<Document>) result;
+            MongoIterable<Document> resultCursor = (MongoIterable<Document>)result;
             // Ensure that all returned documents contain all fields
             for (Document document : resultCursor) {
                 assertNotNull("Document in returned list should contain all fields", document.get(MONGO_ID));
@@ -69,7 +68,7 @@ public class MongoDbOutputTypeTest extends AbstractMongoDbTest {
         Object result = template.requestBody("direct:findAllDocumentList", ObjectUtils.NULL);
         assertTrue("Result is not of type List", result instanceof List);
         @SuppressWarnings("unchecked")
-        List<Document> resultList = (List<Document>) result;
+        List<Document> resultList = (List<Document>)result;
 
         assertListSize("Result does not contain 1000 elements", resultList, 1000);
 
@@ -91,7 +90,8 @@ public class MongoDbOutputTypeTest extends AbstractMongoDbTest {
             RouteBuilder taillableRouteBuilder = new RouteBuilder() {
                 @Override
                 public void configure() throws Exception {
-                    from("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.testCollection}}&operation=findById&dynamicity=true&outputType=MongoIterable").to("mock:dummy");
+                    from("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.testCollection}}&operation=findById&dynamicity=true&outputType=MongoIterable")
+                        .to("mock:dummy");
                 }
             };
             template.getCamelContext().addRoutes(taillableRouteBuilder);
@@ -108,9 +108,7 @@ public class MongoDbOutputTypeTest extends AbstractMongoDbTest {
                 @Override
                 public void configure() throws Exception {
                     from("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.cappedTestCollection}}&tailTrackIncreasingField=increasing&outputType=MongoIterable")
-                            .id("tailableCursorConsumer1")
-                            .autoStartup(false)
-                            .to("mock:test");
+                        .id("tailableCursorConsumer1").autoStartup(false).to("mock:test");
                 }
             };
             template.getCamelContext().addRoutes(taillableRouteBuilder);
@@ -126,11 +124,10 @@ public class MongoDbOutputTypeTest extends AbstractMongoDbTest {
             public void configure() {
 
                 from("direct:findAllDBCursor")
-                        .to("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.testCollection}}&operation=findAll&dynamicity=true&outputType=MongoIterable")
-                        .to("mock:resultFindAllDBCursor");
-                from("direct:findAllDocumentList")
-                        .to("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.testCollection}}&operation=findAll&outputType=DocumentList")
-                        .to("mock:resultFindAllDocumentList");
+                    .to("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.testCollection}}&operation=findAll&dynamicity=true&outputType=MongoIterable")
+                    .to("mock:resultFindAllDBCursor");
+                from("direct:findAllDocumentList").to("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.testCollection}}&operation=findAll&outputType=DocumentList")
+                    .to("mock:resultFindAllDocumentList");
 
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/5715fce7/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbReadPreferenceOptionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbReadPreferenceOptionTest.java b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbReadPreferenceOptionTest.java
index 55f40ea..0d0c1e7 100644
--- a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbReadPreferenceOptionTest.java
+++ b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbReadPreferenceOptionTest.java
@@ -16,76 +16,74 @@
  */
 package org.apache.camel.component.mongodb3;
 
+import com.mongodb.ReadPreference;
+
 import org.apache.camel.Endpoint;
 import org.apache.camel.ResolveEndpointFailedException;
-import org.apache.camel.component.mongodb3.MongoDbEndpoint;
 import org.junit.Test;
 
-import com.mongodb.ReadPreference;
-
 public class MongoDbReadPreferenceOptionTest extends AbstractMongoDbTest {
 
-	private MongoDbEndpoint endpoint;
+    private MongoDbEndpoint endpoint;
 
-	@Test
-	public void testInvalidReadPreferenceOptionValue() throws Exception {
-		try {
-			createMongoDbEndpoint("mongodb3:myDb?database={{mongodb.testDb}}&readPreference=foo");
-			fail("Should have thrown exception");
-		} catch (ResolveEndpointFailedException refe) {
-			assertTrue(refe.getMessage(), refe.getMessage().endsWith("Unknown parameters=[{readPreference=foo}]"));
-		}
-	}
+    @Test
+    public void testInvalidReadPreferenceOptionValue() throws Exception {
+        try {
+            createMongoDbEndpoint("mongodb3:myDb?database={{mongodb.testDb}}&readPreference=foo");
+            fail("Should have thrown exception");
+        } catch (ResolveEndpointFailedException refe) {
+            assertTrue(refe.getMessage(), refe.getMessage().endsWith("Unknown parameters=[{readPreference=foo}]"));
+        }
+    }
 
-	@Test
-	public void testNoReadPreferenceOptionValue() throws Exception {
-		endpoint = createMongoDbEndpoint("mongodb3:myDb?database={{mongodb.testDb}}");
-		assertSame(ReadPreference.primary(), endpoint.getReadPreference());
-		assertSame(ReadPreference.primary(), endpoint.getMongoConnection().getReadPreference());
-		// the default is primary
-	}
+    @Test
+    public void testNoReadPreferenceOptionValue() throws Exception {
+        endpoint = createMongoDbEndpoint("mongodb3:myDb?database={{mongodb.testDb}}");
+        assertSame(ReadPreference.primary(), endpoint.getReadPreference());
+        assertSame(ReadPreference.primary(), endpoint.getMongoConnection().getReadPreference());
+        // the default is primary
+    }
 
-	@Test
-	public void testPrimaryReadPreferenceOptionValue() throws Exception {
-		endpoint = createMongoDbEndpoint("mongodb3:myDbP?database={{mongodb.testDb}}");
-		assertSame(ReadPreference.primary(), endpoint.getReadPreference());
-		assertSame(ReadPreference.primary(), endpoint.getMongoConnection().getReadPreference());
-	}
+    @Test
+    public void testPrimaryReadPreferenceOptionValue() throws Exception {
+        endpoint = createMongoDbEndpoint("mongodb3:myDbP?database={{mongodb.testDb}}");
+        assertSame(ReadPreference.primary(), endpoint.getReadPreference());
+        assertSame(ReadPreference.primary(), endpoint.getMongoConnection().getReadPreference());
+    }
 
-	@Test
-	public void testPrimaryPreferredReadPreferenceOptionValue() throws Exception {
-		endpoint = createMongoDbEndpoint("mongodb3:myDbPP?database={{mongodb.testDb}}");
-		assertSame(ReadPreference.primaryPreferred(), endpoint.getReadPreference());
-		assertSame(ReadPreference.primaryPreferred(), endpoint.getMongoConnection().getReadPreference());
-	}
+    @Test
+    public void testPrimaryPreferredReadPreferenceOptionValue() throws Exception {
+        endpoint = createMongoDbEndpoint("mongodb3:myDbPP?database={{mongodb.testDb}}");
+        assertSame(ReadPreference.primaryPreferred(), endpoint.getReadPreference());
+        assertSame(ReadPreference.primaryPreferred(), endpoint.getMongoConnection().getReadPreference());
+    }
 
-	@Test
-	public void testSecondaryReadPreferenceOptionValue() throws Exception {
-		endpoint = createMongoDbEndpoint("mongodb3:myDbS?database={{mongodb.testDb}}");
-		;// &readPreference=secondary");
-		assertSame(ReadPreference.secondary(), endpoint.getReadPreference());
-		assertSame(ReadPreference.secondary(), endpoint.getMongoConnection().getReadPreference());
-	}
+    @Test
+    public void testSecondaryReadPreferenceOptionValue() throws Exception {
+        endpoint = createMongoDbEndpoint("mongodb3:myDbS?database={{mongodb.testDb}}");
+        assertSame(ReadPreference.secondary(), endpoint.getReadPreference());
+        assertSame(ReadPreference.secondary(), endpoint.getMongoConnection().getReadPreference());
+    }
 
-	@Test
-	public void testSecondaryPreferredReadPreferenceOptionValue() throws Exception {
-		endpoint = createMongoDbEndpoint("mongodb3:myDbSP?database={{mongodb.testDb}}");
-		assertSame(ReadPreference.secondaryPreferred(), endpoint.getReadPreference());
-		assertSame(ReadPreference.secondaryPreferred(), endpoint.getMongoConnection().getReadPreference());
-	}
+    @Test
+    public void testSecondaryPreferredReadPreferenceOptionValue() throws Exception {
+        endpoint = createMongoDbEndpoint("mongodb3:myDbSP?database={{mongodb.testDb}}");
+        assertSame(ReadPreference.secondaryPreferred(), endpoint.getReadPreference());
+        assertSame(ReadPreference.secondaryPreferred(), endpoint.getMongoConnection().getReadPreference());
+    }
 
-	@Test
-	public void testNearestReadPreferenceOptionValue() throws Exception {
-		endpoint = createMongoDbEndpoint("mongodb3:myDbN?database={{mongodb.testDb}}");
-		assertSame(ReadPreference.nearest(), endpoint.getReadPreference());
-		assertSame(ReadPreference.nearest(), endpoint.getMongoConnection().getReadPreference());
-	}
+    @Test
+    public void testNearestReadPreferenceOptionValue() throws Exception {
+        endpoint = createMongoDbEndpoint("mongodb3:myDbN?database={{mongodb.testDb}}");
+        assertSame(ReadPreference.nearest(), endpoint.getReadPreference());
+        assertSame(ReadPreference.nearest(), endpoint.getMongoConnection().getReadPreference());
+    }
 
-	private MongoDbEndpoint createMongoDbEndpoint(String uri) throws Exception {
-		Endpoint mongoEndpoint = context().getComponent("mongodb3").createEndpoint(uri);
-		mongoEndpoint.start();
-		return MongoDbEndpoint.class.cast(mongoEndpoint);
+    private MongoDbEndpoint createMongoDbEndpoint(String uri) throws Exception {
+        Endpoint mongoEndpoint = context().getComponent("mongodb3").createEndpoint(uri);
+        mongoEndpoint.start();
+        return MongoDbEndpoint.class.cast(mongoEndpoint);
 
-	}
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/5715fce7/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbSpringDslOperationsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbSpringDslOperationsTest.java b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbSpringDslOperationsTest.java
index 76ac602..b0e7edc 100644
--- a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbSpringDslOperationsTest.java
+++ b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbSpringDslOperationsTest.java
@@ -22,12 +22,12 @@ import org.apache.camel.spring.SpringCamelContext;
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 
 public class MongoDbSpringDslOperationsTest extends MongoDbOperationsTest {
-    
+
     @Override
     protected CamelContext createCamelContext() throws Exception {
         applicationContext = new AnnotationConfigApplicationContext(MongoBasicOperationsConfiguration.class);
         @SuppressWarnings("deprecation")
-		CamelContext ctx = SpringCamelContext.springCamelContext(applicationContext);
+        CamelContext ctx = SpringCamelContext.springCamelContext(applicationContext);
         return ctx;
     }
 
@@ -36,9 +36,10 @@ public class MongoDbSpringDslOperationsTest extends MongoDbOperationsTest {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                // Nothing, all routes are initialized by the Spring DSL context file
+                // Nothing, all routes are initialized by the Spring DSL context
+                // file
             }
         };
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/5715fce7/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbTailableCursorConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbTailableCursorConsumerTest.java b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbTailableCursorConsumerTest.java
index c33caa8..3379aa0 100644
--- a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbTailableCursorConsumerTest.java
+++ b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbTailableCursorConsumerTest.java
@@ -17,24 +17,24 @@
 package org.apache.camel.component.mongodb3;
 
 import java.util.Calendar;
-import static com.mongodb.client.model.Filters.eq;
+
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.CreateCollectionOptions;
 
 import org.apache.camel.ServiceStatus;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.mongodb3.MongoDbTailTrackingConfig;
 import org.bson.Document;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import com.mongodb.client.MongoCollection;
-import com.mongodb.client.model.CreateCollectionOptions;
+import static com.mongodb.client.model.Filters.eq;
 
 public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
-    
+
     private MongoCollection<Document> cappedTestCollection;
     private String cappedTestCollectionName;
-    
+
     @Test
     public void testThousandRecordsWithoutReadPreference() throws Exception {
         testThousandRecordsWithRouteId("tailableCursorConsumer1");
@@ -44,20 +44,17 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
     public void testThousandRecordsWithReadPreference() throws Exception {
         testThousandRecordsWithRouteId("tailableCursorConsumer1.readPreference");
     }
-    
+
     @Test
     public void testNoRecords() throws Exception {
         assertEquals(0, cappedTestCollection.count());
         MockEndpoint mock = getMockEndpoint("mock:test");
         mock.expectedMessageCount(0);
-        //DocumentBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
+        // DocumentBuilder.start().add("capped", true).add("size",
+        // 1000000000).add("max", 1000).get()
         // create a capped collection with max = 1000
-        CreateCollectionOptions collectionOptions = new CreateCollectionOptions()
-                .capped(true)
-                .sizeInBytes(1000000000)
-                .maxDocuments(1000);
-        db.createCollection(cappedTestCollectionName,
-                collectionOptions);
+        CreateCollectionOptions collectionOptions = new CreateCollectionOptions().capped(true).sizeInBytes(1000000000).maxDocuments(1000);
+        db.createCollection(cappedTestCollectionName, collectionOptions);
         cappedTestCollection = db.getCollection(cappedTestCollectionName, Document.class);
         assertEquals(0, cappedTestCollection.count());
 
@@ -68,25 +65,23 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         context.stopRoute("tailableCursorConsumer1");
 
     }
-    
+
     @Test
     public void testMultipleBursts() throws Exception {
         assertEquals(0, cappedTestCollection.count());
         MockEndpoint mock = getMockEndpoint("mock:test");
         mock.expectedMessageCount(5000);
-        //DocumentBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
+        // DocumentBuilder.start().add("capped", true).add("size",
+        // 1000000000).add("max", 1000).get()
         // create a capped collection with max = 1000
-        CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions()
-                .capped(true)
-                .sizeInBytes(1000000000)
-                .maxDocuments(1000);
-        db.createCollection(cappedTestCollectionName,
-                createCollectionOptions);
+        CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions().capped(true).sizeInBytes(1000000000).maxDocuments(1000);
+        db.createCollection(cappedTestCollectionName, createCollectionOptions);
         cappedTestCollection = db.getCollection(cappedTestCollectionName, Document.class);
         addTestRoutes();
         context.startRoute("tailableCursorConsumer1");
-        
-        // pump 5 bursts of 1000 records each with 500ms pause between burst and burst
+
+        // pump 5 bursts of 1000 records each with 500ms pause between burst and
+        // burst
         Thread t = new Thread(new Runnable() {
             @Override
             public void run() {
@@ -100,86 +95,82 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
                     }
                     cappedTestCollection.insertOne(new Document("increasing", i).append("string", "value" + i));
                 }
-                
+
             }
         });
-        
+
         // start the data pumping
         t.start();
         // before we assert, wait for the data pumping to end
         t.join();
-        
+
         mock.assertIsSatisfied();
         context.stopRoute("tailableCursorConsumer1");
 
     }
-    
+
     @Test
     public void testHundredThousandRecords() throws Exception {
         assertEquals(0, cappedTestCollection.count());
         final MockEndpoint mock = getMockEndpoint("mock:test");
         mock.expectedMessageCount(1000);
-       
+
         // create a capped collection with max = 1000
-        //DocumentBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get())
-        db.createCollection(cappedTestCollectionName,
-                new CreateCollectionOptions()
-                        .capped(true)
-                        .sizeInBytes(1000000000)
-                        .maxDocuments(1000));
+        // DocumentBuilder.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, Document.class);
         addTestRoutes();
         context.startRoute("tailableCursorConsumer1");
-        
-        // continuous pump of 100000 records, asserting incrementally to reduce overhead on the mock endpoint
+
+        // continuous pump of 100000 records, asserting incrementally to reduce
+        // overhead on the mock endpoint
         Thread t = new Thread(new Runnable() {
             @Override
             public void run() {
                 for (int i = 1; i <= 100000; i++) {
                     cappedTestCollection.insertOne(new Document("increasing", i).append("string", "value" + i));
-                    
-                    // incrementally assert, as the mock endpoint stores all messages and otherwise the test would be sluggish
+
+                    // incrementally assert, as the mock endpoint stores all
+                    // messages and otherwise the test would be sluggish
                     if (i % 1000 == 0) {
                         try {
                             MongoDbTailableCursorConsumerTest.this.assertAndResetMockEndpoint(mock);
                         } catch (Exception e) {
                             return;
                         }
-                    }       
+                    }
                 }
             }
         });
-        
+
         // start the data pumping
         t.start();
         // before we stop the route, wait for the data pumping to end
         t.join();
-        
+
         context.stopRoute("tailableCursorConsumer1");
 
     }
-    
+
     @Test
     @Ignore
     public void testPersistentTailTrack() throws Exception {
         assertEquals(0, cappedTestCollection.count());
         final MockEndpoint mock = getMockEndpoint("mock:test");
-        
+
         // drop the tracking collection
         db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION).drop();
         // create a capped collection with max = 1000
-        // DocumentBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
-        db.createCollection(cappedTestCollectionName,
-                new CreateCollectionOptions()
-                        .capped(true)
-                        .sizeInBytes(1000000000)
-                        .maxDocuments(1000));
+        // DocumentBuilder.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, Document.class);
         cappedTestCollection.createIndex(new Document("increasing", 1));
 
         addTestRoutes();
         context.startRoute("tailableCursorConsumer2");
-        
+
         mock.expectedMessageCount(300);
         // pump 300 records
         Thread t = new Thread(new Runnable() {
@@ -190,7 +181,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
                 }
             }
         });
-        
+
         // start the data pumping
         t.start();
         // before we continue wait for the data pump to end
@@ -198,9 +189,10 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         mock.assertIsSatisfied();
         mock.reset();
         context.stopRoute("tailableCursorConsumer2");
-        while (context.getRouteStatus("tailableCursorConsumer2") != ServiceStatus.Stopped) { }
+        while (context.getRouteStatus("tailableCursorConsumer2") != ServiceStatus.Stopped) {
+        }
         context.startRoute("tailableCursorConsumer2");
-        
+
         // expect 300 messages and not 600
         mock.expectedMessageCount(300);
         // pump 300 records
@@ -217,57 +209,57 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         // before we continue wait for the data pump to end
         t.join();
         mock.assertIsSatisfied();
-        
-        // check that the first message received in this second batch corresponds to increasing=301
+
+        // check that the first message received in this second batch
+        // corresponds to increasing=301
         Object firstBody = mock.getExchanges().get(0).getIn().getBody();
         assertTrue(firstBody instanceof Document);
         assertEquals(301, Document.class.cast(firstBody).get("increasing"));
-        
-        // check that the lastVal is persisted at the right time: check before and after stopping the route
+
+        // check that the lastVal is persisted at the right time: check before
+        // and after stopping the route
         assertEquals(300, db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION).find(eq("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) { }
+        while (context.getRouteStatus("tailableCursorConsumer2") != ServiceStatus.Stopped) {
+        }
         assertEquals(600, db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION).find(eq("persistentId", "darwin")).first().get("lastTrackingValue"));
 
     }
-    
+
     @Test
     @Ignore
     public void testPersistentTailTrackIncreasingDateField() throws Exception {
         assertEquals(0, cappedTestCollection.count());
         final MockEndpoint mock = getMockEndpoint("mock:test");
         final Calendar startTimestamp = Calendar.getInstance();
-        
+
         // get default tracking collection
         MongoCollection<Document> trackingCol = db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION, Document.class);
         trackingCol.drop();
         trackingCol = db.getCollection(MongoDbTailTrackingConfig.DEFAULT_COLLECTION, Document.class);
-        
+
         // create a capped collection with max = 1000
-        //DocumentBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
-        db.createCollection(cappedTestCollectionName,
-                new CreateCollectionOptions()
-                        .capped(true)
-                        .sizeInBytes(1000000000)
-                        .maxDocuments(1000));
+        // DocumentBuilder.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, Document.class);
         addTestRoutes();
         context.startRoute("tailableCursorConsumer2");
-        
+
         mock.expectedMessageCount(300);
         // pump 300 records
         Thread t = new Thread(new Runnable() {
             @Override
             public void run() {
                 for (int i = 1; i <= 300; i++) {
-                    Calendar c = (Calendar) (startTimestamp.clone());
+                    Calendar c = (Calendar)(startTimestamp.clone());
                     c.add(Calendar.MINUTE, i);
                     cappedTestCollection.insertOne(new Document("increasing", c.getTime()).append("string", "value" + i));
                 }
             }
         });
-        
+
         // start the data pumping
         t.start();
         // before we continue wait for the data pump to end
@@ -275,12 +267,12 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         mock.assertIsSatisfied();
         mock.reset();
         // ensure that the persisted lastVal is startTimestamp + 300min
-        Calendar cal300 = (Calendar) startTimestamp.clone();
+        Calendar cal300 = (Calendar)startTimestamp.clone();
         cal300.add(Calendar.MINUTE, 300);
         context.stopRoute("tailableCursorConsumer2");
         assertEquals(cal300.getTime(), trackingCol.find(eq("persistentId", "darwin")).first().get(MongoDbTailTrackingConfig.DEFAULT_FIELD));
         context.startRoute("tailableCursorConsumer2");
-        
+
         // expect 300 messages and not 600
         mock.expectedMessageCount(300);
         // pump 300 records
@@ -288,7 +280,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
             @Override
             public void run() {
                 for (int i = 301; i <= 600; i++) {
-                    Calendar c = (Calendar) (startTimestamp.clone());
+                    Calendar c = (Calendar)(startTimestamp.clone());
                     c.add(Calendar.MINUTE, i);
                     cappedTestCollection.insertOne(new Document("increasing", c.getTime()).append("string", "value" + i));
                 }
@@ -304,35 +296,34 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         Calendar cal301 = Calendar.class.cast(startTimestamp.clone());
         cal301.add(Calendar.MINUTE, 301);
         assertEquals(cal301.getTime(), Document.class.cast(firstBody).get("increasing"));
-        // check that the persisted lastVal after stopping the route is startTimestamp + 600min
+        // check that the persisted lastVal after stopping the route is
+        // startTimestamp + 600min
         context.stopRoute("tailableCursorConsumer2");
-        Calendar cal600 = (Calendar) startTimestamp.clone();
+        Calendar cal600 = (Calendar)startTimestamp.clone();
         cal600.add(Calendar.MINUTE, 600);
         assertEquals(cal600.getTime(), trackingCol.find(eq("persistentId", "darwin")).first().get(MongoDbTailTrackingConfig.DEFAULT_FIELD));
     }
-    
+
     @Test
     @Ignore
     public void testCustomTailTrackLocation() throws Exception {
         assertEquals(0, cappedTestCollection.count());
         final MockEndpoint mock = getMockEndpoint("mock:test");
-        
-        // get the custom tracking collection and drop it (tailTrackDb=einstein&tailTrackCollection=curie&tailTrackField=newton)
+
+        // get the custom tracking collection and drop it
+        // (tailTrackDb=einstein&tailTrackCollection=curie&tailTrackField=newton)
         MongoCollection<Document> trackingCol = mongo.getDatabase("einstein").getCollection("curie", Document.class);
         trackingCol.drop();
         trackingCol = mongo.getDatabase("einstein").getCollection("curie", Document.class);
-        
+
         // create a capped collection with max = 1000
-        //DocumentBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
-        db.createCollection(cappedTestCollectionName,
-                new CreateCollectionOptions()
-                        .capped(true)
-                        .sizeInBytes(1000000000)
-                        .maxDocuments(1000));
+        // DocumentBuilder.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, Document.class);
         addTestRoutes();
         context.startRoute("tailableCursorConsumer3");
-        
+
         mock.expectedMessageCount(300);
         // pump 300 records
         Thread t = new Thread(new Runnable() {
@@ -343,20 +334,21 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
                 }
             }
         });
-        
+
         // start the data pumping
         t.start();
         // before we continue wait for the data pump to end
         t.join();
         mock.assertIsSatisfied();
         mock.reset();
-        
+
         // 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
+        // ensure that the persisted lastVal is 300, newton is the name of the
+        // trackingField we are using
         assertEquals(300, trackingCol.find(eq("persistentId", "darwin")).first().get("newton"));
         context.startRoute("tailableCursorConsumer3");
-        
+
         // expect 300 messages and not 600
         mock.expectedMessageCount(300);
         // pump 300 records
@@ -373,16 +365,18 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         // before we continue wait for the data pump to end
         t.join();
         mock.assertIsSatisfied();
-        // check that the first received body contains increasing=301 and not increasing=1, i.e. it's not starting from the top
+        // check that the first received body contains increasing=301 and not
+        // increasing=1, i.e. it's not starting from the top
         Object firstBody = mock.getExchanges().get(0).getIn().getBody();
         assertTrue(firstBody instanceof Document);
         assertEquals(301, (Document.class.cast(firstBody)).get("increasing"));
-        // check that the persisted lastVal after stopping the route is 600, newton is the name of the trackingField we are using
+        // 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.find(eq("persistentId", "darwin")).first().get("newton"));
 
     }
-    
+
     public void assertAndResetMockEndpoint(MockEndpoint mock) throws Exception {
         mock.assertIsSatisfied();
         mock.reset();
@@ -392,14 +386,11 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         assertEquals(0, cappedTestCollection.count());
         MockEndpoint mock = getMockEndpoint("mock:test");
         mock.expectedMessageCount(1000);
-       
+
         // create a capped collection with max = 1000
-        //DocumentBuilder.start().add("capped", true).add("size", 1000000000).add("max", 1000).get()
-        db.createCollection(cappedTestCollectionName,
-                new CreateCollectionOptions()
-                        .capped(true)
-                        .sizeInBytes(1000000000)
-                        .maxDocuments(1000));
+        // DocumentBuilder.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, Document.class);
         for (int i = 0; i < 1000; i++) {
             cappedTestCollection.insertOne(new Document("increasing", i).append("string", "value" + i));
@@ -412,7 +403,7 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
         mock.assertIsSatisfied();
         context.stopRoute(routeId);
     }
-    
+
     @Override
     public void doPostSetup() {
         super.doPostSetup();
@@ -424,33 +415,25 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest {
 
     protected void addTestRoutes() throws Exception {
         context.addRoutes(new RouteBuilder() {
-            
+
             @Override
             public void configure() throws Exception {
-                
-                from("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.cappedTestCollection}}&tailTrackIncreasingField=increasing")
-                    .id("tailableCursorConsumer1")
-                    .autoStartup(false)
-                    .to("mock:test");
-                
+
+                from("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.cappedTestCollection}}&tailTrackIncreasingField=increasing").id("tailableCursorConsumer1")
+                    .autoStartup(false).to("mock:test");
+
                 from("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.cappedTestCollection}}&tailTrackIncreasingField=increasing&persistentTailTracking=true&persistentId=darwin")
-                    .id("tailableCursorConsumer2")
-                    .autoStartup(false)
-                    .to("mock:test");
-                
-                from("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.cappedTestCollection}}&tailTrackIncreasingField=increasing&" 
-                     + "persistentTailTracking=true&persistentId=darwin&tailTrackDb=einstein&tailTrackCollection=curie&tailTrackField=newton")
-                    .id("tailableCursorConsumer3")
-                    .autoStartup(false)
-                    .to("mock:test");
-                
-                from("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.cappedTestCollection}}&tailTrackIncreasingField=increasing")//&readPreference=primary")
-                    .id("tailableCursorConsumer1.readPreference")
-                    .autoStartup(false)
-                    .to("mock:test");
+                    .id("tailableCursorConsumer2").autoStartup(false).to("mock:test");
+
+                from("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.cappedTestCollection}}&tailTrackIncreasingField=increasing&"
+                     + "persistentTailTracking=true&persistentId=darwin&tailTrackDb=einstein&tailTrackCollection=curie&tailTrackField=newton").id("tailableCursorConsumer3")
+                         .autoStartup(false).to("mock:test");
+
+                from("mongodb3:myDb?database={{mongodb.testDb}}&collection={{mongodb.cappedTestCollection}}&tailTrackIncreasingField=increasing")// &readPreference=primary")
+                    .id("tailableCursorConsumer1.readPreference").autoStartup(false).to("mock:test");
 
             }
         });
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/5715fce7/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/processor/idempotent/MongoDbIdempotentRepositoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/processor/idempotent/MongoDbIdempotentRepositoryTest.java b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/processor/idempotent/MongoDbIdempotentRepositoryTest.java
index 98e428b..d98c19b 100644
--- a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/processor/idempotent/MongoDbIdempotentRepositoryTest.java
+++ b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/processor/idempotent/MongoDbIdempotentRepositoryTest.java
@@ -18,15 +18,14 @@ package org.apache.camel.component.mongodb3.processor.idempotent;
 
 import java.util.UUID;
 
+import com.mongodb.MongoClient;
+
 import org.apache.camel.component.mongodb3.AbstractMongoDbTest;
-import org.apache.camel.component.mongodb3.processor.idempotent.MongoDbIdempotentRepository;
 import org.bson.Document;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.mongodb.MongoClient;
-
 public class MongoDbIdempotentRepositoryTest extends AbstractMongoDbTest {
 
     MongoDbIdempotentRepository<String> repo;
@@ -40,7 +39,7 @@ public class MongoDbIdempotentRepositoryTest extends AbstractMongoDbTest {
     @Override
     public void doPostSetup() {
         super.doPostSetup();
-        repo = new MongoDbIdempotentRepository<>((MongoClient) mongo, testCollectionName, dbName);
+        repo = new MongoDbIdempotentRepository<>((MongoClient)mongo, testCollectionName, dbName);
     }
 
     @Test
@@ -59,7 +58,7 @@ public class MongoDbIdempotentRepositoryTest extends AbstractMongoDbTest {
         repo.add(randomUUIDString);
         assertEquals(1, testCollection.count());
 
-        boolean found =  repo.contains(randomUUIDString);
+        boolean found = repo.contains(randomUUIDString);
         assertTrue("Added uid was found", found);
     }
 
@@ -70,7 +69,7 @@ public class MongoDbIdempotentRepositoryTest extends AbstractMongoDbTest {
         repo.add(randomUUIDString);
         assertEquals(1, testCollection.count());
 
-        boolean removed =  repo.remove(randomUUIDString);
+        boolean removed = repo.remove(randomUUIDString);
         assertTrue("Added uid was removed correctly", removed);
         assertEquals(0, testCollection.count());
     }
@@ -82,7 +81,7 @@ public class MongoDbIdempotentRepositoryTest extends AbstractMongoDbTest {
         repo.add(randomUUIDString);
         assertEquals(1, testCollection.count());
 
-        boolean added =  repo.add(randomUUIDString);
+        boolean added = repo.add(randomUUIDString);
         assertTrue("Duplicated entry was not added", !added);
         assertEquals(1, testCollection.count());
     }
@@ -91,26 +90,25 @@ public class MongoDbIdempotentRepositoryTest extends AbstractMongoDbTest {
     public void deleteMissingiIsFailse() throws Exception {
         String randomUUIDString = UUID.randomUUID().toString();
         assertEquals(0, testCollection.count());
-        boolean removed =  repo.remove(randomUUIDString);
+        boolean removed = repo.remove(randomUUIDString);
         assertTrue("Non exisint uid returns false", !removed);
     }
 
     @Test
     public void containsMissingReturnsFalse() throws Exception {
         String randomUUIDString = UUID.randomUUID().toString();
-        boolean found =  repo.contains(randomUUIDString);
+        boolean found = repo.contains(randomUUIDString);
         assertTrue("Non existing item is not found", !found);
     }
 
     @Test
     public void confirmAllwaysReturnsTrue() throws Exception {
         String randomUUIDString = UUID.randomUUID().toString();
-        boolean found =  repo.confirm(randomUUIDString);
+        boolean found = repo.confirm(randomUUIDString);
         assertTrue("Confirm always returns true", found);
 
-        found =  repo.confirm(null);
+        found = repo.confirm(null);
         assertTrue("Confirm always returns true, even with null", found);
     }
 
 }
-