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:33:48 GMT
Repository: camel
Updated Branches:
  refs/heads/master 8d5570a30 -> 14ad4785a


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/14ad4785
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/14ad4785
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/14ad4785

Branch: refs/heads/master
Commit: 14ad4785a89fba6ef61483e24f628d26442b25a6
Parents: 8d5570a
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:32:26 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/14ad4785/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 e2eb6df..a9c4820 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
@@ -153,8 +153,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/14ad4785/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 f7d2a58..9085ff7 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