camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject camel git commit: CAMEL-8483 Removed readPreference from the list of invalid options for camel-mongodb tailable consumer.
Date Fri, 13 Mar 2015 17:35:54 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x a4fcbb625 -> 82d7c3a7c


CAMEL-8483 Removed readPreference from the list of invalid options for camel-mongodb tailable
consumer.

Thanks to Jörg Peschke (GitHub: jpeschke2608). Added unit test to his contribution.

This closes #434.


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

Branch: refs/heads/camel-2.14.x
Commit: 82d7c3a7c8cc86c53e1b225ce5e89a139b23e039
Parents: a4fcbb6
Author: Raul Kripalani <raulk@apache.org>
Authored: Fri Mar 13 17:32:26 2015 +0000
Committer: Raul Kripalani <raulk@apache.org>
Committed: Fri Mar 13 17:35:47 2015 +0000

----------------------------------------------------------------------
 .../component/mongodb/MongoDbEndpoint.java      |  4 +-
 .../MongoDbTailableCursorConsumerTest.java      | 51 ++++++++++++--------
 2 files changed, 34 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/82d7c3a7/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java
b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java
index 398a5d6..d015955 100644
--- a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java
+++ b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java
@@ -133,8 +133,8 @@ public class MongoDbEndpoint extends DefaultEndpoint {
             }
         } else if (role == 'C') {
             if (!ObjectHelper.isEmpty(operation) || !ObjectHelper.isEmpty(writeConcern) ||
writeConcernRef != null
-                    || readPreference != null || dynamicity || invokeGetLastError) {
-                throw new IllegalArgumentException("operation, writeConcern, writeConcernRef,
readPreference, dynamicity, invokeGetLastError "
+                   || dynamicity || invokeGetLastError) {
+                throw new IllegalArgumentException("operation, writeConcern, writeConcernRef,
dynamicity, invokeGetLastError "
                         + "options cannot appear on a consumer endpoint");
             }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/82d7c3a7/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 fb65f22..cbcf2f5 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
@@ -36,26 +36,13 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest
{
     private String cappedTestCollectionName;
     
     @Test
-    public void testThousandRecords() throws Exception {
-        assertEquals(0, cappedTestCollection.count());
-        MockEndpoint mock = getMockEndpoint("mock:test");
-        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());
-        
-        for (int i = 0; i < 1000; i++) {
-            cappedTestCollection.insert(BasicDBObjectBuilder.start("increasing", i).add("string",
"value" + i).get(), WriteConcern.SAFE);
-        }
-        assertEquals(1000, cappedTestCollection.count());
-
-        addTestRoutes();
-        context.startRoute("tailableCursorConsumer1");
-        Thread.sleep(1000);
-        mock.assertIsSatisfied();
-        context.stopRoute("tailableCursorConsumer1");
+    public void testThousandRecordsWithoutReadPreference() throws Exception {
+        testThousandRecordsWithRouteId("tailableCursorConsumer1");
+    }
 
+    @Test
+    public void testThousandRecordsWithReadPreference() throws Exception {
+        testThousandRecordsWithRouteId("tailableCursorConsumer1.readPreference");
     }
     
     @Test
@@ -371,6 +358,27 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest
{
         mock.assertIsSatisfied();
         mock.reset();
     }
+
+    private void testThousandRecordsWithRouteId(String routeId) throws Exception {
+        assertEquals(0, cappedTestCollection.count());
+        MockEndpoint mock = getMockEndpoint("mock:test");
+        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());
+        
+        for (int i = 0; i < 1000; i++) {
+            cappedTestCollection.insert(BasicDBObjectBuilder.start("increasing", i).add("string",
"value" + i).get(), WriteConcern.SAFE);
+        }
+        assertEquals(1000, cappedTestCollection.count());
+
+        addTestRoutes();
+        context.startRoute(routeId);
+        Thread.sleep(1000);
+        mock.assertIsSatisfied();
+        context.stopRoute(routeId);
+    }
     
     @Override
     public void doPostSetup() {
@@ -403,6 +411,11 @@ public class MongoDbTailableCursorConsumerTest extends AbstractMongoDbTest
{
                     .autoStartup(false)
                     .to("mock:test");
                 
+                from("mongodb:myDb?database={{mongodb.testDb}}&collection={{mongodb.cappedTestCollection}}&tailTrackIncreasingField=increasing&readPreference=primary")
+                    .id("tailableCursorConsumer1.readPreference")
+                    .autoStartup(false)
+                    .to("mock:test");
+
             }
         });
     }


Mime
View raw message