/hg/icedtea-web: Reset the LogConfig in unit tests

omajid at icedtea.classpath.org omajid at icedtea.classpath.org
Tue Oct 22 13:31:44 PDT 2013


changeset c6c2998cc359 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=c6c2998cc359
author: Omair Majid <omajid at redhat.com>
date: Tue Oct 22 16:21:40 2013 -0400

	Reset the LogConfig in unit tests

	LogConfig is globally shared. Fix unit tests that modify the logging
	configuration to reset it after (and before) to avoid affecting other
	unit tests or being affected by the results of other tests.

	Before this patch, if the tests were executed in a certain order, it
	was possible for them to leave behind a LogConfig that enabled logging
	in the most verbose manner possible. This would generate megabytes of
	output when running unit tests.

	2013-10-22  Omair Majid  <omajid at redhat.com>

	    * netx/net/sourceforge/jnlp/util/logging/LogConfig.java
	    (resetLogConfig): New method.
	    * tests/netx/unit/net/sourceforge/jnlp/util/logging/OutputControllerTest.java
	    (setUp, tearDown): New method.


diffstat:

 ChangeLog                                                                   |   7 +++++
 netx/net/sourceforge/jnlp/util/logging/LogConfig.java                       |   7 +++++
 tests/netx/unit/net/sourceforge/jnlp/util/logging/OutputControllerTest.java |  12 ++++++++++
 3 files changed, 26 insertions(+), 0 deletions(-)

diffs (60 lines):

diff -r c91a4eb28c97 -r c6c2998cc359 ChangeLog
--- a/ChangeLog	Tue Oct 22 11:48:27 2013 +0200
+++ b/ChangeLog	Tue Oct 22 16:21:40 2013 -0400
@@ -1,3 +1,10 @@
+2013-10-22  Omair Majid  <omajid at redhat.com>
+
+	* netx/net/sourceforge/jnlp/util/logging/LogConfig.java
+	(resetLogConfig): New method.
+	* tests/netx/unit/net/sourceforge/jnlp/util/logging/OutputControllerTest.java
+	(setUp, tearDown): New method.
+
 2013-10-22  Jiri Vanek  <jvanek at redhat.com>
 
 	More synchronized error/debug methods
diff -r c91a4eb28c97 -r c6c2998cc359 netx/net/sourceforge/jnlp/util/logging/LogConfig.java
--- a/netx/net/sourceforge/jnlp/util/logging/LogConfig.java	Tue Oct 22 11:48:27 2013 +0200
+++ b/netx/net/sourceforge/jnlp/util/logging/LogConfig.java	Tue Oct 22 16:21:40 2013 -0400
@@ -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 -r c91a4eb28c97 -r c6c2998cc359 tests/netx/unit/net/sourceforge/jnlp/util/logging/OutputControllerTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/util/logging/OutputControllerTest.java	Tue Oct 22 11:48:27 2013 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/util/logging/OutputControllerTest.java	Tue Oct 22 16:21:40 2013 -0400
@@ -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