/*
 * Copyright 2014 Red Hat, Inc.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 * The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * The Apache License v2.0 is available at
 * http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 */

package io.vertx.ext.embeddedmongo.test;

import io.vertx.core.VertxOptions;
import io.vertx.test.core.VertxTestBase;
import org.junit.Test;

/**
 * @author <a href="http://tfox.org">Tim Fox</a>
 */
public class EmbeddedMongoVerticleTest extends VertxTestBase {

  @Override
  public VertxOptions getOptions() {
    // It can take some time to download the first time!
    return new VertxOptions().setMaxWorkerExecuteTime(30 * 60 * 1000);
  }

  @Test
  public void testEmbeddedMongo() {
    // Not really sure what to test here apart from start and stop
    vertx.deployVerticle("service:io.vertx.vertx-mongo-embedded-db", onSuccess(deploymentID -> {
      assertNotNull(deploymentID);
      vertx.undeploy(deploymentID, onSuccess(v -> {
        assertNull(v);
        testComplete();
      }));
    }));
    await();
  }
}

@@ -574,28 +574,163 @@
 tx.core.
-VertxOptions
+DeploymentOptions;%0Aimport io.vertx.core.VertxOptions;%0Aimport io.vertx.core.json.JsonObject;%0Aimport io.vertx.ext.embeddedmongo.EmbeddedMongoVerticle
 ;%0Aimport
@@ -1344,131 +1344,1426 @@
     
-vertx.undeploy(deploymentID, onSuccess(v -%3E %7B%0A        assertNull(v);%0A        testComplete();%0A      %7D));%0A    %7D));%0A    await(
+undeploy(deploymentID);%0A    %7D));%0A    await();%0A  %7D%0A%0A  @Test%0A  public void testConfiguredPort() %7B%0A    EmbeddedMongoVerticle mongo = new EmbeddedMongoVerticle();%0A    vertx.deployVerticle(mongo, createOptions(7533), onSuccess(deploymentID -%3E %7B%0A      assertNotNull(deploymentID);%0A      assertEquals(7533, mongo.actualPort());%0A      undeploy(deploymentID);%0A    %7D));%0A    await();%0A  %7D%0A%0A  @Test%0A  public void testRandomPort() %7B%0A    EmbeddedMongoVerticle mongo = new EmbeddedMongoVerticle();%0A    vertx.deployVerticle(mongo, createOptions(0), onSuccess(deploymentID -%3E %7B%0A      assertNotNull(deploymentID);%0A      assertNotSame(0, mongo.actualPort());%0A      undeploy(deploymentID);%0A    %7D));%0A    await();%0A  %7D%0A%0A  @Test%0A  public void testRandomPortNoConfig() %7B%0A    EmbeddedMongoVerticle mongo = new EmbeddedMongoVerticle();%0A    vertx.deployVerticle(mongo, createEmptyOptions(), onSuccess(deploymentID -%3E %7B%0A      assertNotNull(deploymentID);%0A      assertNotSame(0, mongo.actualPort());%0A      undeploy(deploymentID);%0A    %7D));%0A    await();%0A  %7D%0A%0A  private DeploymentOptions createOptions(int port) %7B%0A    return createEmptyOptions().setConfig(new JsonObject().put(%22port%22, port));%0A  %7D%0A%0A  private DeploymentOptions createEmptyOptions() %7B%0A    return new DeploymentOptions().setWorker(true);%0A  %7D%0A%0A  private void undeploy(String deploymentID) %7B%0A    vertx.undeploy(deploymentID, onSuccess(v -%3E %7B%0A      assertNull(v);%0A      testComplete();%0A    %7D)
 );%0A 

add some tests for dynamic port