<?xml version="1.0" encoding="UTF-8"?>
<test-data
    xmlns="http://pmd.sourceforge.net/rule-tests"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
    <test-code>
        <description><![CDATA[
Format called from non-synchronized block
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    private static final SimpleDateFormat sdf = new SimpleDateFormat();
    void bar() {
        sdf.format();
    }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
2, No call to format
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    private final SimpleDateFormat sdf = new SimpleDateFormat();
    void bar() {
    }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
3, Inside synchronized, OK
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    private static final SimpleDateFormat sdf = new SimpleDateFormat();
    synchronized void bar() {
        sdf.format();
    }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
4, Inside synchronized, OK
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    private static final SimpleDateFormat sdf = new SimpleDateFormat();
    public void bar() {
        synchronized (sdf) {
            sdf.format();
        }
    }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
5, Use DateFormat, ok
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    private static final DateFormat sdf = new DateFormat();
    synchronized void bar() {
        sdf.format();
    }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
6, Use DateFormat, fail
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    private static final DateFormat sdf = new DateFormat();
    void bar() {
        sdf.format();
    }
}
     ]]></code>
    </test-code>

    <test-code>
        <description>#940 False positive on UnsynchronizedStaticDateFormatter</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Test {
    private static final DateFormat enFormat = new SimpleDateFormat("EEEE MMMM d, yyyy 'at' hh':'mma", Locale.US);
    private static final DateFormat frFormat = new SimpleDateFormat("EEEE 'le' d MMMM yyyy 'à' HH'h'mm", Locale.CANADA_FRENCH);

    protected DateFormat getDateFormat() {
        return getLang() == LangEnum.FR ? frFormat : enFormat;
    }
}
        ]]></code>
    </test-code>
</test-data>
