This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git
commit a6c3139af84b4ed15ddbdf02ea0061c54e87ef4f Author: Stefan Seifert <[email protected]> AuthorDate: Tue Jan 19 15:57:39 2016 +0000 SLING-5078 fix invalid index attribute names git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1725553 13f79535-47bb-0310-9956-ffa450edef68 --- .../mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java | 8 ++++---- .../mongodb/resourceprovider/integration/IndexCreationIT.java | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java index 782021e..5239c5f 100644 --- a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java +++ b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java @@ -67,19 +67,19 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter { // create index on parent path field (if it does not exist yet) try { - Document parenPathtIndex = new Document("_parentPath", 1); + Document parenPathtIndex = new Document(PN_PARENT_PATH, 1); this.collection.createIndex(parenPathtIndex); } catch (DuplicateKeyException ex) { // index already exists, ignore } catch (Throwable ex) { - log.error("Unable to create index on _parentPath: " + ex.getMessage(), ex); + log.error("Unable to create index on " + PN_PARENT_PATH + ": " + ex.getMessage(), ex); } // create unique index on path field (if it does not exist yet) try { - Document pathIndex = new Document("_path", 1); + Document pathIndex = new Document(PN_PATH, 1); IndexOptions idxOptions = new IndexOptions(); idxOptions.unique(true); this.collection.createIndex(pathIndex, idxOptions); @@ -88,7 +88,7 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter { // index already exists, ignore } catch (Throwable ex) { - log.error("Unable to create unique index on _path: " + ex.getMessage(), ex); + log.error("Unable to create unique index on " + PN_PATH + ": " + ex.getMessage(), ex); } } diff --git a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java index a159514..e99ec8f 100644 --- a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java +++ b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java @@ -18,6 +18,7 @@ */ package org.apache.sling.nosql.mongodb.resourceprovider.integration; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.Arrays; @@ -60,17 +61,17 @@ public class IndexCreationIT { public void testIndexesPresent() { assertNotNull(underTest); - //expecting at least 3 indexes (_id, _path, _parentPath) - int expected = 3; + //expecting 2 indexes (_id, parentPath) + int expected = 2; int actual = 0; - final String[] expectedIndexesNames= {"_id_", "_path_1", "_parentPath_1"}; + final String[] expectedIndexesNames= {"_id_", "parentPath_1"}; - for( Document d : mongoClient.getDatabase(database).getCollection(collection).listIndexes()){ + for (Document d : mongoClient.getDatabase(database).getCollection(collection).listIndexes()){ assert Arrays.asList(expectedIndexesNames).contains( d.get("name") ); actual++; } - assert expected == actual; + assertEquals(expected, actual); } } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
