@@ -29,12 +29,14 @@ import com.mongodb.connection.netty.NettyStreamFactory
2929import com.mongodb.event.CommandFailedEvent
3030import com.mongodb.event.CommandStartedEvent
3131import com.mongodb.event.CommandSucceededEvent
32+ import com.mongodb.internal.validator.NoOpFieldNameValidator
3233import org.bson.BsonArray
3334import org.bson.BsonBinary
3435import org.bson.BsonBoolean
3536import org.bson.BsonDocument
3637import org.bson.BsonInt32
3738import org.bson.BsonString
39+ import org.bson.codecs.BsonDocumentCodec
3840import spock.lang.IgnoreIf
3941import spock.lang.Shared
4042
@@ -84,6 +86,10 @@ class WriteProtocolCommandEventSpecification extends OperationFunctionalSpecific
8486 [new BsonDocument (' _id' , new BsonInt32 (1 ))]))),
8587 new CommandSucceededEvent (1 , connection. getDescription(), ' insert' ,
8688 new BsonDocument (' ok' , new BsonInt32 (1 )), 0 )])
89+ cleanup :
90+ // force acknowledgement
91+ new CommandProtocol (getDatabaseName(), new BsonDocument (' drop' , new BsonString (getCollectionName())),
92+ new NoOpFieldNameValidator (), new BsonDocumentCodec ()). execute(connection)
8793 }
8894
8995 @IgnoreIf ({ !serverVersionAtLeast([2 , 4 , 0 ]) })
@@ -123,6 +129,10 @@ class WriteProtocolCommandEventSpecification extends OperationFunctionalSpecific
123129 .append(' documents' , new BsonArray ([documentFour]))),
124130 new CommandSucceededEvent (1 , connection. getDescription(), ' insert' ,
125131 new BsonDocument (' ok' , new BsonInt32 (1 )), 0 )])
132+ cleanup :
133+ // force acknowledgement
134+ new CommandProtocol (getDatabaseName(), new BsonDocument (' drop' , new BsonString (getCollectionName())),
135+ new NoOpFieldNameValidator (), new BsonDocumentCodec ()). execute(connection)
126136 }
127137
128138 def ' should deliver started and completed command events when there is a write error' () {
@@ -214,7 +224,11 @@ class WriteProtocolCommandEventSpecification extends OperationFunctionalSpecific
214224 .append(' upsert' , BsonBoolean . TRUE )]))),
215225 new CommandSucceededEvent (1 , connection. getDescription(), ' update' ,
216226 new BsonDocument (' ok' , new BsonInt32 (1 )), 0 )])
217- }
227+
228+ cleanup :
229+ // force acknowledgement
230+ new CommandProtocol (getDatabaseName(), new BsonDocument (' drop' , new BsonString (getCollectionName())),
231+ new NoOpFieldNameValidator (), new BsonDocumentCodec ()). execute(connection)}
218232
219233 def ' should deliver started and completed command events for a single unacknowleded delete' () {
220234 given :
0 commit comments