From b231173250c4f83f178ac45357a08aed6330af18 Mon Sep 17 00:00:00 2001 From: Pierantonio Merlino Date: Thu, 5 Sep 2024 10:32:18 +0200 Subject: [PATCH] refactor(core)!: Added H2Db provider bundle (#5343) * Added db.h2db.provider bundle Signed-off-by: pierantoniomerlino * Removed H2Db code from core bundle Signed-off-by: pierantoniomerlino * Added new bundle in distrib Signed-off-by: pierantoniomerlino * Updated names in component definitions Signed-off-by: pierantoniomerlino * Fixed tests Signed-off-by: pierantoniomerlino * Removed core.db test Signed-off-by: pierantoniomerlino * Fixed some sonar issues Signed-off-by: pierantoniomerlino * Tried to fix sonar complain Signed-off-by: pierantoniomerlino * Fixed copyright; fixed import order Signed-off-by: pierantoniomerlino * Fixed copyright Signed-off-by: pierantoniomerlino --------- Signed-off-by: pierantoniomerlino --- kura/distrib/config/kura.build.properties | 1 + kura/distrib/pom.xml | 7 + .../src/main/ant/build_equinox_distrib.xml | 19 ++ .../META-INF/MANIFEST.MF | 9 - .../kura/core/data/DataServiceImpl.java | 39 +-- .../kura/core/data/DataServiceOptions.java | 13 +- .../.gitignore | 1 + .../META-INF/MANIFEST.MF | 33 ++ .../OSGI-INF/h2db.xml | 4 +- .../OSGI-INF/h2dbhelper.xml | 4 +- .../OSGI-INF/h2dbserver.xml | 4 +- .../org.eclipse.kura.core.db.H2DbServer.xml | 2 +- .../org.eclipse.kura.core.db.H2DbService.xml | 2 +- .../about.html | 0 .../about_files/epl-v20.html | 301 ++++++++++++++++++ .../build.properties | 23 ++ .../org.eclipse.kura.db.h2db.provider/pom.xml | 35 ++ .../db/h2db/provider}/H2DbHelper.java | 8 +- .../h2db/provider}/H2DbMessageStoreImpl.java | 4 +- .../H2DbQueryableWireRecordStoreImpl.java | 4 +- .../db/h2db/provider}/H2DbServer.java | 4 +- .../db/h2db/provider}/H2DbServerOptions.java | 6 +- .../db/h2db/provider}/H2DbServiceImpl.java | 13 +- .../db/h2db/provider}/H2DbServiceOptions.java | 26 +- .../provider}/H2DbWireRecordStoreImpl.java | 2 +- kura/pom.xml | 1 + .../META-INF/MANIFEST.MF | 20 -- .../OSGI-INF/dbservice.xml | 37 --- .../core/db/test/H2DbServiceImplTest.java | 211 ------------ .../META-INF/MANIFEST.MF | 20 ++ .../about.html | 36 +++ .../build.properties | 14 +- .../pom.xml | 32 +- .../provider}/DbDataStoreStorageTest.java | 6 +- .../h2db/provider}/H2DbServiceImplTest.java | 4 +- kura/test/pom.xml | 11 +- 36 files changed, 569 insertions(+), 387 deletions(-) create mode 100644 kura/org.eclipse.kura.db.h2db.provider/.gitignore create mode 100644 kura/org.eclipse.kura.db.h2db.provider/META-INF/MANIFEST.MF rename kura/{org.eclipse.kura.core => org.eclipse.kura.db.h2db.provider}/OSGI-INF/h2db.xml (89%) rename kura/{org.eclipse.kura.core => org.eclipse.kura.db.h2db.provider}/OSGI-INF/h2dbhelper.xml (82%) rename kura/{org.eclipse.kura.core => org.eclipse.kura.db.h2db.provider}/OSGI-INF/h2dbserver.xml (83%) rename kura/{org.eclipse.kura.core => org.eclipse.kura.db.h2db.provider}/OSGI-INF/metatype/org.eclipse.kura.core.db.H2DbServer.xml (96%) rename kura/{org.eclipse.kura.core => org.eclipse.kura.db.h2db.provider}/OSGI-INF/metatype/org.eclipse.kura.core.db.H2DbService.xml (98%) rename kura/{test/org.eclipse.kura.core.db.test => org.eclipse.kura.db.h2db.provider}/about.html (100%) create mode 100644 kura/org.eclipse.kura.db.h2db.provider/about_files/epl-v20.html create mode 100644 kura/org.eclipse.kura.db.h2db.provider/build.properties create mode 100644 kura/org.eclipse.kura.db.h2db.provider/pom.xml rename kura/{org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db => org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider}/H2DbHelper.java (91%) rename kura/{org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db => org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider}/H2DbMessageStoreImpl.java (98%) rename kura/{org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db => org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider}/H2DbQueryableWireRecordStoreImpl.java (93%) rename kura/{org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db => org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider}/H2DbServer.java (96%) rename kura/{org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db => org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider}/H2DbServerOptions.java (92%) rename kura/{org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db => org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider}/H2DbServiceImpl.java (98%) rename kura/{org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db => org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider}/H2DbServiceOptions.java (97%) rename kura/{org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db => org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider}/H2DbWireRecordStoreImpl.java (98%) delete mode 100644 kura/test/org.eclipse.kura.core.db.test/META-INF/MANIFEST.MF delete mode 100644 kura/test/org.eclipse.kura.core.db.test/OSGI-INF/dbservice.xml delete mode 100644 kura/test/org.eclipse.kura.core.db.test/src/main/java/org/eclipse/kura/core/db/test/H2DbServiceImplTest.java create mode 100644 kura/test/org.eclipse.kura.db.h2db.provider.test/META-INF/MANIFEST.MF create mode 100644 kura/test/org.eclipse.kura.db.h2db.provider.test/about.html rename kura/test/{org.eclipse.kura.core.db.test => org.eclipse.kura.db.h2db.provider.test}/build.properties (63%) rename kura/test/{org.eclipse.kura.core.db.test => org.eclipse.kura.db.h2db.provider.test}/pom.xml (69%) rename kura/test/{org.eclipse.kura.core.test/src/test/java/org/eclipse/kura/core/data/store => org.eclipse.kura.db.h2db.provider.test/src/test/java/org/eclipse/kura/internal/db/h2db/provider}/DbDataStoreStorageTest.java (98%) rename kura/test/{org.eclipse.kura.core.db.test/src/test/java/org/eclipse/kura/core/db => org.eclipse.kura.db.h2db.provider.test/src/test/java/org/eclipse/kura/internal/db/h2db/provider}/H2DbServiceImplTest.java (98%) diff --git a/kura/distrib/config/kura.build.properties b/kura/distrib/config/kura.build.properties index 416ba1f54cc..d14d414ff52 100644 --- a/kura/distrib/config/kura.build.properties +++ b/kura/distrib/config/kura.build.properties @@ -129,6 +129,7 @@ org.eclipse.kura.container.provider.version=2.0.0-SNAPSHOT org.eclipse.kura.configuration.change.manager.version=2.0.0-SNAPSHOT org.eclipse.kura.event.publisher.version=2.0.0-SNAPSHOT org.eclipse.kura.db.sqlite.provider.version=2.0.0-SNAPSHOT +org.eclipse.kura.db.h2db.provider.version=1.0.0-SNAPSHOT org.eclipse.kura.rest.network.status.provider.version=2.0.0-SNAPSHOT org.eclipse.kura.wire.script.tools.version=2.0.0-SNAPSHOT org.eclipse.kura.cloudconnection.sparkplug.mqtt.provider.version=2.0.0-SNAPSHOT diff --git a/kura/distrib/pom.xml b/kura/distrib/pom.xml index 49f8430b4c5..3647d2934b0 100644 --- a/kura/distrib/pom.xml +++ b/kura/distrib/pom.xml @@ -676,6 +676,11 @@ org.eclipse.kura.rest.network.status.provider ${org.eclipse.kura.rest.network.status.provider.version} + + org.eclipse.kura + org.eclipse.kura.db.h2db.provider + ${org.eclipse.kura.db.h2db.provider.version} + true ${project.basedir}/target/plugins @@ -837,6 +842,7 @@ + @@ -2086,6 +2092,7 @@ + diff --git a/kura/distrib/src/main/ant/build_equinox_distrib.xml b/kura/distrib/src/main/ant/build_equinox_distrib.xml index 0f0cb7bf181..e8bb1277f17 100644 --- a/kura/distrib/src/main/ant/build_equinox_distrib.xml +++ b/kura/distrib/src/main/ant/build_equinox_distrib.xml @@ -158,6 +158,7 @@ + @@ -701,6 +702,7 @@ fi]]> + @@ -1281,6 +1283,14 @@ fi]]> + + + + + + @@ -1754,6 +1764,15 @@ fi]]> todir="${build.install.dir.kura}/kura/plugins" /> + + + + + + diff --git a/kura/org.eclipse.kura.core/META-INF/MANIFEST.MF b/kura/org.eclipse.kura.core/META-INF/MANIFEST.MF index c695117aa8c..3ca36ebae38 100644 --- a/kura/org.eclipse.kura.core/META-INF/MANIFEST.MF +++ b/kura/org.eclipse.kura.core/META-INF/MANIFEST.MF @@ -50,16 +50,7 @@ Import-Package: javax.crypto, org.eclipse.kura.type;version="[1.1,2.0)", org.eclipse.kura.util.configuration;version="[1.0,2.0)", org.eclipse.kura.util.jdbc;version="[1.0,2.0)", - org.eclipse.kura.util.message.store;version="[1.0,1.1)", - org.eclipse.kura.util.store.listener;version="[1.0,2.0)", - org.eclipse.kura.util.wire.store;version="[1.0,1.1)", org.eclipse.kura.watchdog;version="[1.0,2.0)", - org.eclipse.kura.wire;version="[2.0,3.0)", - org.eclipse.kura.wire.store.provider;version="[1.0,1.1)", - org.h2;version="2.1.214", - org.h2.api;version="2.1.214", - org.h2.jdbcx;version="2.1.214", - org.h2.tools;version="2.1.214", org.osgi.framework;version="1.5.0", org.osgi.service.component;version="1.2.0", org.osgi.service.event;version="1.4.0", diff --git a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/data/DataServiceImpl.java b/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/data/DataServiceImpl.java index 1254b51c9e9..48615c7aa2c 100644 --- a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/data/DataServiceImpl.java +++ b/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/data/DataServiceImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2023 Eurotech and/or its affiliates and others + * Copyright (c) 2011, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -13,8 +13,6 @@ package org.eclipse.kura.core.data; import java.security.SecureRandom; -import java.sql.Connection; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -45,7 +43,6 @@ import org.eclipse.kura.configuration.ConfigurationService; import org.eclipse.kura.connection.listener.ConnectionListener; import org.eclipse.kura.core.data.store.MessageStoreState; -import org.eclipse.kura.core.db.H2DbMessageStoreImpl; import org.eclipse.kura.core.internal.data.TokenBucket; import org.eclipse.kura.data.DataService; import org.eclipse.kura.data.DataTransportService; @@ -59,8 +56,6 @@ import org.eclipse.kura.status.CloudConnectionStatusComponent; import org.eclipse.kura.status.CloudConnectionStatusEnum; import org.eclipse.kura.status.CloudConnectionStatusService; -import org.eclipse.kura.util.jdbc.ConnectionProvider; -import org.eclipse.kura.util.jdbc.SQLFunction; import org.eclipse.kura.watchdog.CriticalComponent; import org.eclipse.kura.watchdog.WatchdogService; import org.eclipse.paho.client.mqttv3.MqttException; @@ -178,8 +173,6 @@ public Object addingService(ServiceReference reference) { if (service instanceof MessageStoreProvider) { setMessageStoreProvider((MessageStoreProvider) service); - } else if (service instanceof H2DbService) { - setH2DbService((H2DbService) service); } else { DataServiceImpl.this.componentContext.getBundleContext().ungetService(reference); return null; @@ -346,36 +339,6 @@ public synchronized void unsetMessageStoreProvider() { } - public synchronized void setH2DbService(H2DbService dbService) { - setMessageStoreProvider(new MessageStoreProvider() { - - @SuppressWarnings("restriction") - @Override - public MessageStore openMessageStore(String name) throws KuraStoreException { - return new H2DbMessageStoreImpl(new ConnectionProvider() { - - @Override - public T withConnection(final SQLFunction task) throws SQLException { - return dbService.withConnection(task::call); - } - }, name); - } - - @Override - public void addListener(ConnectionListener listener) { - // Do nothing - - } - - @Override - public void removeListener(ConnectionListener listener) { - // Do nothin - - } - }); - - } - public synchronized void unsetH2DbService(H2DbService dbService) { unsetMessageStoreProvider(); } diff --git a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/data/DataServiceOptions.java b/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/data/DataServiceOptions.java index e537befc310..8ac114aec2d 100644 --- a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/data/DataServiceOptions.java +++ b/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/data/DataServiceOptions.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2023 Eurotech and/or its affiliates and others + * Copyright (c) 2017, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -12,19 +12,18 @@ *******************************************************************************/ package org.eclipse.kura.core.data; -import static java.util.Objects.requireNonNull; - import java.util.Collections; import java.util.Map; import java.util.Optional; import java.util.concurrent.TimeUnit; import org.eclipse.kura.configuration.ConfigurationService; -import org.eclipse.kura.db.H2DbService; import org.quartz.CronExpression; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static java.util.Objects.requireNonNull; + public class DataServiceOptions { private static final Logger logger = LoggerFactory.getLogger(DataServiceOptions.class); @@ -55,7 +54,7 @@ public class DataServiceOptions { private static final boolean AUTOCONNECT_PROP_DEFAULT = false; private static final int CONNECT_DELAY_DEFAULT = 60; private static final int DISCONNECT_DELAY_DEFAULT = 10; - private static final String DB_SERVICE_INSTANCE_DEFAULT = H2DbService.DEFAULT_INSTANCE_PID; + private static final String DB_SERVICE_INSTANCE_DEFAULT = "org.eclipse.kura.db.H2DbService"; private static final int STORE_HOUSEKEEPER_INTERVAL_DEFAULT = 900; private static final int STORE_PURGE_AGE_DEFAULT = 60; private static final int STORE_CAPACITY_DEFAULT = 10000; @@ -181,11 +180,11 @@ public boolean isConnectionScheduleEnabled() { } public Optional getConnectionScheduleExpression() { - + if (!this.isConnectionScheduleEnabled()) { return Optional.empty(); } - + try { return Optional.of(new CronExpression((String) this.properties.get(CONNECTION_SCHECULE_EXPRESSION))); } catch (final Exception e) { diff --git a/kura/org.eclipse.kura.db.h2db.provider/.gitignore b/kura/org.eclipse.kura.db.h2db.provider/.gitignore new file mode 100644 index 00000000000..f1ff06d608f --- /dev/null +++ b/kura/org.eclipse.kura.db.h2db.provider/.gitignore @@ -0,0 +1 @@ +lib/ \ No newline at end of file diff --git a/kura/org.eclipse.kura.db.h2db.provider/META-INF/MANIFEST.MF b/kura/org.eclipse.kura.db.h2db.provider/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..b0f46507153 --- /dev/null +++ b/kura/org.eclipse.kura.db.h2db.provider/META-INF/MANIFEST.MF @@ -0,0 +1,33 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.eclipse.kura.db.h2db.provider +Bundle-SymbolicName: org.eclipse.kura.db.h2db.provider;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: Eclipse Kura +Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))" +Service-Component: OSGI-INF/*.xml +Bundle-ClassPath: . +Bundle-ActivationPolicy: lazy +Import-Package: org.eclipse.kura;version="[1.7,2.0)", + org.eclipse.kura.configuration;version="[1.2,2.0)", + org.eclipse.kura.connection.listener;version="1.0.0", + org.eclipse.kura.crypto;version="1.3.0", + org.eclipse.kura.data;version="[1.1,2.0)", + org.eclipse.kura.db;version="[2.0,2.1)", + org.eclipse.kura.message.store;version="[1.0,2.0)", + org.eclipse.kura.message.store.provider;version="[1.0,1.1)", + org.eclipse.kura.type;version="[1.1,2.0)", + org.eclipse.kura.util.configuration;version="[1.0,1.1)", + org.eclipse.kura.util.jdbc;version="[1.0,2.0)", + org.eclipse.kura.util.message.store;version="[1.0,2.0)", + org.eclipse.kura.util.store.listener;version="[1.0,2.0)", + org.eclipse.kura.util.wire.store;version="[1.0,1.1)", + org.eclipse.kura.wire;version="[2.0,3.0)", + org.eclipse.kura.wire.store.provider;version="[1.0,1.1)", + org.h2;version="2.1.214", + org.h2.api;version="2.1.214", + org.h2.jdbcx;version="2.1.214", + org.h2.tools;version="2.1.214", + org.osgi.framework;version="1.10.0", + org.osgi.service.component;version="1.4.0", + org.slf4j;version="1.7.32" diff --git a/kura/org.eclipse.kura.core/OSGI-INF/h2db.xml b/kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/h2db.xml similarity index 89% rename from kura/org.eclipse.kura.core/OSGI-INF/h2db.xml rename to kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/h2db.xml index c2201a80959..b39c948a6f3 100644 --- a/kura/org.eclipse.kura.core/OSGI-INF/h2db.xml +++ b/kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/h2db.xml @@ -1,7 +1,7 @@ - + diff --git a/kura/org.eclipse.kura.core/OSGI-INF/h2dbhelper.xml b/kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/h2dbhelper.xml similarity index 82% rename from kura/org.eclipse.kura.core/OSGI-INF/h2dbhelper.xml rename to kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/h2dbhelper.xml index 68ebc833550..3dd0ececafe 100644 --- a/kura/org.eclipse.kura.core/OSGI-INF/h2dbhelper.xml +++ b/kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/h2dbhelper.xml @@ -1,7 +1,7 @@ - + diff --git a/kura/org.eclipse.kura.core/OSGI-INF/h2dbserver.xml b/kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/h2dbserver.xml similarity index 83% rename from kura/org.eclipse.kura.core/OSGI-INF/h2dbserver.xml rename to kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/h2dbserver.xml index 8a50be4901f..1da2284f41d 100644 --- a/kura/org.eclipse.kura.core/OSGI-INF/h2dbserver.xml +++ b/kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/h2dbserver.xml @@ -1,7 +1,7 @@ - + diff --git a/kura/org.eclipse.kura.core/OSGI-INF/metatype/org.eclipse.kura.core.db.H2DbServer.xml b/kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/metatype/org.eclipse.kura.core.db.H2DbServer.xml similarity index 96% rename from kura/org.eclipse.kura.core/OSGI-INF/metatype/org.eclipse.kura.core.db.H2DbServer.xml rename to kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/metatype/org.eclipse.kura.core.db.H2DbServer.xml index d0b58c00b5b..4276f395310 100644 --- a/kura/org.eclipse.kura.core/OSGI-INF/metatype/org.eclipse.kura.core.db.H2DbServer.xml +++ b/kura/org.eclipse.kura.db.h2db.provider/OSGI-INF/metatype/org.eclipse.kura.core.db.H2DbServer.xml @@ -1,7 +1,7 @@ + + 4.0.0 + + + org.eclipse.kura + kura + 6.0.0-SNAPSHOT + + + org.eclipse.kura.db.h2db.provider + 1.0.0-SNAPSHOT + eclipse-plugin + + + ${project.basedir}/.. + ${project.basedir}/../test/*/target/site/jacoco-aggregate/jacoco.xml + + + diff --git a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbHelper.java b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbHelper.java similarity index 91% rename from kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbHelper.java rename to kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbHelper.java index 815f29d4288..8df309e72e2 100644 --- a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbHelper.java +++ b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2020 Eurotech and/or its affiliates and others + * Copyright (c) 2017, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -10,7 +10,7 @@ * Contributors: * Eurotech *******************************************************************************/ -package org.eclipse.kura.core.db; +package org.eclipse.kura.internal.db.h2db.provider; import org.eclipse.kura.KuraException; import org.eclipse.kura.configuration.ConfigurationService; @@ -31,7 +31,9 @@ protected void setConfigurationService(ConfigurationService configurationService } protected void unsetConfigurationService(ConfigurationService configurationService) { - this.configurationService = null; + if (this.configurationService.equals(configurationService)) { + this.configurationService = null; + } } private void startDefaultDbServiceInstance() { diff --git a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbMessageStoreImpl.java b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbMessageStoreImpl.java similarity index 98% rename from kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbMessageStoreImpl.java rename to kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbMessageStoreImpl.java index 1567ab056c0..b74c01852a4 100644 --- a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbMessageStoreImpl.java +++ b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbMessageStoreImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Eurotech and/or its affiliates and others + * Copyright (c) 2023, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -10,7 +10,7 @@ * Contributors: * Eurotech ******************************************************************************/ -package org.eclipse.kura.core.db; +package org.eclipse.kura.internal.db.h2db.provider; import java.io.ByteArrayInputStream; import java.sql.PreparedStatement; diff --git a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbQueryableWireRecordStoreImpl.java b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbQueryableWireRecordStoreImpl.java similarity index 93% rename from kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbQueryableWireRecordStoreImpl.java rename to kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbQueryableWireRecordStoreImpl.java index 544889512c3..fa6162def26 100644 --- a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbQueryableWireRecordStoreImpl.java +++ b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbQueryableWireRecordStoreImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Eurotech and/or its affiliates and others + * Copyright (c) 2023, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -10,7 +10,7 @@ * Contributors: * Eurotech ******************************************************************************/ -package org.eclipse.kura.core.db; +package org.eclipse.kura.internal.db.h2db.provider; import static java.util.Objects.isNull; diff --git a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServer.java b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServer.java similarity index 96% rename from kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServer.java rename to kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServer.java index f990f802029..8a3cb8457ff 100644 --- a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServer.java +++ b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2020 Eurotech and/or its affiliates and others + * Copyright (c) 2017, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -10,7 +10,7 @@ * Contributors: * Eurotech *******************************************************************************/ -package org.eclipse.kura.core.db; +package org.eclipse.kura.internal.db.h2db.provider; import java.sql.SQLException; import java.util.Map; diff --git a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServerOptions.java b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServerOptions.java similarity index 92% rename from kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServerOptions.java rename to kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServerOptions.java index decc1bb9092..07ea0874773 100644 --- a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServerOptions.java +++ b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServerOptions.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2020 Eurotech and/or its affiliates and others + * Copyright (c) 2017, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -10,11 +10,11 @@ * Contributors: * Eurotech *******************************************************************************/ -package org.eclipse.kura.core.db; +package org.eclipse.kura.internal.db.h2db.provider; import java.util.Map; -import org.eclipse.kura.core.db.H2DbServer.ServerType; +import org.eclipse.kura.internal.db.h2db.provider.H2DbServer.ServerType; class H2DbServerOptions { diff --git a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServiceImpl.java b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceImpl.java similarity index 98% rename from kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServiceImpl.java rename to kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceImpl.java index ddcdcb0d53f..506e3d85d01 100644 --- a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServiceImpl.java +++ b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2023 Eurotech and/or its affiliates and others + * Copyright (c) 2017, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -10,7 +10,7 @@ * Contributors: * Eurotech *******************************************************************************/ -package org.eclipse.kura.core.db; +package org.eclipse.kura.internal.db.h2db.provider; import java.sql.Connection; import java.sql.DriverManager; @@ -114,7 +114,9 @@ public void setCryptoService(CryptoService cryptoService) { } public void unsetCryptoService(CryptoService cryptoService) { - this.cryptoService = null; + if (this.cryptoService.equals(cryptoService)) { + this.cryptoService = null; + } } // ---------------------------------------------------------------- @@ -402,8 +404,11 @@ private void syncWithExecutor() { try { this.executor.submit(() -> { }).get(); - } catch (final Exception e) { + } catch (final InterruptedException e) { + Thread.currentThread().interrupt(); throw new IllegalStateException(e); + } catch (final Exception e1) { + throw new IllegalStateException(e1); } } diff --git a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServiceOptions.java b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceOptions.java similarity index 97% rename from kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServiceOptions.java rename to kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceOptions.java index 199985ae42d..e033f86cefa 100644 --- a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbServiceOptions.java +++ b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceOptions.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2020 Eurotech and/or its affiliates and others + * Copyright (c) 2017, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -10,7 +10,7 @@ * Contributors: * Eurotech *******************************************************************************/ -package org.eclipse.kura.core.db; +package org.eclipse.kura.internal.db.h2db.provider; import java.io.File; import java.util.Map; @@ -106,15 +106,7 @@ private void computeUrlParts() { } } - if ("mem".equals(protocol)) { - this.isInMemory = true; - } else if ("file".equals(protocol)) { - this.isFileBased = true; - } else if ("zip".equals(protocol)) { - this.isZipBased = true; - } else { - this.isRemote = true; - } + parseProtocol(protocol); this.baseUrl = "jdbc:h2:" + protocol + ':' + url; @@ -130,6 +122,18 @@ private void computeUrlParts() { this.isFileBasedLogLevelSpecified = FILE_LOG_LEVEL_PATTERN.matcher(this.dbUrl).find(); } + private void parseProtocol(String protocol) { + if ("mem".equals(protocol)) { + this.isInMemory = true; + } else if ("file".equals(protocol)) { + this.isFileBased = true; + } else if ("zip".equals(protocol)) { + this.isZipBased = true; + } else { + this.isRemote = true; + } + } + public String getDbUrl() { return this.dbUrl; } diff --git a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbWireRecordStoreImpl.java b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbWireRecordStoreImpl.java similarity index 98% rename from kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbWireRecordStoreImpl.java rename to kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbWireRecordStoreImpl.java index 27ee9ce381a..c3d70a1d1bd 100644 --- a/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/db/H2DbWireRecordStoreImpl.java +++ b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbWireRecordStoreImpl.java @@ -10,7 +10,7 @@ * Contributors: * Eurotech ******************************************************************************/ -package org.eclipse.kura.core.db; +package org.eclipse.kura.internal.db.h2db.provider; import java.util.Collections; import java.util.HashMap; diff --git a/kura/pom.xml b/kura/pom.xml index 29ec71c900e..eabdc6aabe3 100644 --- a/kura/pom.xml +++ b/kura/pom.xml @@ -125,6 +125,7 @@ org.eclipse.kura.configuration.change.manager org.eclipse.kura.wire.script.tools org.eclipse.kura.db.sqlite.provider + org.eclipse.kura.db.h2db.provider org.eclipse.kura.rest.network.status.provider org.eclipse.kura.cloudconnection.sparkplug.mqtt.provider emulator diff --git a/kura/test/org.eclipse.kura.core.db.test/META-INF/MANIFEST.MF b/kura/test/org.eclipse.kura.core.db.test/META-INF/MANIFEST.MF deleted file mode 100644 index 8fb43a95339..00000000000 --- a/kura/test/org.eclipse.kura.core.db.test/META-INF/MANIFEST.MF +++ /dev/null @@ -1,20 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: org.eclipse.kura.core.db.test -Bundle-SymbolicName: org.eclipse.kura.core.db.test;singleton:=true -Bundle-Version: 6.0.0.qualifier -Bundle-Vendor: Eclipse Kura -Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))" -Fragment-Host: org.eclipse.kura.core -Import-Package: org.eclipse.kura;version="[1.2,2.0)", - org.eclipse.kura.core.testutil, - org.eclipse.kura.db;version="[2.0,3.0)", - org.h2;version="2.1.214", - org.h2.jdbc;version="2.1.214", - org.junit;version="[4.12.0,5.0.0)", - org.junit.runner;version="[4.12.0,5.0.0)", - org.junit.runners;version="[4.12.0,5.0.0)", - org.mockito;version="[4.0.0,5.0.0)", - org.mockito.invocation;version="[4.0.0,5.0.0)", - org.mockito.stubbing;version="[4.0.0,5.0.0)" -Bundle-ActivationPolicy: lazy diff --git a/kura/test/org.eclipse.kura.core.db.test/OSGI-INF/dbservice.xml b/kura/test/org.eclipse.kura.core.db.test/OSGI-INF/dbservice.xml deleted file mode 100644 index 8e7c1b68c13..00000000000 --- a/kura/test/org.eclipse.kura.core.db.test/OSGI-INF/dbservice.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/kura/test/org.eclipse.kura.core.db.test/src/main/java/org/eclipse/kura/core/db/test/H2DbServiceImplTest.java b/kura/test/org.eclipse.kura.core.db.test/src/main/java/org/eclipse/kura/core/db/test/H2DbServiceImplTest.java deleted file mode 100644 index 211f78a0666..00000000000 --- a/kura/test/org.eclipse.kura.core.db.test/src/main/java/org/eclipse/kura/core/db/test/H2DbServiceImplTest.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 2020 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - ******************************************************************************/ -package org.eclipse.kura.core.db.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.eclipse.kura.KuraException; -import org.eclipse.kura.configuration.ComponentConfiguration; -import org.eclipse.kura.configuration.ConfigurationService; -import org.eclipse.kura.crypto.CryptoService; -import org.eclipse.kura.db.H2DbService; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class H2DbServiceImplTest { - - private static ConfigurationService cfgService; - private static H2DbService dbService; - private static CryptoService cryptoService; - private static CountDownLatch dependencyLatch = new CountDownLatch(3); // initialize with number of dependencies - - private static final String PID = "org.eclipse.kura.db.H2DbService"; - - @BeforeClass - public static void setUp() throws SQLException, ClassNotFoundException { - Class.forName("org.h2.Driver"); - - // Wait for OSGi dependencies - try { - boolean ok = dependencyLatch.await(10, TimeUnit.SECONDS); - assertTrue(ok); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - fail("OSGi dependencies unfulfilled"); - } - } - - @Before - public void init() throws KuraException { - // reset the url and password - - ComponentConfiguration componentConfiguration = cfgService.getComponentConfiguration(PID); - - Map properties = componentConfiguration.getConfigurationProperties(); - properties.put("db.password", ""); - properties.put("db.connector.url", "jdbc:h2:mem:kuradb"); - - cfgService.updateConfiguration(PID, properties); - } - - protected void bindCfgSvc(ConfigurationService cfgSvc) { - cfgService = cfgSvc; - dependencyLatch.countDown(); - } - - protected void unbindCfgSvc(ConfigurationService cfgSvc) { - cfgService = null; - } - - protected void bindCryptoSvc(CryptoService cSvc) { - cryptoService = cSvc; - dependencyLatch.countDown(); - } - - protected void unbindCryptoSvc(CryptoService cSvc) { - cryptoService = null; - } - - protected void bindDbSvc(H2DbService dbSvc) { - dbService = dbSvc; - dependencyLatch.countDown(); - } - - protected void unbindDbSvc(H2DbService dbSvc) { - dbService = null; - } - - @Test - public void testSvcs() { - assertNotNull(cfgService); - assertNotNull(cryptoService); - assertNotNull(dbService); - } - - @Test - public void testPasswordUpdate() throws Exception { - // connect to DB, update password and check that connection only succeeds with the new password - - final String url = "jdbc:h2:mem:kuradb"; - final String user = "SA"; - String pass = ""; - String newPass = "newPass"; - - Connection conn = null; - try { - conn = DriverManager.getConnection(url, user, pass); - } catch (Exception e) { - e.printStackTrace(); - - pass = newPass; - newPass = ""; - - conn = DriverManager.getConnection(url, user, pass); - } - - assertNotNull(conn); - - verifyUserAndClose(user, conn); - - char[] encPass = cryptoService.encryptAes(newPass.toCharArray()); - - String pid = "org.eclipse.kura.db.H2DbService"; - - ComponentConfiguration componentConfiguration = cfgService.getComponentConfiguration(pid); - Map properties = componentConfiguration.getConfigurationProperties(); - properties.put("db.password", new String(encPass)); - - cfgService.updateConfiguration(pid, properties); - - try { - Thread.sleep(100); // wait a bit, just in case - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - - conn = null; - try { - conn = DriverManager.getConnection(url, user, pass); - fail("Exception expected - password was changed."); - } catch (Exception e) { - conn = DriverManager.getConnection(url, user, newPass); - } - - assertNotNull(conn); - - verifyUserAndClose(user, conn); - } - - private void verifyUserAndClose(final String user, Connection conn) throws SQLException { - try (PreparedStatement statement = conn.prepareStatement("SELECT USER()"); - ResultSet rs = statement.executeQuery();) { - - rs.next(); - String result = rs.getString(1); - - assertEquals(user, result); - - conn.close(); - } - } - - @Test - public void testUrlUpdate() throws Exception { - // connect to DB, update url to file protocol and check that connection succeeds with the new url - - final String url = "jdbc:h2:mem:kuradb"; - File f = new File("/tmp/kuradb"); - final String newUrl = "jdbc:h2:file:" + f.getAbsolutePath(); // on windows /tmp/kuradb is not absolute! - final String user = "SA"; - String pass = ""; - - Connection conn = null; - conn = DriverManager.getConnection(url, user, pass); - assertNotNull(conn); - - verifyUserAndClose(user, conn); - - ComponentConfiguration componentConfiguration = cfgService.getComponentConfiguration(PID); - Map properties = componentConfiguration.getConfigurationProperties(); - properties.put("db.connector.url", newUrl); - - cfgService.updateConfiguration(PID, properties); - - try { - Thread.sleep(100); // wait a bit, just in case - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - - conn = DriverManager.getConnection(newUrl, user, pass); - - assertNotNull(conn); - - verifyUserAndClose(user, conn); - } - -} diff --git a/kura/test/org.eclipse.kura.db.h2db.provider.test/META-INF/MANIFEST.MF b/kura/test/org.eclipse.kura.db.h2db.provider.test/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..f1697fc15f1 --- /dev/null +++ b/kura/test/org.eclipse.kura.db.h2db.provider.test/META-INF/MANIFEST.MF @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.eclipse.kura.db.h2db.provider.test +Bundle-SymbolicName: org.eclipse.kura.db.h2db.provider.test;singleton:=true +Bundle-Version: 6.0.0.qualifier +Bundle-Vendor: Eclipse Kura +Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))" +Bundle-ClassPath: . +Bundle-ActivationPolicy: lazy +Import-Package: org.apache.felix.service.command;version="1.0.0", + org.eclipse.kura;version="[1.7,2.0)", + org.eclipse.kura.configuration;version="[1.2,2.0)", + org.eclipse.kura.core.testutil.service;version="[1.0,2.0)", + org.eclipse.kura.db;version="2.0.0", + org.junit;version="4.12.0", + org.mockito;version="4.8.1", + org.mockito.invocation;version="4.8.1", + org.mockito.stubbing;version="4.8.1", + org.osgi.framework;version="1.10.0" +Fragment-Host: org.eclipse.kura.db.h2db.provider diff --git a/kura/test/org.eclipse.kura.db.h2db.provider.test/about.html b/kura/test/org.eclipse.kura.db.h2db.provider.test/about.html new file mode 100644 index 00000000000..ec5809fefb9 --- /dev/null +++ b/kura/test/org.eclipse.kura.db.h2db.provider.test/about.html @@ -0,0 +1,36 @@ + + + + + About + + +

About This Content

+ +

November 30, 2017

+

License

+ +

+ The Eclipse Foundation makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content + is provided to you under the terms and conditions of the Eclipse + Public License Version 2.0 ("EPL"). A copy of the EPL is + available at http://www.eclipse.org/legal/epl-2.0. + For purposes of the EPL, "Program" will mean the Content. +

+ +

+ If you did not receive this Content directly from the Eclipse + Foundation, the Content is being redistributed by another party + ("Redistributor") and different terms and conditions may + apply to your use of any object code in the Content. Check the + Redistributor's license that was provided with the Content. If no such + license exists, contact the Redistributor. Unless otherwise indicated + below, the terms and conditions of the EPL still apply to any source + code in the Content and such source code may be obtained at http://www.eclipse.org. +

+ + + \ No newline at end of file diff --git a/kura/test/org.eclipse.kura.core.db.test/build.properties b/kura/test/org.eclipse.kura.db.h2db.provider.test/build.properties similarity index 63% rename from kura/test/org.eclipse.kura.core.db.test/build.properties rename to kura/test/org.eclipse.kura.db.h2db.provider.test/build.properties index b13e14aead5..d229c553982 100644 --- a/kura/test/org.eclipse.kura.core.db.test/build.properties +++ b/kura/test/org.eclipse.kura.db.h2db.provider.test/build.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, 2020 Eurotech and/or its affiliates and others +# Copyright (c) 2022 Eurotech and/or its affiliates and others # # This program and the accompanying materials are made # available under the terms of the Eclipse Public License 2.0 @@ -10,11 +10,11 @@ # Contributors: # Eurotech # -output.. = target/classes/ -source.. = src/main/java/ -bin.includes = META-INF/,\ - .,\ + +bin.includes = .,\ + META-INF/,\ about.html -additional.bundles = slf4j.api,\ - org.junit,\ +source.. = src/main/java/ +additional.bundles = org.eclipse.kura.api,\ + slf4j.api,\ org.apache.logging.log4j.api diff --git a/kura/test/org.eclipse.kura.core.db.test/pom.xml b/kura/test/org.eclipse.kura.db.h2db.provider.test/pom.xml similarity index 69% rename from kura/test/org.eclipse.kura.core.db.test/pom.xml rename to kura/test/org.eclipse.kura.db.h2db.provider.test/pom.xml index b6e62b36a63..8f52ac799b9 100644 --- a/kura/test/org.eclipse.kura.core.db.test/pom.xml +++ b/kura/test/org.eclipse.kura.db.h2db.provider.test/pom.xml @@ -1,7 +1,7 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - org.eclipse.kura - test - 6.0.0-SNAPSHOT - - - org.eclipse.kura.core.db.test - eclipse-test-plugin - - - ${project.basedir}/../.. - ${project.build.directory}/site/jacoco-aggregate/jacoco.xml - + + org.eclipse.kura + test + 6.0.0-SNAPSHOT + + org.eclipse.kura.db.h2db.provider.test + eclipse-test-plugin + + + ${project.basedir}/../.. + ${project.build.directory}/site/jacoco-aggregate/jacoco.xml + + diff --git a/kura/test/org.eclipse.kura.core.test/src/test/java/org/eclipse/kura/core/data/store/DbDataStoreStorageTest.java b/kura/test/org.eclipse.kura.db.h2db.provider.test/src/test/java/org/eclipse/kura/internal/db/h2db/provider/DbDataStoreStorageTest.java similarity index 98% rename from kura/test/org.eclipse.kura.core.test/src/test/java/org/eclipse/kura/core/data/store/DbDataStoreStorageTest.java rename to kura/test/org.eclipse.kura.db.h2db.provider.test/src/test/java/org/eclipse/kura/internal/db/h2db/provider/DbDataStoreStorageTest.java index d03ae4a5805..ca4b0be28d5 100644 --- a/kura/test/org.eclipse.kura.core.test/src/test/java/org/eclipse/kura/core/data/store/DbDataStoreStorageTest.java +++ b/kura/test/org.eclipse.kura.db.h2db.provider.test/src/test/java/org/eclipse/kura/internal/db/h2db/provider/DbDataStoreStorageTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022, 2023 Eurotech and/or its affiliates and others + * Copyright (c) 2022, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -10,7 +10,7 @@ * Contributors: * Eurotech ******************************************************************************/ -package org.eclipse.kura.core.data.store; +package org.eclipse.kura.internal.db.h2db.provider; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -27,8 +27,8 @@ import java.util.Arrays; import org.eclipse.kura.KuraStoreException; -import org.eclipse.kura.core.db.H2DbMessageStoreImpl; import org.eclipse.kura.db.H2DbService; +import org.eclipse.kura.db.H2DbService.ConnectionCallable; import org.eclipse.kura.message.store.StoredMessage; import org.eclipse.kura.message.store.provider.MessageStore; import org.eclipse.kura.util.jdbc.ConnectionProvider; diff --git a/kura/test/org.eclipse.kura.core.db.test/src/test/java/org/eclipse/kura/core/db/H2DbServiceImplTest.java b/kura/test/org.eclipse.kura.db.h2db.provider.test/src/test/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceImplTest.java similarity index 98% rename from kura/test/org.eclipse.kura.core.db.test/src/test/java/org/eclipse/kura/core/db/H2DbServiceImplTest.java rename to kura/test/org.eclipse.kura.db.h2db.provider.test/src/test/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceImplTest.java index 6cd6de29093..6bf6e903cba 100644 --- a/kura/test/org.eclipse.kura.core.db.test/src/test/java/org/eclipse/kura/core/db/H2DbServiceImplTest.java +++ b/kura/test/org.eclipse.kura.db.h2db.provider.test/src/test/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceImplTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2020 Eurotech and/or its affiliates and others + * Copyright (c) 2017, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -10,7 +10,7 @@ * Contributors: * Eurotech ******************************************************************************/ -package org.eclipse.kura.core.db; +package org.eclipse.kura.internal.db.h2db.provider; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/kura/test/pom.xml b/kura/test/pom.xml index a14f6b60edb..2a88a5bacce 100644 --- a/kura/test/pom.xml +++ b/kura/test/pom.xml @@ -281,6 +281,10 @@ p2-installable-unit org.apache.logging.log4j.core + + p2-installable-unit + org.eclipse.kura.db.h2db.provider + @@ -840,6 +844,11 @@ org.eclipse.kura.emulator.position 0.0.0 + + eclipse-plugin + org.eclipse.kura.db.h2db.provider + 0.0.0 + @@ -881,7 +890,6 @@ org.eclipse.kura.core.cloud.test org.eclipse.kura.core.cloud.factory.test org.eclipse.kura.core.crypto.test - org.eclipse.kura.core.db.test org.eclipse.kura.core.deployment.test org.eclipse.kura.core.identity.test org.eclipse.kura.core.inventory.test @@ -956,6 +964,7 @@ org.eclipse.kura.container.provider.test org.eclipse.kura.ai.triton.server.test org.eclipse.kura.db.sqlite.provider.test + org.eclipse.kura.db.h2db.provider.test org.eclipse.kura.message.store.provider.test org.eclipse.kura.cloudconnection.sparkplug.mqtt.provider.test