From 7d272ccf1c7a47f274ae9a49cff3cea486aa23be Mon Sep 17 00:00:00 2001 From: Joram Barrez Date: Wed, 3 Jul 2024 17:06:42 +0200 Subject: [PATCH] More test fixes --- .../rest/conf/engine/EngineConfiguration.java | 5 +--- ...ractFlowableDmnEngineConfiguratorTest.java | 2 -- .../engine/test/AbstractFlowableDmnTest.java | 2 -- .../rest/conf/engine/EngineConfiguration.java | 5 +--- .../rest/conf/jpa/DatabaseConfiguration.java | 29 ++++++++++++++----- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/modules/flowable-cmmn-rest/src/test/java/org/flowable/cmmn/rest/conf/engine/EngineConfiguration.java b/modules/flowable-cmmn-rest/src/test/java/org/flowable/cmmn/rest/conf/engine/EngineConfiguration.java index 2acf77a56f7..bad5df66550 100644 --- a/modules/flowable-cmmn-rest/src/test/java/org/flowable/cmmn/rest/conf/engine/EngineConfiguration.java +++ b/modules/flowable-cmmn-rest/src/test/java/org/flowable/cmmn/rest/conf/engine/EngineConfiguration.java @@ -56,13 +56,10 @@ public class EngineConfiguration { @Bean public DataSource dataSource() { SimpleDriverDataSource ds = new SimpleDriverDataSource(); + ds.setUrl(jdbcUrl); ds.setDriverClass(jdbcDriver); - - // Connection settings - ds.setUrl("jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000"); ds.setUsername(jdbcUsername); ds.setPassword(jdbcPassword); - return ds; } diff --git a/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/engine/test/AbstractFlowableDmnEngineConfiguratorTest.java b/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/engine/test/AbstractFlowableDmnEngineConfiguratorTest.java index f0874fc63cf..52eaa4d39b7 100644 --- a/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/engine/test/AbstractFlowableDmnEngineConfiguratorTest.java +++ b/modules/flowable-dmn-engine-configurator/src/test/java/org/flowable/dmn/engine/test/AbstractFlowableDmnEngineConfiguratorTest.java @@ -26,8 +26,6 @@ */ public class AbstractFlowableDmnEngineConfiguratorTest { - public static final String H2_TEST_JDBC_URL = "jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000"; - @Rule public FlowableRule flowableRule = new FlowableRule(); diff --git a/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/AbstractFlowableDmnTest.java b/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/AbstractFlowableDmnTest.java index 14a930a7e10..7c09634f22b 100644 --- a/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/AbstractFlowableDmnTest.java +++ b/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/AbstractFlowableDmnTest.java @@ -33,8 +33,6 @@ */ public class AbstractFlowableDmnTest { - public static final String H2_TEST_JDBC_URL = "jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000"; - @Rule public FlowableDmnRule flowableDmnRule = new FlowableDmnRule(); diff --git a/modules/flowable-rest/src/test/java/org/flowable/rest/conf/engine/EngineConfiguration.java b/modules/flowable-rest/src/test/java/org/flowable/rest/conf/engine/EngineConfiguration.java index 20d1b27c9ed..fa6e39671a3 100644 --- a/modules/flowable-rest/src/test/java/org/flowable/rest/conf/engine/EngineConfiguration.java +++ b/modules/flowable-rest/src/test/java/org/flowable/rest/conf/engine/EngineConfiguration.java @@ -63,13 +63,10 @@ public class EngineConfiguration { @Bean public DataSource dataSource() { SimpleDriverDataSource ds = new SimpleDriverDataSource(); + ds.setUrl(jdbcUrl); ds.setDriverClass(jdbcDriver); - - // Connection settings - ds.setUrl("jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000"); ds.setUsername(jdbcUsername); ds.setPassword(jdbcPassword); - return ds; } diff --git a/modules/flowable-rest/src/test/java/org/flowable/rest/conf/jpa/DatabaseConfiguration.java b/modules/flowable-rest/src/test/java/org/flowable/rest/conf/jpa/DatabaseConfiguration.java index 88b7b93d949..f091a496c1a 100644 --- a/modules/flowable-rest/src/test/java/org/flowable/rest/conf/jpa/DatabaseConfiguration.java +++ b/modules/flowable-rest/src/test/java/org/flowable/rest/conf/jpa/DatabaseConfiguration.java @@ -12,10 +12,11 @@ */ package org.flowable.rest.conf.jpa; -import javax.sql.DataSource; +import java.sql.Driver; -import jakarta.persistence.EntityManagerFactory; +import javax.sql.DataSource; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @@ -27,11 +28,25 @@ import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; +import jakarta.persistence.EntityManagerFactory; + @Configuration(proxyBeanMethods = false) @EnableJpaRepositories({ "org.flowable.rest.api.jpa.repository" }) @EnableTransactionManagement public class DatabaseConfiguration { + @Value("${jdbc.url:jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000}") + protected String jdbcUrl; + + @Value("${jdbc.driver:org.h2.Driver}") + protected Class jdbcDriver; + + @Value("${jdbc.username:sa}") + protected String jdbcUsername; + + @Value("${jdbc.password:}") + protected String jdbcPassword; + @Bean(name = "entityManagerFactory") public EntityManagerFactory entityManagerFactory(DataSource dataSource) { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); @@ -50,12 +65,10 @@ public EntityManagerFactory entityManagerFactory(DataSource dataSource) { @Bean public DataSource dataSource() { SimpleDriverDataSource ds = new SimpleDriverDataSource(); - ds.setDriverClass(org.h2.Driver.class); - - // Connection settings - ds.setUrl("jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000"); - ds.setUsername("sa"); - + ds.setUrl(jdbcUrl); + ds.setDriverClass(jdbcDriver); + ds.setUsername(jdbcUsername); + ds.setPassword(jdbcPassword); return ds; }