diff --git a/bonita-integration-tests/bonita-integration-tests-client/src/main/java/org/bonitasoft/engine/business/data/ClassloaderRefresher.java b/bonita-integration-tests/bonita-integration-tests-client/src/main/java/org/bonitasoft/engine/business/data/ClassloaderRefresher.java index 97ca18be325..f8bb0757987 100644 --- a/bonita-integration-tests/bonita-integration-tests-client/src/main/java/org/bonitasoft/engine/business/data/ClassloaderRefresher.java +++ b/bonita-integration-tests/bonita-integration-tests-client/src/main/java/org/bonitasoft/engine/business/data/ClassloaderRefresher.java @@ -15,7 +15,6 @@ import java.io.File; import java.io.IOException; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; @@ -42,9 +41,9 @@ public class ClassloaderRefresher { */ public ClassLoader loadClientModelInClassloader(final byte[] clientZipContent, final ClassLoader contextClassLoader, final String modelClass, - final File fsFolderToPutJars) throws IOException, MalformedURLException { + final File fsFolderToPutJars) throws IOException { final Map ressources = IOUtils.unzip(clientZipContent); - final List urls = new ArrayList(); + final List urls = new ArrayList<>(); for (final Entry e : ressources.entrySet()) { final File file = new File(fsFolderToPutJars, e.getKey()); if (file.getName().endsWith(".jar")) { @@ -58,7 +57,7 @@ public ClassLoader loadClientModelInClassloader(final byte[] clientZipContent, f } if (file.getName().contains("dao")) { try { - contextClassLoader.loadClass(modelClass + "DAO"); + contextClassLoader.loadClass(modelClass + "DAOImpl"); } catch (final ClassNotFoundException e1) { FileUtils.writeByteArrayToFile(file, e.getValue()); urls.add(file.toURI().toURL()); @@ -76,7 +75,7 @@ public ClassLoader loadClientModelInClassloader(final byte[] clientZipContent, f } ClassLoader classLoaderWithBDM = contextClassLoader; if (!urls.isEmpty()) { - classLoaderWithBDM = new URLClassLoader(urls.toArray(new URL[urls.size()]), contextClassLoader); + classLoaderWithBDM = new URLClassLoader(urls.toArray(new URL[0]), contextClassLoader); } return classLoaderWithBDM; } diff --git a/bonita-integration-tests/bonita-integration-tests-client/src/test/java/org/bonitasoft/engine/business/data/BDMUpdateIT.java b/bonita-integration-tests/bonita-integration-tests-client/src/test/java/org/bonitasoft/engine/business/data/BDMUpdateIT.java index 1ea58b879fd..2f322186b6b 100644 --- a/bonita-integration-tests/bonita-integration-tests-client/src/test/java/org/bonitasoft/engine/business/data/BDMUpdateIT.java +++ b/bonita-integration-tests/bonita-integration-tests-client/src/test/java/org/bonitasoft/engine/business/data/BDMUpdateIT.java @@ -32,17 +32,15 @@ import org.bonitasoft.engine.tenant.TenantResource; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.xml.sax.SAXException; /** - * Those tests fail because after installing the second BDM version, Hibernate is not aware of + * Those tests fail on MySQL and SQLServer because after installing the second BDM version, Hibernate is not aware of * previous FK_ that stay in database, so it does not drop them, and then the 'drop table' fails on test cleanup. * Those cases should be handled when we support more "BDM update" scenarios, leveraging Hibernate poor level of * support on HBM2DDL. */ -@Ignore("FIXME: Not working on mysql and sql server") public class BDMUpdateIT extends CommonAPIIT { public static final String DOT = "."; diff --git a/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/application/installer/ApplicationInstallerIT.java b/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/application/installer/ApplicationInstallerIT.java index 094e5d12463..7cf8136a2f5 100644 --- a/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/application/installer/ApplicationInstallerIT.java +++ b/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/application/installer/ApplicationInstallerIT.java @@ -22,16 +22,7 @@ import org.bonitasoft.engine.api.impl.application.installer.ApplicationArchive; import org.bonitasoft.engine.api.impl.application.installer.ApplicationArchiveReader; import org.bonitasoft.engine.api.impl.application.installer.ApplicationInstaller; -import org.bonitasoft.engine.api.impl.application.installer.detector.ArtifactTypeDetector; -import org.bonitasoft.engine.api.impl.application.installer.detector.BdmDetector; -import org.bonitasoft.engine.api.impl.application.installer.detector.CustomPageDetector; -import org.bonitasoft.engine.api.impl.application.installer.detector.IconDetector; -import org.bonitasoft.engine.api.impl.application.installer.detector.LayoutDetector; -import org.bonitasoft.engine.api.impl.application.installer.detector.LivingApplicationDetector; -import org.bonitasoft.engine.api.impl.application.installer.detector.OrganizationDetector; -import org.bonitasoft.engine.api.impl.application.installer.detector.PageAndFormDetector; -import org.bonitasoft.engine.api.impl.application.installer.detector.ProcessDetector; -import org.bonitasoft.engine.api.impl.application.installer.detector.ThemeDetector; +import org.bonitasoft.engine.api.impl.application.installer.detector.*; import org.bonitasoft.engine.bpm.process.ActivationState; import org.bonitasoft.engine.bpm.process.ConfigurationState; import org.bonitasoft.engine.bpm.process.ProcessDeploymentInfo; @@ -55,6 +46,11 @@ public void before() throws Exception { @After public void after() throws Exception { + if (!getTenantAdministrationAPI().isPaused()) { + getTenantAdministrationAPI().pause(); + getTenantAdministrationAPI().cleanAndUninstallBusinessDataModel(); + getTenantAdministrationAPI().resume(); + } logoutOnTenant(); } diff --git a/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/application/installer/ApplicationInstallerUpdateIT.java b/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/application/installer/ApplicationInstallerUpdateIT.java index a59eb404d70..770cba2e38e 100644 --- a/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/application/installer/ApplicationInstallerUpdateIT.java +++ b/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/application/installer/ApplicationInstallerUpdateIT.java @@ -75,12 +75,16 @@ public void before() throws Exception { new LivingApplicationDetector(), new OrganizationDetector(), new CustomPageDetector(), new ProcessDetector(), new ThemeDetector(), new PageAndFormDetector(), new LayoutDetector(), new IconDetector())); - initFirstInstall(); } @After public void after() throws Exception { + if (!getTenantAdministrationAPI().isPaused()) { + getTenantAdministrationAPI().pause(); + getTenantAdministrationAPI().cleanAndUninstallBusinessDataModel(); + getTenantAdministrationAPI().resume(); + } logoutOnTenant(); } diff --git a/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/bpm/event/LocalInterruptingTimerBoundaryEventIT.java b/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/bpm/event/LocalInterruptingTimerBoundaryEventIT.java index 0328c7fa3bf..1f2536c16aa 100644 --- a/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/bpm/event/LocalInterruptingTimerBoundaryEventIT.java +++ b/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/bpm/event/LocalInterruptingTimerBoundaryEventIT.java @@ -370,8 +370,7 @@ public void timerBoundaryEvent_should_not_trigger_and_be_deleted_at_flownode_abo waitForUserTask(processInstance.getId(), "step1"); waitForUserTaskAssignAndExecuteIt(processInstance, "step2", user, Map.of()); waitForProcessToFinish(processInstance); - List allJobs = schedulerService.getAllJobs(); - assertThat(allJobs).isEmpty(); + assertThat(schedulerService.getAllJobs()).isEmpty(); disableAndDeleteProcess(processDefinition); } diff --git a/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/business/application/importer/ApplicationImporterIT.java b/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/business/application/importer/ApplicationImporterIT.java index 772d99f22aa..ae50a81a6a3 100644 --- a/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/business/application/importer/ApplicationImporterIT.java +++ b/bonita-integration-tests/bonita-integration-tests-local/src/test/java/org/bonitasoft/engine/business/application/importer/ApplicationImporterIT.java @@ -25,6 +25,8 @@ import org.bonitasoft.engine.business.application.model.SApplicationState; import org.bonitasoft.engine.page.PageService; import org.bonitasoft.engine.page.SPage; +import org.bonitasoft.engine.profile.ProfileService; +import org.bonitasoft.engine.profile.model.SProfile; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -34,6 +36,7 @@ public class ApplicationImporterIT extends CommonBPMServicesTest { private ApplicationImporter applicationImporter; private ApplicationService applicationService; private PageService pageService; + private ProfileService profileService; private static final String APP_1_TOKEN = "app1"; private static final String APP_2_TOKEN = "app2"; @@ -45,6 +48,7 @@ public void setUp() { applicationImporter = getServiceAccessor().getApplicationImporter(); applicationService = getServiceAccessor().getApplicationService(); pageService = getServiceAccessor().getPageService(); + profileService = getServiceAccessor().getProfileService(); } @After @@ -222,7 +226,7 @@ private void assertAppLink1() throws Exception { assertThat(app.getIconPath()).isEqualTo("/app1.jpg"); assertThat(app.getCreatedBy()).isEqualTo(-1L); assertThat(app.getState()).isEqualTo(SApplicationState.ACTIVATED.name()); - assertThat(app.getProfileId()).isEqualTo(1L); + assertThat(getProfile(app.getProfileId()).getName()).isEqualTo("User"); assertThat(app.getInternalProfile()).isNull(); assertThat(app.getHomePageId()).isNull(); assertThat(app.getLayoutId()).isNull(); @@ -231,6 +235,10 @@ private void assertAppLink1() throws Exception { assertThat(app.isLink()).isTrue(); } + private SProfile getProfile(Long profileId) throws Exception { + return getTransactionService().executeInTransaction(() -> profileService.getProfile(profileId)); + } + private void assertAppLink2() throws Exception { SApplication app = getTransactionService() .executeInTransaction(() -> applicationService.getApplicationByToken(APP_2_TOKEN)); @@ -261,7 +269,7 @@ private void assertAppLink3() throws Exception { assertThat(app.getCreatedBy()).isEqualTo(-1L); assertThat(app.getState()).isEqualTo(SApplicationState.ACTIVATED.name()); assertThat(app.getHomePageId()).isNotNull(); - assertThat(app.getProfileId()).isEqualTo(1L); + assertThat(getProfile(app.getProfileId()).getName()).isEqualTo("User"); assertThat(app.getInternalProfile()).isNull(); assertThat(app.getLayoutId()).isNotNull(); assertThat(app.getThemeId()).isNotNull(); diff --git a/bonita-test-api/src/main/java/org/bonitasoft/engine/test/junit/BonitaEngineRule.java b/bonita-test-api/src/main/java/org/bonitasoft/engine/test/junit/BonitaEngineRule.java index 3e2ed4e4647..2a9127158bc 100644 --- a/bonita-test-api/src/main/java/org/bonitasoft/engine/test/junit/BonitaEngineRule.java +++ b/bonita-test-api/src/main/java/org/bonitasoft/engine/test/junit/BonitaEngineRule.java @@ -13,6 +13,8 @@ **/ package org.bonitasoft.engine.test.junit; +import java.lang.reflect.InvocationTargetException; + import org.bonitasoft.engine.test.TestEngine; import org.bonitasoft.engine.test.TestEngineImpl; import org.junit.rules.MethodRule; @@ -32,6 +34,16 @@ protected BonitaEngineRule(TestEngine testEngine) { } public static BonitaEngineRule create() { + try { + var testEngineSpClazz = BonitaEngineRule.class.getClassLoader() + .loadClass("com.bonitasoft.engine.test.TestEngineSP"); + TestEngine testEngineSpInstance = (TestEngine) testEngineSpClazz.getMethod("getInstance").invoke(null); + return new BonitaEngineRule(testEngineSpInstance); + } catch (ClassNotFoundException e) { + // Use Community TestEngine + } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { + throw new RuntimeException(e); + } return new BonitaEngineRule(TestEngineImpl.getInstance()); } diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ServerAPIImpl.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ServerAPIImpl.java index 26241b8f519..74a7a7bcd41 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ServerAPIImpl.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ServerAPIImpl.java @@ -135,17 +135,21 @@ public Object invokeMethod(final Map options, final String } } catch (final BonitaRuntimeException | BonitaException bre) { fillGlobalContextForException(session, bre); + // reset class loader + Thread.currentThread().setContextClassLoader(baseClassLoader); throw createServerWrappedException(bre); } catch (final UndeclaredThrowableException ute) { + // reset class loader + Thread.currentThread().setContextClassLoader(baseClassLoader); throw createServerWrappedException(ute); } catch (final Throwable cause) { final BonitaRuntimeException throwableToWrap = wrapThrowable(cause); fillGlobalContextForException(session, throwableToWrap); + // reset class loader + Thread.currentThread().setContextClassLoader(baseClassLoader); throw createServerWrappedException(throwableToWrap); } finally { cleanSessionIfNeeded(sessionAccessor); - // reset class loader - Thread.currentThread().setContextClassLoader(baseClassLoader); logger.trace("End Server API call {} {}", apiInterfaceName, methodName); } } diff --git a/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DatabaseExtraConfiguration.groovy b/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DatabaseExtraConfiguration.groovy new file mode 100644 index 00000000000..3c6e893723f --- /dev/null +++ b/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DatabaseExtraConfiguration.groovy @@ -0,0 +1,33 @@ +package org.bonitasoft.engine.gradle.docker + +import groovy.transform.Canonical +import org.gradle.api.Project + +@Canonical +class DatabaseExtraConfiguration { + /** + * Include an additional module in the test classpath + */ + Project includeTestModule + /** + * Excludes test class patterns + */ + List excludes + /** + * Enable or disable the execution of the test task for this database configuration + */ + boolean enabled = false + + def excludes(String... excludes) { + this.excludes = [] + this.excludes.addAll(excludes) + } + + def exclude(String excludes) { + if (this.excludes == null) { + this.excludes = [] + } + this.excludes.add(excludes) + } + +} diff --git a/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DatabasePluginExtension.groovy b/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DatabasePluginExtension.groovy index dc0865b7917..bf34db40e28 100644 --- a/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DatabasePluginExtension.groovy +++ b/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DatabasePluginExtension.groovy @@ -13,12 +13,28 @@ **/ package org.bonitasoft.engine.gradle.docker -/** - * @author Baptiste Mesta - */ class DatabasePluginExtension { + /** + * Include test class patterns + */ List includes + /** + * Extra configuration for the postgres database + */ + DatabaseExtraConfiguration postgres = new DatabaseExtraConfiguration(enabled: true) + /** + * Extra configuration for the mysql database + */ + DatabaseExtraConfiguration mysql = new DatabaseExtraConfiguration() + /** + * Extra configuration for the oracle database + */ + DatabaseExtraConfiguration oracle = new DatabaseExtraConfiguration() + /** + * Extra configuration for the sqlserver database + */ + DatabaseExtraConfiguration sqlserver = new DatabaseExtraConfiguration() def includes(String... includes) { this.includes = [] @@ -32,4 +48,28 @@ class DatabasePluginExtension { this.includes.add(include) } + def postgres(Closure closure) { + closure.delegate = postgres + closure.resolveStrategy = Closure.DELEGATE_FIRST + closure() + } + + def mysql(Closure closure) { + closure.delegate = mysql + closure.resolveStrategy = Closure.DELEGATE_FIRST + closure() + } + + def oracle(Closure closure) { + closure.delegate = oracle + closure.resolveStrategy = Closure.DELEGATE_FIRST + closure() + } + + def sqlserver(Closure closure) { + closure.delegate = sqlserver + closure.resolveStrategy = Closure.DELEGATE_FIRST + closure() + } + } diff --git a/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DockerDatabaseContainerTasksCreator.groovy b/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DockerDatabaseContainerTasksCreator.groovy index c5a75bed98c..59fe77f9897 100644 --- a/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DockerDatabaseContainerTasksCreator.groovy +++ b/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DockerDatabaseContainerTasksCreator.groovy @@ -20,8 +20,6 @@ import com.bmuschko.gradle.docker.tasks.container.DockerStartContainer import com.bmuschko.gradle.docker.tasks.container.extras.DockerWaitHealthyContainer import com.bmuschko.gradle.docker.tasks.image.DockerPullImage import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.UnknownTaskException import org.gradle.api.tasks.TaskProvider import org.gradle.api.tasks.bundling.Zip import org.gradle.api.tasks.testing.Test @@ -31,32 +29,6 @@ import org.gradle.api.tasks.testing.Test */ class DockerDatabaseContainerTasksCreator { - def static vendors = [ - [name : 'oracle', - image : 'bonitasoft.jfrog.io/docker-releases/bonita-oracle-19c-ee:0.0.2', - registryUrlEnv : 'DOCKER_BONITASOFT_REGISTRY', - registryUsernameEnv: 'REGISTRY_USERNAME', - registryPasswordEnv: 'REGISTRY_TOKEN', - portBinding : 1521, - uriTemplate : 'jdbc:oracle:thin:@//%s:%s/ORCLPDB1?oracle.net.disableOob=true', - ], - [name : 'postgres', - image : 'bonitasoft/bonita-postgres:15.3', - portBinding: 5432, - uriTemplate: 'jdbc:postgresql://%s:%s/%s', - ], - [name : 'mysql', - image : 'bonitasoft/bonita-mysql:8.0.33', - portBinding: 3306, - uriTemplate: 'jdbc:mysql://%s:%s/%s?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8', - ], - [name : 'sqlserver', - image : 'bonitasoft/bonita-sqlserver:2022-CU13', - portBinding: 1433, - uriTemplate: 'jdbc:sqlserver://%s:%s;database=%s', - ] - ] - private static String getDockerHost(def project) { def dockerHost = System.getenv('DOCKER_HOST') if (dockerHost?.trim()) { @@ -70,7 +42,7 @@ class DockerDatabaseContainerTasksCreator { private static final String SYS_PROP_DB_USER = 'db.user' private static final String SYS_PROP_DB_PASSWORD = 'db.password' - def static createTasks(Project project, DatabasePluginExtension extension) { + def static createTasks(Project project, DatabasePluginExtension extension, List vendors) { // required to have the environment correctly setup: see https://github.com/bmuschko/gradle-docker-plugin/issues/575#issuecomment-383704012 if (!project.rootProject.plugins.hasPlugin('com.bmuschko.docker-remote-api')) { project.rootProject.plugins.apply('com.bmuschko.docker-remote-api') @@ -81,10 +53,8 @@ class DockerDatabaseContainerTasksCreator { DbParser.DbConnectionSettings dbConnectionSettings = new DbParser.DbConnectionSettings() DbParser.DbConnectionSettings bdmDbConnectionSettings = new DbParser.DbConnectionSettings() - TaskProvider inspectContainer - TaskProvider removeContainer - TaskProvider pullImage = registerTaskInRootProject(project, "pull${uniqueName}Image", DockerPullImage) { + def pullImage = project.tasks.register("pull${uniqueName}Image", DockerPullImage) { description "Pull docker image for $uniqueName db vendor" group null // do not show task when running `gradle tasks` @@ -99,7 +69,7 @@ class DockerDatabaseContainerTasksCreator { } } - TaskProvider createContainer = registerTaskInRootProject(project, "create${uniqueName}Container", DockerCreateContainer) { + def createContainer = project.tasks.register("create${uniqueName}Container", DockerCreateContainer) { description "Create a docker container for $uniqueName db vendor" group null // do not show task when running `gradle tasks` @@ -115,14 +85,14 @@ class DockerDatabaseContainerTasksCreator { hostConfig.autoRemove = true } - TaskProvider startContainer = registerTaskInRootProject(project, "start${uniqueName}Container", DockerStartContainer) { + def startContainer = project.tasks.register("start${uniqueName}Container", DockerStartContainer) { description "Start a docker container for $uniqueName db vendor" group "docker" targetContainerId createContainer.get().getContainerId() } - def waitForContainerStartup = registerTaskInRootProject(project, "waitFor${uniqueName}ContainerStartup", DockerWaitHealthyContainer) { + def waitForContainerStartup = project.tasks.register("waitFor${uniqueName}ContainerStartup", DockerWaitHealthyContainer) { description "Wait for a started docker container for $vendor.name db vendor to be healthy" group null // do not show task when running `gradle tasks` @@ -130,7 +100,7 @@ class DockerDatabaseContainerTasksCreator { awaitStatusTimeout = 360 } - inspectContainer = project.tasks.register("inspect${uniqueName}ContainerUrl", DockerInspectContainer) { + def inspectContainer = project.tasks.register("inspect${uniqueName}ContainerUrl", DockerInspectContainer) { description = "Get url of a docker container for $uniqueName db vendor" group = null // do not show task when running `gradle tasks` @@ -153,7 +123,7 @@ class DockerDatabaseContainerTasksCreator { } } - removeContainer = registerTaskInRootProject(project, "remove${uniqueName}Container", DockerRemoveContainer) { + def removeContainer = project.tasks.register("remove${uniqueName}Container", DockerRemoveContainer) { description "Remove a docker container for $uniqueName db vendor" group "docker" @@ -166,8 +136,16 @@ class DockerDatabaseContainerTasksCreator { group = "Verification" description = "Runs slow integration test suite on $vendor.name database." systemProperty "bonita.version", project.version - jvmArgs += ['--add-opens','java.base/java.util=ALL-UNNAMED','--add-opens','java.base/java.lang=ALL-UNNAMED','-Dfile.encoding=UTF-8'] + jvmArgs += ['--add-opens', 'java.base/java.util=ALL-UNNAMED', '--add-opens', 'java.base/java.lang=ALL-UNNAMED', '-Dfile.encoding=UTF-8'] + if (extension."${vendor.name}"?.includeTestModule) { + testClassesDirs += extension."${vendor.name}".includeTestModule.sourceSets.test.output.classesDirs + classpath += extension."${vendor.name}".includeTestModule.sourceSets.test.runtimeClasspath + } classpath += project.files(project.configurations.drivers) + if(extension."${vendor.name}"?.excludes) { + exclude(extension."${vendor.name}".excludes) + } + onlyIf { extension."${vendor.name}"?.enabled } doFirst { String dbUrl = project.hasProperty(SYS_PROP_DB_URL) ? project.property(SYS_PROP_DB_URL) : dbConnectionSettings.dbUrl @@ -205,9 +183,14 @@ class DockerDatabaseContainerTasksCreator { } project.afterEvaluate { databaseTestTask.configure { includes = extension.includes } + pullImage.configure { onlyIf { extension."${vendor.name}"?.enabled } } + createContainer.configure { onlyIf { extension."${vendor.name}"?.enabled } } + startContainer.configure { onlyIf { extension."${vendor.name}"?.enabled } } + waitForContainerStartup.configure { onlyIf { extension."${vendor.name}"?.enabled } } + inspectContainer.configure { onlyIf { extension."${vendor.name}"?.enabled } } + removeContainer.configure { onlyIf { extension."${vendor.name}"?.enabled } } } - if (createContainer) { createContainer.configure { dependsOn(pullImage) } } @@ -235,11 +218,4 @@ class DockerDatabaseContainerTasksCreator { } } - static TaskProvider registerTaskInRootProject(Project project, String taskName, Class taskType, Closure configuration) { - try { - project.rootProject.tasks.named(taskName) - } catch (UnknownTaskException ignored) { - project.rootProject.tasks.register(taskName, taskType, configuration) - } - } } diff --git a/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DockerDatabasePlugin.groovy b/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DockerDatabasePlugin.groovy index dd49a13edbb..0d48608279c 100644 --- a/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DockerDatabasePlugin.groovy +++ b/buildSrc/src/main/groovy/org/bonitasoft/engine/gradle/docker/DockerDatabasePlugin.groovy @@ -14,22 +14,10 @@ class DockerDatabasePlugin implements Plugin { project.configurations { drivers } - - project.dependencies { - // the following jdbc drivers are available for integration tests - drivers(project.extensions.getByType(VersionCatalogsExtension.class).named("libs") - .findLibrary("mysql").get()) - drivers(project.extensions.getByType(VersionCatalogsExtension.class).named("libs") - .findLibrary("oracle").get()) - drivers(project.extensions.getByType(VersionCatalogsExtension.class).named("libs") - .findLibrary("postgresql").get()) - drivers(project.extensions.getByType(VersionCatalogsExtension.class).named("libs") - .findLibrary("msSqlServer").get()) - } - + driversConfiguration(project) def databaseIntegrationTest = project.extensions.create("databaseIntegrationTest", DatabasePluginExtension) - DockerDatabaseContainerTasksCreator.createTasks(project, databaseIntegrationTest) + DockerDatabaseContainerTasksCreator.createTasks(project, databaseIntegrationTest, getVendors()) project.afterEvaluate { if (!databaseIntegrationTest.includes) { @@ -38,4 +26,22 @@ class DockerDatabasePlugin implements Plugin { } } + def driversConfiguration(project) { + project.dependencies { + // the following jdbc drivers are available for integration tests + drivers(project.extensions.getByType(VersionCatalogsExtension.class).named("libs") + .findLibrary("postgresql").get()) + } + } + + List getVendors() { + return [ + [name : 'postgres', + image : 'bonitasoft/bonita-postgres:15.3', + portBinding: 5432, + uriTemplate: 'jdbc:postgresql://%s:%s/%s', + ] + ] + } + } diff --git a/services/bonita-business-data/bonita-business-data-impl/src/main/java/org/bonitasoft/engine/business/data/impl/BusinessDataModelRepositoryImpl.java b/services/bonita-business-data/bonita-business-data-impl/src/main/java/org/bonitasoft/engine/business/data/impl/BusinessDataModelRepositoryImpl.java index fa28db14ef8..60baa51ec07 100644 --- a/services/bonita-business-data/bonita-business-data-impl/src/main/java/org/bonitasoft/engine/business/data/impl/BusinessDataModelRepositoryImpl.java +++ b/services/bonita-business-data/bonita-business-data-impl/src/main/java/org/bonitasoft/engine/business/data/impl/BusinessDataModelRepositoryImpl.java @@ -308,8 +308,9 @@ public void uninstall(final long tenantId) throws SBusinessDataRepositoryExcepti try { dependencyService.deleteDependency(BDR_DEPENDENCY_NAME); classLoaderService.refreshClassLoaderImmediatelyWithRollback(identifier(ScopeType.TENANT, tenantId)); + ClassLoader classLoader = classLoaderService.getClassLoader(identifier(ScopeType.TENANT, tenantId)); Thread.currentThread() - .setContextClassLoader(classLoaderService.getClassLoader(identifier(ScopeType.TENANT, tenantId))); + .setContextClassLoader(classLoader); } catch (final SDependencyNotFoundException sde) { // do nothing } catch (final SDependencyException | SClassLoaderException e) {