From 70c424c2eeb9b0f882da45b2ed57140666501be5 Mon Sep 17 00:00:00 2001 From: Adrien Kantcheff <5028967+akantcheff@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:11:00 +0200 Subject: [PATCH] chore(platform-setup): remove unused datasource config and move db libs to sp (#3160) - Datasouce configs for db vendors are useless and can be removed. Also, the profiles associated to those configs are removed as well. - With those profiles removed, there is no need to specify the spring profile `default` when starting the engine. - Drivers for MySQL, SQLServer and Oracle are moved to SP Closes [BPM-255](https://bonitasoft.atlassian.net/browse/BPM-255) & [BPM-256](https://bonitasoft.atlassian.net/browse/BPM-256) [BPM-255]: https://bonitasoft.atlassian.net/browse/BPM-255?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [BPM-256]: https://bonitasoft.atlassian.net/browse/BPM-256?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --- gradle/libs.versions.toml | 2 + .../platform/setup/ScriptExecutor.java | 2 +- platform/platform-setup/build.gradle | 35 +-- .../command/configure/BundleResolver.java | 14 +- .../command/configure/PropertyReader.java | 12 +- ...ourceConfig.java => DataSourceConfig.java} | 8 +- .../dbconfig/H2LocalDataSourceConfig.java | 30 --- .../setup/dbconfig/MySQLDataSourceConfig.java | 30 --- .../dbconfig/OracleDataSourceConfig.java | 30 --- .../dbconfig/PostgresDataSourceConfig.java | 30 --- .../dbconfig/SQLServerDataSourceConfig.java | 30 --- .../src/main/resources/application.properties | 1 - .../src/main/standalone/setup.bat | 2 +- .../src/main/standalone/setup.sh | 2 +- .../setup/ConfigurationCheckerTest.java | 13 +- .../setup/PlatformSetupDistributionIT.java | 18 +- .../platform/setup/ScriptExecutorTest.java | 16 +- .../setup/command/InitCommandTest.java | 4 + .../configure/DatabaseConfigurationTest.java | 23 +- .../command/configure/PropertyReaderTest.java | 2 +- .../TomcatBundleConfiguratorTest.java | 242 +++++++++--------- .../src/test/resources/database.properties | 59 +++-- .../datasource-config/database.properties | 25 ++ .../database_with_space_values.properties | 12 +- .../incomplete_database.properties | 0 .../incomplete_internal.properties | 0 .../datasource-config/internal.properties | 58 +++++ .../missingDriverClass_internal.properties | 0 .../src/test/resources/h2.properties | 1 - .../src/test/resources/internal.properties | 65 ++--- .../src/test/resources/mysql.properties | 20 -- .../src/test/resources/oracle.properties | 17 -- .../src/test/resources/postgres.properties | 17 -- .../src/test/resources/sqlserver.properties | 17 -- 34 files changed, 343 insertions(+), 494 deletions(-) rename platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/{GenericDataSourceConfig.java => DataSourceConfig.java} (80%) delete mode 100644 platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/H2LocalDataSourceConfig.java delete mode 100644 platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/MySQLDataSourceConfig.java delete mode 100644 platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/OracleDataSourceConfig.java delete mode 100644 platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/PostgresDataSourceConfig.java delete mode 100644 platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/SQLServerDataSourceConfig.java create mode 100644 platform/platform-setup/src/test/resources/datasource-config/database.properties rename platform/platform-setup/src/test/resources/{ => datasource-config}/database_with_space_values.properties (68%) rename platform/platform-setup/src/test/resources/{ => datasource-config}/incomplete_database.properties (100%) rename platform/platform-setup/src/test/resources/{ => datasource-config}/incomplete_internal.properties (100%) create mode 100644 platform/platform-setup/src/test/resources/datasource-config/internal.properties rename platform/platform-setup/src/test/resources/{ => datasource-config}/missingDriverClass_internal.properties (100%) delete mode 100644 platform/platform-setup/src/test/resources/h2.properties delete mode 100644 platform/platform-setup/src/test/resources/mysql.properties delete mode 100644 platform/platform-setup/src/test/resources/oracle.properties delete mode 100644 platform/platform-setup/src/test/resources/postgres.properties delete mode 100644 platform/platform-setup/src/test/resources/sqlserver.properties diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 23aa7cd7aa6..43b253155e2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,6 +13,7 @@ commonsBeanutilsVersion = "1.9.4" commonsCollectionsVersion = "4.4" tomcatDbcpVersion = "9.0.93" commonsCLIVersion = "1.8.0" +commonsTextVersion = "1.10.0" semver4jVersion = '3.1.0' slf4jVersion = "1.7.36" # Attention, see PassingPropertiesJCacheRegionFactory javadoc if this version changes: @@ -105,6 +106,7 @@ commonsBeanUtils = { group = "commons-beanutils", name = "commons-beanutils", ve commonsCollections = { group = "org.apache.commons", name = "commons-collections4", version.ref = "commonsCollectionsVersion" } tomcatDbcp = { group = "org.apache.tomcat", name = "tomcat-dbcp", version.ref = "tomcatDbcpVersion" } commonsCLI = { group = "commons-cli", name = "commons-cli", version.ref = "commonsCLIVersion" } +commonsText = { group = "org.apache.commons", name = "commons-text", version.ref = "commonsTextVersion" } semver4j = { group = "com.vdurmont", name = "semver4j", version.ref = "semver4jVersion" } slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4jVersion" } diff --git a/platform/platform-resources/src/main/java/org/bonitasoft/platform/setup/ScriptExecutor.java b/platform/platform-resources/src/main/java/org/bonitasoft/platform/setup/ScriptExecutor.java index 1f7d3135b0a..72cbdd9529c 100644 --- a/platform/platform-resources/src/main/java/org/bonitasoft/platform/setup/ScriptExecutor.java +++ b/platform/platform-resources/src/main/java/org/bonitasoft/platform/setup/ScriptExecutor.java @@ -128,7 +128,7 @@ protected String getInformationInitialValue() { } } - private void insertTenant() { + protected void insertTenant() { final String sql = "INSERT INTO tenant (id, created, createdBy, description, defaultTenant, name, status) " + "VALUES (?, ?, ?, ?, ?, ?, ?)"; diff --git a/platform/platform-setup/build.gradle b/platform/platform-setup/build.gradle index dc24ff565b9..7a7edd324f1 100644 --- a/platform/platform-setup/build.gradle +++ b/platform/platform-setup/build.gradle @@ -12,7 +12,8 @@ configurations { } dependencies { - api "org.apache.commons:commons-text:1.10.0" + api project(':platform:platform-resources') + api libs.commonsText api libs.slf4jApi api(libs.springBootStarter) { exclude(module: 'jul-to-slf4j') @@ -20,25 +21,15 @@ dependencies { exclude(module: 'snakeyaml') } api libs.springBootStarterJdbc - api(libs.postgresql) - api(libs.mysql) { - exclude(module: 'protobuf-java') - } - api libs.msSqlServer - api(libs.h2) - api(libs.oracle) { - exclude(module: "ons") - exclude(module: "oraclepki") - exclude(module: "osdt_cert") - exclude(module: "osdt_core") - exclude(module: "ucp") - exclude(module: "simplefan") - } + api libs.h2 + api libs.postgresql api libs.commonsCLI + annotationProcessor libs.lombok compileOnly libs.lombok - api(project(":platform:platform-resources")) - runtimeOnly(libs.logback) + + runtimeOnly libs.logback + testImplementation "junit:junit:${Deps.junit4Version}" testImplementation "org.assertj:assertj-core:${Deps.assertjVersion}" testImplementation "org.mockito:mockito-core:${Deps.mockitoVersion}" @@ -76,6 +67,7 @@ processResources { } distTar.enabled = false + distributions { main { distributionBaseName = "Bonita-platform-setup" @@ -124,21 +116,16 @@ distributions { } } - tasks.distZip.dependsOn configurations.inDistrib artifacts { distributionZip distZip } -test { include '**/*Test.class' } - - -def iT = tasks.getByName("integrationTest") -iT.configure { +tasks.named("integrationTest").configure { def testDir = new File(buildDir, "integrationTest") doFirst { testDir.mkdirs() systemProperty "bonita.distribution.path", distZip.outputs.files.first() } workingDir testDir + dependsOn distZip } -tasks.integrationTest.dependsOn distZip diff --git a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/command/configure/BundleResolver.java b/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/command/configure/BundleResolver.java index 6d71c7a2a0f..c6929d9c6b5 100644 --- a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/command/configure/BundleResolver.java +++ b/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/command/configure/BundleResolver.java @@ -20,20 +20,16 @@ import java.nio.file.Path; import java.nio.file.Paths; +import lombok.extern.slf4j.Slf4j; import org.bonitasoft.platform.exception.PlatformException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * This class contains the logic to determine if we are in the context of an application server that we must configure. * Only Tomcat is supported. - * - * @author Emmanuel Duchastenier */ +@Slf4j class BundleResolver { - private static final Logger LOGGER = LoggerFactory.getLogger(BundleConfigurator.class); - private final Path rootPath; BundleResolver() { @@ -48,7 +44,7 @@ class BundleResolver { private boolean fileExists(Path filePath) { final boolean exists = Files.exists(filePath); if (!exists) { - LOGGER.debug("File " + filePath.toString() + " does not exist."); + log.debug("File {} does not exist.", filePath); } return exists; } @@ -71,8 +67,8 @@ BundleConfigurator getConfigurator() throws PlatformException { if (isTomcatEnvironment()) { return new TomcatBundleConfigurator(rootPath); } else { - LOGGER.info( - "No Application Server detected. You may need to manually configure the access to the database. Only Tomcat 8.x is supported"); + log.info("No Application Server detected. You may need to manually configure the access to the database. " + + "Only Tomcat 9.0.x is supported"); return null; } } diff --git a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/command/configure/PropertyReader.java b/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/command/configure/PropertyReader.java index 83d9c7f8ec4..a28c5f4d1a4 100644 --- a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/command/configure/PropertyReader.java +++ b/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/command/configure/PropertyReader.java @@ -15,18 +15,12 @@ import java.util.Properties; +import lombok.extern.slf4j.Slf4j; import org.bonitasoft.platform.exception.PlatformException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -/** - * @author Emmanuel Duchastenier - */ +@Slf4j public class PropertyReader { - // Use BundleConfigurator logger for easier configuration (no need for a specific logger here): - private static final Logger LOGGER = LoggerFactory.getLogger(BundleConfigurator.class); - private final Properties properties; public PropertyReader(Properties properties) { @@ -37,7 +31,7 @@ public String getPropertyAndFailIfNull(String propertyName) throws PlatformExcep // Any property value can be overridden by system property with the same name: final String sysPropValue = System.getProperty(propertyName); if (sysPropValue != null) { - LOGGER.info("System property '{}' set to '{}', overriding value from file database.properties.", + log.info("System property '{}' set to '{}', overriding value from file database.properties.", propertyName, sysPropValue); return sysPropValue.trim(); } diff --git a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/GenericDataSourceConfig.java b/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/DataSourceConfig.java similarity index 80% rename from platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/GenericDataSourceConfig.java rename to platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/DataSourceConfig.java index 0a5dd51587f..45fb4d9c4b0 100644 --- a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/GenericDataSourceConfig.java +++ b/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/DataSourceConfig.java @@ -13,18 +13,14 @@ **/ package org.bonitasoft.platform.setup.dbconfig; -import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Component; /** - * This is enough to get a Datasource that spring creates using parameters provided in properties. - * - * @author Emmanuel Duchastenier + * Used by Spring to create an instance of {@link javax.sql.DataSource} using parameters provided in properties. */ @Component @PropertySource(value = { "classpath:/database.properties", "classpath:/internal.properties" }) -@Profile("default") -public class GenericDataSourceConfig { +public class DataSourceConfig { } diff --git a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/H2LocalDataSourceConfig.java b/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/H2LocalDataSourceConfig.java deleted file mode 100644 index 9d5ab498ddc..00000000000 --- a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/H2LocalDataSourceConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (C) 2019 Bonitasoft S.A. - * Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble - * This library is free software; you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Foundation - * version 2.1 of the License. - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301, USA. - **/ -package org.bonitasoft.platform.setup.dbconfig; - -import org.springframework.context.annotation.Profile; -import org.springframework.context.annotation.PropertySource; -import org.springframework.stereotype.Component; - -/** - * This is enough to get a Datasource that spring creates using parameters provided in properties. - * - * @author Emmanuel Duchastenier - */ -@Component -@PropertySource("classpath:/h2.properties") -@Profile("h2") -public class H2LocalDataSourceConfig { - -} diff --git a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/MySQLDataSourceConfig.java b/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/MySQLDataSourceConfig.java deleted file mode 100644 index 1a6cb2d298a..00000000000 --- a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/MySQLDataSourceConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (C) 2019 Bonitasoft S.A. - * Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble - * This library is free software; you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Foundation - * version 2.1 of the License. - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301, USA. - **/ -package org.bonitasoft.platform.setup.dbconfig; - -import org.springframework.context.annotation.Profile; -import org.springframework.context.annotation.PropertySource; -import org.springframework.stereotype.Component; - -/** - * This is enough to get a Datasource that spring creates using parameters provided in properties. - * - * @author Emmanuel Duchastenier - */ -@Component -@PropertySource("classpath:/mysql.properties") -@Profile("mysql") -public class MySQLDataSourceConfig { - -} diff --git a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/OracleDataSourceConfig.java b/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/OracleDataSourceConfig.java deleted file mode 100644 index 5ae5b2ceb16..00000000000 --- a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/OracleDataSourceConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (C) 2019 Bonitasoft S.A. - * Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble - * This library is free software; you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Foundation - * version 2.1 of the License. - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301, USA. - **/ -package org.bonitasoft.platform.setup.dbconfig; - -import org.springframework.context.annotation.Profile; -import org.springframework.context.annotation.PropertySource; -import org.springframework.stereotype.Component; - -/** - * This is enough to get a Datasource that spring creates using parameters provided in properties. - * - * @author Emmanuel Duchastenier - */ -@Component -@PropertySource("classpath:/oracle.properties") -@Profile("oracle") -public class OracleDataSourceConfig { - -} diff --git a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/PostgresDataSourceConfig.java b/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/PostgresDataSourceConfig.java deleted file mode 100644 index 0204778dbf7..00000000000 --- a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/PostgresDataSourceConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (C) 2019 Bonitasoft S.A. - * Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble - * This library is free software; you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Foundation - * version 2.1 of the License. - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301, USA. - **/ -package org.bonitasoft.platform.setup.dbconfig; - -import org.springframework.context.annotation.Profile; -import org.springframework.context.annotation.PropertySource; -import org.springframework.stereotype.Component; - -/** - * This is enough to get a Datasource that spring creates using parameters provided in properties. - * - * @author Emmanuel Duchastenier - */ -@Component -@PropertySource("classpath:/postgres.properties") -@Profile("postgres") -public class PostgresDataSourceConfig { - -} diff --git a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/SQLServerDataSourceConfig.java b/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/SQLServerDataSourceConfig.java deleted file mode 100644 index 6faae38cf9d..00000000000 --- a/platform/platform-setup/src/main/java/org/bonitasoft/platform/setup/dbconfig/SQLServerDataSourceConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (C) 2019 Bonitasoft S.A. - * Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble - * This library is free software; you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Foundation - * version 2.1 of the License. - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301, USA. - **/ -package org.bonitasoft.platform.setup.dbconfig; - -import org.springframework.context.annotation.Profile; -import org.springframework.context.annotation.PropertySource; -import org.springframework.stereotype.Component; - -/** - * This is enough to get a Datasource that spring creates using parameters provided in properties. - * - * @author Emmanuel Duchastenier - */ -@Component -@PropertySource("classpath:/sqlserver.properties") -@Profile("sqlserver") -public class SQLServerDataSourceConfig { - -} diff --git a/platform/platform-setup/src/main/resources/application.properties b/platform/platform-setup/src/main/resources/application.properties index 5c047636960..d60f1dd57f3 100644 --- a/platform/platform-setup/src/main/resources/application.properties +++ b/platform/platform-setup/src/main/resources/application.properties @@ -1,2 +1 @@ -spring.profiles.active=h2 db.vendor=${sysprop.bonita.db.vendor:h2} diff --git a/platform/platform-setup/src/main/standalone/setup.bat b/platform/platform-setup/src/main/standalone/setup.bat index 9962e8fa82e..74c4ba35701 100644 --- a/platform/platform-setup/src/main/standalone/setup.bat +++ b/platform/platform-setup/src/main/standalone/setup.bat @@ -24,7 +24,7 @@ IF NOT "%BONITA_DATABASE%" == "h2" IF NOT "%BONITA_DATABASE%" == "postgres" ( exit /b 1 ) -"%JAVA_CMD%" -cp "%BASEDIR%;%CFG_FOLDER%;%INITIAL_CFG_FOLDER%;%LIB_FOLDER%\*" -Dspring.profiles.active=default -Dsysprop.bonita.db.vendor=%BONITA_DATABASE% org.bonitasoft.platform.setup.PlatformSetupApplication %* +"%JAVA_CMD%" -cp "%BASEDIR%;%CFG_FOLDER%;%INITIAL_CFG_FOLDER%;%LIB_FOLDER%\*" -Dsysprop.bonita.db.vendor=%BONITA_DATABASE% org.bonitasoft.platform.setup.PlatformSetupApplication %* if errorlevel 1 ( exit /b 1 diff --git a/platform/platform-setup/src/main/standalone/setup.sh b/platform/platform-setup/src/main/standalone/setup.sh index 5f4d22df4c2..70daa77add0 100644 --- a/platform/platform-setup/src/main/standalone/setup.sh +++ b/platform/platform-setup/src/main/standalone/setup.sh @@ -22,7 +22,7 @@ if [ "$BONITA_DATABASE" != "h2" ] && [ "$BONITA_DATABASE" != "postgres" ]; then exit 1 fi -"${JAVA_EXE}" -cp "${BASEDIR}:${CFG_FOLDER}:${INITIAL_CFG_FOLDER}${LIBS_CP}" ${JVM_OPTS} -Dspring.profiles.active=default -Dsysprop.bonita.db.vendor=${BONITA_DATABASE} org.bonitasoft.platform.setup.PlatformSetupApplication "$@" +"${JAVA_EXE}" -cp "${BASEDIR}:${CFG_FOLDER}:${INITIAL_CFG_FOLDER}${LIBS_CP}" ${JVM_OPTS} -Dsysprop.bonita.db.vendor=${BONITA_DATABASE} org.bonitasoft.platform.setup.PlatformSetupApplication "$@" COD_RET=$? if [ ${COD_RET} -ne 0 ]; then cd - 1>/dev/null diff --git a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/ConfigurationCheckerTest.java b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/ConfigurationCheckerTest.java index e16657ec6a7..e5d6a02826c 100644 --- a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/ConfigurationCheckerTest.java +++ b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/ConfigurationCheckerTest.java @@ -32,6 +32,8 @@ */ public class ConfigurationCheckerTest { + private static final String TEST_DATASOURCE_CONFIG_DIR = "/datasource-config/"; + @Rule public TestRule clean = new ClearSystemProperties("db.admin.user", "sysprop.bonita.db.vendor", "db.user", "db.password", "db.vendor", "db.server.name=", @@ -52,7 +54,8 @@ public void validate_should_load_class_if_present() throws Exception { @Test public void validate_should_fail_to_load_class_if_not_found() throws Exception { final ConfigurationChecker configurationChecker = new ConfigurationChecker( - new PropertyLoader("/database.properties", "/missingDriverClass_internal.properties").loadProperties()); + new PropertyLoader(TEST_DATASOURCE_CONFIG_DIR + "database.properties", + TEST_DATASOURCE_CONFIG_DIR + "missingDriverClass_internal.properties").loadProperties()); configurationChecker.loadProperties(); expectedException.expect(PlatformException.class); @@ -65,8 +68,9 @@ public void validate_should_fail_to_load_class_if_not_found() throws Exception { public void validate_should_fail_mandatory_property_is_not_set() throws Exception { final String dbVendor = "dbVendor"; System.setProperty(PlatformSetup.BONITA_DB_VENDOR_PROPERTY, dbVendor); - final Properties propertiesWithMissingServerName = new PropertyLoader("/incomplete_database.properties") - .loadProperties(); + final Properties propertiesWithMissingServerName = new PropertyLoader( + TEST_DATASOURCE_CONFIG_DIR + "incomplete_database.properties") + .loadProperties(); expectedException.expect(PlatformException.class); expectedException.expectMessage("Mandatory property"); @@ -77,7 +81,8 @@ public void validate_should_fail_mandatory_property_is_not_set() throws Exceptio @Test public void validate_should_fail_if_class_to_load_is_not_set() throws Exception { final ConfigurationChecker configurationChecker = new ConfigurationChecker( - new PropertyLoader("/database.properties", "/incomplete_internal.properties").loadProperties()); + new PropertyLoader(TEST_DATASOURCE_CONFIG_DIR + "database.properties", + TEST_DATASOURCE_CONFIG_DIR + "incomplete_internal.properties").loadProperties()); expectedException.expect(PlatformException.class); expectedException.expectMessage("Mandatory property 'postgres.nonXaDriver'"); diff --git a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/PlatformSetupDistributionIT.java b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/PlatformSetupDistributionIT.java index e7521d06081..f099c874eba 100644 --- a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/PlatformSetupDistributionIT.java +++ b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/PlatformSetupDistributionIT.java @@ -72,21 +72,21 @@ public void setupSh_should_work_with_init_on_h2_and_prevent_pushing_deletion() t int iExitValue = executor.execute(oCmdLine); //then - assertThat(iExitValue).isEqualTo(0); + assertThat(iExitValue).isZero(); Connection jdbcConnection = PlatformSetupTestUtils.getJdbcConnection(setupFolder); Statement statement = jdbcConnection.createStatement(); ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) AS nb FROM CONFIGURATION"); resultSet.next(); - assertThat(resultSet.getInt("nb")).isGreaterThan(0); + assertThat(resultSet.getInt("nb")).isPositive(); oCmdLine = PlatformSetupTestUtils.createCommandLine(); oCmdLine.addArgument("pull"); iExitValue = executor.execute(oCmdLine); - assertThat(iExitValue).isEqualTo(0); + assertThat(iExitValue).isZero(); - final Path platform_engine = setupFolder.toPath().resolve("platform_conf").resolve("current") + final Path platformEngine = setupFolder.toPath().resolve("platform_conf").resolve("current") .resolve("platform_engine"); - FileUtils.deleteDirectory(platform_engine.toFile()); + FileUtils.deleteDirectory(platformEngine.toFile()); oCmdLine = PlatformSetupTestUtils.createCommandLine(); oCmdLine.addArgument("push"); @@ -97,7 +97,7 @@ public void setupSh_should_work_with_init_on_h2_and_prevent_pushing_deletion() t oCmdLine.addArgument("--force"); executor.setExitValue(0); iExitValue = executor.execute(oCmdLine); - assertThat(iExitValue).isEqualTo(0); + assertThat(iExitValue).isZero(); } @Test @@ -110,12 +110,12 @@ public void setupSh_should_work_with_init_on_h2_with_overridden_system_property( //when int iExitValue = executor.execute(oCmdLine); //then - assertThat(iExitValue).isEqualTo(0); + assertThat(iExitValue).isZero(); Connection jdbcConnection = PlatformSetupTestUtils.getJdbcConnection(setupFolder, "myUser"); Statement statement = jdbcConnection.createStatement(); ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) AS nb FROM CONFIGURATION"); resultSet.next(); - assertThat(resultSet.getInt("nb")).isGreaterThan(0); + assertThat(resultSet.getInt("nb")).isPositive(); } @Test @@ -155,7 +155,7 @@ public void setupSh_should_work_on_postgres_database() throws Exception { Files.write(databaseProperties, out.toByteArray()); int iExitValue = executor.execute(oCmdLine); //then - assertThat(iExitValue).isEqualTo(0); + assertThat(iExitValue).isZero(); } finally { pgServer.shutdown(); } diff --git a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/ScriptExecutorTest.java b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/ScriptExecutorTest.java index 987a7eb27f4..437b329a215 100644 --- a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/ScriptExecutorTest.java +++ b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/ScriptExecutorTest.java @@ -15,29 +15,21 @@ import static org.mockito.Mockito.*; -import org.bonitasoft.platform.setup.jndi.MemoryJNDISetup; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.junit4.SpringRunner; /** * author Emmanuel Duchastenier */ @RunWith(SpringRunner.class) -@SpringBootTest(classes = { - PlatformSetupApplication.class -}) +@SpringBootTest(classes = PlatformSetupApplication.class, + // use an in-memory h2 database for those tests + properties = "h2.url=jdbc:h2:mem:${db.database.name}") public class ScriptExecutorTest { - @Autowired - MemoryJNDISetup memoryJNDISetup; - - @Autowired - JdbcTemplate jdbcTemplate; - @Autowired private ScriptExecutor scriptExecutor; @@ -55,6 +47,7 @@ public void createAndInitializePlatformIfNecessary_should_not_create_platform_if verify(spy, times(0)).createTables(); verify(spy, times(0)).initializePlatformStructure(); verify(spy, times(0)).insertPlatform(); + verify(spy, times(0)).insertTenant(); } @Test @@ -70,6 +63,7 @@ public void createAndInitializePlatformIfNecessary_should_create_platform_if_not verify(spy).createTables(); verify(spy).initializePlatformStructure(); verify(spy).insertPlatform(); + verify(spy).insertTenant(); //cleanup scriptExecutor.deleteTables(); diff --git a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/InitCommandTest.java b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/InitCommandTest.java index 46c75640eaf..7a19a6b6f6c 100644 --- a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/InitCommandTest.java +++ b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/InitCommandTest.java @@ -53,6 +53,8 @@ public void before() throws Exception { @Test public void should_execute_init() throws Exception { + doNothing().when(initCommand).askConfirmationIfH2(); + initCommand.execute(new Options(), buildCommandLine()); verify(platformSetup).init(); @@ -60,6 +62,8 @@ public void should_execute_init() throws Exception { @Test public void should_call_h2_confirmation() throws Exception { + doNothing().when(initCommand).askConfirmationIfH2(); + initCommand.execute(new Options(), buildCommandLine()); verify(initCommand).askConfirmationIfH2(); diff --git a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/DatabaseConfigurationTest.java b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/DatabaseConfigurationTest.java index 7733e79b841..d4f4044783f 100644 --- a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/DatabaseConfigurationTest.java +++ b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/DatabaseConfigurationTest.java @@ -31,6 +31,8 @@ */ public class DatabaseConfigurationTest { + private static final String TEST_DATASOURCE_CONFIG_DIR = "/datasource-config/"; + @Rule public TestRule clean = new RestoreSystemProperties(); @@ -39,7 +41,7 @@ public void bonita_database_values_can_be_overridden_by_system_properties() thro // given: final Properties properties = new PropertyLoader().loadProperties(); - System.setProperty("db.vendor", "mysql"); + System.setProperty("db.vendor", "postgres"); System.setProperty("db.server.name", "postgresServer"); System.setProperty("db.server.port", "3333"); System.setProperty("db.database.name", "bonita_database"); @@ -50,7 +52,7 @@ public void bonita_database_values_can_be_overridden_by_system_properties() thro final DatabaseConfiguration bonitaConfig = new DatabaseConfiguration("", properties, null); // then: - assertThat(bonitaConfig.getDbVendor()).isEqualTo("mysql"); + assertThat(bonitaConfig.getDbVendor()).isEqualTo("postgres"); assertThat(bonitaConfig.getServerName()).isEqualTo("postgresServer"); assertThat(bonitaConfig.getServerPort()).isEqualTo("3333"); assertThat(bonitaConfig.getDatabaseName()).isEqualTo("bonita_database"); @@ -62,7 +64,7 @@ public void bonita_database_values_can_be_overridden_by_system_properties() thro public void bdm_database_values_can_be_overridden_by_system_properties() throws Exception { // given: final Properties properties = new Properties(); - properties.load(this.getClass().getResourceAsStream("/internal.properties")); + properties.load(this.getClass().getResourceAsStream(TEST_DATASOURCE_CONFIG_DIR + "internal.properties")); System.setProperty("bdm.db.vendor", "postgres"); System.setProperty("bdm.db.server.name", "myServer"); @@ -87,8 +89,9 @@ public void bdm_database_values_can_be_overridden_by_system_properties() throws public void database_values_should_be_trimmed() throws Exception { // given: final Properties properties = new Properties(); - properties.load(this.getClass().getResourceAsStream("/database_with_space_values.properties")); - properties.load(this.getClass().getResourceAsStream("/internal.properties")); + properties.load(this.getClass() + .getResourceAsStream(TEST_DATASOURCE_CONFIG_DIR + "database_with_space_values.properties")); + properties.load(this.getClass().getResourceAsStream(TEST_DATASOURCE_CONFIG_DIR + "internal.properties")); System.setProperty("db.server.name", " localhost "); System.setProperty("db.server.port", " 5135 "); @@ -100,7 +103,7 @@ public void database_values_should_be_trimmed() throws Exception { // then: assertThat(dbConfig.getUrl()).isEqualTo("jdbc:postgresql://localhost:5135/bonita"); assertThat(bdmDbConfig.getUrl()) - .isEqualTo("jdbc:oracle:thin:@//ora1.rd.lan:1521/ORCL_DATABASE?oracle.net.disableOob=true"); + .isEqualTo("jdbc:postgresql://postgres.rd.lan:5432/business_data"); } @Test @@ -124,7 +127,7 @@ public void support_absolute_path_in_h2_database_dir() throws Exception { assertThat(bonitaConfig.getUrl()) .isEqualTo("jdbc:h2:file:" + h2DatabaseDir - + "/bonita;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE;"); + + "/bonita_journal.db;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE;"); } @Test @@ -144,7 +147,7 @@ public void support_properties_in_h2_database_dir() throws Exception { assertThat(dbConfig.getUrl()) .isEqualTo("jdbc:h2:file:" + h2DatabaseDir - + "/bonita;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE;"); + + "/bonita_journal.db;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE;"); } @Test @@ -165,14 +168,14 @@ public void convert_relative_path_to_absolute_path_in_h2_database_dir() throws E .isEqualTo("jdbc:h2:file:" + rootPath.resolve("setup").resolve(h2DatabaseDir).toAbsolutePath().normalize().toString() .replace("\\", "/") - + "/bonita;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE;"); + + "/bonita_journal.db;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE;"); } @Test public void jdbc_pool_size_values_must_be_integers() throws Exception { // given: final Properties properties = new Properties(); - properties.load(this.getClass().getResourceAsStream("/internal.properties")); + properties.load(this.getClass().getResourceAsStream(TEST_DATASOURCE_CONFIG_DIR + "internal.properties")); System.setProperty("bdm.db.vendor", "postgres"); System.setProperty("bdm.db.server.name", "myServer"); diff --git a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/PropertyReaderTest.java b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/PropertyReaderTest.java index c23939923ec..3796ee7183a 100644 --- a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/PropertyReaderTest.java +++ b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/PropertyReaderTest.java @@ -39,7 +39,7 @@ public class PropertyReaderTest { public void properties_file_values_can_be_overridden_by_system_properties() throws Exception { // given: final Properties properties = new Properties(); - properties.load(this.getClass().getResourceAsStream("/database.properties")); + properties.load(this.getClass().getResourceAsStream("/datasource-config/database.properties")); final PropertyReader bdmConfig = new PropertyReader(properties); assertThat(bdmConfig.getPropertyAndFailIfNull("bdm.db.vendor")).isEqualTo("oracle"); diff --git a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/TomcatBundleConfiguratorTest.java b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/TomcatBundleConfiguratorTest.java index 706e031d7aa..97ad84799db 100644 --- a/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/TomcatBundleConfiguratorTest.java +++ b/platform/platform-setup/src/test/java/org/bonitasoft/platform/setup/command/configure/TomcatBundleConfiguratorTest.java @@ -13,17 +13,12 @@ **/ package org.bonitasoft.platform.setup.command.configure; -import static junit.framework.TestCase.fail; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.bonitasoft.platform.setup.PlatformSetup.BONITA_SETUP_FOLDER; import static org.bonitasoft.platform.setup.command.configure.BundleConfiguratorTest.checkFileContains; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; import java.io.File; import java.nio.file.Path; @@ -37,7 +32,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.contrib.java.lang.system.RestoreSystemProperties; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.junit.rules.TestRule; import org.junit.runner.RunWith; @@ -52,9 +46,6 @@ public class TomcatBundleConfiguratorTest { @Rule public final TestRule restoreSystemProperties = new RestoreSystemProperties(); - @Rule - public final ExpectedException expectedException = ExpectedException.none(); - @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @@ -82,16 +73,15 @@ public void setupTempConfFolder() throws Exception { @Test public void should_delete_h2_jar_from_classpath_if_h2_is_not_used() throws Exception { // given: - System.setProperty("db.vendor", "oracle"); - System.setProperty("db.database.name", "bonita_with$dollarXXX\\myInstance.of.bonita&perf=good"); - System.setProperty("db.user", "_bonita_with$dollar\\andBackSlash"); - System.setProperty("db.password", "bpm_With$dollar\\andBackSlash"); + System.setProperty("db.vendor", "postgres"); + System.setProperty("db.database.name", "bonita"); + System.setProperty("db.user", "bonita"); + System.setProperty("db.password", "bpm"); - System.setProperty("bdm.db.vendor", "oracle"); - System.setProperty("bdm.db.database.name", - "bonita_bdm_with$dollarXXX\\myInstance.of.bdm&perf=good?oracle.net.disableOob=true"); - System.setProperty("bdm.db.user", "_bdmWith$dollar\\andBackSlash"); - System.setProperty("bdm.db.password", "bdm_bpm_With$dollar\\andBackSlash"); + System.setProperty("bdm.db.vendor", "postgres"); + System.setProperty("bdm.db.database.name", "business_data"); + System.setProperty("bdm.db.user", "bizUser"); + System.setProperty("bdm.db.password", "bizPwd"); // given: final Path h2jarPath = tomcatFolder.resolve("lib").resolve("bonita").resolve("h2.jar"); @@ -108,10 +98,10 @@ public void should_delete_h2_jar_from_classpath_if_h2_is_not_used() throws Excep @Test public void should_not_delete_h2_jar_from_classpath_if_h2_is_used_for_bdm() throws Exception { // given: - System.setProperty("db.vendor", "oracle"); - System.setProperty("db.database.name", "bonita_with$dollarXXX\\myInstance.of.bonita&perf=good"); - System.setProperty("db.user", "_bonita_with$dollar\\andBackSlash"); - System.setProperty("db.password", "bpm_With$dollar\\andBackSlash"); + System.setProperty("db.vendor", "postgres"); + System.setProperty("db.database.name", "bonita"); + System.setProperty("db.user", "bonita"); + System.setProperty("db.password", "bpm"); System.setProperty("bdm.db.vendor", "h2"); System.setProperty("bdm.db.database.name", "business_data.db"); @@ -138,11 +128,10 @@ public void should_not_delete_h2_jar_from_classpath_if_h2_is_used_for_bonita() t System.setProperty("db.user", "myUser"); System.setProperty("db.password", "myPwd"); - System.setProperty("bdm.db.vendor", "oracle"); - System.setProperty("bdm.db.database.name", - "bonita_bdm_with$dollarXXX\\myInstance.of.bdm&perf=good?oracle.net.disableOob=true"); - System.setProperty("bdm.db.user", "_bdmWith$dollar\\andBackSlash"); - System.setProperty("bdm.db.password", "bdm_bpm_With$dollar\\andBackSlash"); + System.setProperty("bdm.db.vendor", "postgres"); + System.setProperty("bdm.db.database.name", "business_data"); + System.setProperty("bdm.db.user", "bizUser"); + System.setProperty("bdm.db.password", "bizPwd"); // given: final Path h2jarPath = tomcatFolder.resolve("lib").resolve("bonita").resolve("h2.jar"); @@ -182,7 +171,7 @@ public void should_not_delete_h2_jar_from_classpath_if_h2_is_used_for_bonita_and } @Test - public void should_not_fail_if_bonita_xml_file_does_not_pre_exist() throws Exception { + public void should_not_fail_if_bonitaXml_file_does_not_pre_exist() throws Exception { // given: final Path bonitaXmlPath = tomcatFolder.resolve("conf").resolve("Catalina").resolve("localhost") .resolve("bonita.xml"); @@ -198,6 +187,10 @@ public void should_not_fail_if_bonita_xml_file_does_not_pre_exist() throws Excep @Test public void configureApplicationServer_should_update_setEnv_file() throws Exception { + // given: + System.setProperty("db.vendor", "postgres"); + System.setProperty("bdm.db.vendor", "postgres"); + // when: configurator.configureApplicationServer(); @@ -205,9 +198,9 @@ public void configureApplicationServer_should_update_setEnv_file() throws Except assertThat(numberOfBackups("setenv.sh")).isEqualTo(1); assertThat(numberOfBackups("setenv.bat")).isEqualTo(1); checkFileContains(tomcatFolder.resolve("bin").resolve("setenv.sh"), "-Dsysprop.bonita.db.vendor=postgres", - "-Dsysprop.bonita.bdm.db.vendor=oracle"); + "-Dsysprop.bonita.bdm.db.vendor=postgres"); checkFileContains(tomcatFolder.resolve("bin").resolve("setenv.bat"), "-Dsysprop.bonita.db.vendor=postgres", - "-Dsysprop.bonita.bdm.db.vendor=oracle"); + "-Dsysprop.bonita.bdm.db.vendor=postgres"); } private int numberOfBackups(String file) { @@ -222,34 +215,50 @@ public void configureApplicationServer_should_fail_if_no_driver_folder() throws final Path driverFolder = bundleFolder.resolve("setup").resolve("lib"); FileUtils.deleteDirectory(driverFolder.toFile()); - // then: - expectedException.expect(PlatformException.class); - expectedException.expectMessage("Drivers folder not found: " + driverFolder.toString()); - - // when: - configurator.configureApplicationServer(); + // when - then: + assertThatExceptionOfType(PlatformException.class).isThrownBy(configurator::configureApplicationServer) + .withMessage("Drivers folder not found: " + driverFolder + + ". Make sure it exists and put a jar or zip file containing drivers there."); } @Test - public void configureApplicationServer_should_update_bonita_xml_file() throws Exception { + public void configureApplicationServer_should_update_bonitaXml_file() throws Exception { + // given: + System.setProperty("db.vendor", "postgres"); + System.setProperty("db.server.name", "db.localhost"); + System.setProperty("db.server.port", "5432"); + System.setProperty("db.database.name", "bonita"); + System.setProperty("db.user", "bonita"); + System.setProperty("db.password", "bpm"); + + System.setProperty("bdm.db.vendor", "postgres"); + System.setProperty("bdm.db.server.name", "biz.localhost"); + System.setProperty("bdm.db.server.port", "5433"); + System.setProperty("bdm.db.database.name", "business_data"); + System.setProperty("bdm.db.user", "bizUser"); + System.setProperty("bdm.db.password", "bizPwd"); + + System.setProperty("connection-pool.maxTotal", "200"); + // when: configurator.configureApplicationServer(); // then: - final Path bonita_xml = tomcatFolder.resolve("conf").resolve("Catalina").resolve("localhost") + final Path bonitaXml = tomcatFolder.resolve("conf").resolve("Catalina").resolve("localhost") .resolve("bonita.xml"); - checkFileContains(bonita_xml, + checkFileContains(bonitaXml, "validationQuery=\"SELECT 1\"", "username=\"bonita\"", "password=\"bpm\"", - "driverClassName=\"org.postgresql.Driver\"", - "url=\"jdbc:postgresql://localhost:5432/bonita\""); - checkFileContains(bonita_xml, - "validationQuery=\"SELECT 1 FROM DUAL\"", "username=\"bizUser\"", "password=\"bizPwd\"", - "driverClassName=\"oracle.jdbc.OracleDriver\"", - "url=\"jdbc:oracle:thin:@//ora1.rd.lan:1521/ORCL_with\\backslash?oracle.net.disableOob=true\""); - checkFileContains(bonita_xml, "type=\"org.postgresql.xa.PGXADataSource\"", - "class=\"org.postgresql.xa.PGXADataSource\"", "factory=\"org.postgresql.xa.PGXADataSourceFactory\"", - "serverName=\"localhost\"", "portNumber=\"5432\"", "port=\"5432\"", "databaseName=\"bonita\""); - checkFileContains(bonita_xml, "initialSize=\"8\"", + "serverName=\"db.localhost\"", "portNumber=\"5432\"", "port=\"5432\"", "databaseName=\"bonita\"", + "url=\"jdbc:postgresql://db.localhost:5432/bonita\""); + checkFileContains(bonitaXml, + "validationQuery=\"SELECT 1\"", "username=\"bizUser\"", "password=\"bizPwd\"", + "serverName=\"biz.localhost\"", "portNumber=\"5433\"", "port=\"5433\"", + "databaseName=\"business_data\"", + "url=\"jdbc:postgresql://biz.localhost:5433/business_data\""); + checkFileContains(bonitaXml, "driverClassName=\"org.postgresql.Driver\"", + "type=\"org.postgresql.xa.PGXADataSource\"", "class=\"org.postgresql.xa.PGXADataSource\"", + "factory=\"org.postgresql.xa.PGXADataSourceFactory\""); + checkFileContains(bonitaXml, "initialSize=\"8\"", // maxTotal value overridden in database.properties "maxTotal=\"200\"", "minIdle=\"8\"", @@ -259,49 +268,34 @@ public void configureApplicationServer_should_update_bonita_xml_file() throws Ex } @Test - public void configureApplicationServer_should_support_H2_replacements_for_Bonita_database() throws Exception { + public void configureApplicationServer_should_support_H2_replacements_for_Bonita_database_and_BDM() + throws Exception { // given: System.setProperty("db.vendor", "h2"); System.setProperty("db.database.name", "internal_database.db"); System.setProperty("db.user", "myUser"); System.setProperty("db.password", "myPwd"); + System.setProperty("bdm.db.vendor", "h2"); + System.setProperty("bdm.db.database.name", "internal_business_data.db"); + System.setProperty("bdm.db.user", "bizUser"); + System.setProperty("bdm.db.password", "bizPwd"); + // when: configurator.configureApplicationServer(); // then: - final Path bonita_xml = tomcatFolder.resolve("conf").resolve("Catalina").resolve("localhost") + final Path bonitaXml = tomcatFolder.resolve("conf").resolve("Catalina").resolve("localhost") .resolve("bonita.xml"); - checkFileContains(bonita_xml, "validationQuery=\"SELECT 1\"", "username=\"myUser\"", "password=\"myPwd\"", + checkFileContains(bonitaXml, "validationQuery=\"SELECT 1\"", "username=\"myUser\"", "password=\"myPwd\"", "driverClassName=\"org.h2.Driver\"", "url=\"jdbc:h2:file:" + databaseAbsolutePath + "/internal_database.db;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE;\""); - checkFileContains(bonita_xml, "validationQuery=\"SELECT 1 FROM DUAL\"", "username=\"bizUser\"", - "password=\"bizPwd\"", - "driverClassName=\"oracle.jdbc.OracleDriver\"", - "url=\"jdbc:oracle:thin:@//ora1.rd.lan:1521/ORCL_with\\backslash?oracle.net.disableOob=true\""); - } - - @Test - public void configureApplicationServer_should_support_H2_replacements_for_BDM() throws Exception { - // given: - System.setProperty("bdm.db.vendor", "h2"); - System.setProperty("bdm.db.database.name", "business_data.db"); - System.setProperty("bdm.db.user", "sa"); - System.setProperty("bdm.db.password", ""); - - // when: - configurator.configureApplicationServer(); - - // then: - final Path bonita_xml = tomcatFolder.resolve("conf").resolve("Catalina").resolve("localhost") - .resolve("bonita.xml"); - - checkFileContains(bonita_xml, "validationQuery=\"SELECT 1\"", "username=\"sa\"", "password=\"\"", + checkFileContains(bonitaXml, "validationQuery=\"SELECT 1\"", "username=\"bizUser\"", "password=\"bizPwd\"", "driverClassName=\"org.h2.Driver\"", "url=\"jdbc:h2:file:" + databaseAbsolutePath - + "/business_data.db;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE;\""); + + "/internal_business_data.db;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE;\""); } @Test @@ -321,26 +315,30 @@ public void configureApplicationServer_should_support_special_characters_for_h2_ configurator.configureApplicationServer(); // then: - final Path bonita_xml = tomcatFolder.resolve("conf").resolve("Catalina").resolve("localhost") + final Path bonitaXml = tomcatFolder.resolve("conf").resolve("Catalina").resolve("localhost") .resolve("bonita.xml"); - checkFileContains(bonita_xml, "validationQuery=\"SELECT 1\"", "username=\"_bonita_with$dollar\\andBackSlash\"", + checkFileContains(bonitaXml, "validationQuery=\"SELECT 1\"", "username=\"_bonita_with$dollar\\andBackSlash\"", "password=\"bpm_With$dollar\\andBackSlash\"", "driverClassName=\"org.h2.Driver\"", "url=\"jdbc:h2:file:" + databaseAbsolutePath + "/bonita_bdm_with$dollarXXX.db;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE;\""); } @Test - public void configureApplicationServer_should_support_special_characters_for_oracle_database() throws Exception { + public void configureApplicationServer_should_support_special_characters_for_database() throws Exception { // given: - System.setProperty("db.vendor", "oracle"); + System.setProperty("db.vendor", "postgres"); + System.setProperty("db.server.name", "localhost"); + System.setProperty("db.server.port", "5432"); System.setProperty("db.database.name", "bonita_with$dollarXXX\\myInstance.of.bonita&perf=good"); System.setProperty("db.user", "_bonita_with$dollar\\andBackSlash"); System.setProperty("db.password", "bpm_With$dollar\\andBackSlash"); - System.setProperty("bdm.db.vendor", "oracle"); + System.setProperty("bdm.db.vendor", "postgres"); + System.setProperty("bdm.db.server.name", "localhost"); + System.setProperty("bdm.db.server.port", "5432"); System.setProperty("bdm.db.database.name", - "bonita_bdm_with$dollarXXX\\myInstance.of.bdm&perf=good?oracle.net.disableOob=true"); + "bonita_bdm_with$dollarXXX\\myInstance.of.bdm&perf=good?host.net.disableOob=true"); System.setProperty("bdm.db.user", "_bdmWith$dollar\\andBackSlash"); System.setProperty("bdm.db.password", "bdm_bpm_With$dollar\\andBackSlash"); @@ -348,27 +346,34 @@ public void configureApplicationServer_should_support_special_characters_for_ora configurator.configureApplicationServer(); // then: - final Path bonita_xml = tomcatFolder.resolve("conf").resolve("Catalina").resolve("localhost") + final Path bonitaXml = tomcatFolder.resolve("conf").resolve("Catalina").resolve("localhost") .resolve("bonita.xml"); - checkFileContains(bonita_xml, "validationQuery=\"SELECT 1 FROM DUAL\"", + checkFileContains(bonitaXml, "validationQuery=\"SELECT 1\"", "username=\"_bonita_with$dollar\\andBackSlash\"", "password=\"bpm_With$dollar\\andBackSlash\"", - "driverClassName=\"oracle.jdbc.OracleDriver\"", - "url=\"jdbc:oracle:thin:@//localhost:5432/bonita_with$dollarXXX\\myInstance.of.bonita&perf=good?oracle.net.disableOob=true\""); + "driverClassName=\"org.postgresql.Driver\"", + "url=\"jdbc:postgresql://localhost:5432/bonita_with$dollarXXX\\myInstance.of.bonita&perf=good\"", + "url=\"jdbc:postgresql://localhost:5432/bonita_bdm_with$dollarXXX\\myInstance.of.bdm&perf=good?host.net.disableOob=true\""); } @Test public void should_copy_both_drivers_if_not_the_same_dbVendor_for_bdm() throws Exception { + // given: + System.setProperty("db.vendor", "h2"); + System.setProperty("bdm.db.vendor", "postgres"); + // when: spy.configureApplicationServer(); // then: + verify(spy).copyDriverFile(any(Path.class), any(Path.class), eq("h2")); verify(spy).copyDriverFile(any(Path.class), any(Path.class), eq("postgres")); - verify(spy).copyDriverFile(any(Path.class), any(Path.class), eq("oracle")); } @Test public void should_not_copy_drivers_again_if_same_dbVendor_for_bdm() throws Exception { + // given: + System.setProperty("db.vendor", "postgres"); System.setProperty("bdm.db.vendor", "postgres"); // when: @@ -381,49 +386,47 @@ public void should_not_copy_drivers_again_if_same_dbVendor_for_bdm() throws Exce @Test public void should_fail_if_tomcat_mandatory_file_not_present() throws Exception { final Path confFile = tomcatFolder.resolve("bin").resolve("setenv.sh"); - FileUtils.deleteQuietly(confFile.toFile()); + FileUtils.delete(confFile.toFile()); - // then: - expectedException.expect(PlatformException.class); - expectedException.expectMessage("File setenv.sh is mandatory but is not found"); - - // when: - configurator.configureApplicationServer(); + // when - then: + assertThatExceptionOfType(PlatformException.class).isThrownBy(configurator::configureApplicationServer) + .withMessage("File setenv.sh is mandatory but is not found"); } @Test public void configureApplicationServer_should_fail_if_drivers_not_found() throws Exception { // given: - final String dbVendor = "sqlserver"; + final String dbVendor = "postgres"; System.setProperty("db.vendor", dbVendor); - - // then: - expectedException.expect(PlatformException.class); - expectedException.expectMessage("No " + dbVendor + " drivers found in folder"); - - // when: - configurator.configureApplicationServer(); + final Path libFolder = bundleFolder.resolve("setup").resolve("lib"); + final Path driverJar = libFolder.resolve("postgres9.2-drivers.jar"); + FileUtils.delete(driverJar.toFile()); + + // when - then: + assertThatExceptionOfType(PlatformException.class).isThrownBy(configurator::configureApplicationServer) + .withMessage("No " + dbVendor + " drivers found in folder " + libFolder + + ". Make sure to put a jar or zip file containing drivers there."); } @Test public void exception_in_configure_should_restore_previous_configuration() throws Exception { // given: doThrow(PlatformException.class).when(spy).copyDatabaseDriversIfNecessary(any(Path.class), any(Path.class), - eq("oracle")); + eq("h2")); - // when: - try { - spy.configureApplicationServer(); - fail("Should have thrown exception"); - } catch (PlatformException e) { - // then: - verify(spy).restorePreviousConfiguration(any(Path.class), any(Path.class), any(Path.class)); - } + // when - then: + assertThatExceptionOfType(PlatformException.class).isThrownBy(spy::configureApplicationServer); + verify(spy).restorePreviousConfiguration(any(Path.class), any(Path.class), any(Path.class)); } @Test public void should_not_make_backup_if_content_is_the_same() throws Exception { // given: + System.setProperty("db.vendor", "postgres"); + System.setProperty("db.database.name", "bonita"); + System.setProperty("db.user", "bonita"); + System.setProperty("db.password", "bpm"); + configurator.configureApplicationServer(); assertThat(numberOfBackups("bonita.xml")).isEqualTo(1); @@ -442,16 +445,21 @@ public void should_not_make_backup_if_content_is_the_same() throws Exception { @Test public void should_make_new_backup_if_configuration_changes() throws Exception { // given: + System.setProperty("db.vendor", "postgres"); + System.setProperty("db.database.name", "bonita"); + System.setProperty("db.user", "bonita"); + System.setProperty("db.password", "bpm"); + configurator.configureApplicationServer(); assertThat(numberOfBackups("bonita.xml")).isEqualTo(1); assertThat(numberOfBackups("setenv.bat")).isEqualTo(1); assertThat(numberOfBackups("setenv.sh")).isEqualTo(1); - System.setProperty("bdm.db.vendor", "h2"); - System.setProperty("bdm.db.database.name", "business_data.db"); - System.setProperty("bdm.db.user", "sa"); - System.setProperty("bdm.db.password", ""); + System.setProperty("db.vendor", "h2"); + System.setProperty("db.database.name", "bonita_journal.db"); + System.setProperty("db.user", "sa"); + System.setProperty("db.password", ""); // so that horodated file has different Thread.sleep(1020); diff --git a/platform/platform-setup/src/test/resources/database.properties b/platform/platform-setup/src/test/resources/database.properties index b8c7ce580cd..645b9aac736 100644 --- a/platform/platform-setup/src/test/resources/database.properties +++ b/platform/platform-setup/src/test/resources/database.properties @@ -1,25 +1,46 @@ -##################################### -# Bonita internal database properties -##################################### +##################################################################### +# Nominal database.properties copied from src/main/standalone folder +##################################################################### -db.vendor=postgres -db.server.name=localhost -db.server.port=5432 -db.database.name=bonita -db.user=bonita -db.password=bpm -# Override default maxTotal value -connection-pool.maxTotal = 200 +#################################################################################### +# +# Modify the following values to suit your database needs. +# Fore more information, see file ../HOW_TO_CONFIGURE_AND_RUN.txt +# +#################################################################################### -##################################### + +######################################### +# Bonita database properties +######################################### + +# Valid values are: h2, postgres in Community edition, and also sqlserver, oracle, mysql in Subscription editions +db.vendor=h2 +# when using h2, no server or port setting is needed since connexion is made using file protocol mode using relative directory: +db.server.name=SERVER_NAME +db.server.port=SERVER_PORT +# if your database name contains a backslash (\) character, you must double it (\\): +db.database.name=bonita_journal.db +db.user=sa +# if your database password contains a backslash (\) character, you must double it (\\): +db.password= + +################################### # Business Data database properties -##################################### -bdm.db.vendor=oracle -bdm.db.server.name=ora1.rd.lan -bdm.db.server.port=1521 -bdm.db.database.name=ORCL_with\\backslash -bdm.db.user=bizUser -bdm.db.password=bizPwd +################################### +# Valid values are: h2, postgres in Community edition, and also sqlserver, oracle, mysql in Subscription editions +bdm.db.vendor=h2 +bdm.db.server.name=SERVER_NAME +bdm.db.server.port=SERVER_PORT +bdm.db.database.name=business_data.db +bdm.db.user=sa +bdm.db.password= + +# IMPORTANT NOTE regarding H2 database: +# in case you move whole setup folder to another directory, you must change property below +# to point to original folder containing h2 database folder +# new value can be relative or absolute since it still points to the right folder +# WARNING for Windows users: keep forward slashes like below (instead of backslashes): h2.database.dir=../h2_database diff --git a/platform/platform-setup/src/test/resources/datasource-config/database.properties b/platform/platform-setup/src/test/resources/datasource-config/database.properties new file mode 100644 index 00000000000..b8c7ce580cd --- /dev/null +++ b/platform/platform-setup/src/test/resources/datasource-config/database.properties @@ -0,0 +1,25 @@ +##################################### +# Bonita internal database properties +##################################### + +db.vendor=postgres +db.server.name=localhost +db.server.port=5432 +db.database.name=bonita +db.user=bonita +db.password=bpm + +# Override default maxTotal value +connection-pool.maxTotal = 200 + +##################################### +# Business Data database properties +##################################### +bdm.db.vendor=oracle +bdm.db.server.name=ora1.rd.lan +bdm.db.server.port=1521 +bdm.db.database.name=ORCL_with\\backslash +bdm.db.user=bizUser +bdm.db.password=bizPwd + +h2.database.dir=../h2_database diff --git a/platform/platform-setup/src/test/resources/database_with_space_values.properties b/platform/platform-setup/src/test/resources/datasource-config/database_with_space_values.properties similarity index 68% rename from platform/platform-setup/src/test/resources/database_with_space_values.properties rename to platform/platform-setup/src/test/resources/datasource-config/database_with_space_values.properties index 319ba88fca2..c53191161d4 100644 --- a/platform/platform-setup/src/test/resources/database_with_space_values.properties +++ b/platform/platform-setup/src/test/resources/datasource-config/database_with_space_values.properties @@ -12,9 +12,9 @@ db.password=bpm ##################################### # Business Data database properties ##################################### -bdm.db.vendor=oracle -bdm.db.server.name= ora1.rd.lan -bdm.db.server.port= 1521 -bdm.db.database.name= ORCL_DATABASE -bdm.db.user=bizUser -bdm.db.password=bizPwd +bdm.db.vendor=postgres +bdm.db.server.name= postgres.rd.lan +bdm.db.server.port= 5432 +bdm.db.database.name= business_data +bdm.db.user=bonita +bdm.db.password=bpm diff --git a/platform/platform-setup/src/test/resources/incomplete_database.properties b/platform/platform-setup/src/test/resources/datasource-config/incomplete_database.properties similarity index 100% rename from platform/platform-setup/src/test/resources/incomplete_database.properties rename to platform/platform-setup/src/test/resources/datasource-config/incomplete_database.properties diff --git a/platform/platform-setup/src/test/resources/incomplete_internal.properties b/platform/platform-setup/src/test/resources/datasource-config/incomplete_internal.properties similarity index 100% rename from platform/platform-setup/src/test/resources/incomplete_internal.properties rename to platform/platform-setup/src/test/resources/datasource-config/incomplete_internal.properties diff --git a/platform/platform-setup/src/test/resources/datasource-config/internal.properties b/platform/platform-setup/src/test/resources/datasource-config/internal.properties new file mode 100644 index 00000000000..cf7e5f6dda5 --- /dev/null +++ b/platform/platform-setup/src/test/resources/datasource-config/internal.properties @@ -0,0 +1,58 @@ +# Nominal internal.properties copied from src/main/standalone module + +h2.nonXaDriver=org.h2.Driver +h2.xaDriver=org.h2.jdbcx.JdbcDataSource +h2.xaDSFactory=org.h2.jdbcx.JdbcDataSourceFactory + +postgres.nonXaDriver=org.postgresql.Driver +postgres.xaDriver=org.postgresql.xa.PGXADataSource +postgres.xaDSFactory=org.postgresql.xa.PGXADataSourceFactory + +########################### +## Bonita database +########################### + +# h2 properties +h2.url=jdbc:h2:file:${h2.database.dir}/${db.database.name};DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE; +h2.testQuery=SELECT 1 + +# postgres properties +postgres.url=jdbc:postgresql://${db.server.name}:${db.server.port}/${db.database.name} +postgres.testQuery=SELECT 1 + + +# spring properties +spring.datasource.username=${db.user} +spring.datasource.password=${db.password} +spring.datasource.driver-class-name=${${db.vendor}.nonXaDriver} +spring.datasource.url=${${db.vendor}.url} + +# The initial number of connections when the connection pool starts. +connection-pool.initialSize=8 +# The maximum number of active connections that can be allocated from this pool at the same time. +connection-pool.maxTotal=50 +# The minimum number of active connections that always established after pool created and connection has reached this size. +connection-pool.minIdle=8 +# The maximum number of connections that should be kept in the pool at all times. +connection-pool.maxIdle=16 + +########################### +# Business Data database +########################### + +# h2 properties +h2.bdm.url=jdbc:h2:file:${h2.database.dir}/${bdm.db.database.name};DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE;AUTO_SERVER=TRUE; +h2.bdm.testQuery=SELECT 1 + +# postgres properties +postgres.bdm.url=jdbc:postgresql://${bdm.db.server.name}:${bdm.db.server.port}/${bdm.db.database.name} +postgres.bdm.testQuery=SELECT 1 + +# The initial number of connections when the connection pool starts. +bdm.connection-pool.initialSize=4 +# The maximum number of active connections that can be allocated from this pool at the same time. +bdm.connection-pool.maxTotal=20 +# The minimum number of active connections that always established after pool created and connection has reached this size. +bdm.connection-pool.minIdle=4 +# The maximum number of connections that should be kept in the pool at all times. +bdm.connection-pool.maxIdle=10 diff --git a/platform/platform-setup/src/test/resources/missingDriverClass_internal.properties b/platform/platform-setup/src/test/resources/datasource-config/missingDriverClass_internal.properties similarity index 100% rename from platform/platform-setup/src/test/resources/missingDriverClass_internal.properties rename to platform/platform-setup/src/test/resources/datasource-config/missingDriverClass_internal.properties diff --git a/platform/platform-setup/src/test/resources/h2.properties b/platform/platform-setup/src/test/resources/h2.properties deleted file mode 100644 index b47f5f920a3..00000000000 --- a/platform/platform-setup/src/test/resources/h2.properties +++ /dev/null @@ -1 +0,0 @@ -# file is required but no specific properties are necessary with H2 diff --git a/platform/platform-setup/src/test/resources/internal.properties b/platform/platform-setup/src/test/resources/internal.properties index 740c38e85b9..dd0e0c37b5f 100644 --- a/platform/platform-setup/src/test/resources/internal.properties +++ b/platform/platform-setup/src/test/resources/internal.properties @@ -1,4 +1,15 @@ -### properties below don't need to be modified unless specific requirements +##################################################################### +# Nominal internal.properties copied from src/main/standalone folder +##################################################################### + +################################################################################## +# # +# properties below must NOT be modified unless specific requirements # +# # +################################################################################## +# /!\ WARNING /!\ # +# Any value containing a backslash (\) character MUST be doubled (\\) # +################################################################################## h2.nonXaDriver=org.h2.Driver h2.xaDriver=org.h2.jdbcx.JdbcDataSource @@ -8,24 +19,8 @@ postgres.nonXaDriver=org.postgresql.Driver postgres.xaDriver=org.postgresql.xa.PGXADataSource postgres.xaDSFactory=org.postgresql.xa.PGXADataSourceFactory -# use this drivers for pre-8.0 MySQL version: -# mysql.nonXaDriver=com.mysql.jdbc.Driver -# mysql.xaDriver=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource -# Otherwise use MySQL 8+ new driver: -mysql.nonXaDriver=com.mysql.cj.jdbc.Driver -mysql.xaDriver=com.mysql.cj.jdbc.MysqlXADataSource -mysql.xaDSFactory=com.mysql.cj.jdbc.MysqlDataSourceFactory - -sqlserver.nonXaDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver -sqlserver.xaDriver=com.microsoft.sqlserver.jdbc.SQLServerXADataSource -sqlserver.xaDSFactory=com.microsoft.sqlserver.jdbc.SQLServerDataSourceObjectFactory - -oracle.nonXaDriver=oracle.jdbc.OracleDriver -oracle.xaDriver=oracle.jdbc.xa.client.OracleXADataSource -oracle.xaDSFactory=oracle.jdbc.pool.OracleDataSourceFactory - ########################### -## Bonita internal database +## Bonita database ########################### # h2 properties @@ -36,17 +31,6 @@ h2.testQuery=SELECT 1 postgres.url=jdbc:postgresql://${db.server.name}:${db.server.port}/${db.database.name} postgres.testQuery=SELECT 1 -# mysql properties -mysql.url=jdbc:mysql://${db.server.name}:${db.server.port}/${db.database.name}?dontTrackOpenResources=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true -mysql.testQuery=SELECT 1 - -# sqlserver properties -sqlserver.url=jdbc:sqlserver://${db.server.name}:${db.server.port};database=${db.database.name} -sqlserver.testQuery=SELECT 1 - -# oracle properties -oracle.url=jdbc:oracle:thin:@//${db.server.name}:${db.server.port}/${db.database.name}?oracle.net.disableOob=true -oracle.testQuery=SELECT 1 FROM DUAL # spring properties spring.datasource.username=${db.user} @@ -54,14 +38,17 @@ spring.datasource.password=${db.password} spring.datasource.driver-class-name=${${db.vendor}.nonXaDriver} spring.datasource.url=${${db.vendor}.url} -# datasource jdbc connection pool sizes +# The initial number of connections when the connection pool starts. connection-pool.initialSize=8 +# The maximum number of active connections that can be allocated from this pool at the same time. connection-pool.maxTotal=50 +# The minimum number of active connections that always established after pool created and connection has reached this size. connection-pool.minIdle=8 +# The maximum number of connections that should be kept in the pool at all times. connection-pool.maxIdle=16 ########################### -# BusinessData database +# Business Data database ########################### # h2 properties @@ -72,19 +59,11 @@ h2.bdm.testQuery=SELECT 1 postgres.bdm.url=jdbc:postgresql://${bdm.db.server.name}:${bdm.db.server.port}/${bdm.db.database.name} postgres.bdm.testQuery=SELECT 1 -# mysql properties -mysql.bdm.url=jdbc:mysql://${bdm.db.server.name}:${bdm.db.server.port}/${bdm.db.database.name}?dontTrackOpenResources=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true -mysql.bdm.testQuery=SELECT 1 - -# sqlserver properties -sqlserver.bdm.url=jdbc:sqlserver://${bdm.db.server.name}:${bdm.db.server.port};database=${bdm.db.database.name} -sqlserver.bdm.testQuery=SELECT 1 - -# oracle properties -oracle.bdm.url=jdbc:oracle:thin:@//${bdm.db.server.name}:${bdm.db.server.port}/${bdm.db.database.name}?oracle.net.disableOob=true -oracle.bdm.testQuery=SELECT 1 FROM DUAL - +# The initial number of connections when the connection pool starts. bdm.connection-pool.initialSize=4 +# The maximum number of active connections that can be allocated from this pool at the same time. bdm.connection-pool.maxTotal=20 +# The minimum number of active connections that always established after pool created and connection has reached this size. bdm.connection-pool.minIdle=4 +# The maximum number of connections that should be kept in the pool at all times. bdm.connection-pool.maxIdle=10 diff --git a/platform/platform-setup/src/test/resources/mysql.properties b/platform/platform-setup/src/test/resources/mysql.properties deleted file mode 100644 index 6e8c7735e7a..00000000000 --- a/platform/platform-setup/src/test/resources/mysql.properties +++ /dev/null @@ -1,20 +0,0 @@ -##################### -# Database properties -##################### -db.server.name=mysql2.rd.lan -db.server.port=3306 -db.database.name=bos6_manu -db.user=bos6_manu -db.password=bos6_manu - - -################# -# JDBC properties -################# -spring.datasource.username=${db.user} -spring.datasource.password=${db.password} -spring.datasource.url=jdbc:mysql://${db.server.name}:${db.server.port}/${db.database.name}?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true -# use this driver / datasource for pre-8.0 MySQL version: -# spring.datasource.driver-class-name=com.mysql.jdbc.Driver -# Otherwise use MySQL 8+ version: -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver diff --git a/platform/platform-setup/src/test/resources/oracle.properties b/platform/platform-setup/src/test/resources/oracle.properties deleted file mode 100644 index fe0ad9ae299..00000000000 --- a/platform/platform-setup/src/test/resources/oracle.properties +++ /dev/null @@ -1,17 +0,0 @@ -##################### -# Database properties -##################### -db.server.name=ora1.rd.lan -db.server.port=1521 -db.database.name=orcl -db.user=bos6_manu -db.password=bos6_manu - - -################# -# JDBC properties -################# -spring.datasource.username=${db.user} -spring.datasource.password=${db.password} -spring.datasource.url=jdbc:oracle:thin:@//${db.server.name}:${db.server.port}/${db.database.name}?oracle.net.disableOob=true -spring.datasource.driver-class-name=oracle.jdbc.OracleDriver diff --git a/platform/platform-setup/src/test/resources/postgres.properties b/platform/platform-setup/src/test/resources/postgres.properties deleted file mode 100644 index b3ba4d159ee..00000000000 --- a/platform/platform-setup/src/test/resources/postgres.properties +++ /dev/null @@ -1,17 +0,0 @@ -##################### -# Database properties -##################### -db.server.name=localhost -db.server.port=5432 -db.database.name=bonita -db.user=bonita -db.password=bpm - - -################# -# JDBC properties -################# -spring.datasource.username=${db.user} -spring.datasource.password=${db.password} -spring.datasource.url=jdbc:postgresql://${db.server.name}:${db.server.port}/${db.database.name} -spring.datasource.driver-class-name=org.postgresql.Driver diff --git a/platform/platform-setup/src/test/resources/sqlserver.properties b/platform/platform-setup/src/test/resources/sqlserver.properties deleted file mode 100644 index 54bb16dda0b..00000000000 --- a/platform/platform-setup/src/test/resources/sqlserver.properties +++ /dev/null @@ -1,17 +0,0 @@ -##################### -# Database properties -##################### -db.server.name=localhost -db.server.port=1433 -db.database.name=bonita -db.user=bonita -db.password=bpm - - -################# -# JDBC properties -################# -spring.datasource.username=${db.user} -spring.datasource.password=${db.password} -spring.datasource.url=jdbc:sqlserver://${db.server.name}:${db.server.port};database=${db.database.name} -spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver