package io.vertx.db2client.tck;

import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import io.vertx.db2client.junit.DB2Resource;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import io.vertx.sqlclient.tck.PreparedQueryCachedTestBase;

@RunWith(VertxUnitRunner.class)
public class DB2PreparedQueryCachedTest extends PreparedQueryCachedTestBase {
  @ClassRule
  public static DB2Resource rule = DB2Resource.SHARED_INSTANCE;

  @Override
  protected void initConnector() {
    options = rule.options();
    connector = ClientConfig.CONNECT.connect(vertx, options);
  }

  @Override
  protected String statement(String... parts) {
    return String.join("?", parts);
  } 
  
  @Override
  protected void cleanTestTable(TestContext ctx) {
      // use DELETE FROM because DB2 does not support TRUNCATE TABLE
      connect(ctx.asyncAssertSuccess(conn -> {
          conn.query("DELETE FROM mutable", ctx.asyncAssertSuccess(result -> {
              conn.close();
          }));
      }));
  }
  
  @Test
  @Ignore // TODO: Enable this test after implementing error path handling
  @Override
  public void testPrepareError(TestContext ctx) {
  }

  @Test
  @Ignore // TODO: Enable this test after implementing error path handling
  @Override
  public void testPreparedQueryParamCoercionTypeError(TestContext ctx) {
  }

  @Test
  @Ignore // TODO: Enable this test after implementing error path handling
  @Override
  public void testPreparedQueryParamCoercionQuantityError(TestContext ctx) {
  }

  @Test
  @Ignore // TODO: Enable this test after implementing error path handling
  @Override
  public void testPreparedUpdateWithNullParams(TestContext ctx) {
  }

  // NOTE: for the following cursor tests, the base TCK class issues a BEGIN
  // statement because PostgreSQL requires a transaction for cursors. On DB2
  // this fails (even with JDBC) because there is no END statement to terminate
  // the SQL procedure. Since DB2 gives cursors all the time, when we enable
  // these tests just issue the prepared query and don't begin a procedure

  @Test
  @Ignore // TODO: Enable this test after implementing incremental cursor fetch
  @Override
  public void testQueryCursor(TestContext ctx) {
  }

  @Test
  @Ignore // TODO: Enable this test after implementing incremental cursor fetch
  @Override
  public void testQueryCloseCursor(TestContext ctx) {
  }

  @Test
  @Ignore // TODO: Enable this test after implementing incremental cursor fetch
  @Override
  public void testQueryStreamCloseCursor(TestContext ctx) {
  }

  @Test
  @Ignore // TODO: Enable this test after implementing incremental cursor fetch
  @Override
  public void testStreamQuery(TestContext ctx) {
  }

  @Test
  @Ignore // TODO: Enable this test after implementing incremental cursor fetch
  @Override
  public void testStreamQueryPauseInBatch(TestContext ctx) {
  }

  @Test
  @Ignore // TODO: Enable this test after implementing incremental cursor fetch
  @Override
  public void testStreamQueryPauseInBatchFromAnotherThread(TestContext ctx) {
  }

}

@@ -758,17 +758,94 @@
 ts);%0A  %7D
- 
+%0A  %0A  @Override%0A  protected boolean cursorRequiresTx() %7B%0A    return false;%0A  %7D
 %0A  %0A  @O
@@ -1746,32 +1746,32 @@
 ing%0A  @Override%0A
+
   public void te
@@ -1829,1374 +1829,6 @@
  %7D%0A%0A
-  // NOTE: for the following cursor tests, the base TCK class issues a BEGIN%0A  // statement because PostgreSQL requires a transaction for cursors. On DB2%0A  // this fails (even with JDBC) because there is no END statement to terminate%0A  // the SQL procedure. Since DB2 gives cursors all the time, when we enable%0A  // these tests just issue the prepared query and don't begin a procedure%0A%0A  @Test%0A  @Ignore // TODO: Enable this test after implementing incremental cursor fetch%0A  @Override%0A  public void testQueryCursor(TestContext ctx) %7B%0A  %7D%0A%0A  @Test%0A  @Ignore // TODO: Enable this test after implementing incremental cursor fetch%0A  @Override%0A  public void testQueryCloseCursor(TestContext ctx) %7B%0A  %7D%0A%0A  @Test%0A  @Ignore // TODO: Enable this test after implementing incremental cursor fetch%0A  @Override%0A  public void testQueryStreamCloseCursor(TestContext ctx) %7B%0A  %7D%0A%0A  @Test%0A  @Ignore // TODO: Enable this test after implementing incremental cursor fetch%0A  @Override%0A  public void testStreamQuery(TestContext ctx) %7B%0A  %7D%0A%0A  @Test%0A  @Ignore // TODO: Enable this test after implementing incremental cursor fetch%0A  @Override%0A  public void testStreamQueryPauseInBatch(TestContext ctx) %7B%0A  %7D%0A%0A  @Test%0A  @Ignore // TODO: Enable this test after implementing incremental cursor fetch%0A  @Override%0A  public void testStreamQueryPauseInBatchFromAnotherThread(TestContext ctx) %7B%0A  %7D%0A%0A
 %7D%0A

Enable tests in DB2PreparedQueryCachedTest related to incremental cursor fetch