Skip to content

Commit 73b2a36

Browse files
committed
Remove use of Config.global() setter. Add @Testing.Test annotation
1 parent 28a5629 commit 73b2a36

File tree

9 files changed

+35
-8
lines changed

9 files changed

+35
-8
lines changed

examples/dbclient/jdbc/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@
162162
<artifactId>helidon-webclient</artifactId>
163163
<scope>test</scope>
164164
</dependency>
165+
<dependency>
166+
<groupId>io.helidon.testing</groupId>
167+
<artifactId>helidon-testing-junit5</artifactId>
168+
<scope>test</scope>
169+
</dependency>
165170
<dependency>
166171
<groupId>org.junit.jupiter</groupId>
167172
<artifactId>junit-jupiter-api</artifactId>

examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceH2IT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import io.helidon.config.Config;
2222
import io.helidon.config.ConfigSources;
2323

24+
import io.helidon.service.registry.Services;
25+
import io.helidon.testing.junit5.Testing;
2426
import org.junit.jupiter.api.AfterAll;
2527
import org.junit.jupiter.api.BeforeAll;
2628
import org.testcontainers.containers.GenericContainer;
@@ -31,6 +33,7 @@
3133

3234
import static io.helidon.config.ConfigSources.classpath;
3335

36+
@Testing.Test
3437
@Testcontainers(disabledWithoutDocker = true)
3538
class PokemonServiceH2IT extends AbstractPokemonServiceTest {
3639
private static final DockerImageName H2_IMAGE = DockerImageName.parse("nemerosa/h2");
@@ -43,7 +46,7 @@ class PokemonServiceH2IT extends AbstractPokemonServiceTest {
4346
@BeforeAll
4447
static void start() {
4548
String url = String.format("jdbc:h2:tcp://localhost:%s/~./test", container.getMappedPort(9082));
46-
Config.global(Config.builder()
49+
Services.set(Config.class, Config.builder()
4750
.addSource(ConfigSources.create(Map.of("db.connection.url", url)))
4851
.addSource(classpath("application-h2-test.yaml"))
4952
.build());

examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceMySQLIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import io.helidon.config.Config;
2222
import io.helidon.config.ConfigSources;
2323

24+
import io.helidon.service.registry.Services;
25+
import io.helidon.testing.junit5.Testing;
2426
import org.junit.jupiter.api.AfterAll;
2527
import org.junit.jupiter.api.BeforeAll;
2628
import org.testcontainers.containers.MySQLContainer;
@@ -29,6 +31,7 @@
2931

3032
import static io.helidon.config.ConfigSources.classpath;
3133

34+
@Testing.Test
3235
@Testcontainers(disabledWithoutDocker = true)
3336
class PokemonServiceMySQLIT extends AbstractPokemonServiceTest {
3437

@@ -41,7 +44,7 @@ class PokemonServiceMySQLIT extends AbstractPokemonServiceTest {
4144

4245
@BeforeAll
4346
static void start() {
44-
Config.global(Config.builder()
47+
Services.set(Config.class, Config.builder()
4548
.addSource(ConfigSources.create(Map.of("db.connection.url", container.getJdbcUrl())))
4649
.addSource(classpath("application-mysql-test.yaml"))
4750
.build());

examples/dbclient/jdbc/src/test/java/io/helidon/examples/dbclient/jdbc/PokemonServiceOracleIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import io.helidon.config.Config;
2121
import io.helidon.config.ConfigSources;
2222

23+
import io.helidon.service.registry.Services;
24+
import io.helidon.testing.junit5.Testing;
2325
import org.junit.jupiter.api.AfterAll;
2426
import org.junit.jupiter.api.BeforeAll;
2527
import org.testcontainers.containers.OracleContainer;
@@ -30,6 +32,7 @@
3032

3133
import static io.helidon.config.ConfigSources.classpath;
3234

35+
@Testing.Test
3336
@Testcontainers(disabledWithoutDocker = true)
3437
public class PokemonServiceOracleIT extends AbstractPokemonServiceTest {
3538

@@ -45,7 +48,7 @@ public class PokemonServiceOracleIT extends AbstractPokemonServiceTest {
4548

4649
@BeforeAll
4750
static void start() {
48-
Config.global(Config.builder()
51+
Services.set(Config.class, Config.builder()
4952
.addSource(ConfigSources.create(Map.of("db.connection.url", container.getJdbcUrl())))
5053
.addSource(classpath("application-oracle-test.yaml"))
5154
.build());

examples/dbclient/pokemons/src/main/java/io/helidon/examples/dbclient/pokemons/Main.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.helidon.dbclient.DbClient;
2323
import io.helidon.dbclient.health.DbClientHealthCheck;
2424
import io.helidon.logging.common.LogConfig;
25+
import io.helidon.service.registry.Services;
2526
import io.helidon.webserver.WebServer;
2627
import io.helidon.webserver.WebServerConfig;
2728
import io.helidon.webserver.http.HttpRouting;
@@ -72,7 +73,7 @@ private static void startServer() {
7273

7374
// By default, this will pick up application.yaml from the classpath
7475
Config config = mongo ? Config.create(ConfigSources.classpath(MONGO_CFG)) : Config.create();
75-
Config.global(config);
76+
Services.set(Config.class, config);
7677

7778
WebServer server = setupServer(WebServer.builder())
7879
.build()

examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceH2IT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import io.helidon.config.Config;
2121
import io.helidon.config.ConfigSources;
2222

23+
import io.helidon.service.registry.Services;
24+
import io.helidon.testing.junit5.Testing;
2325
import org.junit.jupiter.api.AfterAll;
2426
import org.junit.jupiter.api.BeforeAll;
2527
import org.testcontainers.containers.GenericContainer;
@@ -33,6 +35,7 @@
3335
/**
3436
* Tests {@link io.helidon.examples.dbclient.pokemons.PokemonService}.
3537
*/
38+
@Testing.Test
3639
@Testcontainers(disabledWithoutDocker = true)
3740
class PokemonServiceH2IT extends AbstractPokemonServiceTest {
3841
private static final DockerImageName H2_IMAGE = DockerImageName.parse("nemerosa/h2");
@@ -45,7 +48,7 @@ class PokemonServiceH2IT extends AbstractPokemonServiceTest {
4548
@BeforeAll
4649
static void start() {
4750
String url = String.format("jdbc:h2:tcp://localhost:%s/~./test", container.getMappedPort(9082));
48-
Config.global(Config.builder()
51+
Services.set(Config.class, Config.builder()
4952
.addSource(ConfigSources.create(Map.of("db.connection.url", url)))
5053
.addSource(classpath("application-h2-test.yaml"))
5154
.build());

examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMongoIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import io.helidon.config.Config;
2121
import io.helidon.config.ConfigSources;
2222

23+
import io.helidon.service.registry.Services;
24+
import io.helidon.testing.junit5.Testing;
2325
import org.junit.jupiter.api.AfterAll;
2426
import org.junit.jupiter.api.BeforeAll;
2527
import org.testcontainers.containers.MongoDBContainer;
@@ -28,6 +30,7 @@
2830

2931
import static io.helidon.config.ConfigSources.classpath;
3032

33+
@Testing.Test
3134
@Testcontainers(disabledWithoutDocker = true)
3235
public class PokemonServiceMongoIT extends AbstractPokemonServiceTest {
3336

@@ -38,7 +41,7 @@ public class PokemonServiceMongoIT extends AbstractPokemonServiceTest {
3841
@BeforeAll
3942
static void start() {
4043
String url = String.format("mongodb://127.0.0.1:%s/pokemon", container.getMappedPort(27017));
41-
Config.global(Config.builder()
44+
Services.set(Config.class, Config.builder()
4245
.addSource(ConfigSources.create(Map.of("db.connection.url", url)))
4346
.addSource(classpath("application-mongo-test.yaml"))
4447
.build());

examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceMySQLIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import io.helidon.config.Config;
2121
import io.helidon.config.ConfigSources;
2222

23+
import io.helidon.service.registry.Services;
24+
import io.helidon.testing.junit5.Testing;
2325
import org.junit.jupiter.api.AfterAll;
2426
import org.junit.jupiter.api.BeforeAll;
2527
import org.testcontainers.containers.MySQLContainer;
@@ -28,6 +30,7 @@
2830

2931
import static io.helidon.config.ConfigSources.classpath;
3032

33+
@Testing.Test
3134
@Testcontainers(disabledWithoutDocker = true)
3235
public class PokemonServiceMySQLIT extends AbstractPokemonServiceTest {
3336

@@ -40,7 +43,7 @@ public class PokemonServiceMySQLIT extends AbstractPokemonServiceTest {
4043

4144
@BeforeAll
4245
static void start() {
43-
Config.global(Config.builder()
46+
Services.set(Config.class, Config.builder()
4447
.addSource(ConfigSources.create(Map.of("db.connection.url", container.getJdbcUrl())))
4548
.addSource(classpath("application-mysql-test.yaml"))
4649
.build());

examples/dbclient/pokemons/src/test/java/io/helidon/examples/dbclient/pokemons/PokemonServiceOracleIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import io.helidon.config.Config;
2121
import io.helidon.config.ConfigSources;
2222

23+
import io.helidon.service.registry.Services;
24+
import io.helidon.testing.junit5.Testing;
2325
import org.junit.jupiter.api.AfterAll;
2426
import org.junit.jupiter.api.BeforeAll;
2527
import org.testcontainers.containers.OracleContainer;
@@ -30,6 +32,7 @@
3032

3133
import static io.helidon.config.ConfigSources.classpath;
3234

35+
@Testing.Test
3336
@Testcontainers(disabledWithoutDocker = true)
3437
public class PokemonServiceOracleIT extends AbstractPokemonServiceTest {
3538

@@ -45,7 +48,7 @@ public class PokemonServiceOracleIT extends AbstractPokemonServiceTest {
4548

4649
@BeforeAll
4750
static void setup() {
48-
Config.global(Config.builder()
51+
Services.set(Config.class, Config.builder()
4952
.addSource(ConfigSources.create(Map.of("db.connection.url", container.getJdbcUrl())))
5053
.addSource(classpath("application-oracle-test.yaml"))
5154
.build());

0 commit comments

Comments
 (0)