From 477c1a0d6f264512f71f920815b2326143d44665 Mon Sep 17 00:00:00 2001 From: Manuel Soulier Date: Sun, 8 Oct 2023 07:23:35 +0200 Subject: [PATCH] fix: setting new connection properties reset the connection attribute --- .../insee/arc/utils/ressourceUtils/PropertiesHandler.java | 8 ++++++++ .../java/fr/insee/arc/utils/dao/UtilitaireDaoTest.java | 4 +--- .../fr/insee/arc/utils/query/InitializeQueryTest.java | 2 -- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arc-utils/src/main/java/fr/insee/arc/utils/ressourceUtils/PropertiesHandler.java b/arc-utils/src/main/java/fr/insee/arc/utils/ressourceUtils/PropertiesHandler.java index a26d8444e..4fada6403 100644 --- a/arc-utils/src/main/java/fr/insee/arc/utils/ressourceUtils/PropertiesHandler.java +++ b/arc-utils/src/main/java/fr/insee/arc/utils/ressourceUtils/PropertiesHandler.java @@ -98,6 +98,8 @@ public String getDatabaseUrl() { public void setDatabaseUrl(String databaseUrl) { this.databaseUrl = databaseUrl; + // reset the connection getter + this.connectionProperties=null; } public String getDatabaseUsername() { @@ -106,6 +108,8 @@ public String getDatabaseUsername() { public void setDatabaseUsername(String databaseUsername) { this.databaseUsername = databaseUsername; + // reset the connection getter + this.connectionProperties=null; } public String getDatabasePassword() { @@ -114,6 +118,8 @@ public String getDatabasePassword() { public void setDatabasePassword(String databasePassword) { this.databasePassword = databasePassword; + // reset the connection getter + this.connectionProperties=null; } public String getDatabaseDriverClassName() { @@ -122,6 +128,8 @@ public String getDatabaseDriverClassName() { public void setDatabaseDriverClassName(String databaseDriverClassName) { this.databaseDriverClassName = databaseDriverClassName; + // reset the connection getter + this.connectionProperties=null; } public String getDatabaseSchema() { diff --git a/arc-utils/src/test/java/fr/insee/arc/utils/dao/UtilitaireDaoTest.java b/arc-utils/src/test/java/fr/insee/arc/utils/dao/UtilitaireDaoTest.java index 7e2ea7b25..d9f17a368 100644 --- a/arc-utils/src/test/java/fr/insee/arc/utils/dao/UtilitaireDaoTest.java +++ b/arc-utils/src/test/java/fr/insee/arc/utils/dao/UtilitaireDaoTest.java @@ -21,8 +21,6 @@ public class UtilitaireDaoTest extends InitializeQueryTest { @Test public void numberOfNods_test() { - - u.getProperties().setConnectionProperties(null); u.getProperties().setDatabaseUrl("{0=>\"db1\"},{1=>\"db2\"}"); u.getProperties().setDatabaseUsername("{0=>\"db1\"},{1=>\"db2\"}"); u.getProperties().setDatabasePassword("{0=>\"db1\"},{1=>\"db2\"}"); @@ -36,7 +34,6 @@ public void numberOfNods_test() { public void getDriverConnexion_OK() throws SQLException, ArcException { PropertiesHandler testProperties=new PropertiesHandler(); - testProperties.setConnectionProperties(null); testProperties.setDatabaseDriverClassName("org.postgresql.Driver"); testProperties.setDatabaseUrl(c.getMetaData().getURL()); testProperties.setDatabaseUsername(c.getMetaData().getUserName()); @@ -62,6 +59,7 @@ public void getDriverConnexion_KO() throws SQLException, ArcException { u.getProperties().setDatabasePassword("NA"); u.getDriverConnexion(); + } diff --git a/arc-utils/src/test/java/fr/insee/arc/utils/query/InitializeQueryTest.java b/arc-utils/src/test/java/fr/insee/arc/utils/query/InitializeQueryTest.java index c7272f770..d2a425971 100644 --- a/arc-utils/src/test/java/fr/insee/arc/utils/query/InitializeQueryTest.java +++ b/arc-utils/src/test/java/fr/insee/arc/utils/query/InitializeQueryTest.java @@ -49,8 +49,6 @@ protected static void buildProperties(String repertoire, Connection[] connection PropertiesHandler testProperties=PropertiesHandler.getInstance(); // reset connection properties - testProperties.setConnectionProperties(null); - StringBuilder url=new StringBuilder(); StringBuilder username=new StringBuilder(); StringBuilder password=new StringBuilder();