package io.vertx.ext.asyncsql;

import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.impl.LoggerFactory;
import io.vertx.test.core.VertxTestBase;
import org.junit.Test;

import java.util.concurrent.CountDownLatch;

/**
 * @author <a href="http://www.campudus.com">Joern Bernhardt</a>.
 */
public class PostgresqlTest extends VertxTestBase {
  private static final Logger log = LoggerFactory.getLogger(VertxTestBase.class);

  AsyncSqlService asyncSqlService;

  final String address = "campudus.postgresql";

  final JsonObject config = new JsonObject().put("postgresql", new JsonObject().put("address", address));

  @Override
  public void setUp() throws Exception {
    super.setUp();
    asyncSqlService = AsyncSqlService.create(vertx, config);

    CountDownLatch latch = new CountDownLatch(1);

    asyncSqlService.start(onSuccess(x -> {
      log.info("in onSuccess of start asyncSqlService");
      latch.countDown();
    }));

    awaitLatch(latch);
  }

//  @Test
//  public void someTest() throws Exception {
//    log.info("before getConnection");
//    asyncSqlService.getConnection(onSuccess(conn -> {
//      log.info("in getConnection");
//      conn.query("SELECT 1 AS something", onSuccess(resultSet -> {
//        assertNotNull(resultSet);
//        assertNotNull(resultSet.getColumnNames());
//        assertNotNull(resultSet.getResults());
//        assertEquals(new JsonArray().add(1), resultSet.getResults().get(0));
//        testComplete();
//      }));
//    }));
//
//    await();
//  }

}

@@ -1049,18 +1049,16 @@
  %7D%0A%0A
-//
   @Test%0A
 //  
@@ -1053,18 +1053,16 @@
   @Test%0A
-//
   public
@@ -1097,18 +1097,16 @@
 ption %7B%0A
-//
     log.
@@ -1131,26 +1131,24 @@
 nnection%22);%0A
-//
     asyncSql
@@ -1185,26 +1185,24 @@
 s(conn -%3E %7B%0A
-//
       log.in
@@ -1225,18 +1225,16 @@
 tion%22);%0A
-//
       co
@@ -1292,18 +1292,16 @@
 et -%3E %7B%0A
-//
         
@@ -1326,18 +1326,16 @@
 ltSet);%0A
-//
         
@@ -1373,26 +1373,24 @@
 mnNames());%0A
-//
         asse
@@ -1420,26 +1420,24 @@
 Results());%0A
-//
         asse
@@ -1497,26 +1497,24 @@
 ().get(0));%0A
-//
         test
@@ -1525,18 +1525,16 @@
 lete();%0A
-//
       %7D)
@@ -1536,18 +1536,16 @@
    %7D));%0A
-//
     %7D));
@@ -1549,13 +1549,9 @@
 ));%0A
-//%0A//
+%0A
     
@@ -1559,17 +1559,15 @@
 wait();%0A
-//
   %7D%0A%0A%7D%0A

Add Java test that seems to throw weird exception