package io.vertx.ext.mongo;

import io.vertx.core.*;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import org.junit.Test;

import java.util.concurrent.*;

/**
 * @author <a href="mailto:kostya05983@mail.ru">Konstantin Volivach</a>
 */
public class CloseTest extends MongoClientTestBase {
  private static final JsonObject theConfig = getConfig();

  public static class SharedVerticle extends AbstractVerticle {

    @Override
    public void start(Future<Void> startFuture) {
      MongoClient client = MongoClient.createNonShared(vertx, theConfig);
      startFuture.complete();
    }
  }

  @Test
  public void testCloseWhenVerticleUndeployed() throws InterruptedException, ExecutionException, TimeoutException {
    CompletableFuture<String> id = new CompletableFuture<>();
    vertx.deployVerticle(SharedVerticle.class.getName(), new DeploymentOptions().setInstances(1), onSuccess(id::complete));

    close(id.get(10, TimeUnit.SECONDS));
  }

  private void close(String deploymentId) throws InterruptedException {
    CountDownLatch closeLatch = new CountDownLatch(1);
    vertx.undeploy(deploymentId, onSuccess(v -> {
      closeLatch.countDown();
    }));
    awaitLatch(closeLatch);
  }
}

@@ -362,16 +362,305 @@
 fig();%0A%0A
+  @Override%0A  public void setUp() throws Exception%7B%0A    super.setUp();%0A    JsonObject config = getConfig();%0A    mongoClient = MongoClient.createNonShared(vertx, config);%0A    CountDownLatch latch = new CountDownLatch(1);%0A    dropCollections(mongoClient, latch);%0A    awaitLatch(latch);%0A  %7D%0A%0A
   public

fix tests