commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r987621 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
Date Fri, 20 Aug 2010 20:01:11 GMT
Author: oheger
Date: Fri Aug 20 20:01:10 2010
New Revision: 987621

URL: http://svn.apache.org/viewvc?rev=987621&view=rev
Log:
Added a new isSuccessful() method to the result object of MultiBackgroundInitializer.

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java?rev=987621&r1=987620&r2=987621&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
Fri Aug 20 20:01:10 2010
@@ -319,6 +319,16 @@ public class MultiBackgroundInitializer
         }
 
         /**
+         * Returns a flag whether the whole initialization was successful. This
+         * is the case if no child initializer has thrown an exception.
+         *
+         * @return a flag whether the initialization was successful
+         */
+        public boolean isSuccessful() {
+            return exceptions.isEmpty();
+        }
+
+        /**
          * Checks whether an initializer with the given name exists. If not,
          * throws an exception. If it exists, the associated child initializer
          * is returned.

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java?rev=987621&r1=987620&r2=987621&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
Fri Aug 20 20:01:10 2010
@@ -286,6 +286,37 @@ public class MultiBackgroundInitializerT
     }
 
     /**
+     * Tests the isSuccessful() method of the result object if no child
+     * initializer has thrown an exception.
+     */
+    @Test
+    public void testInitializeResultsIsSuccessfulTrue()
+            throws ConcurrentException {
+        ChildBackgroundInitializer child = new ChildBackgroundInitializer();
+        initializer.addInitializer(CHILD_INIT, child);
+        initializer.start();
+        MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+                .get();
+        assertTrue("Wrong success flag", res.isSuccessful());
+    }
+
+    /**
+     * Tests the isSuccessful() method of the result object if at least one
+     * child initializer has thrown an exception.
+     */
+    @Test
+    public void testInitializeResultsIsSuccessfulFalse()
+            throws ConcurrentException {
+        ChildBackgroundInitializer child = new ChildBackgroundInitializer();
+        child.ex = new Exception();
+        initializer.addInitializer(CHILD_INIT, child);
+        initializer.start();
+        MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+                .get();
+        assertFalse("Wrong success flag", res.isSuccessful());
+    }
+
+    /**
      * Tests whether MultiBackgroundInitializers can be combined in a nested
      * way.
      */



Mime
View raw message