From 78041d3755021610ea989465e605ee32155d600c Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Wed, 5 Aug 2009 12:55:47 +0000 Subject: [PATCH] Take two at fixing the failing Jabber account uninstallation test this time pretty much forcing the XML store on the ConfigurationService implementation because the configuration tests write the configuration file in XML format on their own, without the ConfigurationService implementation. --- .../ConfigurationServiceImpl.java | 26 ++++++++++++------- .../TestConfigurationSlickFinalizer.java | 11 +++++++- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java index fe493e1a8..dfaff607d 100644 --- a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java +++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java @@ -552,7 +552,7 @@ private File getConfigurationFile() if (!(this.store instanceof XMLConfigurationStore)) this.store = new XMLConfigurationStore(); } - else if (configurationFile.exists()) + else { String name = configurationFile.getName(); int extensionBeginIndex = name.lastIndexOf('.'); @@ -583,21 +583,26 @@ else if (configurationFile.exists()) if (!(this.store instanceof PropertyConfigurationStore)) this.store = new PropertyConfigurationStore(); } + else if (!configurationFile.exists() + && (getSystemProperty(PNAME_CONFIGURATION_FILE_NAME) + == null)) + { + this.configurationFile + = getConfigurationFile("properties", true); + if (!(this.store instanceof PropertyConfigurationStore)) + this.store = new PropertyConfigurationStore(); + } else { - this.configurationFile = configurationFile; + this.configurationFile = + configurationFile.exists() + ? configurationFile + : getConfigurationFile("xml", true); if (!(this.store instanceof XMLConfigurationStore)) this.store = new XMLConfigurationStore(); } } } - else - { - this.configurationFile - = getConfigurationFile("properties", true); - if (!(this.store instanceof PropertyConfigurationStore)) - this.store = new PropertyConfigurationStore(); - } /* * Make sure that the properties SC_HOME_DIR_LOCATION and @@ -914,6 +919,9 @@ public void purgeStoredConfiguration() configurationFile.delete(); configurationFile = null; } + if (store != null) + for (String name : store.getPropertyNames()) + store.removeProperty(name); } /** diff --git a/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java b/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java index 65f52d62e..e9505a267 100644 --- a/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java +++ b/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java @@ -6,10 +6,13 @@ */ package net.java.sip.communicator.slick.configuration; -import org.osgi.framework.*; +import java.util.*; + import junit.framework.*; import net.java.sip.communicator.service.configuration.*; +import org.osgi.framework.*; + /** * Performs finalization tasks (such as removing the configuration file) at the * end of the ConfigurationServiceLick. @@ -42,5 +45,11 @@ public void testPurgeConfiguration() configurationService.purgeStoredConfiguration(); + List propertyNames + = configurationService.getPropertyNamesByPrefix("", false); + + assertTrue( + "The configuration service contains properties after purging.", + (propertyNames == null) || (propertyNames.size() <= 0)); } }