Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 29036 invoked from network); 26 Sep 2006 03:39:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Sep 2006 03:39:45 -0000 Received: (qmail 32301 invoked by uid 500); 26 Sep 2006 03:39:45 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 32202 invoked by uid 500); 26 Sep 2006 03:39:45 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 32191 invoked by uid 99); 26 Sep 2006 03:39:45 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Sep 2006 20:39:45 -0700 Authentication-Results: idunn.apache.osuosl.org smtp.mail=pyang@apache.org; spf=permerror X-ASF-Spam-Status: No, hits=-9.4 required=5.0 tests=ALL_TRUSTED,NO_REAL_NAME Received-SPF: error (idunn.apache.osuosl.org: domain apache.org from 140.211.166.113 cause and error) Received: from [140.211.166.113] ([140.211.166.113:57223] helo=eris.apache.org) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id 4E/50-04762-EF0A8154 for ; Mon, 25 Sep 2006 20:39:43 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 637251A981A; Mon, 25 Sep 2006 20:39:40 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: harmony-commits@incubator.apache.org From: pyang@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060926033940.637251A981A@eris.apache.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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; + /** *

* 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. *

* - * @param message The error message, which may be null. - * @param exception The exception associated with the error, which may be - * null. - * @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 null. + * @param exception + * The exception associated with the error, which may be + * null. + * @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(); } /*