You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2013/10/01 13:53:07 UTC

git commit: CAMEL-6805: Fixed the failing MongoDbIndexTest.

Updated Branches:
  refs/heads/master 19a08bf51 -> bcc7b751c


CAMEL-6805: Fixed the failing MongoDbIndexTest.

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

Branch: refs/heads/master
Commit: bcc7b751cb7226e3c74d0736325699665d85ae52
Parents: 19a08bf
Author: Babak Vahdat <bv...@apache.org>
Authored: Tue Oct 1 13:52:58 2013 +0200
Committer: Babak Vahdat <bv...@apache.org>
Committed: Tue Oct 1 13:52:58 2013 +0200

----------------------------------------------------------------------
 .../camel/component/mongodb/MongoDbEndpoint.java   |  5 ++++-
 .../camel/component/mongodb/MongoDbIndexTest.java  | 17 +++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bcc7b751/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 c216ccb..3bcfa9e 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
@@ -218,7 +218,10 @@ public class MongoDbEndpoint extends DefaultEndpoint {
 
             for (Map.Entry<String, String> set : indexMap.entrySet()) {
                 DBObject index = new BasicDBObject();
-                index.put(set.getKey(), set.getValue());
+                // MongoDB 2.4 upwards is restrictive about the type of the 'single field index' being in use so that
+                // we should convert the index value to an Integer, see also:
+                // http://docs.mongodb.org/manual/release-notes/2.4/#improved-validation-of-index-types
+                index.put(set.getKey(), Integer.valueOf(set.getValue()));
 
                 indexList.add(index);
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/bcc7b751/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 25468f5..8081577 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
@@ -59,11 +59,9 @@ public class MongoDbIndexTest extends AbstractMongoDbTest {
 
         List<DBObject> indexInfos = dynamicCollection.getIndexInfo();
 
-        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");
-        BasicDBObject key2 = (BasicDBObject) indexInfos.get(2).get("key");
+        BasicDBObject key = (BasicDBObject) indexInfos.get(0).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")));
+        assertTrue("The field _id with the expected value not found", key.containsField("_id") && "1".equals(key.getString("_id")));
 
         DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledDBAndCollection");
         assertNotNull("No record with 'testInsertDynamicityEnabledDBAndCollection' _id", b);
@@ -102,11 +100,9 @@ public class MongoDbIndexTest extends AbstractMongoDbTest {
 
         List<DBObject> indexInfos = dynamicCollection.getIndexInfo();
 
-        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");
-        BasicDBObject key2 = (BasicDBObject) indexInfos.get(2).get("key");
+        BasicDBObject key = (BasicDBObject) indexInfos.get(0).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")));
+        assertTrue("The field _id with the expected value not found", key.containsField("_id") && "1".equals(key.getString("_id")));
 
         DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledCollectionAndIndex");
         assertNotNull("No record with 'testInsertDynamicityEnabledCollectionAndIndex' _id", b);
@@ -133,11 +129,12 @@ public class MongoDbIndexTest extends AbstractMongoDbTest {
         assertEquals("Response isn't of type WriteResult", WriteResult.class, result.getClass());
 
         DBCollection dynamicCollection = db.getCollection("otherCollection");
+
         List<DBObject> indexInfos = dynamicCollection.getIndexInfo();
 
-        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");
+        BasicDBObject key = (BasicDBObject)indexInfos.get(0).get("key");
 
-        assertFalse("No index on the field a", key1.containsField("a") && "-1".equals(key1.getString("a")));
+        assertTrue("The field _id with the expected value not found", key.containsField("_id") && "1".equals(key.getString("_id")));
 
         DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledCollectionOnlyAndURIIndex");
         assertNotNull("No record with 'testInsertDynamicityEnabledCollectionOnlyAndURIIndex' _id", b);