diff --git a/src/test/java/io/vertx/cassandra/tests/CassandraClientTestBase.java b/src/test/java/io/vertx/cassandra/tests/CassandraClientTestBase.java index 4f59b70..1242b78 100644 --- a/src/test/java/io/vertx/cassandra/tests/CassandraClientTestBase.java +++ b/src/test/java/io/vertx/cassandra/tests/CassandraClientTestBase.java @@ -144,6 +144,11 @@ protected static void getCassandraReleaseVersion(CassandraClient client, Handler }); } + protected static Future getCassandraReleaseVersion(CassandraClient client) { + return client.executeWithFullFetch("select release_version from system.local") + .map(result -> result.iterator().next().getString("release_version")); + } + protected static String randomClientName() { return CassandraClient.class.getSimpleName() + "-" + UUID.randomUUID(); } diff --git a/src/test/java/io/vertx/cassandra/tests/VerticleWithCassandraClient.java b/src/test/java/io/vertx/cassandra/tests/VerticleWithCassandraClient.java index d34e956..c5f7cbd 100644 --- a/src/test/java/io/vertx/cassandra/tests/VerticleWithCassandraClient.java +++ b/src/test/java/io/vertx/cassandra/tests/VerticleWithCassandraClient.java @@ -18,10 +18,10 @@ import io.vertx.cassandra.CassandraClient; import io.vertx.cassandra.CassandraClientOptions; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Promise; +import io.vertx.core.Future; +import io.vertx.core.VerticleBase; -public class VerticleWithCassandraClient extends AbstractVerticle { +public class VerticleWithCassandraClient extends VerticleBase { private final CassandraClientOptions options; private final String clientName; @@ -38,27 +38,21 @@ public VerticleWithCassandraClient(CassandraClientOptions options, String client } @Override - public void start(Promise startFuture) { + public Future start() throws Exception { client = CassandraClient.createShared(vertx, clientName, options); if (executeRequestOnStart) { - CassandraClientTestBase.getCassandraReleaseVersion(client, ar -> { - if (ar.succeeded()) { - startFuture.complete(); - } else { - startFuture.fail(ar.cause()); - } - }); + return CassandraClientTestBase.getCassandraReleaseVersion(client); } else { - startFuture.complete(); + return super.start(); } } @Override - public void stop(Promise stopFuture) { + public Future stop() throws Exception { if (closeOnStop && client != null) { - client.close().onComplete(stopFuture); + return client.close(); } else { - stopFuture.complete(); + return super.stop(); } } } diff --git a/src/test/java/io/vertx/cassandra/tests/impl/SessionHolderMapCleaningTest.java b/src/test/java/io/vertx/cassandra/tests/impl/SessionHolderMapCleaningTest.java index 4362216..528e245 100644 --- a/src/test/java/io/vertx/cassandra/tests/impl/SessionHolderMapCleaningTest.java +++ b/src/test/java/io/vertx/cassandra/tests/impl/SessionHolderMapCleaningTest.java @@ -19,9 +19,7 @@ import io.vertx.cassandra.CassandraClient; import io.vertx.cassandra.impl.CassandraClientImpl; import io.vertx.cassandra.impl.SessionHolder; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.DeploymentOptions; -import io.vertx.core.Vertx; +import io.vertx.core.*; import io.vertx.core.shareddata.LocalMap; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.After; @@ -61,13 +59,14 @@ public void testMapCleaned() throws Exception { assertEquals(0, holders.size()); } - private static class SampleVerticle extends AbstractVerticle { + private static class SampleVerticle extends VerticleBase { CassandraClient shared; @Override - public void start() { + public Future start() throws Exception { shared = CassandraClient.createShared(vertx, CLIENT_NAME); + return super.start(); } } }