From 4dc688da558f18b6060b0d9dce30943db10c84bd Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 16:14:09 +0200 Subject: [PATCH 01/15] Uncomment JPMS module --- pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6efa0baa2..ea92830a7 100644 --- a/pom.xml +++ b/pom.xml @@ -42,8 +42,7 @@ cassandra-examples web-graphql-examples openapi-examples - - + jpms-examples From 8e717819468b2767e7d802c82778ff6256ba2f3b Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 16:22:26 +0200 Subject: [PATCH 02/15] Adapt to Linux --- jpms-examples/pom.xml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/jpms-examples/pom.xml b/jpms-examples/pom.xml index 08dced1a7..ca2e391e5 100644 --- a/jpms-examples/pom.xml +++ b/jpms-examples/pom.xml @@ -161,7 +161,7 @@ - mac + Mac mac @@ -180,6 +180,26 @@ + + Linux + + + linux + + + + epoll + + + + io.netty + netty-transport-native-epoll + linux-${os.detected.arch} + 4.2.0.Alpha4 + + + + From 5ebdeeef614a6fbd8896721b7635584d4987003a Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 16:29:04 +0200 Subject: [PATCH 03/15] Comment out broken rxjava 2 for now --- pom.xml | 2 +- .../SomeDatabaseServiceVertxEBProxy.java | 75 ---------- .../SomeDatabaseServiceVertxProxyHandler.java | 133 ------------------ .../reactivex/SomeDatabaseService.java | 98 ------------- 4 files changed, 1 insertion(+), 307 deletions(-) delete mode 100644 rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxEBProxy.java delete mode 100644 rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxProxyHandler.java delete mode 100644 rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/reactivex/SomeDatabaseService.java diff --git a/pom.xml b/pom.xml index ea92830a7..449251d87 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ zipkin-examples web-examples web-client-examples - rxjava-2-examples + rxjava-3-examples metrics-examples micrometer-metrics-examples diff --git a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxEBProxy.java b/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxEBProxy.java deleted file mode 100644 index 6927c2bd6..000000000 --- a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxEBProxy.java +++ /dev/null @@ -1,75 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package io.vertx.example.reactivex.services.serviceproxy; - -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.Vertx; -import io.vertx.core.Future; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.function.Function; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.ProxyUtils; - -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class SomeDatabaseServiceVertxEBProxy implements SomeDatabaseService { - private Vertx _vertx; - private String _address; - private DeliveryOptions _options; - private boolean closed; - - public SomeDatabaseServiceVertxEBProxy(Vertx vertx, String address) { - this(vertx, address, null); - } - - public SomeDatabaseServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) { - this._vertx = vertx; - this._address = address; - this._options = options; - try { - this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) { - } - } - - @Override - public Future getDataById(int id){ - if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); - JsonObject _json = new JsonObject(); - _json.put("id", id); - - DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); - _deliveryOptions.addHeader("action", "getDataById"); - _deliveryOptions.getHeaders().set("action", "getDataById"); - return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { - return msg.body(); - }); - } -} diff --git a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxProxyHandler.java b/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxProxyHandler.java deleted file mode 100644 index 5e6711170..000000000 --- a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxProxyHandler.java +++ /dev/null @@ -1,133 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package io.vertx.example.reactivex.services.serviceproxy; - -import io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService; -import io.vertx.core.Vertx; -import io.vertx.core.Handler; -import io.vertx.core.AsyncResult; -import io.vertx.core.eventbus.EventBus; -import io.vertx.core.eventbus.Message; -import io.vertx.core.eventbus.MessageConsumer; -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.eventbus.ReplyException; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.Collection; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.stream.Collectors; -import io.vertx.serviceproxy.ProxyHandler; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.HelperUtils; -import io.vertx.serviceproxy.ServiceBinder; - -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class SomeDatabaseServiceVertxProxyHandler extends ProxyHandler { - - public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes - private final Vertx vertx; - private final SomeDatabaseService service; - private final long timerID; - private long lastAccessed; - private final long timeoutSeconds; - private final boolean includeDebugInfo; - - public SomeDatabaseServiceVertxProxyHandler(Vertx vertx, SomeDatabaseService service){ - this(vertx, service, DEFAULT_CONNECTION_TIMEOUT); - } - - public SomeDatabaseServiceVertxProxyHandler(Vertx vertx, SomeDatabaseService service, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond); - } - - public SomeDatabaseServiceVertxProxyHandler(Vertx vertx, SomeDatabaseService service, boolean topLevel, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond, false); - } - - public SomeDatabaseServiceVertxProxyHandler(Vertx vertx, SomeDatabaseService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) { - this.vertx = vertx; - this.service = service; - this.includeDebugInfo = includeDebugInfo; - this.timeoutSeconds = timeoutSeconds; - try { - this.vertx.eventBus().registerDefaultCodec(ServiceException.class, - new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) {} - if (timeoutSeconds != -1 && !topLevel) { - long period = timeoutSeconds * 1000 / 2; - if (period > 10000) { - period = 10000; - } - this.timerID = vertx.setPeriodic(period, this::checkTimedOut); - } else { - this.timerID = -1; - } - accessed(); - } - - - private void checkTimedOut(long id) { - long now = System.nanoTime(); - if (now - lastAccessed > timeoutSeconds * 1000000000) { - close(); - } - } - - @Override - public void close() { - if (timerID != -1) { - vertx.cancelTimer(timerID); - } - super.close(); - } - - private void accessed() { - this.lastAccessed = System.nanoTime(); - } - - public void handle(Message msg) { - try{ - JsonObject json = msg.body(); - String action = msg.headers().get("action"); - if (action == null) throw new IllegalStateException("action not specified"); - accessed(); - switch (action) { - case "getDataById": { - service.getDataById(json.getValue("id") == null ? null : (json.getLong("id").intValue())).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); - break; - } - default: throw new IllegalStateException("Invalid action: " + action); - } - } catch (Throwable t) { - if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t))); - else msg.reply(new ServiceException(500, t.getMessage())); - throw t; - } - } -} \ No newline at end of file diff --git a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/reactivex/SomeDatabaseService.java b/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/reactivex/SomeDatabaseService.java deleted file mode 100644 index a87794ba7..000000000 --- a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/reactivex/SomeDatabaseService.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version 2.0 - * (the "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -package io.vertx.example.reactivex.services.serviceproxy.reactivex; - -import io.vertx.reactivex.RxHelper; -import io.vertx.reactivex.ObservableHelper; -import io.vertx.reactivex.FlowableHelper; -import io.vertx.reactivex.impl.AsyncResultMaybe; -import io.vertx.reactivex.impl.AsyncResultSingle; -import io.vertx.reactivex.impl.AsyncResultCompletable; -import io.vertx.reactivex.WriteStreamObserver; -import io.vertx.reactivex.WriteStreamSubscriber; -import java.util.Map; -import java.util.Set; -import java.util.List; -import java.util.Iterator; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import io.vertx.core.Handler; -import io.vertx.core.AsyncResult; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import io.vertx.lang.rx.RxGen; -import io.vertx.lang.rx.TypeArg; -import io.vertx.lang.rx.MappingIterator; - - -@RxGen(io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService.class) -public class SomeDatabaseService { - - @Override - public String toString() { - return delegate.toString(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - SomeDatabaseService that = (SomeDatabaseService) o; - return delegate.equals(that.delegate); - } - - @Override - public int hashCode() { - return delegate.hashCode(); - } - - public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new SomeDatabaseService((io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService) obj), - SomeDatabaseService::getDelegate - ); - - private final io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService delegate; - - public SomeDatabaseService(io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService delegate) { - this.delegate = delegate; - } - - public SomeDatabaseService(Object delegate) { - this.delegate = (io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService)delegate; - } - - public io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService getDelegate() { - return delegate; - } - - - public io.vertx.core.Future getDataById(int id) { - io.vertx.core.Future ret = delegate.getDataById(id).map(val -> val); - return ret; - } - - public io.reactivex.Single rxGetDataById(int id) { - return AsyncResultSingle.toSingle($handler -> { - this.getDataById(id).onComplete($handler); - }); - } - - public static SomeDatabaseService newInstance(io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService arg) { - return arg != null ? new SomeDatabaseService(arg) : null; - } - -} From 8f7c36d047e8accae7d771c079c68ff52b650970 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 16:34:47 +0200 Subject: [PATCH 04/15] Remove -q mvn switch --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5cc403f9b..70c6ab0b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,4 +31,4 @@ jobs: with: java-version: ${{ matrix.jdk }} - name: Run tests - run: mvn -q clean verify -B -s settings.xml + run: mvn clean verify -B -s settings.xml From e19e8464bc439267f9b291a19f4dcce714cca9c8 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 16:44:05 +0200 Subject: [PATCH 05/15] maven settings tweak --- settings.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/settings.xml b/settings.xml index 5919f7baf..e62b6d22a 100644 --- a/settings.xml +++ b/settings.xml @@ -233,11 +233,6 @@ file-system-maven-settings sonatype-repository - - sonatype-nexus-releases - https://s01.oss.sonatype.org/content/repositories/releases - default - sonatype-nexus-snapshots https://s01.oss.sonatype.org/content/repositories/snapshots From 25ceaa398f3ee1850b418da504ad9d457fd66dba Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 16:49:52 +0200 Subject: [PATCH 06/15] Alpha5 bump --- jpms-examples/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jpms-examples/pom.xml b/jpms-examples/pom.xml index ca2e391e5..879a1acf8 100644 --- a/jpms-examples/pom.xml +++ b/jpms-examples/pom.xml @@ -131,7 +131,7 @@ io.netty netty-resolver-dns-native-macos osx-${osx.arch} - 4.2.0.Alpha4 + 4.2.0.Alpha5 @@ -176,7 +176,7 @@ io.netty netty-transport-native-kqueue osx-${osx.arch} - 4.2.0.Alpha4 + 4.2.0.Alpha5 @@ -195,7 +195,7 @@ io.netty netty-transport-native-epoll linux-${os.detected.arch} - 4.2.0.Alpha4 + 4.2.0.Alpha5 From b56d05eeeb075e899c6979b7a784585e9d01755d Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 16:54:31 +0200 Subject: [PATCH 07/15] Add Maven Central to the list of repos --- jpms-examples/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jpms-examples/pom.xml b/jpms-examples/pom.xml index 879a1acf8..80fe71412 100644 --- a/jpms-examples/pom.xml +++ b/jpms-examples/pom.xml @@ -22,6 +22,11 @@ + + maven-central + Maven Central + https://repo1.maven.org/maven2/. + jpms-attic JPMS Attic From 7c356f7b714da662fa2de8d23629d07cfca1606e Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 17:02:40 +0200 Subject: [PATCH 08/15] more --- jpms-examples/pom.xml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/jpms-examples/pom.xml b/jpms-examples/pom.xml index 80fe71412..e5d1064d1 100644 --- a/jpms-examples/pom.xml +++ b/jpms-examples/pom.xml @@ -18,7 +18,7 @@ 4.27.2 1.20.1 - aarch64 + aarch_64 @@ -135,8 +135,6 @@ io.netty netty-resolver-dns-native-macos - osx-${osx.arch} - 4.2.0.Alpha5 @@ -177,6 +175,12 @@ ${os.detected.arch} + + io.netty + netty-resolver-dns-native-macos + osx-${osx.arch} + 4.2.0.Alpha5 + io.netty netty-transport-native-kqueue From db942db0a96dfe902ff951cc8de9b68a0a8ef81d Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 17:05:35 +0200 Subject: [PATCH 09/15] Revert "Add Maven Central to the list of repos" This reverts commit b56d05eeeb075e899c6979b7a784585e9d01755d. --- jpms-examples/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/jpms-examples/pom.xml b/jpms-examples/pom.xml index e5d1064d1..5a8468193 100644 --- a/jpms-examples/pom.xml +++ b/jpms-examples/pom.xml @@ -22,11 +22,6 @@ - - maven-central - Maven Central - https://repo1.maven.org/maven2/. - jpms-attic JPMS Attic From 5457b26cae99b24e4d44d89b39e0bc5b3aaeb1fa Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 17:05:46 +0200 Subject: [PATCH 10/15] Revert "maven settings tweak" This reverts commit e19e8464bc439267f9b291a19f4dcce714cca9c8. --- settings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/settings.xml b/settings.xml index e62b6d22a..5919f7baf 100644 --- a/settings.xml +++ b/settings.xml @@ -233,6 +233,11 @@ file-system-maven-settings sonatype-repository + + sonatype-nexus-releases + https://s01.oss.sonatype.org/content/repositories/releases + default + sonatype-nexus-snapshots https://s01.oss.sonatype.org/content/repositories/snapshots From b210bcf9b0d977772ba3068208cf75bcb333fcfa Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 17:09:09 +0200 Subject: [PATCH 11/15] Enable docker based tests on platform with docker --- .../test/java/io/vertx/example/jpms/tests/SqlClientTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java b/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java index 2592b021b..0e765b5c1 100644 --- a/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java +++ b/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java @@ -11,6 +11,8 @@ import io.vertx.example.jpms.sqlclient.Client; import io.vertx.pgclient.PgConnectOptions; import org.junit.jupiter.api.*; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.OS; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; import org.testcontainers.utility.DockerImageName; @@ -18,6 +20,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; +@EnabledOnOs(value = { OS.LINUX, OS.MAC }) public class SqlClientTest { private static GenericContainer container; From bb4e33a4ee254806ba13c632f1884db77303e98b Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 17:16:50 +0200 Subject: [PATCH 12/15] For now use macos instead of windows for CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70c6ab0b1..b69133652 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: name: Run tests strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest, macos-latest] jdk: [11] include: - os: ubuntu-latest From 3848a7bec58efa3460c66e4e1411bac403942905 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 17:21:42 +0200 Subject: [PATCH 13/15] ok ok, docker only for linux in CI :-) --- .../test/java/io/vertx/example/jpms/tests/SqlClientTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java b/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java index 0e765b5c1..c735c4eb9 100644 --- a/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java +++ b/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java @@ -20,7 +20,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; -@EnabledOnOs(value = { OS.LINUX, OS.MAC }) +@EnabledOnOs(value = { OS.LINUX }) public class SqlClientTest { private static GenericContainer container; From 386ae525241fa044cc70a63731693edcc1e439ab Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 17:49:52 +0200 Subject: [PATCH 14/15] Native server test --- jpms-examples/src/main/java/module-info.java | 1 + .../jpms/tests/NativeTransportTest.java | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 jpms-examples/src/test/java/io/vertx/example/jpms/tests/NativeTransportTest.java diff --git a/jpms-examples/src/main/java/module-info.java b/jpms-examples/src/main/java/module-info.java index 2819f8203..c569b982c 100644 --- a/jpms-examples/src/main/java/module-info.java +++ b/jpms-examples/src/main/java/module-info.java @@ -18,5 +18,6 @@ requires jdk.crypto.ec; exports io.vertx.example.jpms.sqlclient; + exports io.vertx.example.jpms.native_transport; } diff --git a/jpms-examples/src/test/java/io/vertx/example/jpms/tests/NativeTransportTest.java b/jpms-examples/src/test/java/io/vertx/example/jpms/tests/NativeTransportTest.java new file mode 100644 index 000000000..901b10ed8 --- /dev/null +++ b/jpms-examples/src/test/java/io/vertx/example/jpms/tests/NativeTransportTest.java @@ -0,0 +1,51 @@ +package io.vertx.example.jpms.tests; + +import io.vertx.core.Vertx; +import io.vertx.core.VertxOptions; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpClient; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpResponseExpectation; +import io.vertx.core.json.JsonObject; +import io.vertx.example.jpms.native_transport.Server; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class NativeTransportTest { + + private Vertx vertx; + + @BeforeEach + public void before() { + vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true)); + assertTrue(vertx.isNativeTransportEnabled()); + } + + @AfterEach + public void after() { + vertx + .close() + .await(); + } + + @Test + public void testNativeTransport() { + vertx + .deployVerticle(new Server()) + .await(); + HttpClient client = vertx.createHttpClient(); + JsonObject res = client.request(HttpMethod.GET, 8080, "localhost", "/") + .compose(req -> req.send() + .expecting(HttpResponseExpectation.SC_OK) + .compose(resp -> resp + .body() + .map(Buffer::toJsonObject)) + ) + .await(); + assertEquals("Hello World", res.getString("message")); + assertTrue(res.getBoolean("nativeTransport")); + } +} From 632ce496cd1e53e09272189b81571ac6eb1229c2 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Fri, 25 Oct 2024 18:37:00 +0200 Subject: [PATCH 15/15] Adapt to new VerticleBase --- .../io/vertx/example/jpms/grpc/Server.java | 32 +++++++++---------- .../io/vertx/example/jpms/http/Server.java | 24 +++++++------- .../io/vertx/example/jpms/http2/Server.java | 29 ++++++++--------- .../example/jpms/native_transport/Server.java | 20 ++++++------ .../io/vertx/example/jpms/openssl/Server.java | 24 +++++++------- .../vertx/example/jpms/sqlclient/Client.java | 17 +++------- 6 files changed, 66 insertions(+), 80 deletions(-) diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/grpc/Server.java b/jpms-examples/src/main/java/io/vertx/example/jpms/grpc/Server.java index df7b232a5..535daa81d 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/grpc/Server.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/grpc/Server.java @@ -3,16 +3,13 @@ import io.grpc.examples.helloworld.HelloReply; import io.grpc.examples.helloworld.HelloRequest; import io.grpc.examples.helloworld.VertxGreeterGrpcServer; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Future; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; +import io.vertx.core.*; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.net.JksOptions; import io.vertx.grpc.server.GrpcServer; -public class Server extends AbstractVerticle { +public class Server extends VerticleBase { public static void main(String[] args) { Vertx vertx = Vertx.vertx(); @@ -21,14 +18,9 @@ public static void main(String[] args) { } @Override - public void start(Promise startFuture) { - HttpServer server = vertx.createHttpServer( - new HttpServerOptions() - .setUseAlpn(true) - .setKeyCertOptions(new JksOptions().setPath("server-keystore.jks").setPassword("wibble")) - .setSsl(false) - ); + public Future start() { GrpcServer grpcServer = GrpcServer.server(vertx); + VertxGreeterGrpcServer.GreeterApi api = new VertxGreeterGrpcServer.GreeterApi() { @Override public Future sayHello(HelloRequest request) { @@ -40,10 +32,16 @@ public Future sayHello(HelloRequest request) { } }; api.bind_sayHello(grpcServer); - server - .requestHandler(grpcServer) - .listen(8080) - .mapEmpty() - .onComplete(startFuture); + + HttpServer server = vertx + .createHttpServer( + new HttpServerOptions() + .setUseAlpn(true) + .setKeyCertOptions(new JksOptions().setPath("server-keystore.jks").setPassword("wibble")) + .setSsl(false) + ) + .requestHandler(grpcServer); + + return server.listen(8080); } } diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/http/Server.java b/jpms-examples/src/main/java/io/vertx/example/jpms/http/Server.java index f4c6020e3..b146d9c78 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/http/Server.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/http/Server.java @@ -1,12 +1,10 @@ package io.vertx.example.jpms.http; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; +import io.vertx.core.*; import io.vertx.core.http.HttpServer; import io.vertx.core.json.JsonObject; -public class Server extends AbstractVerticle { +public class Server extends VerticleBase { public static void main(String[] args) { Vertx vertx = Vertx.vertx(); @@ -15,15 +13,17 @@ public static void main(String[] args) { } @Override - public void start(Promise startFuture) { + public Future start() { + HttpServer server = vertx.createHttpServer(); + server.requestHandler(req -> { - req.response().end(new JsonObject() - .put("http", req.version()) - .put("message", "Hello World") - .toString()); - }).listen(8080) - .mapEmpty() - .onComplete(startFuture); + req.response().end(new JsonObject() + .put("http", req.version()) + .put("message", "Hello World") + .toString()); + }); + + return server.listen(8080); } } diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/http2/Server.java b/jpms-examples/src/main/java/io/vertx/example/jpms/http2/Server.java index 8886f9475..910c35c61 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/http2/Server.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/http2/Server.java @@ -1,14 +1,12 @@ package io.vertx.example.jpms.http2; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; +import io.vertx.core.*; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.json.JsonObject; import io.vertx.core.net.JksOptions; -public class Server extends AbstractVerticle { +public class Server extends VerticleBase { public static void main(String[] args) { Vertx vertx = Vertx.vertx(); @@ -17,20 +15,21 @@ public static void main(String[] args) { } @Override - public void start(Promise startFuture) { - HttpServer server = vertx.createHttpServer( - new HttpServerOptions() - .setUseAlpn(true) - .setKeyCertOptions(new JksOptions().setPath("server-keystore.jks").setPassword("wibble")) - .setSsl(true) - ); - server.requestHandler(req -> { + public Future start() { + HttpServerOptions options = new HttpServerOptions() + .setUseAlpn(true) + .setKeyCertOptions(new JksOptions().setPath("server-keystore.jks").setPassword("wibble")) + .setSsl(true); + + HttpServer server = vertx + .createHttpServer(options) + .requestHandler(req -> { req.response().end(new JsonObject() .put("http", req.version()) .put("message", "Hello World") .toString()); - }).listen(8443) - .mapEmpty() - .onComplete(startFuture); + }); + + return server.listen(8443); } } diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/native_transport/Server.java b/jpms-examples/src/main/java/io/vertx/example/jpms/native_transport/Server.java index 9954efaab..4fbef1054 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/native_transport/Server.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/native_transport/Server.java @@ -1,15 +1,12 @@ package io.vertx.example.jpms.native_transport; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; -import io.vertx.core.VertxOptions; +import io.vertx.core.*; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.json.JsonObject; import io.vertx.core.net.JksOptions; -public class Server extends AbstractVerticle { +public class Server extends VerticleBase { public static void main(String[] args) { Vertx vertx = Vertx.vertx(new VertxOptions() @@ -22,16 +19,17 @@ public static void main(String[] args) { } @Override - public void start(Promise startFuture) { - HttpServer server = vertx.createHttpServer(); - server.requestHandler(req -> { + public Future start() { + HttpServer server = vertx + .createHttpServer() + .requestHandler(req -> { req.response().end(new JsonObject() .put("http", req.version()) .put("message", "Hello World") .put("nativeTransport", vertx.isNativeTransportEnabled()) .toString()); - }).listen(8080) - .mapEmpty() - .onComplete(startFuture); + }); + + return server.listen(8080); } } diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/openssl/Server.java b/jpms-examples/src/main/java/io/vertx/example/jpms/openssl/Server.java index 9160eee9a..f347ed683 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/openssl/Server.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/openssl/Server.java @@ -1,16 +1,13 @@ package io.vertx.example.jpms.openssl; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; -import io.vertx.core.VertxOptions; +import io.vertx.core.*; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.json.JsonObject; import io.vertx.core.net.JksOptions; import io.vertx.core.net.OpenSSLEngineOptions; -public class Server extends AbstractVerticle { +public class Server extends VerticleBase { public static void main(String[] args) { Vertx vertx = Vertx.vertx(); @@ -19,21 +16,24 @@ public static void main(String[] args) { } @Override - public void start(Promise startFuture) { - HttpServer server = vertx.createHttpServer(new HttpServerOptions() + public Future start() { + HttpServerOptions options = new HttpServerOptions() .setSslEngineOptions(new OpenSSLEngineOptions()) .setKeyCertOptions(new JksOptions() .setPath("server-keystore.jks") .setPassword("wibble")) - .setSsl(true)); - server.requestHandler(req -> { + .setSsl(true); + + HttpServer server = vertx + .createHttpServer(options) + .requestHandler(req -> { req.response().end(new JsonObject() .put("http", req.version()) .put("message", "Hello World") .put("nativeTransport", vertx.isNativeTransportEnabled()) .toString()); - }).listen(8443) - .mapEmpty() - .onComplete(startFuture); + }); + + return server.listen(8443); } } diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/sqlclient/Client.java b/jpms-examples/src/main/java/io/vertx/example/jpms/sqlclient/Client.java index 3f5b66232..7a80dca39 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/sqlclient/Client.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/sqlclient/Client.java @@ -1,25 +1,19 @@ package io.vertx.example.jpms.sqlclient; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; +import io.vertx.core.*; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpServer; import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; import io.vertx.pgclient.PgBuilder; import io.vertx.pgclient.PgConnectOptions; import io.vertx.sqlclient.Pool; -import io.vertx.sqlclient.Row; -import java.util.Map; -import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /* * @author Paulo Lopes */ -public class Client extends AbstractVerticle { +public class Client extends VerticleBase { private PgConnectOptions database; private HttpServer server; @@ -30,8 +24,7 @@ public Client(PgConnectOptions database) { this.database = database; } - @Override - public void start(Promise start) { + public Future start() { client = PgBuilder.pool() .connectingTo(database) .using(vertx) @@ -56,8 +49,6 @@ public void start(Promise start) { }); }); - server.listen(8080) - .mapEmpty() - .onComplete(start); + return server.listen(8080); } }