Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 132E9F48F for ; Tue, 19 Mar 2013 21:08:59 +0000 (UTC) Received: (qmail 91137 invoked by uid 500); 19 Mar 2013 21:08:58 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 91077 invoked by uid 500); 19 Mar 2013 21:08:58 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 91070 invoked by uid 99); 19 Mar 2013 21:08:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Mar 2013 21:08:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Mar 2013 21:08:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0156823889BF; Tue, 19 Mar 2013 21:08:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1458517 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/ test/java/org/apache/commons/configuration/ test/java/org/apache/commons/configuration/reloading/ Date: Tue, 19 Mar 2013 21:08:35 -0000 To: commits@commons.apache.org From: oheger@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130319210836.0156823889BF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: oheger Date: Tue Mar 19 21:08:34 2013 New Revision: 1458517 URL: http://svn.apache.org/r1458517 Log: Changed the way the layout of a PropertiesConfiguration instance is initialized. The constructor does no longer call non-private, non-final methods. Note that in the current state some constructors do not work any more. They will be removed in a later stage. This caused many tests to be adapted. Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PropertiesConfiguration.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCombinedConfiguration.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfiguration.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfigurationNonStringProperties.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestEqualBehaviour.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestEqualsProperty.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestFileConfiguration.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNonStringProperties.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNullCompositeConfiguration.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesConfiguration.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesSequence.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestThreesomeConfiguration.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestXMLPropertiesConfiguration.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestManagedReloadingStrategy.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestVFSFileChangedReloadingStrategy.java Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PropertiesConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PropertiesConfiguration.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PropertiesConfiguration.java (original) +++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PropertiesConfiguration.java Tue Mar 19 21:08:34 2013 @@ -237,7 +237,7 @@ public class PropertiesConfiguration ext */ public PropertiesConfiguration() { - layout = getLayout(); + installLayout(createLayout()); } /** @@ -396,10 +396,6 @@ public class PropertiesConfiguration ext */ public synchronized PropertiesConfigurationLayout getLayout() { - if (layout == null) - { - setLayout(createLayout()); - } return layout; } @@ -412,6 +408,18 @@ public class PropertiesConfiguration ext */ public synchronized void setLayout(PropertiesConfigurationLayout layout) { + installLayout(layout); + } + + /** + * Installs a layout object. It has to be ensured that the layout is + * registered as change listener at this configuration. If there is already + * a layout object installed, it has to be removed properly. + * + * @param layout the layout object to be installed + */ + private void installLayout(PropertiesConfigurationLayout layout) + { // only one layout must exist if (this.layout != null) { @@ -430,14 +438,12 @@ public class PropertiesConfiguration ext } /** - * Creates the associated layout object. This method is invoked when the - * layout object is accessed and has not been created yet. Derived classes - * can override this method to hook in a different layout implementation. + * Creates a standard layout object. This configuration is initialized with + * such a standard layout. * - * @return the layout object to use - * @since 1.3 + * @return the newly created layout object */ - protected PropertiesConfigurationLayout createLayout() + private PropertiesConfigurationLayout createLayout() { return new PropertiesConfigurationLayout(); } Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCombinedConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCombinedConfiguration.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCombinedConfiguration.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCombinedConfiguration.java Tue Mar 19 21:08:34 2013 @@ -462,7 +462,9 @@ public class TestCombinedConfiguration File testPropsFile = writeReloadFile(RELOAD_PROPS_NAME, RELOAD_PROPS_CONTENT, 0); XMLConfiguration c1 = new XMLConfiguration(testXmlFile); c1.setReloadingStrategy(new FileAlwaysReloadingStrategy()); - PropertiesConfiguration c2 = new PropertiesConfiguration(testPropsFile); + PropertiesConfiguration c2 = new PropertiesConfiguration(); + c2.setFile(testPropsFile); + c2.load(); c2.setThrowExceptionOnMissing(true); c2.setReloadingStrategy(new FileAlwaysReloadingStrategy()); config.addConfiguration(c1); @@ -514,7 +516,9 @@ public class TestCombinedConfiguration writeReloadFile(RELOAD_PROPS_NAME, RELOAD_PROPS_CONTENT, 0); XMLConfiguration c1 = new XMLConfiguration(testXmlFile); c1.setReloadingStrategy(new FileAlwaysReloadingStrategy()); - PropertiesConfiguration c2 = new PropertiesConfiguration(testPropsFile); + PropertiesConfiguration c2 = new PropertiesConfiguration(); + c2.setFile(testPropsFile); + c2.load(); c2.setReloadingStrategy(new FileAlwaysReloadingStrategy()); config.addConfiguration(c2); CombinedConfiguration cc2 = new CombinedConfiguration(); @@ -686,8 +690,9 @@ public class TestCombinedConfiguration public void testDeadlockWithReload() throws ConfigurationException, InterruptedException { - final PropertiesConfiguration child = new PropertiesConfiguration( - "test.properties"); + final PropertiesConfiguration child = new PropertiesConfiguration(); + child.setFileName("test.properties"); + child.load(); child.setReloadingStrategy(new FileAlwaysReloadingStrategy()); config.addConfiguration(child); final int count = 1000; Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfiguration.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfiguration.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfiguration.java Tue Mar 19 21:08:34 2013 @@ -69,8 +69,12 @@ public class TestCompositeConfiguration public void setUp() throws Exception { cc = new CompositeConfiguration(); - conf1 = new PropertiesConfiguration(testProperties); - conf2 = new PropertiesConfiguration(testProperties2); + conf1 = new PropertiesConfiguration(); + conf1.setFileName(testProperties); + conf1.load(); + conf2 = new PropertiesConfiguration(); + conf2.setFileName(testProperties2); + conf2.load(); xmlConf = new XMLConfiguration(new File(testPropertiesXML)); cc.setThrowExceptionOnMissing(true); @@ -509,7 +513,9 @@ public class TestCompositeConfiguration try { writeTestConfig(testFile, propFirst, "John"); - PropertiesConfiguration c1 = new PropertiesConfiguration(testFile); + PropertiesConfiguration c1 = new PropertiesConfiguration(); + c1.setFile(testFile); + c1.load(); c1.setReloadingStrategy(new FileAlwaysReloadingStrategy()); PropertiesConfiguration c2 = new PropertiesConfiguration(); c2.addProperty(propFull, "${" + propFirst + "} Doe"); Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfigurationNonStringProperties.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfigurationNonStringProperties.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfigurationNonStringProperties.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfigurationNonStringProperties.java Tue Mar 19 21:08:34 2013 @@ -34,7 +34,10 @@ public class TestCompositeConfigurationN public void setUp() throws Exception { CompositeConfiguration cc = new CompositeConfiguration(); - cc.addConfiguration(new PropertiesConfiguration(testProperties)); + PropertiesConfiguration pc = new PropertiesConfiguration(); + pc.setFileName(testProperties); + pc.load(); + cc.addConfiguration(pc); conf = cc; nonStringTestHolder.setConfiguration(conf); } Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestEqualBehaviour.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestEqualBehaviour.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestEqualBehaviour.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestEqualBehaviour.java Tue Mar 19 21:08:34 2013 @@ -38,7 +38,10 @@ public class TestEqualBehaviour throws Exception { String simpleConfigurationFile = ConfigurationAssert.getTestFile("testEqual.properties").getAbsolutePath(); - return new PropertiesConfiguration(simpleConfigurationFile); + PropertiesConfiguration c = new PropertiesConfiguration(); + c.setFileName(simpleConfigurationFile); + c.load(); + return c; } @SuppressWarnings("deprecation") Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestEqualsProperty.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestEqualsProperty.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestEqualsProperty.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestEqualsProperty.java Tue Mar 19 21:08:34 2013 @@ -34,7 +34,9 @@ public class TestEqualsProperty @Test public void testEquals() throws Exception { - PropertiesConfiguration conf = new PropertiesConfiguration(testProperties); + PropertiesConfiguration conf = new PropertiesConfiguration(); + conf.setFileName(testProperties); + conf.load(); String equals = conf.getString("test.equals"); assertEquals("value=one", equals); Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestFileConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestFileConfiguration.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestFileConfiguration.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestFileConfiguration.java Tue Mar 19 21:08:34 2013 @@ -167,7 +167,8 @@ public class TestFileConfiguration { assertFalse("The file should not exist", OUT_FILE.exists()); - FileConfiguration config = new PropertiesConfiguration(OUT_FILE); + FileConfiguration config = new PropertiesConfiguration(); + config.setFile(OUT_FILE); config.save(); assertTrue("The file doesn't exist", OUT_FILE.exists()); @@ -267,7 +268,8 @@ public class TestFileConfiguration props.store(out, "TestFileOverwrite"); out.close(); out = null; - FileConfiguration config = new PropertiesConfiguration(tempFile); + FileConfiguration config = new PropertiesConfiguration(); + config.setFile(tempFile); config.load(); String value = config.getString("1"); assertTrue("one".equals(value)); @@ -323,8 +325,9 @@ public class TestFileConfiguration out.close(); out = null; - PropertiesConfiguration config = new PropertiesConfiguration( - configFile); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setFile(configFile); + config.load(); config.setReloadingStrategy(new FileChangedReloadingStrategy()); config.setAutoSave(true); @@ -360,7 +363,8 @@ public class TestFileConfiguration out = null; URL url = confFile.toURI().toURL(); - PropertiesConfiguration config = new PropertiesConfiguration(url); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setURL(url); config.load(); assertFalse(config.getBoolean("saved")); @@ -388,7 +392,8 @@ public class TestFileConfiguration public void testPathWithPlus() throws ConfigurationException, IOException { File saveFile = folder.newFile("test+config.properties"); - FileConfiguration config = new PropertiesConfiguration(saveFile); + FileConfiguration config = new PropertiesConfiguration(); + config.setFile(saveFile); config.addProperty("test", Boolean.TRUE); config.save(); File configFile = config.getFile(); @@ -507,8 +512,8 @@ public class TestFileConfiguration PropertiesConfiguration config1 = new PropertiesConfiguration(); config1.setFileName(RESOURCE_NAME); config1.load(); - PropertiesConfiguration config2 = new PropertiesConfiguration( - RESOURCE_NAME); + PropertiesConfiguration config2 = new PropertiesConfiguration(); + config2.load(RESOURCE_NAME); compare(config1, config2); } @@ -536,8 +541,9 @@ public class TestFileConfiguration @Test public void testClone() throws ConfigurationException { - PropertiesConfiguration config = new PropertiesConfiguration( - RESOURCE_NAME); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setFileName(RESOURCE_NAME); + config.load(); PropertiesConfiguration copy = (PropertiesConfiguration) config.clone(); compare(config, copy); assertNull("URL was not reset", copy.getURL()); @@ -565,8 +571,9 @@ public class TestFileConfiguration public void testReloadError() throws ConfigurationException { ConfigurationErrorListenerImpl l = new ConfigurationErrorListenerImpl(); - PropertiesConfiguration config = new PropertiesConfiguration( - RESOURCE_NAME); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setFileName(RESOURCE_NAME); + config.load(); config.clearErrorListeners(); config.addErrorListener(l); config.setReloadingStrategy(new FileAlwaysReloadingStrategy()); @@ -585,7 +592,9 @@ public class TestFileConfiguration @Test public void testIterationWithReloadFlat() throws ConfigurationException { - PropertiesConfiguration config = new PropertiesConfiguration(TEST_FILE); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setFile(TEST_FILE); + config.load(); checkIterationWithReload(config); } @@ -607,7 +616,9 @@ public class TestFileConfiguration @Test public void testRefresh() throws ConfigurationException { - PropertiesConfiguration config = new PropertiesConfiguration(TEST_FILE); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setFile(TEST_FILE); + config.load(); assertEquals("Wrong value", 10, config.getInt("test.integer")); config.setProperty("test.integer", new Integer(42)); assertEquals("Wrong value after update", 42, Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNonStringProperties.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNonStringProperties.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNonStringProperties.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNonStringProperties.java Tue Mar 19 21:08:34 2013 @@ -32,7 +32,10 @@ public class TestNonStringProperties ext @Before public void setUp() throws Exception { - conf = new PropertiesConfiguration(testProperties); + PropertiesConfiguration c = new PropertiesConfiguration(); + c.setFileName(testProperties); + c.load(); + conf = c; nonStringTestHolder.setConfiguration(conf); } } Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNullCompositeConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNullCompositeConfiguration.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNullCompositeConfiguration.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNullCompositeConfiguration.java Tue Mar 19 21:08:34 2013 @@ -52,8 +52,12 @@ public class TestNullCompositeConfigurat public void setUp() throws Exception { cc = new CompositeConfiguration(); - conf1 = new PropertiesConfiguration(testProperties); - conf2 = new PropertiesConfiguration(testProperties2); + conf1 = new PropertiesConfiguration(); + conf1.setFileName(testProperties); + conf1.load(); + conf2 = new PropertiesConfiguration(); + conf2.setFileName(testProperties2); + conf2.load(); xmlConf = new XMLConfiguration(new File(testPropertiesXML)); cc.setThrowExceptionOnMissing(false); Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesConfiguration.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesConfiguration.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesConfiguration.java Tue Mar 19 21:08:34 2013 @@ -51,7 +51,6 @@ import java.util.List; import java.util.Set; import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy; -import org.apache.commons.lang.SystemUtils; import org.junit.Before; import org.junit.Test; @@ -84,7 +83,9 @@ public class TestPropertiesConfiguration @Before public void setUp() throws Exception { - conf = new PropertiesConfiguration(testProperties); + conf = new PropertiesConfiguration(); + conf.setFileName(testProperties); + conf.load(); // remove the test save file if it exists if (testSavePropertiesFile.exists()) @@ -237,7 +238,9 @@ public class TestPropertiesConfiguration assertTrue("The saved file doesn't exist", testSavePropertiesFile.exists()); // read the configuration and compare the properties - PropertiesConfiguration checkConfig = new PropertiesConfiguration(filename); + PropertiesConfiguration checkConfig = new PropertiesConfiguration(); + checkConfig.setFileName(filename); + checkConfig.load(); ConfigurationAssert.assertEquals(conf, checkConfig); // Save it again, verifying a save with a filename works. @@ -252,7 +255,9 @@ public class TestPropertiesConfiguration conf.save(url); // reload the configuration - Configuration config2 = new PropertiesConfiguration(url); + PropertiesConfiguration config2 = new PropertiesConfiguration(); + config2.setURL(url); + config2.load(); assertEquals("true", config2.getString("configuration.loaded")); } @@ -276,7 +281,9 @@ public class TestPropertiesConfiguration assertTrue("The saved file doesn't exist", testSavePropertiesFile.exists()); // read the configuration and compare the properties - PropertiesConfiguration checkConfig = new PropertiesConfiguration(filename); + PropertiesConfiguration checkConfig = new PropertiesConfiguration(); + checkConfig.setFileName(filename); + checkConfig.load(); ConfigurationAssert.assertEquals(pc, checkConfig); // Save it again, verifying a save with a filename works. @@ -337,8 +344,9 @@ public class TestPropertiesConfiguration assertEquals("Wrong number of list elements", 3, dirs.size()); conf.save(testSavePropertiesFile); - PropertiesConfiguration checkConfig = new PropertiesConfiguration( - testSavePropertiesFile); + PropertiesConfiguration checkConfig = new PropertiesConfiguration(); + checkConfig.setFile(testSavePropertiesFile); + checkConfig.load(); ConfigurationAssert.assertEquals(conf, checkConfig); } @@ -385,7 +393,9 @@ public class TestPropertiesConfiguration public void testLoadFromFile() throws Exception { File file = ConfigurationAssert.getTestFile("test.properties"); - conf = new PropertiesConfiguration(file); + conf = new PropertiesConfiguration(); + conf.setFile(file); + conf.load(); assertEquals("true", conf.getString("configuration.loaded")); } @@ -498,7 +508,9 @@ public class TestPropertiesConfiguration private PropertiesConfiguration checkSavedConfig() throws ConfigurationException { - PropertiesConfiguration checkConfig = new PropertiesConfiguration(testSavePropertiesFile); + PropertiesConfiguration checkConfig = new PropertiesConfiguration(); + checkConfig.setFile(testSavePropertiesFile); + checkConfig.load(); ConfigurationAssert.assertEquals(conf, checkConfig); return checkConfig; } @@ -557,12 +569,16 @@ public class TestPropertiesConfiguration @Test public void testChangingDefaultListDelimiter() throws Exception { - PropertiesConfiguration pc = new PropertiesConfiguration(testProperties); + PropertiesConfiguration pc = new PropertiesConfiguration(); + pc.setFileName(testProperties); + pc.load(); assertEquals(4, pc.getList("test.mixed.array").size()); char delimiter = PropertiesConfiguration.getDefaultListDelimiter(); PropertiesConfiguration.setDefaultListDelimiter('^'); - pc = new PropertiesConfiguration(testProperties); + pc = new PropertiesConfiguration(); + pc.setFileName(testProperties); + pc.load(); assertEquals(2, pc.getList("test.mixed.array").size()); PropertiesConfiguration.setDefaultListDelimiter(delimiter); } @@ -570,7 +586,9 @@ public class TestPropertiesConfiguration @Test public void testChangingListDelimiter() throws Exception { - PropertiesConfiguration pc1 = new PropertiesConfiguration(testProperties); + PropertiesConfiguration pc1 = new PropertiesConfiguration(); + pc1.setFileName(testProperties); + pc1.load(); assertEquals(4, pc1.getList("test.mixed.array").size()); PropertiesConfiguration pc2 = new PropertiesConfiguration(); @@ -584,7 +602,9 @@ public class TestPropertiesConfiguration @Test public void testDisableListDelimiter() throws Exception { - PropertiesConfiguration pc1 = new PropertiesConfiguration(testProperties); + PropertiesConfiguration pc1 = new PropertiesConfiguration(); + pc1.setFileName(testProperties); + pc1.load(); assertEquals(4, pc1.getList("test.mixed.array").size()); PropertiesConfiguration pc2 = new PropertiesConfiguration(); @@ -613,7 +633,9 @@ public class TestPropertiesConfiguration @Test public void testLoadIncludeFromClassPath() throws ConfigurationException { - conf = new PropertiesConfiguration("test.properties"); + conf = new PropertiesConfiguration(); + conf.setFileName("test.properties"); + conf.load(); assertEquals("true", conf.getString("include.loaded")); } @@ -818,8 +840,9 @@ public class TestPropertiesConfiguration assertTrue("Wrong output flag", con.getDoOutput()); assertEquals("Wrong method", "PUT", con.getRequestMethod()); - PropertiesConfiguration checkConfig = new PropertiesConfiguration( - testSavePropertiesFile); + PropertiesConfiguration checkConfig = new PropertiesConfiguration(); + checkConfig.setFile(testSavePropertiesFile); + checkConfig.load(); ConfigurationAssert.assertEquals(conf, checkConfig); } @@ -852,16 +875,15 @@ public class TestPropertiesConfiguration @Test public void testFileWithSharpSymbol() throws Exception { - if (SystemUtils.isJavaVersionAtLeast(1.4f)) - { - File file = new File("target/sharp#1.properties"); - file.createNewFile(); + File file = new File("target/sharp#1.properties"); + file.createNewFile(); - PropertiesConfiguration conf = new PropertiesConfiguration(file); - conf.save(); + PropertiesConfiguration conf = new PropertiesConfiguration(); + conf.setFile(file); + conf.load(); + conf.save(); - assertTrue("Missing file " + file, file.exists()); - } + assertTrue("Missing file " + file, file.exists()); } /** @@ -873,11 +895,13 @@ public class TestPropertiesConfiguration public void testInitFromNonExistingFile() throws ConfigurationException { final String testProperty = "test.successfull"; - conf = new PropertiesConfiguration(testSavePropertiesFile); + conf = new PropertiesConfiguration(); + conf.setFile(testSavePropertiesFile); conf.addProperty(testProperty, Boolean.TRUE); conf.save(); - PropertiesConfiguration checkConfig = new PropertiesConfiguration( - testSavePropertiesFile); + PropertiesConfiguration checkConfig = new PropertiesConfiguration(); + checkConfig.setFile(testSavePropertiesFile); + checkConfig.load(); assertTrue("Test property not found", checkConfig .getBoolean(testProperty)); } @@ -914,14 +938,15 @@ public class TestPropertiesConfiguration @Test public void testSaveWithDataConfig() throws ConfigurationException { - conf = new PropertiesConfiguration(testSavePropertiesFile); + conf = new PropertiesConfiguration(); + conf.setFile(testSavePropertiesFile); DataConfiguration dataConfig = new DataConfiguration(conf); dataConfig.setProperty("foo", "bar"); assertEquals("Property not set", "bar", conf.getString("foo")); conf.save(); - PropertiesConfiguration config2 = new PropertiesConfiguration( - testSavePropertiesFile); + PropertiesConfiguration config2 = new PropertiesConfiguration(); + config2.load(testSavePropertiesFile); assertEquals("Property not saved", "bar", config2.getString("foo")); } @@ -936,12 +961,6 @@ public class TestPropertiesConfiguration { String loadEncoding; - public PropertiesConfigurationTestImpl(String fileName) - throws ConfigurationException - { - super(fileName); - } - @Override public void load(InputStream in, String encoding) throws ConfigurationException @@ -951,8 +970,9 @@ public class TestPropertiesConfiguration } } - PropertiesConfigurationTestImpl testConf = new PropertiesConfigurationTestImpl( - testProperties); + PropertiesConfigurationTestImpl testConf = new PropertiesConfigurationTestImpl(); + testConf.setFileName(testProperties); + testConf.load(); assertEquals("Default encoding not used", "ISO-8859-1", testConf.loadEncoding); } @@ -1189,8 +1209,9 @@ public class TestPropertiesConfiguration throws ConfigurationException { conf.save(testSavePropertiesFile); - PropertiesConfiguration checkConf = new PropertiesConfiguration( - testSavePropertiesFile); + PropertiesConfiguration checkConf = new PropertiesConfiguration(); + checkConf.setFile(testSavePropertiesFile); + checkConf.load(); for (Iterator it = copyConf.getKeys(); it.hasNext();) { String key = it.next(); Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesSequence.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesSequence.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesSequence.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesSequence.java Tue Mar 19 21:08:34 2013 @@ -42,7 +42,9 @@ public class TestPropertiesSequence String simpleConfigurationFile = ConfigurationAssert.getTestFile("testSequence.properties").getAbsolutePath(); String compositeConfigurationFile = ConfigurationAssert.getTestFile("testSequenceDigester.xml").getAbsolutePath(); - Configuration simpleConfiguration = new PropertiesConfiguration(simpleConfigurationFile); + PropertiesConfiguration simpleConfiguration = new PropertiesConfiguration(); + simpleConfiguration.setFileName(simpleConfigurationFile); + simpleConfiguration.load(); ConfigurationFactory configurationFactory = new ConfigurationFactory(); configurationFactory.setConfigurationFileName(compositeConfigurationFile); @@ -69,7 +71,9 @@ public class TestPropertiesSequence String simpleConfigurationFile = ConfigurationAssert.getTestFile("testSequence.properties").getAbsolutePath(); String compositeConfigurationFile = ConfigurationAssert.getTestFile("testSequenceDigester.xml").getAbsolutePath(); - Configuration simpleConfiguration = new PropertiesConfiguration(simpleConfigurationFile); + PropertiesConfiguration simpleConfiguration = new PropertiesConfiguration(); + simpleConfiguration.setFileName(simpleConfigurationFile); + simpleConfiguration.load(); ConfigurationFactory configurationFactory = new ConfigurationFactory(); configurationFactory.setConfigurationFileName(compositeConfigurationFile); @@ -102,7 +106,9 @@ public class TestPropertiesSequence String simpleConfigurationFile = ConfigurationAssert.getTestFile("testSequence.properties").getAbsolutePath(); String compositeConfigurationFile = ConfigurationAssert.getTestFile("testSequenceDigester.xml").getAbsolutePath(); - Configuration simpleConfiguration = new PropertiesConfiguration(simpleConfigurationFile); + PropertiesConfiguration simpleConfiguration = new PropertiesConfiguration(); + simpleConfiguration.setFileName(simpleConfigurationFile); + simpleConfiguration.load(); ConfigurationFactory configurationFactory = new ConfigurationFactory(); configurationFactory.setConfigurationFileName(compositeConfigurationFile); Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestThreesomeConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestThreesomeConfiguration.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestThreesomeConfiguration.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestThreesomeConfiguration.java Tue Mar 19 21:08:34 2013 @@ -38,7 +38,10 @@ public class TestThreesomeConfiguration @Before public void setUp() throws Exception { - conf = new PropertiesConfiguration("threesome.properties"); + PropertiesConfiguration c = new PropertiesConfiguration(); + c.setFileName("threesome.properties"); + c.load(); + conf = c; } @Test Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestXMLPropertiesConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestXMLPropertiesConfiguration.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestXMLPropertiesConfiguration.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestXMLPropertiesConfiguration.java Tue Mar 19 21:08:34 2013 @@ -44,7 +44,9 @@ public class TestXMLPropertiesConfigurat @Test public void testLoad() throws Exception { - XMLPropertiesConfiguration conf = new XMLPropertiesConfiguration("test.properties.xml"); + XMLPropertiesConfiguration conf = new XMLPropertiesConfiguration(); + conf.setFileName("test.properties.xml"); + conf.load(); assertEquals("header", "Description of the property list", conf.getHeader()); @@ -76,7 +78,9 @@ public class TestXMLPropertiesConfigurat public void testSave() throws Exception { // load the configuration - XMLPropertiesConfiguration conf = new XMLPropertiesConfiguration("test.properties.xml"); + XMLPropertiesConfiguration conf = new XMLPropertiesConfiguration(); + conf.setFileName("test.properties.xml"); + conf.load(); // update the configuration conf.addProperty("key4", "value4"); @@ -92,7 +96,8 @@ public class TestXMLPropertiesConfigurat conf.save(saveFile); // reload the configuration - XMLPropertiesConfiguration conf2 = new XMLPropertiesConfiguration(saveFile); + XMLPropertiesConfiguration conf2 = new XMLPropertiesConfiguration(); + conf2.load(saveFile); // test the configuration assertEquals("header", "Description of the new property list", conf2.getHeader()); @@ -107,7 +112,9 @@ public class TestXMLPropertiesConfigurat public void testDOMSave() throws Exception { // load the configuration - XMLPropertiesConfiguration conf = new XMLPropertiesConfiguration("test.properties.xml"); + XMLPropertiesConfiguration conf = new XMLPropertiesConfiguration(); + conf.setFileName("test.properties.xml"); + conf.load(); // update the configuration conf.addProperty("key4", "value4"); @@ -133,7 +140,8 @@ public class TestXMLPropertiesConfigurat transformer.transform(source, result); // reload the configuration - XMLPropertiesConfiguration conf2 = new XMLPropertiesConfiguration(saveFile); + XMLPropertiesConfiguration conf2 = new XMLPropertiesConfiguration(); + conf2.load(saveFile); // test the configuration assertEquals("header", "Description of the new property list", conf2.getHeader()); Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java Tue Mar 19 21:08:34 2013 @@ -68,7 +68,9 @@ public class TestFileChangedReloadingStr out.close(); // load the configuration - PropertiesConfiguration config = new PropertiesConfiguration("target/testReload.properties"); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setFileName("target/testReload.properties"); + config.load(); FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy(); strategy.setRefreshDelay(500); config.setReloadingStrategy(strategy); @@ -175,7 +177,9 @@ public class TestFileChangedReloadingStr } }; strategy.setRefreshDelay(100000); - PropertiesConfiguration config = new PropertiesConfiguration(TEST_FILE); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setFileName(TEST_FILE); + config.load(); config.setReloadingStrategy(strategy); assertTrue("Reloading not required", strategy.reloadingRequired()); assertTrue("Reloading no more required", strategy.reloadingRequired()); @@ -208,7 +212,9 @@ public class TestFileChangedReloadingStr out.close(); // load the configuration - PropertiesConfiguration config = new PropertiesConfiguration("target/testReload.properties"); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setFileName("target/testReload.properties"); + config.load(); FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy(); strategy.setRefreshDelay(500); config.setReloadingStrategy(strategy); Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestManagedReloadingStrategy.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestManagedReloadingStrategy.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestManagedReloadingStrategy.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestManagedReloadingStrategy.java Tue Mar 19 21:08:34 2013 @@ -48,7 +48,9 @@ public class TestManagedReloadingStrateg out.close(); // load the configuration - PropertiesConfiguration config = new PropertiesConfiguration("target/testReload.properties"); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setFileName("target/testReload.properties"); + config.load(); ManagedReloadingStrategy strategy = new ManagedReloadingStrategy(); config.setReloadingStrategy(strategy); assertEquals("Initial value", "value1", config.getString("string")); Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestVFSFileChangedReloadingStrategy.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestVFSFileChangedReloadingStrategy.java?rev=1458517&r1=1458516&r2=1458517&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestVFSFileChangedReloadingStrategy.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/TestVFSFileChangedReloadingStrategy.java Tue Mar 19 21:08:34 2013 @@ -74,7 +74,9 @@ public class TestVFSFileChangedReloading out.close(); // load the configuration - PropertiesConfiguration config = new PropertiesConfiguration("target/testReload.properties"); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setFileName("target/testReload.properties"); + config.load(); VFSFileChangedReloadingStrategy strategy = new VFSFileChangedReloadingStrategy(); strategy.setRefreshDelay(500); config.setReloadingStrategy(strategy); @@ -149,7 +151,9 @@ public class TestVFSFileChangedReloading } }; strategy.setRefreshDelay(100000); - PropertiesConfiguration config = new PropertiesConfiguration(TEST_FILE); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.setFileName(TEST_FILE); + config.load(); config.setReloadingStrategy(strategy); assertTrue("Reloading not required", strategy.reloadingRequired()); assertTrue("Reloading no more required", strategy.reloadingRequired());