<?xml version="1.0" encoding="UTF-8"?>
<test-data>
    <test-code>
        <description><![CDATA[
ok, no error expected
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Test {
    private static final Log __log = LogFactory.getLog(Test.class);
    public void test() {
        // good:
        if (__log.isDebugEnabled()) {
        __log.debug("bla" + "",e );
        }
    }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
Complex logging without guard
     ]]></description>
        <expected-problems>2</expected-problems>
        <code><![CDATA[
public class Test {
    private static final Log __log = LogFactory.getLog(Test.class);
    public void test() {

        // bad:
        __log.debug("log something" + " and " + "concat strings");

        // bad:
        __log.debug("log something" + " and " + "concat strings", e);

        // good:
        if (__log.isDebugEnabled()) {
        __log.debug("bla" + "",e );
        }
    }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
Complex logging wit misplaced guard
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Test {
    private static final Log __log = LogFactory.getLog(Test.class);
    public void test() {
        if (true) {
            // bad:
            __log.debug("log something" + " and " + "concat strings");
            // this is useless:
            __log.isDebugEnabled();
        }
    }
}
     ]]></code>
    </test-code>
    <test-code>
        <description>ok #1189 GuardLogStatementRule and GuardDebugLoggingRule broken for log4j2</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Test {
    public void test() {
        final Marker m = MarkerManager.getMarker(mymarker);
        if (logger.isDebugEnabled(m)) {
          logger.debug(m, message + "");
        }
    }
}
        ]]></code>
    </test-code>
    <test-code>
        <description>violation - wrong guard #1189 GuardLogStatementRule and GuardDebugLoggingRule broken for log4j2</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Test {
    public void test() {
        final Marker m = MarkerManager.getMarker(mymarker);
        if (logger.isTraceEnabled(m)) {
          logger.debug(m, message + "");
        }
    }
}
        ]]></code>
    </test-code>
    <test-code>
        <description>violation - no if #1189 GuardLogStatementRule and GuardDebugLoggingRule broken for log4j2</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Test {
    public void test() {
        final Marker m = MarkerManager.getMarker(mymarker);
        logger.isDebugEnabled(m); // must be within an if
        logger.debug(m, message + "");
    }
}
        ]]></code>
    </test-code>
    <test-code>
        <description>#1224 GuardDebugLogging broken in 5.1.1 - missing additive statement check in log statement</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Test {
    private static final Log __log = LogFactory.getLog(Test.class);
    public void test() {
        // okay:
        __log.debug("log something");

        // okay:
        __log.debug("log something with exception", e);

        // good:
        if (__log.isDebugEnabled()) {
        __log.debug("bla" + "",e );
        }
    }
}
        ]]></code>
    </test-code>
    <test-code>
        <description>#1341 pmd:GuardDebugLogging violates LOGGER.debug with format "{}"</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class GuardDebugFalsePositive {
    public void test() {
        String tempSelector = "a";
        LOGGER.debug("MessageSelector={}" , tempSelector);
    }
}
        ]]></code>
    </test-code>
</test-data>
