From f7e7df5fe7583b6c41e2383e768d72b255b733a5 Mon Sep 17 00:00:00 2001 From: Joe Di Pol Date: Mon, 4 Aug 2025 12:57:42 -0700 Subject: [PATCH 1/2] Remove use of Config.global() setter. Add @Testing.Test annotation --- examples/dbclient/jdbc/pom.xml | 5 +++++ .../helidon/examples/dbclient/jdbc/PokemonServiceH2IT.java | 5 ++++- .../examples/dbclient/jdbc/PokemonServiceMySQLIT.java | 5 ++++- .../examples/dbclient/jdbc/PokemonServiceOracleIT.java | 5 ++++- .../java/io/helidon/examples/dbclient/pokemons/Main.java | 3 ++- .../examples/dbclient/pokemons/PokemonServiceH2IT.java | 5 ++++- .../examples/dbclient/pokemons/PokemonServiceMongoIT.java | 5 ++++- .../examples/dbclient/pokemons/PokemonServiceMySQLIT.java | 5 ++++- .../examples/dbclient/pokemons/PokemonServiceOracleIT.java | 5 ++++- 9 files changed, 35 insertions(+), 8 deletions(-) diff --git a/examples/dbclient/jdbc/pom.xml b/examples/dbclient/jdbc/pom.xml index 9760f8478..c729fb03e 100644 --- a/examples/dbclient/jdbc/pom.xml +++ b/examples/dbclient/jdbc/pom.xml @@ -162,6 +162,11 @@ helidon-webclient test + + io.helidon.testing + helidon-testing-junit5 + test + org.junit.jupiter junit-jupiter-api diff --git a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceH2IT.java b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceH2IT.java index 7f5c8dee1..e06534f19 100644 --- a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceH2IT.java +++ b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceH2IT.java @@ -21,6 +21,8 @@ import io.helidon.config.Config; import io.helidon.config.ConfigSources; +import io.helidon.service.registry.Services; +import io.helidon.testing.junit5.Testing; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.GenericContainer; @@ -31,6 +33,7 @@ import static io.helidon.config.ConfigSources.classpath; +@Testing.Test @Testcontainers(disabledWithoutDocker = true) class PokemonServiceH2IT extends AbstractPokemonServiceTest { private static final DockerImageName H2_IMAGE = DockerImageName.parse("nemerosa/h2"); @@ -43,7 +46,7 @@ class PokemonServiceH2IT extends AbstractPokemonServiceTest { @BeforeAll static void start() { String url = String.format("jdbc:h2:tcp://localhost:%s/~./test", container.getMappedPort(9082)); - Config.global(Config.builder() + Services.set(Config.class, Config.builder() .addSource(ConfigSources.create(Map.of("db.connection.url", url))) .addSource(classpath("application-h2-test.yaml")) .build()); diff --git a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceMySQLIT.java b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceMySQLIT.java index eee51c64b..5efd6316c 100644 --- a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceMySQLIT.java +++ b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceMySQLIT.java @@ -21,6 +21,8 @@ import io.helidon.config.Config; import io.helidon.config.ConfigSources; +import io.helidon.service.registry.Services; +import io.helidon.testing.junit5.Testing; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.MySQLContainer; @@ -29,6 +31,7 @@ import static io.helidon.config.ConfigSources.classpath; +@Testing.Test @Testcontainers(disabledWithoutDocker = true) class PokemonServiceMySQLIT extends AbstractPokemonServiceTest { @@ -41,7 +44,7 @@ class PokemonServiceMySQLIT extends AbstractPokemonServiceTest { @BeforeAll static void start() { - Config.global(Config.builder() + Services.set(Config.class, Config.builder() .addSource(ConfigSources.create(Map.of("db.connection.url", container.getJdbcUrl()))) .addSource(classpath("application-mysql-test.yaml")) .build()); diff --git a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceOracleIT.java b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceOracleIT.java index a37525049..339510af2 100644 --- a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceOracleIT.java +++ b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceOracleIT.java @@ -20,6 +20,8 @@ import io.helidon.config.Config; import io.helidon.config.ConfigSources; +import io.helidon.service.registry.Services; +import io.helidon.testing.junit5.Testing; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.OracleContainer; @@ -30,6 +32,7 @@ import static io.helidon.config.ConfigSources.classpath; +@Testing.Test @Testcontainers(disabledWithoutDocker = true) public class PokemonServiceOracleIT extends AbstractPokemonServiceTest { @@ -45,7 +48,7 @@ public class PokemonServiceOracleIT extends AbstractPokemonServiceTest { @BeforeAll static void start() { - Config.global(Config.builder() + Services.set(Config.class, Config.builder() .addSource(ConfigSources.create(Map.of("db.connection.url", container.getJdbcUrl()))) .addSource(classpath("application-oracle-test.yaml")) .build()); diff --git a/examples/dbclient/pokemons/src/main/java/io/helidon/examples/dbclient/pokemons/Main.java b/examples/dbclient/pokemons/src/main/java/io/helidon/examples/dbclient/pokemons/Main.java index bf56292d7..04cfa7b95 100644 --- a/examples/dbclient/pokemons/src/main/java/io/helidon/examples/dbclient/pokemons/Main.java +++ b/examples/dbclient/pokemons/src/main/java/io/helidon/examples/dbclient/pokemons/Main.java @@ -22,6 +22,7 @@ import io.helidon.dbclient.DbClient; import io.helidon.dbclient.health.DbClientHealthCheck; import io.helidon.logging.common.LogConfig; +import io.helidon.service.registry.Services; import io.helidon.webserver.WebServer; import io.helidon.webserver.WebServerConfig; import io.helidon.webserver.http.HttpRouting; @@ -72,7 +73,7 @@ private static void startServer() { // By default, this will pick up application.yaml from the classpath Config config = mongo ? Config.create(ConfigSources.classpath(MONGO_CFG)) : Config.create(); - Config.global(config); + Services.set(Config.class, config); WebServer server = setupServer(WebServer.builder()) .build() diff --git a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceH2IT.java b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceH2IT.java index 25774f174..89988a990 100644 --- a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceH2IT.java +++ b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceH2IT.java @@ -20,6 +20,8 @@ import io.helidon.config.Config; import io.helidon.config.ConfigSources; +import io.helidon.service.registry.Services; +import io.helidon.testing.junit5.Testing; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.GenericContainer; @@ -33,6 +35,7 @@ /** * Tests {@link io.helidon.examples.dbclient.pokemons.PokemonService}. */ +@Testing.Test @Testcontainers(disabledWithoutDocker = true) class PokemonServiceH2IT extends AbstractPokemonServiceTest { private static final DockerImageName H2_IMAGE = DockerImageName.parse("nemerosa/h2"); @@ -45,7 +48,7 @@ class PokemonServiceH2IT extends AbstractPokemonServiceTest { @BeforeAll static void start() { String url = String.format("jdbc:h2:tcp://localhost:%s/~./test", container.getMappedPort(9082)); - Config.global(Config.builder() + Services.set(Config.class, Config.builder() .addSource(ConfigSources.create(Map.of("db.connection.url", url))) .addSource(classpath("application-h2-test.yaml")) .build()); diff --git a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMongoIT.java b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMongoIT.java index d0013d565..dd2aa879e 100644 --- a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMongoIT.java +++ b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMongoIT.java @@ -20,6 +20,8 @@ import io.helidon.config.Config; import io.helidon.config.ConfigSources; +import io.helidon.service.registry.Services; +import io.helidon.testing.junit5.Testing; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.MongoDBContainer; @@ -28,6 +30,7 @@ import static io.helidon.config.ConfigSources.classpath; +@Testing.Test @Testcontainers(disabledWithoutDocker = true) public class PokemonServiceMongoIT extends AbstractPokemonServiceTest { @@ -38,7 +41,7 @@ public class PokemonServiceMongoIT extends AbstractPokemonServiceTest { @BeforeAll static void start() { String url = String.format("mongodb://127.0.0.1:%s/pokemon", container.getMappedPort(27017)); - Config.global(Config.builder() + Services.set(Config.class, Config.builder() .addSource(ConfigSources.create(Map.of("db.connection.url", url))) .addSource(classpath("application-mongo-test.yaml")) .build()); diff --git a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMySQLIT.java b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMySQLIT.java index 36d03ddc0..ba96f8008 100644 --- a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMySQLIT.java +++ b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMySQLIT.java @@ -20,6 +20,8 @@ import io.helidon.config.Config; import io.helidon.config.ConfigSources; +import io.helidon.service.registry.Services; +import io.helidon.testing.junit5.Testing; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.MySQLContainer; @@ -28,6 +30,7 @@ import static io.helidon.config.ConfigSources.classpath; +@Testing.Test @Testcontainers(disabledWithoutDocker = true) public class PokemonServiceMySQLIT extends AbstractPokemonServiceTest { @@ -40,7 +43,7 @@ public class PokemonServiceMySQLIT extends AbstractPokemonServiceTest { @BeforeAll static void start() { - Config.global(Config.builder() + Services.set(Config.class, Config.builder() .addSource(ConfigSources.create(Map.of("db.connection.url", container.getJdbcUrl()))) .addSource(classpath("application-mysql-test.yaml")) .build()); diff --git a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceOracleIT.java b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceOracleIT.java index cf2d4f6d9..3415584a0 100644 --- a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceOracleIT.java +++ b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceOracleIT.java @@ -20,6 +20,8 @@ import io.helidon.config.Config; import io.helidon.config.ConfigSources; +import io.helidon.service.registry.Services; +import io.helidon.testing.junit5.Testing; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.OracleContainer; @@ -30,6 +32,7 @@ import static io.helidon.config.ConfigSources.classpath; +@Testing.Test @Testcontainers(disabledWithoutDocker = true) public class PokemonServiceOracleIT extends AbstractPokemonServiceTest { @@ -45,7 +48,7 @@ public class PokemonServiceOracleIT extends AbstractPokemonServiceTest { @BeforeAll static void setup() { - Config.global(Config.builder() + Services.set(Config.class, Config.builder() .addSource(ConfigSources.create(Map.of("db.connection.url", container.getJdbcUrl()))) .addSource(classpath("application-oracle-test.yaml")) .build()); From 6d1d485779cf067b8712d93eda78ac5834e14de5 Mon Sep 17 00:00:00 2001 From: Joe Di Pol Date: Mon, 4 Aug 2025 16:04:39 -0700 Subject: [PATCH 2/2] Fix copyright --- .../io/helidon/examples/dbclient/jdbc/PokemonServiceH2IT.java | 2 +- .../helidon/examples/dbclient/jdbc/PokemonServiceMySQLIT.java | 2 +- .../helidon/examples/dbclient/jdbc/PokemonServiceOracleIT.java | 2 +- .../main/java/io/helidon/examples/dbclient/pokemons/Main.java | 2 +- .../helidon/examples/dbclient/pokemons/PokemonServiceH2IT.java | 2 +- .../examples/dbclient/pokemons/PokemonServiceMongoIT.java | 2 +- .../examples/dbclient/pokemons/PokemonServiceMySQLIT.java | 2 +- .../examples/dbclient/pokemons/PokemonServiceOracleIT.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceH2IT.java b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceH2IT.java index e06534f19..2a6351de5 100644 --- a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceH2IT.java +++ b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceH2IT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Copyright (c) 2023, 2025 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceMySQLIT.java b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceMySQLIT.java index 5efd6316c..5583e71c3 100644 --- a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceMySQLIT.java +++ b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceMySQLIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Copyright (c) 2023, 2025 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceOracleIT.java b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceOracleIT.java index 339510af2..1d4ac74c5 100644 --- a/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceOracleIT.java +++ b/examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceOracleIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Oracle and/or its affiliates. + * Copyright (c) 2024, 2025 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/dbclient/pokemons/src/main/java/io/helidon/examples/dbclient/pokemons/Main.java b/examples/dbclient/pokemons/src/main/java/io/helidon/examples/dbclient/pokemons/Main.java index 04cfa7b95..321122aad 100644 --- a/examples/dbclient/pokemons/src/main/java/io/helidon/examples/dbclient/pokemons/Main.java +++ b/examples/dbclient/pokemons/src/main/java/io/helidon/examples/dbclient/pokemons/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024 Oracle and/or its affiliates. + * Copyright (c) 2019, 2025 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceH2IT.java b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceH2IT.java index 89988a990..0019c4b19 100644 --- a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceH2IT.java +++ b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceH2IT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Copyright (c) 2023, 2025 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMongoIT.java b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMongoIT.java index dd2aa879e..287583f5e 100644 --- a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMongoIT.java +++ b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMongoIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Oracle and/or its affiliates. + * Copyright (c) 2024, 2025 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMySQLIT.java b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMySQLIT.java index ba96f8008..136c3be3c 100644 --- a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMySQLIT.java +++ b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMySQLIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Copyright (c) 2023, 2025 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceOracleIT.java b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceOracleIT.java index 3415584a0..4a0f23122 100644 --- a/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceOracleIT.java +++ b/examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceOracleIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Oracle and/or its affiliates. + * Copyright (c) 2024, 2025 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.