[rfc][icedtea-web] refactored logging

Omair Majid omajid at redhat.com
Tue Oct 22 06:42:13 PDT 2013


* Jiri Vanek <jvanek at redhat.com> [2013-10-22 03:40]:
> On 10/22/2013 12:42 AM, Omair Majid wrote:
> >It's a bad test. It modifies the global logging configuration and does
> >not restore the original. The modified logging configuration is not
> >visible on all machines because the order in which junit runs the test
> >is not guaranteed; sometimes a later tests modifies the configuration to
> >something which happens to be the default configuration.
> >
> >Does the attached patch look okay?
> 
> I would vote for backuping whole  LogConfig instead of individual
> fields, but do as you wish. Thanx for catching it.

Okay, how about the following?

Thanks,
Omair
-------------- next part --------------
diff --git a/netx/net/sourceforge/jnlp/util/logging/LogConfig.java b/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
--- a/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
+++ b/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
@@ -98,6 +98,13 @@
         return logConfig;
     }
 
+    /** For testing only: throw away the previous config */
+    static void resetLogConfig() {
+        if (logConfig != null) {
+            logConfig = new LogConfig();
+        }
+    }
+
     public String getIcedteaLogDir() {
         return icedteaLogDir;
     }
diff --git a/tests/netx/unit/net/sourceforge/jnlp/util/logging/OutputControllerTest.java b/tests/netx/unit/net/sourceforge/jnlp/util/logging/OutputControllerTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/util/logging/OutputControllerTest.java
+++ b/tests/netx/unit/net/sourceforge/jnlp/util/logging/OutputControllerTest.java
@@ -43,6 +43,8 @@
 import net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener;
 import net.sourceforge.jnlp.util.StreamUtils;
 import org.junit.Assert;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
 public class OutputControllerTest {
@@ -71,6 +73,16 @@
         }
     }
 
+    @Before
+    public void setUp() {
+        LogConfig.resetLogConfig();
+    }
+
+    @After
+    public void tearDown() {
+        LogConfig.resetLogConfig();
+    }
+
     @Test
     public void isLoggingStdStreams() throws Exception {
         ByteArrayOutputStream os1 = new ByteArrayOutputStream();


More information about the distro-pkg-dev mailing list