harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhouke...@apache.org
Subject svn commit: r901080 - in /harmony/enhanced/classlib/trunk/modules/logging/src: main/java/java/util/logging/LogManager.java test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java
Date Wed, 20 Jan 2010 06:22:35 GMT
Author: zhoukevin
Date: Wed Jan 20 06:22:24 2010
New Revision: 901080

URL: http://svn.apache.org/viewvc?rev=901080&view=rev
Log:
Remove e.printStackTrace() in LogManager class, add a test case, and fix a potenital defect
in LogManagerTest

Modified:
    harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
    harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java?rev=901080&r1=901079&r2=901080&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
Wed Jan 20 06:22:24 2010
@@ -205,7 +205,7 @@
                 try {
                     manager.readConfiguration();
                 } catch (Exception e) {
-                    e.printStackTrace();
+                    // e.printStackTrace();
                 }
 
                 // if global logger has been initialized, set root as its parent

Modified: harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java?rev=901080&r1=901079&r2=901080&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java
Wed Jan 20 06:22:24 2010
@@ -19,6 +19,7 @@
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
@@ -811,23 +812,46 @@
         }
 
     }
-    
-    public void testValidConfigClass() throws Exception{
-        String oldProperty = System.getProperty("java.util.logging.config.class");
-        try{
-//            System.setProperty("java.util.logging.config.class", "org.apache.harmony.logging.tests.java.util.logging.LogManagerTest$ConfigClass");
-            System.setProperty("java.util.logging.config.class", this.getClass().getName()+"$ConfigClass");
           
+
+    public void testValidConfigClass() throws Exception {
+        String oldPropertyValue = System
+                .getProperty("java.util.logging.config.class");
+        try {
+            System.setProperty("java.util.logging.config.class", this
+                    .getClass().getName()
+                    + "$ConfigClass");
             assertNull(manager.getLogger("testConfigClass.foo"));
-            
+
             manager.readConfiguration();
             assertNull(manager.getLogger("testConfigClass.foo"));
             Logger l = Logger.getLogger("testConfigClass.foo.child");
             assertSame(Level.FINEST, manager.getLogger("").getLevel());
-            assertEquals(0, manager.getLogger("").getHandlers().length);            
+            assertEquals(0, manager.getLogger("").getHandlers().length);
             assertEquals("testConfigClass.foo", l.getParent().getName());
-        }finally{
-            if(oldProperty != null){
-                System.setProperty("java.util.logging.config.class", oldProperty);
+        } finally {
+            Properties systemProperties = System.getProperties();
+            if (oldPropertyValue != null) {
+                systemProperties.setProperty(CONFIG_CLASS, oldPropertyValue);
+            } else {
+                systemProperties.remove(CONFIG_CLASS);
+            }
+        }
+    }
+
+    public void testNotExistConfigFile() throws Exception {
+        String oldPropertyValue = System.getProperty(CONFIG_FILE);
+        System.setProperty(CONFIG_FILE, "not.exist.config.file");
+        try {
+            LogManager.getLogManager().readConfiguration();
+            fail("should throw FileNotFoundException");
+        } catch (FileNotFoundException e) {
+            // Expected
+        } finally {
+            Properties systemProperties = System.getProperties();
+            if (oldPropertyValue != null) {
+                systemProperties.setProperty(CONFIG_FILE, oldPropertyValue);
+            } else {
+                systemProperties.remove(CONFIG_FILE);
             }
         }
     }



Mime
View raw message