diff --git a/all/pom.xml b/all/pom.xml
index 7bf40904ed8..8a423d9567e 100644
--- a/all/pom.xml
+++ b/all/pom.xml
@@ -595,6 +595,10 @@
io.helidon.integrations.db
helidon-integrations-db-mysql
+
+ io.helidon.integrations.db
+ helidon-integrations-db-pgsql
+
io.helidon.integrations.cdi
helidon-integrations-cdi-configurable
diff --git a/bom/pom.xml b/bom/pom.xml
index adddfc941d6..b5532308d1a 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -793,6 +793,11 @@
helidon-integrations-db-mysql
${helidon.version}
+
+ io.helidon.integrations.db
+ helidon-integrations-db-pgsql
+ ${helidon.version}
+
io.helidon.integrations.cdi
helidon-integrations-cdi-configurable
diff --git a/dependencies/pom.xml b/dependencies/pom.xml
index 6694d157097..cc8c1d3e252 100644
--- a/dependencies/pom.xml
+++ b/dependencies/pom.xml
@@ -1304,6 +1304,11 @@
mysql
${version.lib.testcontainers}
+
+ org.testcontainers
+ jdbc
+ ${version.lib.testcontainers}
+
org.testcontainers
oracle-xe
diff --git a/docs/pom.xml b/docs/pom.xml
index feebb6ebea1..dbce12da1a4 100644
--- a/docs/pom.xml
+++ b/docs/pom.xml
@@ -52,6 +52,7 @@
mockito-core
+
org.apache.activemq
activemq-client
@@ -80,6 +81,11 @@
${version.lib.jbatch.container}
true
+
+ org.postgresql
+ postgresql
+ true
+
diff --git a/etc/copyright-exclude.txt b/etc/copyright-exclude.txt
index 3c4b0e2df76..cf1dcc364f8 100644
--- a/etc/copyright-exclude.txt
+++ b/etc/copyright-exclude.txt
@@ -67,3 +67,4 @@ src/test/resources/static/classpath/index.html
._java_
._inject_
service.loader
+.repo
diff --git a/etc/pods/mysql.yaml b/etc/pods/mysql.yaml
deleted file mode 100644
index 40f46b5aa62..00000000000
--- a/etc/pods/mysql.yaml
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (c) 2018, 2020 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.
-# 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.
-#
-
-apiVersion: v1
-kind: Pod
-metadata:
- name: mysql
-spec:
- containers:
- - name: mysql
- image: mysql:8
- ports:
- - containerPort: 3306
- env:
- - name: MYSQL_USER
- value: "user"
- - name: MYSQL_PASSWORD
- value: "password"
- - name: MYSQL_ROOT_PASSWORD
- value: "root"
- - name: MYSQL_DATABASE
- value: "pokemon"
diff --git a/etc/pods/vault.yaml b/etc/pods/vault.yaml
deleted file mode 100644
index ad21996bc48..00000000000
--- a/etc/pods/vault.yaml
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (c) 2021 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.
-# 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.
-#
-
-apiVersion: v1
-kind: Pod
-metadata:
- name: vault
-spec:
- containers:
- - name: mysql
- image: mysql:8
- imagePullPolicy: "IfNotPresent"
- ports:
- - containerPort: 3306
- env:
- - name: MYSQL_USER
- value: "user"
- - name: MYSQL_PASSWORD
- value: "password"
- - name: MYSQL_ROOT_PASSWORD
- value: "root"
- - name: MYSQL_DATABASE
- value: "pokemon"
- - name: vault
- image: vault:1.7.0
- imagePullPolicy: "IfNotPresent"
- ports:
- - containerPort: 8200
- env:
- - name: VAULT_DEV_ROOT_TOKEN_ID
- value: "myroot"
\ No newline at end of file
diff --git a/tests/integration/dbclient/app/pom.xml b/tests/integration/dbclient/app/pom.xml
deleted file mode 100644
index 0b01742c984..00000000000
--- a/tests/integration/dbclient/app/pom.xml
+++ /dev/null
@@ -1,265 +0,0 @@
-
-
-
- 4.0.0
-
- io.helidon.applications
- helidon-se
- 4.1.0-SNAPSHOT
- ../../../../applications/se/pom.xml
-
- io.helidon.tests.integration.dbclient
- helidon-tests-integration-dbclient-app
- 4.1.0-SNAPSHOT
- Helidon Tests Integration Database Client Application
-
-
- io.helidon.tests.integration.dbclient.app.Main
- true
- 1.9.3
-
-
-
-
- io.helidon.webserver
- helidon-webserver
-
-
- io.helidon.webserver.observe
- helidon-webserver-observe-health
-
-
- io.helidon.webserver.observe
- helidon-webserver-observe-metrics
-
-
- io.helidon.config
- helidon-config
-
-
- io.helidon.config
- helidon-config-yaml
-
-
- io.helidon.logging
- helidon-logging-jul
-
-
- io.helidon.dbclient
- helidon-dbclient-jdbc
-
-
- io.helidon.dbclient
- helidon-dbclient-hikari
-
-
- io.helidon.dbclient
- helidon-dbclient-health
-
-
- io.helidon.dbclient
- helidon-dbclient-metrics
-
-
- io.helidon.dbclient
- helidon-dbclient-metrics-hikari
-
-
- io.helidon.tests.integration.dbclient
- helidon-tests-integration-dbclient-common
- ${project.version}
-
-
- io.helidon.tests.integration
- helidon-tests-integration-harness
- ${project.version}
-
-
- org.eclipse.parsson
- parsson
-
-
- org.slf4j
- slf4j-jdk14
-
-
- io.helidon.webclient
- helidon-webclient
- test
-
-
- org.junit.jupiter
- junit-jupiter-api
- test
-
-
- org.junit.platform
- junit-platform-suite-engine
- ${version.lib.junit-suite}
- test
-
-
- org.hamcrest
- hamcrest-all
- test
-
-
-
-
-
- src/main/resources
- true
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy-libs
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- **/*IT
-
-
-
-
- org.apache.maven.plugins
- maven-failsafe-plugin
-
- false
- methods
- 10
-
- true
- ${app.config}
- ${db.user}
- ${db.password}
- ${db.url}
-
-
-
-
- test
- integration-test
-
- integration-test
- verify
-
-
-
- **/*SuiteIT
-
-
-
-
-
-
-
-
-
- native-image
-
-
-
- org.apache.maven.plugins
- maven-failsafe-plugin
-
-
- native
-
-
-
-
-
-
-
- h2
-
-
- !db
-
-
-
- h2.yaml
- test
- sa
-
- jdbc:h2:mem:${db.database};INIT=SET TRACE_LEVEL_FILE=2;DATABASE_TO_UPPER=FALSE
-
-
-
- io.helidon.integrations.db
- h2
-
-
- com.h2database
- h2
-
-
-
-
- mysql
-
-
- db
- mysql
-
-
-
-
- io.helidon.integrations.db
- helidon-integrations-db-mysql
- ${project.version}
-
-
- com.mysql
- mysql-connector-j
-
-
-
-
- pgsql
-
-
- db
- pgsql
-
-
-
-
- io.helidon.integrations.db
- helidon-integrations-db-pgsql
- ${project.version}
-
-
- org.postgresql
- postgresql
-
-
-
-
-
diff --git a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/ErrorHandlerImpl.java b/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/ErrorHandlerImpl.java
deleted file mode 100644
index f62cb574ff7..00000000000
--- a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/ErrorHandlerImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2023 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.
- * 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.helidon.tests.integration.dbclient.app;
-
-import io.helidon.webserver.http.ErrorHandler;
-import io.helidon.webserver.http.ServerRequest;
-import io.helidon.webserver.http.ServerResponse;
-
-import static io.helidon.tests.integration.harness.AppResponse.exceptionStatus;
-
-/**
- * Error handler.
- */
-class ErrorHandlerImpl implements ErrorHandler {
-
- /**
- * Singleton.
- */
- static final ErrorHandler INSTANCE = new ErrorHandlerImpl();
-
- private ErrorHandlerImpl() {
- }
-
- @Override
- public void handle(ServerRequest req, ServerResponse res, Throwable th) {
- th.printStackTrace();
- res.send(exceptionStatus(th));
- }
-}
diff --git a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/InitService.java b/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/InitService.java
deleted file mode 100644
index 9255caf9b96..00000000000
--- a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/InitService.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 2021, 2023 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.
- * 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.helidon.tests.integration.dbclient.app;
-
-import java.lang.System.Logger.Level;
-import java.util.List;
-import java.util.Map;
-
-import io.helidon.config.Config;
-import io.helidon.dbclient.DbClient;
-import io.helidon.dbclient.DbClientException;
-import io.helidon.dbclient.DbExecute;
-import io.helidon.dbclient.DbTransaction;
-import io.helidon.dbclient.health.DbClientHealthCheck;
-import io.helidon.health.HealthCheck;
-import io.helidon.health.HealthCheckResponse;
-import io.helidon.webserver.http.HttpRules;
-import io.helidon.webserver.http.HttpService;
-import io.helidon.webserver.http.ServerRequest;
-import io.helidon.webserver.http.ServerResponse;
-import io.helidon.tests.integration.dbclient.common.model.Pokemon;
-import io.helidon.tests.integration.dbclient.common.model.Type;
-
-import jakarta.json.Json;
-import jakarta.json.JsonObjectBuilder;
-
-import static io.helidon.tests.integration.harness.AppResponse.okStatus;
-
-/**
- * Service for tests initialization services.
- */
-public class InitService implements HttpService {
-
- private static final System.Logger LOGGER = System.getLogger(InitService.class.getName());
-
- private final DbClient dbClient;
- private final Config dbConfig;
-
- /**
- * Creates an instance of web resource for tests initialization services.
- *
- * @param dbClient DbClient instance
- * @param dbConfig testing application configuration
- */
- InitService(DbClient dbClient, Config dbConfig) {
- this.dbClient = dbClient;
- this.dbConfig = dbConfig;
- }
-
- @Override
- public void routing(HttpRules rules) {
- rules
- .get("/testPing", this::testPing)
- .get("/testHealthCheck", this::testHealthCheck)
- .get("/testDropSchema", this::testDropSchema)
- .get("/testInitSchema", this::testInitSchema)
- .get("/testInitTypes", this::testInitTypes)
- .get("/testInitPokemons", this::testInitPokemons)
- .get("/testInitPokemonTypes", this::testInitPokemonTypes);
- }
-
- private void testPing(ServerRequest request, ServerResponse response) {
- boolean ping = dbConfig.get("test.ping-dml")
- .map(c -> c.asBoolean().get())
- .orElse(false);
- JsonObjectBuilder data = Json.createObjectBuilder();
- data.add("ping-dml", ping);
- response.send(okStatus(data.build()));
- }
-
- private void testHealthCheck(ServerRequest request, ServerResponse response) {
- HealthCheck check = DbClientHealthCheck.create(
- dbClient,
- dbConfig.get("health-check"));
- HealthCheckResponse checkResponse = check.call();
- HealthCheckResponse.Status checkState = checkResponse.status();
- JsonObjectBuilder data = Json.createObjectBuilder();
- data.add("state", checkState.name());
- response.send(okStatus(data.build()));
- }
-
- private void testDropSchema(ServerRequest request, ServerResponse response) {
- DbExecute exec = dbClient.execute();
- long count = 0;
- for (String schema : List.of("poketypes", "pokemons", "types")) {
- String statementName = "drop-" + schema;
- try {
- count += exec.namedDml(statementName);
- } catch (DbClientException ex) {
- LOGGER.log(Level.DEBUG, () -> String.format(
- "Unable to execute statement: %s, %s",
- statementName,
- ex.getMessage()));
- }
- }
- response.send(okStatus(Json.createValue(count)));
- }
-
- private void testInitSchema(ServerRequest request, ServerResponse response) {
- DbExecute exec = dbClient.execute();
- long count = 0;
- for (String schema : List.of("types", "pokemons", "poketypes")) {
- String statementName = "create-" + schema;
- try {
- count += exec.namedDml(statementName);
- } catch (DbClientException ex) {
- LOGGER.log(Level.DEBUG, () -> String.format(
- "Unable to execute statement: %s, %s",
- statementName,
- ex.getMessage()));
- }
- }
- response.send(okStatus(Json.createValue(count)));
- }
-
- private void testInitTypes(ServerRequest request, ServerResponse response) {
- DbTransaction tx = dbClient.transaction();
- long count = 0;
- for (Map.Entry entry : Type.TYPES.entrySet()) {
- count += tx.namedDml("insert-type", entry.getKey(), entry.getValue().name());
- }
- tx.commit();
- response.send(okStatus(Json.createValue(count)));
- }
-
- private void testInitPokemons(ServerRequest request, ServerResponse response) {
- DbTransaction tx = dbClient.transaction();
- long count = 0;
- for (Map.Entry entry : Pokemon.POKEMONS.entrySet()) {
- count += tx.namedDml("insert-pokemon", entry.getKey(), entry.getValue().getName());
- }
- tx.commit();
- response.send(okStatus(Json.createValue(count)));
- }
-
- private void testInitPokemonTypes(ServerRequest request, ServerResponse response) {
- DbTransaction tx = dbClient.transaction();
- long count = 0;
- for (Map.Entry entry : Pokemon.POKEMONS.entrySet()) {
- Pokemon pokemon = entry.getValue();
- for (Type type : pokemon.getTypes()) {
- count += tx.namedDml("insert-poketype", pokemon.getId(), type.id());
- }
- }
- tx.commit();
- response.send(okStatus(Json.createValue(count)));
- }
-}
diff --git a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/Main.java b/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/Main.java
deleted file mode 100644
index 4f6cf0c0ce9..00000000000
--- a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/Main.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 2021, 2023 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.
- * 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.helidon.tests.integration.dbclient.app;
-
-import java.lang.System.Logger.Level;
-import java.util.Map;
-
-import io.helidon.config.Config;
-import io.helidon.config.ConfigSources;
-import io.helidon.dbclient.DbClient;
-import io.helidon.dbclient.DbClientException;
-import io.helidon.dbclient.DbClientService;
-import io.helidon.dbclient.DbStatementType;
-import io.helidon.dbclient.health.DbClientHealthCheck;
-import io.helidon.dbclient.metrics.DbClientMetrics;
-import io.helidon.metrics.api.MetricsFactory;
-import io.helidon.tests.integration.dbclient.app.tests.FlowControlService;
-import io.helidon.tests.integration.dbclient.app.tests.HealthCheckService;
-import io.helidon.tests.integration.dbclient.app.tests.InterceptorService;
-import io.helidon.tests.integration.dbclient.app.tests.MapperService;
-import io.helidon.tests.integration.dbclient.app.tests.SimpleDeleteService;
-import io.helidon.tests.integration.dbclient.app.tests.SimpleGetService;
-import io.helidon.tests.integration.dbclient.app.tests.SimpleInsertService;
-import io.helidon.tests.integration.dbclient.app.tests.SimpleQueryService;
-import io.helidon.tests.integration.dbclient.app.tests.SimpleUpdateService;
-import io.helidon.tests.integration.dbclient.app.tests.StatementDmlService;
-import io.helidon.tests.integration.dbclient.app.tests.StatementGetService;
-import io.helidon.tests.integration.dbclient.app.tests.StatementQueryService;
-import io.helidon.tests.integration.dbclient.app.tests.TransactionDeleteService;
-import io.helidon.tests.integration.dbclient.app.tests.TransactionGetService;
-import io.helidon.tests.integration.dbclient.app.tests.TransactionInsertService;
-import io.helidon.tests.integration.dbclient.app.tests.TransactionQueryService;
-import io.helidon.tests.integration.dbclient.app.tests.TransactionUpdateService;
-import io.helidon.tests.integration.dbclient.app.tools.ExitService;
-import io.helidon.tests.integration.harness.RemoteTestException;
-import io.helidon.webserver.WebServer;
-import io.helidon.webserver.observe.ObserveFeature;
-import io.helidon.webserver.observe.health.HealthObserver;
-
-/**
- * Main class.
- * Testing application entry point.
- */
-public class Main {
-
- private static final System.Logger LOGGER = System.getLogger(Main.class.getName());
- private static final String CONFIG_PROPERTY_NAME = "app.config";
- private static final String DEFAULT_CONFIG_FILE = "test.yaml";
-
- /**
- * Start the server.
- *
- * @param configFile config file
- * @return server
- */
- public static WebServer startServer(String configFile) {
-
- Config config = Config.create(ConfigSources.classpath("common.yaml"),
- ConfigSources.classpath(configFile));
- Config.global(config);
-
- Config dbConfig = config.get("db");
- MetricsFactory.getInstance(config.get("metrics"));
-
- // Client services are added through a service loader - see mongoDB example for explicit services
- DbClient dbClient = DbClient.builder(dbConfig)
- .addService(DbClientMetrics.counter()
- .statementNames(
- "select-pokemon-named-arg",
- "select-pokemon-order-arg",
- "insert-pokemon"))
- .addService(DbClientMetrics.timer().statementTypes(DbStatementType.GET))
- .build();
-
- HealthObserver health = HealthObserver.builder()
- .addCheck(DbClientHealthCheck.builder(dbClient)
- .statementName("ping-query")
- .build())
- .build();
-
- Map statements = dbConfig.get("statements")
- .detach()
- .asMap()
- .get();
-
- ExitService exitResource = new ExitService();
-
- DbClientService interceptorTestService = new InterceptorService.TestClientService();
-
- // Prepare routing for the server
- WebServer server = WebServer.builder()
- .featuresDiscoverServices(false)
- .addFeature(ObserveFeature.builder().addObserver(health).build())
- .routing(routing -> routing
- .register("/Init", new InitService(dbClient, dbConfig))
- .register("/Exit", exitResource)
- .register("/Verify", new VerifyService(dbClient, config))
- .register("/SimpleGet", new SimpleGetService(dbClient, statements))
- .register("/SimpleQuery", new SimpleQueryService(dbClient, statements))
- .register("/SimpleUpdate", new SimpleUpdateService(dbClient, statements))
- .register("/SimpleInsert", new SimpleInsertService(dbClient, statements))
- .register("/SimpleDelete", new SimpleDeleteService(dbClient, statements))
- .register("/TransactionGet", new TransactionGetService(dbClient, statements))
- .register("/TransactionQueries", new TransactionQueryService(dbClient, statements))
- .register("/TransactionUpdate", new TransactionUpdateService(dbClient, statements))
- .register("/TransactionInsert", new TransactionInsertService(dbClient, statements))
- .register("/TransactionDelete", new TransactionDeleteService(dbClient, statements))
- .register("/StatementDml", new StatementDmlService(dbClient, statements))
- .register("/StatementGet", new StatementGetService(dbClient, statements))
- .register("/StatementQuery", new StatementQueryService(dbClient, statements))
- .register("/FlowControl", new FlowControlService(dbClient, statements))
- .register("/Mapper", new MapperService(dbClient, statements))
- .register("/Interceptor", new InterceptorService(
- DbClient.builder(dbConfig)
- .addService(interceptorTestService).build(),
- statements,
- interceptorTestService))
- .register("/HealthCheck", new HealthCheckService(dbClient, dbConfig, statements))
- .error(DbClientException.class, ErrorHandlerImpl.INSTANCE)
- .error(RemoteTestException.class, ErrorHandlerImpl.INSTANCE))
- .config(config.get("server"))
- .build()
- .start();
-
- exitResource.setServer(server);
-
- // Start the server and print some info.
- System.out.println("WEB server is up! http://localhost:" + server.port() + "/");
-
- return server;
- }
-
- /**
- * Main method.
- *
- * @param args command line arguments
- */
- public static void main(String[] args) {
- String configFile;
- if (args != null && args.length > 0) {
- configFile = args[0];
- } else {
- configFile = System.getProperty(CONFIG_PROPERTY_NAME, DEFAULT_CONFIG_FILE);
- }
- LOGGER.log(Level.INFO, () -> String.format("Configuration file: %s", configFile));
- startServer(configFile);
- }
-}
diff --git a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/VerifyService.java b/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/VerifyService.java
deleted file mode 100644
index 20dfe368832..00000000000
--- a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/VerifyService.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2021, 2023 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.
- * 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.helidon.tests.integration.dbclient.app;
-
-import io.helidon.config.Config;
-import io.helidon.dbclient.DbClient;
-import io.helidon.dbclient.DbExecute;
-import io.helidon.tests.integration.dbclient.app.tests.AbstractService;
-import io.helidon.tests.integration.dbclient.app.tools.QueryParams;
-import io.helidon.webserver.http.HttpRules;
-import io.helidon.webserver.http.HttpService;
-import io.helidon.webserver.http.ServerRequest;
-import io.helidon.webserver.http.ServerResponse;
-
-import jakarta.json.Json;
-import jakarta.json.JsonArrayBuilder;
-import jakarta.json.JsonObject;
-import jakarta.json.JsonObjectBuilder;
-
-import static io.helidon.tests.integration.harness.AppResponse.okStatus;
-
-/**
- * Service for test data verification.
- */
-public class VerifyService implements HttpService {
-
- private final DbClient dbClient;
- private final Config config;
-
- VerifyService(DbClient dbClient, Config config) {
- this.dbClient = dbClient;
- this.config = config;
- }
-
- @Override
- public void routing(HttpRules rules) {
- rules.get("/getPokemonById", this::getPokemonById)
- .get("/getDatabaseType", this::getDatabaseType)
- .get("/getConfigParam", this::getConfigParam);
- }
-
- private void getPokemonById(ServerRequest request, ServerResponse response) {
- DbExecute exec = dbClient.execute();
- String idStr = AbstractService.queryParam(request, QueryParams.ID);
- int id = Integer.parseInt(idStr);
- JsonObject jsonObject = exec
- .namedGet("get-pokemon-by-id", id)
- .map(row -> Json.createObjectBuilder()
- .add("name", row.column("name").getString())
- .add("id", row.column("id").getInt())
- .add("types", exec.namedQuery("get-pokemon-types", id)
- .map(typeRow -> typeRow.as(JsonObject.class))
- .collect(
- Json::createArrayBuilder,
- JsonArrayBuilder::add,
- JsonArrayBuilder::add)
- .build())
- .build())
- .orElse(JsonObject.EMPTY_JSON_OBJECT);
- response.send(okStatus(jsonObject));
- }
-
- private void getDatabaseType(ServerRequest request, ServerResponse response) {
- JsonObjectBuilder job = Json.createObjectBuilder();
- job.add("type", dbClient.dbType());
- response.send(okStatus(job.build()));
- }
-
- private void getConfigParam(ServerRequest request, ServerResponse response) {
- String name = AbstractService.queryParam(request, QueryParams.NAME);
- Config node = config.get(name);
- JsonObjectBuilder job = Json.createObjectBuilder();
- if (!node.exists()) {
- response.send(okStatus(job.build()));
- return;
- }
- job.add("config", node.as(String.class).get());
- response.send(okStatus(job.build()));
- }
-
-}
diff --git a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/dbmapper/DbClientMapperProvider.java b/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/dbmapper/DbClientMapperProvider.java
deleted file mode 100644
index 687a3e3d864..00000000000
--- a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/dbmapper/DbClientMapperProvider.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2021, 2023 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.
- * 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.helidon.tests.integration.dbclient.app.dbmapper;
-
-import java.util.Optional;
-
-import io.helidon.dbclient.DbMapper;
-import io.helidon.dbclient.spi.DbMapperProvider;
-import io.helidon.tests.integration.dbclient.common.model.Pokemon;
-import io.helidon.tests.integration.dbclient.common.model.RangePoJo;
-
-import jakarta.json.JsonObject;
-
-/**
- * Provides Database Client mappers.
- */
-public class DbClientMapperProvider implements DbMapperProvider {
-
- @Override
- public Optional> mapper(Class type) {
- if (type.equals(JsonObject.class)) {
- return Optional.of((DbMapper)DbRowToJsonObjectMapper.getInstance());
- } else if (type.equals(RangePoJo.class)) {
- return Optional.of((DbMapper) RangePoJo.Mapper.INSTANCE);
- } else if (type.equals(Pokemon.class)) {
- return Optional.of((DbMapper) Pokemon.PokemonMapper.INSTANCE);
- } else {
- return Optional.empty();
- }
- }
-}
diff --git a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/dbmapper/DbRowToJsonObjectMapper.java b/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/dbmapper/DbRowToJsonObjectMapper.java
deleted file mode 100644
index 4aa2702eae6..00000000000
--- a/tests/integration/dbclient/app/src/main/java/io/helidon/tests/integration/dbclient/app/dbmapper/DbRowToJsonObjectMapper.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2021, 2023 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.
- * 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.helidon.tests.integration.dbclient.app.dbmapper;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.BiConsumer;
-
-import io.helidon.dbclient.DbColumn;
-import io.helidon.dbclient.DbMapper;
-import io.helidon.dbclient.DbRow;
-
-import jakarta.json.Json;
-import jakarta.json.JsonNumber;
-import jakarta.json.JsonObject;
-import jakarta.json.JsonObjectBuilder;
-import jakarta.json.JsonValue;
-
-// This implementation is limited only to conversions required by jUnit tests.
-/**
- * Mapper for DbRow to JsonObject conversion.
- */
-public class DbRowToJsonObjectMapper implements DbMapper {
-
- private static final DbRowToJsonObjectMapper INSTANCE = new DbRowToJsonObjectMapper();
-
- // Conversion is based on code used in EclipseLink:
- // https://github.com/eclipse-ee4j/eclipselink/blob/master/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ConversionManager.java#L164
- // https://github.com/eclipse-ee4j/eclipselink/blob/master/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/databaseaccess/DatabaseAccessor.java#L1347
- private static final Map, BiConsumer> MAPPERS = new HashMap<>();
-
- public static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd");
- public static final SimpleDateFormat TIME_FORMATTER = new SimpleDateFormat("HH:mm:ss");
- public static final SimpleDateFormat DATE_TIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
-
- static {
- MAPPERS.put(Byte.class, (job, column) -> job.add(column.name(), column.get(Byte.class).intValue()));
- MAPPERS.put(Short.class, (job, column) -> job.add(column.name(), column.get(Short.class).intValue()));
- MAPPERS.put(Integer.class, (job, column) -> job.add(column.name(), column.get(Integer.class)));
- MAPPERS.put(Long.class, (job, column) -> job.add(column.name(), column.get(Long.class)));
- MAPPERS.put(Float.class, (job, column) -> job.add(column.name(), column.get(Float.class).doubleValue()));
- MAPPERS.put(Double.class, (job, column) -> job.add(column.name(), column.get(Double.class)));
- MAPPERS.put(BigInteger.class, (job, column) -> job.add(column.name(), column.get(BigInteger.class)));
- MAPPERS.put(BigDecimal.class, (job, column) -> job.add(column.name(), column.get(BigDecimal.class)));
- MAPPERS.put(String.class, (job, column) -> job.add(column.name(), column.get(String.class)));
- MAPPERS.put(Character.class, (job, column) -> job.add(column.name(), column.get(Character.class).toString()));
- MAPPERS.put(Boolean.class, (job, column) -> job.add(column.name(), column.get(Boolean.class)));
- MAPPERS.put(java.sql.Date.class, (job, column) -> job.add(column.name(), DATE_FORMATTER.format(column.as(java.sql.Date.class))));
- MAPPERS.put(java.sql.Time.class, (job, column) -> job.add(column.name(), TIME_FORMATTER.format(column.as(java.sql.Time.class))));
- MAPPERS.put(java.sql.Timestamp.class, (job, column) -> job.add(column.name(), DATE_TIME_FORMATTER.format(column.as(java.sql.Timestamp.class))));
- MAPPERS.put(java.util.Date.class, (job, column) -> job.add(column.name(), DATE_TIME_FORMATTER.format(column.as(java.util.Date.class))));
- }
-
- static final DbRowToJsonObjectMapper getInstance() {
- return INSTANCE;
- }
-
- @Override
- public JsonObject read(DbRow dbRow) {
- JsonObjectBuilder job = Json.createObjectBuilder();
- dbRow.forEach((dbColumn) -> {
- BiConsumer mapper = MAPPERS.get(dbColumn.javaType());
- if (mapper != null) {
- mapper.accept(job, dbColumn);
- } else {
- job.add(dbColumn.name(), dbColumn.get().toString());
- }
- });
- return job.build();
- }
-
- @Override
- public Map toNamedParameters(JsonObject value) {
- Map params = new HashMap<>(value.size());
- for (Map.Entry entry : value.entrySet()) {
- switch(entry.getValue().getValueType()) {
- case STRING:
- params.put(entry.getKey(), entry.getValue().toString());
- break;
- case NUMBER:
- JsonNumber numberValue = (JsonNumber)entry.getValue();
- if (numberValue.isIntegral()) {
- params.put(entry.getKey(), numberValue.bigIntegerValue());
- } else {
- params.put(entry.getKey(), numberValue.bigDecimalValue());
- }
- break;
- case FALSE:
- params.put(entry.getKey(), Boolean.FALSE);
- break;
- case TRUE:
- params.put(entry.getKey(), Boolean.TRUE);
- break;
- case NULL:
- params.put(entry.getKey(), null);
- break;
- }
- }
- return params;
- }
-
- @Override
- public List> toIndexedParameters(JsonObject value) {
- List