commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe...@apache.org
Subject svn commit: r751539 - /commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPreferencesConfiguration.java
Date Sun, 08 Mar 2009 21:44:46 GMT
Author: joehni
Date: Sun Mar  8 21:44:46 2009
New Revision: 751539

URL: http://svn.apache.org/viewvc?rev=751539&view=rev
Log:
Fix test: It is not possible to persist changes in the system preferences without administrator
rights.

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPreferencesConfiguration.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPreferencesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPreferencesConfiguration.java?rev=751539&r1=751538&r2=751539&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPreferencesConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPreferencesConfiguration.java
Sun Mar  8 21:44:46 2009
@@ -133,10 +133,23 @@
      */
     public void testGetPropertiesSystem()
     {
+        boolean administrator = true;
         node = Preferences.systemRoot();
-        setUpTestData();
+        try {
+            setUpTestData();
+        } catch (final ConfigurationRuntimeException e) {
+            if (e.getCause() instanceof BackingStoreException) {
+                administrator = false;
+            } else {
+                throw e;
+            }
+        }
         PreferencesConfiguration config = new PreferencesConfiguration(true);
         checkProperties(config);
+        if (!administrator) {
+            // Changes are not persistent without administrator rights
+            node = null;
+        }
     }
 
     /**
@@ -155,11 +168,24 @@
      */
     public void testGetPropertiesSystemPackage()
     {
+        boolean administrator = true;
         node = Preferences.systemNodeForPackage(getClass());
-        setUpTestData();
+        try {
+            setUpTestData();
+        } catch (final ConfigurationRuntimeException e) {
+            if (e.getCause() instanceof BackingStoreException) {
+                administrator = false;
+            } else {
+                throw e;
+            }
+        }
         PreferencesConfiguration config = new PreferencesConfiguration(true,
                 getClass());
         checkProperties(config);
+        if (!administrator) {
+            // Changes are not persistent without administrator rights
+            node = null;
+        }
     }
 
     /**



Mime
View raw message