From f81fed58a85dcf39e0557ad730d23619fc2015fa Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sat, 26 Nov 2022 01:50:30 -0800 Subject: [PATCH 1/3] Update versions for hotfix --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d0b120db..9b9b0792 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ baseCode baseCode baseCode - 1.1.4 + 1.1.5 2003 From 440fce256a217610704207734d6ed7d4ca8b04bb Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sat, 26 Nov 2022 01:50:01 -0800 Subject: [PATCH 2/3] Add support for comma-delimited entries in configuration --- src/ubic/basecode/util/ConfigUtils.java | 16 +++++++++++++--- test/data/test.properties | 1 + test/ubic/basecode/util/ConfigUtilsTest.java | 7 +++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/ubic/basecode/util/ConfigUtils.java b/src/ubic/basecode/util/ConfigUtils.java index 61c11842..c1b446a7 100644 --- a/src/ubic/basecode/util/ConfigUtils.java +++ b/src/ubic/basecode/util/ConfigUtils.java @@ -22,6 +22,8 @@ import org.apache.commons.configuration2.PropertiesConfiguration; import org.apache.commons.configuration2.builder.FileBasedBuilderParametersImpl; import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; +import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler; +import org.apache.commons.configuration2.convert.ListDelimiterHandler; import org.apache.commons.configuration2.ex.ConfigurationException; import org.apache.commons.configuration2.io.FileHandler; import org.apache.commons.configuration2.io.FileLocator; @@ -36,6 +38,8 @@ */ public class ConfigUtils { + private static final ListDelimiterHandler LIST_DELIMITER_HANDLER = new DefaultListDelimiterHandler( ',' ); + /** * @param file * @return @@ -51,7 +55,7 @@ public static FileBasedConfigurationBuilder getConfigBu } FileBasedConfigurationBuilder builder = new FileBasedConfigurationBuilder( PropertiesConfiguration.class ); - builder.configure( new FileBasedBuilderParametersImpl().setFile( file ) ); + builder.configure( new FileBasedBuilderParametersImpl().setFile( file ).setListDelimiterHandler( LIST_DELIMITER_HANDLER ) ); return builder; } @@ -96,7 +100,7 @@ public static PropertiesConfiguration loadClasspathConfig( String name ) throws throw new ConfigurationException( "Couldn't locate: " + name ); } - PropertiesConfiguration pc = new PropertiesConfiguration(); + PropertiesConfiguration pc = createConfiguration(); FileHandler handler = new FileHandler( pc ); handler.setURL( url ); handler.load(); @@ -116,7 +120,7 @@ public static PropertiesConfiguration loadConfig( File file ) throws Configurati throw new ConfigurationException( "Couldn't create the file: " + e.getMessage() ); } } - PropertiesConfiguration pc = new PropertiesConfiguration(); + PropertiesConfiguration pc = createConfiguration(); FileHandler handler = new FileHandler( pc ); handler.setFile( file ); handler.load(); @@ -187,4 +191,10 @@ public static URL locate( String name ) { FileLocator fl = FileLocatorUtils.fileLocator().fileName( name ).create(); return FileLocatorUtils.locate( fl ); } + + private static PropertiesConfiguration createConfiguration() { + PropertiesConfiguration pc = new PropertiesConfiguration(); + pc.setListDelimiterHandler( LIST_DELIMITER_HANDLER ); + return pc; + } } diff --git a/test/data/test.properties b/test/data/test.properties index 0bd430bc..04d98701 100644 --- a/test/data/test.properties +++ b/test/data/test.properties @@ -1,3 +1,4 @@ foo=bar ack=yup tek=6 +list=1,2 ,3 diff --git a/test/ubic/basecode/util/ConfigUtilsTest.java b/test/ubic/basecode/util/ConfigUtilsTest.java index ff26e8a7..6018267c 100644 --- a/test/ubic/basecode/util/ConfigUtilsTest.java +++ b/test/ubic/basecode/util/ConfigUtilsTest.java @@ -14,10 +14,6 @@ */ package ubic.basecode.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.io.File; import org.apache.commons.configuration2.PropertiesConfiguration; @@ -27,6 +23,8 @@ import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.*; + /** * @author Paul * @@ -58,6 +56,7 @@ public void testGetConfigBuilderFile() throws Exception { testConfigPath ) ); assertNotNull( config ); assertEquals( "bar", config.getConfiguration().getProperty( "foo" ) ); + assertArrayEquals( new String[] { "1", "2", "3" }, config.getConfiguration().getStringArray( "list" ) ); } @Test From e78d33aac836fdfcee5b0ba8f8b7f4c536000d44 Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sat, 26 Nov 2022 01:58:43 -0800 Subject: [PATCH 3/3] Update dependencies --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9b9b0792..7a0adc25 100644 --- a/pom.xml +++ b/pom.xml @@ -142,7 +142,7 @@ org.slf4j slf4j-api - 1.7.36 + 2.0.4 @@ -224,7 +224,7 @@ com.opencsv opencsv - 5.6 + 5.7.1 @@ -237,7 +237,7 @@ org.mockito mockito-core - 4.6.1 + 4.8.0 test