From 3928ac8a145036a9acc42d4ab6030c07992e4349 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Thu, 12 Sep 2024 17:24:44 +0200 Subject: [PATCH] Remove usage of Handler/AsyncResult idiom. --- .../io/vertx/core/InfinispanComplexHATest.java | 15 +++++---------- .../test/java/io/vertx/core/InfinispanHATest.java | 15 +++++---------- .../eventbus/InfinispanClusteredEventBusTest.java | 15 +++++---------- .../eventbus/InfinispanFaultToleranceTest.java | 15 +++++---------- .../core/eventbus/InfinispanNodeInfoTest.java | 15 +++++---------- .../InfinispanClusteredAsyncMapTest.java | 15 +++++---------- .../InfinispanClusteredAsynchronousLockTest.java | 15 +++++---------- .../InfinispanClusteredSharedCounterTest.java | 15 +++++---------- .../infinispan/ClusterHealthCheckTest.java | 15 +++++---------- .../InfinispanClusteredSessionHandlerTest.java | 15 +++++---------- 10 files changed, 50 insertions(+), 100 deletions(-) diff --git a/vertx-infinispan/src/test/java/io/vertx/core/InfinispanComplexHATest.java b/vertx-infinispan/src/test/java/io/vertx/core/InfinispanComplexHATest.java index 0fe11c4..3e4a3fd 100644 --- a/vertx-infinispan/src/test/java/io/vertx/core/InfinispanComplexHATest.java +++ b/vertx-infinispan/src/test/java/io/vertx/core/InfinispanComplexHATest.java @@ -41,19 +41,14 @@ public void setUp() throws Exception { } @Override - protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler> handler) { - CountDownLatch latch = new CountDownLatch(1); - Promise promise = Promise.promise(); - promise.future().onComplete(ar -> { - handler.handle(ar); - latch.countDown(); - }); - super.clusteredVertx(options, clusterManager, promise); + protected Future clusteredVertx(VertxOptions options, ClusterManager clusterManager) { + Future ret = super.clusteredVertx(options, clusterManager); try { - assertTrue(latch.await(2, TimeUnit.MINUTES)); - } catch (InterruptedException e) { + ret.await(2, TimeUnit.MINUTES); + } catch (Exception e) { fail(e.getMessage()); } + return ret; } @Override diff --git a/vertx-infinispan/src/test/java/io/vertx/core/InfinispanHATest.java b/vertx-infinispan/src/test/java/io/vertx/core/InfinispanHATest.java index 343be07..acbdab6 100644 --- a/vertx-infinispan/src/test/java/io/vertx/core/InfinispanHATest.java +++ b/vertx-infinispan/src/test/java/io/vertx/core/InfinispanHATest.java @@ -45,19 +45,14 @@ public void setUp() throws Exception { } @Override - protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler> handler) { - CountDownLatch latch = new CountDownLatch(1); - Promise promise = Promise.promise(); - promise.future().onComplete(ar -> { - handler.handle(ar); - latch.countDown(); - }); - super.clusteredVertx(options, clusterManager, promise); + protected Future clusteredVertx(VertxOptions options, ClusterManager clusterManager) { + Future ret = super.clusteredVertx(options, clusterManager); try { - assertTrue(latch.await(2, TimeUnit.MINUTES)); - } catch (InterruptedException e) { + ret.await(2, TimeUnit.MINUTES); + } catch (Exception e) { fail(e.getMessage()); } + return ret; } @Override diff --git a/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanClusteredEventBusTest.java b/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanClusteredEventBusTest.java index 85752ec..069f055 100644 --- a/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanClusteredEventBusTest.java +++ b/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanClusteredEventBusTest.java @@ -46,19 +46,14 @@ public void setUp() throws Exception { } @Override - protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler> handler) { - CountDownLatch latch = new CountDownLatch(1); - Promise promise = Promise.promise(); - promise.future().onComplete(ar -> { - handler.handle(ar); - latch.countDown(); - }); - super.clusteredVertx(options, clusterManager, promise); + protected Future clusteredVertx(VertxOptions options, ClusterManager clusterManager) { + Future ret = super.clusteredVertx(options, clusterManager); try { - assertTrue(latch.await(2, TimeUnit.MINUTES)); - } catch (InterruptedException e) { + ret.await(2, TimeUnit.MINUTES); + } catch (Exception e) { fail(e.getMessage()); } + return ret; } @Override diff --git a/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanFaultToleranceTest.java b/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanFaultToleranceTest.java index e63b742..3ce407a 100644 --- a/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanFaultToleranceTest.java +++ b/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanFaultToleranceTest.java @@ -42,19 +42,14 @@ public void setUp() throws Exception { } @Override - protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler> handler) { - CountDownLatch latch = new CountDownLatch(1); - Promise promise = Promise.promise(); - promise.future().onComplete(ar -> { - handler.handle(ar); - latch.countDown(); - }); - super.clusteredVertx(options, clusterManager, promise); + protected Future clusteredVertx(VertxOptions options, ClusterManager clusterManager) { + Future ret = super.clusteredVertx(options, clusterManager); try { - assertTrue(latch.await(2, TimeUnit.MINUTES)); - } catch (InterruptedException e) { + ret.await(2, TimeUnit.MINUTES); + } catch (Exception e) { fail(e.getMessage()); } + return ret; } @Override diff --git a/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanNodeInfoTest.java b/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanNodeInfoTest.java index 968d139..808b57c 100644 --- a/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanNodeInfoTest.java +++ b/vertx-infinispan/src/test/java/io/vertx/core/eventbus/InfinispanNodeInfoTest.java @@ -46,19 +46,14 @@ public void setUp() throws Exception { } @Override - protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler> handler) { - CountDownLatch latch = new CountDownLatch(1); - Promise promise = Promise.promise(); - promise.future().onComplete(ar -> { - handler.handle(ar); - latch.countDown(); - }); - super.clusteredVertx(options, clusterManager, promise); + protected Future clusteredVertx(VertxOptions options, ClusterManager clusterManager) { + Future ret = super.clusteredVertx(options, clusterManager); try { - assertTrue(latch.await(2, TimeUnit.MINUTES)); - } catch (InterruptedException e) { + ret.await(2, TimeUnit.MINUTES); + } catch (Exception e) { fail(e.getMessage()); } + return ret; } @Override diff --git a/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredAsyncMapTest.java b/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredAsyncMapTest.java index 06c0da9..4b1cdc2 100644 --- a/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredAsyncMapTest.java +++ b/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredAsyncMapTest.java @@ -58,19 +58,14 @@ public void setUp() throws Exception { } @Override - protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler> handler) { - CountDownLatch latch = new CountDownLatch(1); - Promise promise = Promise.promise(); - promise.future().onComplete(ar -> { - handler.handle(ar); - latch.countDown(); - }); - super.clusteredVertx(options, clusterManager, promise); + protected Future clusteredVertx(VertxOptions options, ClusterManager clusterManager) { + Future ret = super.clusteredVertx(options, clusterManager); try { - assertTrue(latch.await(2, TimeUnit.MINUTES)); - } catch (InterruptedException e) { + ret.await(2, TimeUnit.MINUTES); + } catch (Exception e) { fail(e.getMessage()); } + return ret; } @Override diff --git a/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredAsynchronousLockTest.java b/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredAsynchronousLockTest.java index 8993755..52ae719 100644 --- a/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredAsynchronousLockTest.java +++ b/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredAsynchronousLockTest.java @@ -47,19 +47,14 @@ public void setUp() throws Exception { } @Override - protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler> handler) { - CountDownLatch latch = new CountDownLatch(1); - Promise promise = Promise.promise(); - promise.future().onComplete(ar -> { - handler.handle(ar); - latch.countDown(); - }); - super.clusteredVertx(options, clusterManager, promise); + protected Future clusteredVertx(VertxOptions options, ClusterManager clusterManager) { + Future ret = super.clusteredVertx(options, clusterManager); try { - assertTrue(latch.await(2, TimeUnit.MINUTES)); - } catch (InterruptedException e) { + ret.await(2, TimeUnit.MINUTES); + } catch (Exception e) { fail(e.getMessage()); } + return ret; } @Override diff --git a/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredSharedCounterTest.java b/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredSharedCounterTest.java index 4da6833..b71fd8c 100644 --- a/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredSharedCounterTest.java +++ b/vertx-infinispan/src/test/java/io/vertx/core/shareddata/InfinispanClusteredSharedCounterTest.java @@ -46,19 +46,14 @@ public void setUp() throws Exception { } @Override - protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler> handler) { - CountDownLatch latch = new CountDownLatch(1); - Promise promise = Promise.promise(); - promise.future().onComplete(ar -> { - handler.handle(ar); - latch.countDown(); - }); - super.clusteredVertx(options, clusterManager, promise); + protected Future clusteredVertx(VertxOptions options, ClusterManager clusterManager) { + Future ret = super.clusteredVertx(options, clusterManager); try { - assertTrue(latch.await(2, TimeUnit.MINUTES)); - } catch (InterruptedException e) { + ret.await(2, TimeUnit.MINUTES); + } catch (Exception e) { fail(e.getMessage()); } + return ret; } @Override diff --git a/vertx-infinispan/src/test/java/io/vertx/ext/cluster/infinispan/ClusterHealthCheckTest.java b/vertx-infinispan/src/test/java/io/vertx/ext/cluster/infinispan/ClusterHealthCheckTest.java index 3876e7b..20a23a2 100644 --- a/vertx-infinispan/src/test/java/io/vertx/ext/cluster/infinispan/ClusterHealthCheckTest.java +++ b/vertx-infinispan/src/test/java/io/vertx/ext/cluster/infinispan/ClusterHealthCheckTest.java @@ -47,19 +47,14 @@ public void setUp() throws Exception { } @Override - protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler> handler) { - CountDownLatch latch = new CountDownLatch(1); - Promise promise = Promise.promise(); - promise.future().onComplete(ar -> { - handler.handle(ar); - latch.countDown(); - }); - super.clusteredVertx(options, clusterManager, promise); + protected Future clusteredVertx(VertxOptions options, ClusterManager clusterManager) { + Future ret = super.clusteredVertx(options, clusterManager); try { - assertTrue(latch.await(2, TimeUnit.MINUTES)); - } catch (InterruptedException e) { + ret.await(2, TimeUnit.MINUTES); + } catch (Exception e) { fail(e.getMessage()); } + return ret; } @Override diff --git a/vertx-infinispan/src/test/java/io/vertx/ext/web/sstore/InfinispanClusteredSessionHandlerTest.java b/vertx-infinispan/src/test/java/io/vertx/ext/web/sstore/InfinispanClusteredSessionHandlerTest.java index 6a0689e..68cda73 100644 --- a/vertx-infinispan/src/test/java/io/vertx/ext/web/sstore/InfinispanClusteredSessionHandlerTest.java +++ b/vertx-infinispan/src/test/java/io/vertx/ext/web/sstore/InfinispanClusteredSessionHandlerTest.java @@ -46,19 +46,14 @@ public void setUp() throws Exception { } @Override - protected void clusteredVertx(VertxOptions options, ClusterManager clusterManager, Handler> handler) { - CountDownLatch latch = new CountDownLatch(1); - Promise promise = Promise.promise(); - promise.future().onComplete(ar -> { - handler.handle(ar); - latch.countDown(); - }); - super.clusteredVertx(options, clusterManager, promise); + protected Future clusteredVertx(VertxOptions options, ClusterManager clusterManager) { + Future ret = super.clusteredVertx(options, clusterManager); try { - assertTrue(latch.await(2, TimeUnit.MINUTES)); - } catch (InterruptedException e) { + ret.await(2, TimeUnit.MINUTES); + } catch (Exception e) { fail(e.getMessage()); } + return ret; } @Override