[rfc][icedtea-web] refactored logging

Omair Majid omajid at redhat.com
Mon Oct 21 15:42:51 PDT 2013


* Jiri Vanek <jvanek at redhat.com> [2013-10-21 09:54]:
> On 10/18/2013 10:26 PM, Omair Majid wrote:
> >One more: running 'make check' should not produce >2M of
> >output :)
> 
> hmm:(( I made some digging oi this, and I'm not able to reproduces.
> 
> Now -verbose, ICEDTEAPLUGIN_DEBUG, and deployment.log=true in
> ~/.config/icedtea-web/deployment.properties enable the same debug
> "level"
> 
> May you verify how output of make check is affected by them?

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?

Thanks,
Omair
-------------- next part --------------
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,34 @@
         }
     }
 
+    private boolean savedEnableHeaders;
+    private boolean savedEnableLogging;
+    private boolean savedLogToFile;
+    private boolean savedLogToStreams;
+    private boolean savedLogToSysLog;
+
+    @Before
+    public void setUp() {
+        // back up global logging configuration
+        LogConfig config = LogConfig.getLogConfig();
+        savedEnableHeaders = config.isEnableHeaders();
+        savedEnableLogging = config.isEnableLogging();
+        savedLogToFile = config.isLogToFile();
+        savedLogToStreams = config.isLogToStreams();
+        savedLogToSysLog = config.isLogToSysLog();
+    }
+
+    @After
+    public void tearDown() {
+        // restore global logging configuration
+        LogConfig config = LogConfig.getLogConfig();
+        config.setEnableHeaders(savedEnableHeaders);
+        config.setEnableLogging(savedEnableLogging);
+        config.setLogToFile(savedLogToFile);
+        config.setLogToStreams(savedLogToStreams);
+        config.setLogToSysLog(savedLogToSysLog);
+    }
+
     @Test
     public void isLoggingStdStreams() throws Exception {
         ByteArrayOutputStream os1 = new ByteArrayOutputStream();


More information about the distro-pkg-dev mailing list