@@ -23,6 +23,7 @@ import spock.lang.IgnoreIf
2323
2424import static com.mongodb.ClusterFixture.serverVersionAtLeast
2525import static com.mongodb.async.client.Fixture.getMongoClient
26+ import static com.mongodb.async.client.Fixture.isSharded
2627import static java.util.Arrays.asList
2728import static java.util.concurrent.TimeUnit.SECONDS
2829
@@ -149,17 +150,6 @@ class SmokeTestSpecification extends FunctionalSpecification {
149150 then : ' has a single index left "_id" '
150151 run(collection. listIndexes(). &into, []). size == 1
151152
152- then : ' can rename the collection'
153- def newCollectionName = ' newCollectionName'
154- run(collection. &renameCollection, new MongoNamespace (databaseName, newCollectionName)) == null
155-
156- then : ' the new collection name is in the collection names list'
157- ! run(database. listCollectionNames(). &into, []). contains(collectionName)
158- run(database. listCollectionNames(). &into, []). contains(newCollectionName)
159-
160- when :
161- collection = database. getCollection(newCollectionName)
162-
163153 then : ' drop the collection'
164154 run(collection. &drop) == null
165155
@@ -170,6 +160,26 @@ class SmokeTestSpecification extends FunctionalSpecification {
170160 ! run(database. listCollectionNames(). &into, []). contains(collectionName)
171161 }
172162
163+ @IgnoreIf ({ isSharded() }) // see JAVA-1757 for why sharded clusters are currently excluded from this test
164+ def ' should handle rename collection administrative scenario without error' () {
165+ given :
166+ def mongoClient = getMongoClient()
167+ def database = mongoClient. getDatabase(databaseName)
168+ def collection = database. getCollection(collectionName)
169+ run(mongoClient. getDatabase(databaseName). &drop) == null
170+
171+ when : ' Create a collection and the created database is in the list'
172+ run(database. &createCollection, collectionName)
173+
174+ then : ' can rename the collection'
175+ def newCollectionName = ' newCollectionName'
176+ run(collection. &renameCollection, new MongoNamespace (databaseName, newCollectionName)) == null
177+
178+ then : ' the new collection name is in the collection names list'
179+ ! run(database. listCollectionNames(). &into, []). contains(collectionName)
180+ run(database. listCollectionNames(). &into, []). contains(newCollectionName)
181+ }
182+
173183 def run (operation , ... args ) {
174184 def futureResultCallback = new FutureResultCallback ()
175185 def opArgs = (args != null ) ? args : []
0 commit comments