commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r892969 - /commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestMultiFileHierarchicalConfiguration.java
Date Mon, 21 Dec 2009 20:34:46 GMT
Author: oheger
Date: Mon Dec 21 20:34:45 2009
New Revision: 892969

URL: http://svn.apache.org/viewvc?rev=892969&view=rev
Log:
Fixed a failing unit test. However, not sure if this is really the desired behavior.

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestMultiFileHierarchicalConfiguration.java
  (contents, props changed)

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestMultiFileHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestMultiFileHierarchicalConfiguration.java?rev=892969&r1=892968&r2=892969&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestMultiFileHierarchicalConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestMultiFileHierarchicalConfiguration.java
Mon Dec 21 20:34:45 2009
@@ -27,11 +27,15 @@
 import junit.framework.TestCase;
 
 import org.apache.commons.configuration2.combined.CombinedConfiguration;
+import org.apache.commons.configuration2.event.ConfigurationErrorEvent;
+import org.apache.commons.configuration2.event.ConfigurationErrorListener;
 import org.apache.commons.configuration2.reloading.FileChangedReloadingStrategy;
+import org.apache.commons.lang.mutable.MutableObject;
 import org.xml.sax.SAXParseException;
 
 /**
  * Unit test for simple MultiConfigurationTest.
+ * @version $Id$
  */
 public class TestMultiFileHierarchicalConfiguration extends TestCase
 {
@@ -252,20 +256,32 @@
         x.setDelimiterParsingDisabled(true);
         x.load();
         x.setProperty("rowsPerPage", "test");
-        //Insure orginal timestamp and new timestamp aren't the same second.
+        //Insure original timestamp and new timestamp aren't the same second.
         Thread.sleep(1100);
         x.save();
         System.setProperty("Id", "3001");
-        try
+
+        // reload should fail, register an error lister which reports this error
+        final MutableObject exception = new MutableObject();
+        ConfigurationErrorListener l = new ConfigurationErrorListener()
         {
-            config.getInt("rowsPerPage");
-            fail("No exception was thrown");
-        }
-        catch (Exception ex)
+            public void configurationError(ConfigurationErrorEvent event)
+            {
+                if (event.getType() == AbstractHierarchicalFileConfiguration.EVENT_RELOAD)
+                {
+                    exception.setValue(event.getCause());
+                }
+            }
+        };
+        for (int i = 0; i < config.getNumberOfConfigurations(); i++)
         {
-
+            ((AbstractConfiguration) config.getConfiguration(i))
+                    .addErrorListener(l);
         }
 
+        config.getInt("rowsPerPage");
+        assertNotNull("No exception received", exception.getValue());
+
         output.delete();
     }
 

Propchange: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestMultiFileHierarchicalConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestMultiFileHierarchicalConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message