harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r449890 - in /incubator/harmony/enhanced/classlib/trunk/modules/logging/src: main/java/java/util/logging/ main/java/org/apache/harmony/logging/internal/nls/ test/java/org/apache/harmony/logging/tests/java/util/logging/
Date Tue, 26 Sep 2006 03:39:39 GMT
Author: pyang
Date: Mon Sep 25 20:39:36 2006
New Revision: 449890

URL: http://svn.apache.org/viewvc?view=rev&rev=449890
Log:
Multi tidy up for logging module:
1. redirect System.err in handler tests so that the ErrorManager doesn't print messegs to
standard output
2. generic uplift
3. StringBuffer -> StringBuilder
4. More i18n messages
5. Make ErrorManager's output more user-friendly, by remove exception stack trace, and print
error type string instead of type code, etc.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/ErrorManager.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ConsoleHandlerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ErrorManagerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SocketHandlerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/ErrorManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/ErrorManager.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/ErrorManager.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/ErrorManager.java
Mon Sep 25 20:39:36 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
 
 package java.util.logging;
 
+import org.apache.harmony.logging.internal.nls.Messages;
+
 /**
  * <p>
  * An error reporting facility for {@link Handler} implementations to record any
@@ -56,6 +58,10 @@
      */
     public static final int FORMAT_FAILURE = 5;
 
+    private static final String[] FAILURES = new String[] { "GENERIC_FAILURE",
+            "WRITE_FAILURE", "FLUSH_FAILURE", "CLOSE_FAILURE", "OPEN_FAILURE",
+            "FORMAT_FAILURE" };
+
     /**
      * An indicator for determining if the error manager has been called at
      * least once before.
@@ -77,11 +83,14 @@
      * should override this method.
      * </p>
      * 
-     * @param message The error message, which may be <code>null</code>.
-     * @param exception The exception associated with the error, which may be
-     *        <code>null</code>.
-     * @param errorCode The error code that identifies the type of error; see
-     *        the constant fields on this class.
+     * @param message
+     *            The error message, which may be <code>null</code>.
+     * @param exception
+     *            The exception associated with the error, which may be
+     *            <code>null</code>.
+     * @param errorCode
+     *            The error code that identifies the type of error; see the
+     *            constant fields on this class.
      */
     public void error(String message, Exception exception, int errorCode) {
         synchronized (this) {
@@ -89,18 +98,14 @@
                 return;
             }
             synchronized (System.err) {
-                System.err.print(getClass().getName());
-                System.err.print(": Error Code - "); //$NON-NLS-1$
-                System.err.print(errorCode);
+                System.err.println(this.getClass().getName()+": "+FAILURES[errorCode]); //$NON-NLS-1$
                 if (message != null) {
-                    System.err.print(", Message - "); //$NON-NLS-1$
-                    System.err.print(message);
+                    //logging.1E=Error message - {0}
+                    System.err.println(Messages.getString("logging.1E", message)); //$NON-NLS-1$
                 }
                 if (exception != null) {
-                    System.err.print(", Exception - "); //$NON-NLS-1$
-                    exception.printStackTrace(System.err);
-                } else {
-                    System.err.println();
+                    //logging.1F=Exception - {0}
+                    System.err.println(Messages.getString("logging.1F", exception)); //$NON-NLS-1$
                 }
             }
             called = true;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
Mon Sep 25 20:39:36 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -304,7 +304,7 @@
         String homePath = System.getProperty("user.home"); //$NON-NLS-1$
         boolean homePathHasSepEnd = (homePath == null ? false : homePath.endsWith(File.separator));
 
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         pattern = pattern.replace('/', File.separatorChar);
 
         char[] value = pattern.toCharArray();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java
Mon Sep 25 20:39:36 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -121,8 +121,8 @@
     // print error message in some format
     void printInvalidPropMessage(String key, String value, Exception e) {
         // logging.12=Invalid property value for
-        String msg = new StringBuffer().append(Messages.getString("logging.12"))  //$NON-NLS-1$
-                .append(prefix).append(".").append(key).append(":").append( //$NON-NLS-1$//$NON-NLS-2$
+        String msg = new StringBuilder().append(Messages.getString("logging.12"))  //$NON-NLS-1$
+                .append(prefix).append(":").append(key).append("/").append( //$NON-NLS-1$//$NON-NLS-2$
                         value).toString();
         errorMan.error(msg, e, ErrorManager.GENERIC_FAILURE);
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
Mon Sep 25 20:39:36 2006
@@ -397,7 +397,6 @@
                     className);
             return clazz.newInstance();
         } catch (Exception e) {
-            e.printStackTrace();
             return null;
         }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
Mon Sep 25 20:39:36 2006
@@ -760,7 +760,7 @@
         if (internalIsLoggable(Level.FINER)) {
         	String msg = "ENTRY";
 			if (null != params) {
-				StringBuffer msgBuffer = new StringBuffer("ENTRY");
+				StringBuilder msgBuffer = new StringBuilder("ENTRY");
 				for (int i = 0; i < params.length; i++) {
 					msgBuffer.append(" {" + i + "}"); //$NON-NLS-1$ //$NON-NLS-2$
 				}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties
Mon Sep 25 20:39:36 2006
@@ -30,6 +30,8 @@
 logging.1B=The limit and count property must be larger than 0 and 1, respectively
 logging.1C=The 'name' parameter is null.
 logging.1D=Cannot parse this name: {0}
+logging.1E=Error message - {0}
+logging.1F=Exception - {0}
 logging.2=The OutputStream parameter is null
 logging.3=The Formatter parameter is null.
 logging.4=The 'level' parameter is null.

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ConsoleHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ConsoleHandlerTest.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ConsoleHandlerTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ConsoleHandlerTest.java
Mon Sep 25 20:39:36 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,7 +32,9 @@
 import java.util.logging.SimpleFormatter;
 
 import junit.framework.TestCase;
+
 import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper;
+
 import tests.util.CallVerificationStack;
 
 /**
@@ -44,7 +46,7 @@
 
 	private final PrintStream err = System.err;
 
-	private ByteArrayOutputStream errSubstituteStream = null;
+	private OutputStream errSubstituteStream = null;
 
 	private static String className = ConsoleHandlerTest.class.getName();
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ErrorManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ErrorManagerTest.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ErrorManagerTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ErrorManagerTest.java
Mon Sep 25 20:39:36 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,11 +15,31 @@
 
 package org.apache.harmony.logging.tests.java.util.logging;
 
+import java.io.OutputStream;
+import java.io.PrintStream;
 import java.util.logging.ErrorManager;
 
+import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream;
+
 import junit.framework.TestCase;
 
 public class ErrorManagerTest extends TestCase {
+    
+    
+    private final PrintStream err = System.err;
+
+    private OutputStream errSubstituteStream = null;        
+    
+    public void setUp() throws Exception{
+        super.setUp();
+        errSubstituteStream = new NullOutputStream();
+        System.setErr(new PrintStream(errSubstituteStream));           
+    }
+    
+    public void tearDown() throws Exception{
+        System.setErr(err);
+        super.tearDown();
+    }
 
     public void test_errorStringStringint() {
         ErrorManager em = new ErrorManager();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java
Mon Sep 25 20:39:36 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.PrintStream;
 import java.io.Reader;
 import java.io.StringWriter;
 import java.security.Permission;
@@ -40,6 +41,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream;
 import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper;
 
 /**
@@ -61,6 +63,10 @@
 	final static String TEMPPATH = System.getProperty("java.io.tmpdir");
 
 	final static String SEP = File.separator;
+    
+    private final PrintStream err = System.err;
+
+    private OutputStream errSubstituteStream = null;        
 
 	FileHandler handler;
 
@@ -79,7 +85,8 @@
 				.PropertiesToInputStream(props));
 		handler = new FileHandler();
 		r = new LogRecord(Level.CONFIG, "msg");
-
+        errSubstituteStream = new NullOutputStream();
+        System.setErr(new PrintStream(errSubstituteStream));        
 	}
 
 	/**
@@ -112,6 +119,7 @@
 			handler.close();
 		}
 		reset(TEMPPATH + SEP + "log", "");
+        System.setErr(err);         
 		super.tearDown();
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java
Mon Sep 25 20:39:36 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
 
 package org.apache.harmony.logging.tests.java.util.logging;
 
+import java.io.IOException;
+import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.security.Permission;
 import java.util.Properties;
@@ -580,7 +582,12 @@
 			CallVerificationStack.getInstance().push(ex);
 			CallVerificationStack.getInstance().push(errorCode);
 		}
-
 	}
+    
+    public static class NullOutputStream extends OutputStream{
+        @Override
+        public void write(int arg0) throws IOException {
+        }
+    }
 
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java
Mon Sep 25 20:39:36 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,8 +15,9 @@
 
 package org.apache.harmony.logging.tests.java.util.logging;
 
-import java.io.File;
 import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
 import java.io.StringWriter;
 import java.security.Permission;
 import java.util.Properties;
@@ -32,6 +33,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream;
 import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper;
 
 /**
@@ -48,13 +50,15 @@
 	final static StringWriter writer = new StringWriter();
 
 	final static SecurityManager securityManager = new MockSecurityManager();
+    
+    private final PrintStream err = System.err;
+
+    private OutputStream errSubstituteStream = null;    
 
 	MemoryHandler handler;
 
 	Handler target = new MockHandler();
 
-	private static File bak = null;
-
 	/*
 	 * @see TestCase#setUp()
 	 */
@@ -65,6 +69,8 @@
 		manager.readConfiguration(EnvironmentHelper
 				.PropertiesToInputStream(props));
 		handler = new MemoryHandler();
+        errSubstituteStream = new NullOutputStream();
+        System.setErr(new PrintStream(errSubstituteStream));        
 	}
 
 	/**
@@ -89,6 +95,7 @@
 		super.tearDown();
 		manager.readConfiguration();
 		props.clear();
+        System.setErr(err);        
 	}
 
 	public void testSecurity() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SocketHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SocketHandlerTest.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SocketHandlerTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SocketHandlerTest.java
Mon Sep 25 20:39:36 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream;
 import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper;
 
 import tests.util.CallVerificationStack;
@@ -48,7 +49,11 @@
 	private static final LogManager LOG_MANAGER = LogManager.getLogManager();
 
     private final static String INVALID_LEVEL = "impossible_level";
+    
+    private final PrintStream err = System.err;
 
+    private OutputStream errSubstituteStream = null;    
+    
 	private static String className = SocketHandlerTest.class.getName();
 
 	private SocketHandler h = null;
@@ -60,13 +65,14 @@
 	 */
 	protected void setUp() throws Exception {
 		super.setUp();
+        errSubstituteStream = new NullOutputStream();
+        System.setErr(new PrintStream(errSubstituteStream));  
 	}
 
 	/*
 	 * @see TestCase#tearDown()
 	 */
 	protected void tearDown() throws Exception {
-		super.tearDown();
         initProps();
 		LOG_MANAGER.reset();
         LOG_MANAGER.readConfiguration(EnvironmentHelper
@@ -76,6 +82,8 @@
 			h.close();
 			h = null;
 		}
+        System.setErr(err);
+        super.tearDown();
 	}
     
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java?view=diff&rev=449890&r1=449889&r2=449890
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java
Mon Sep 25 20:39:36 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 import java.nio.CharBuffer;
 import java.nio.charset.Charset;
@@ -37,6 +38,8 @@
 import java.util.logging.StreamHandler;
 
 import junit.framework.TestCase;
+
+import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream;
 import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper;
 import tests.util.CallVerificationStack;
 
@@ -46,6 +49,10 @@
 public class StreamHandlerTest extends TestCase {
 
 	private final static String INVALID_LEVEL = "impossible_level";
+    
+    private final PrintStream err = System.err;
+
+    private OutputStream errSubstituteStream = null;     
 
 	private static String className = StreamHandlerTest.class.getName();
 
@@ -62,15 +69,18 @@
 	 */
 	protected void setUp() throws Exception {
 		super.setUp();
+        errSubstituteStream = new NullOutputStream();
+        System.setErr(new PrintStream(errSubstituteStream));          
 	}
 
 	/*
 	 * @see TestCase#tearDown()
 	 */
 	protected void tearDown() throws Exception {
-		super.tearDown();
 		LogManager.getLogManager().reset();
 		CallVerificationStack.getInstance().clear();
+        System.setErr(err);        
+        super.tearDown();
 	}
 
 	/*



Mime
View raw message