You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/05/09 11:48:39 UTC

[groovy] branch master updated: add a reworked testcase for suspicious test (currently commented out)

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 26efb1e  add a reworked testcase for suspicious test (currently commented out)
26efb1e is described below

commit 26efb1e2ef970f5eefa50c676f61a788de3d4ab9
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sat May 9 21:48:27 2020 +1000

    add a reworked testcase for suspicious test (currently commented out)
---
 src/test/groovy/util/logging/Log4j2Test.groovy | 36 ++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/src/test/groovy/util/logging/Log4j2Test.groovy b/src/test/groovy/util/logging/Log4j2Test.groovy
index 672d1be..9ff6afc 100644
--- a/src/test/groovy/util/logging/Log4j2Test.groovy
+++ b/src/test/groovy/util/logging/Log4j2Test.groovy
@@ -301,6 +301,42 @@ class Log4j2Test extends GroovyTestCase {
         assert appender.isLogGuarded
     }
 
+    /*
+    @Log4j2
+    static class MyClassLogGuard {
+        def loggingMethod() {
+            log.fatal (prepareLogMessage())
+            log.error (prepareLogMessage())
+            log.warn  (prepareLogMessage())
+            log.info  (prepareLogMessage())
+            log.debug (prepareLogMessage())
+            log.trace (prepareLogMessage())
+        }
+
+        def prepareLogMessage() {
+            log.appenders['MyAppender']?.isLogGuarded = false
+            println log.privateConfig.intLevel
+            println "" + log.isInfoEnabled() + " " + log.isWarnEnabled() + " " + log.isFatalEnabled() + " " + log.isEnabled(Level.TRACE)
+            println 'isLogGuarded = false CALLED!!'
+            return 'should never see message'
+        }
+    }
+
+    void testLogGuard() {
+        MyClassLogGuard.log.addAppender(appender)
+        MyClassLogGuard.log.setLevel(Level.OFF)
+        new MyClassLogGuard().loggingMethod()
+        println appender.isLogGuarded
+
+        // reset
+        log.appenders['MyAppender']?.isLogGuarded = true
+        MyClassLogGuard.log.setLevel(Level.ALL)
+        new MyClassLogGuard().loggingMethod()
+        println !appender.isLogGuarded
+    }
+    */
+
+
     @Log4j2
     static class MyClassDefaultCategory {
         static loggingMethod() {