#!/bin/sh
#
# Some tests for java support
#

tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15

tmpfiles="$tmpfiles xg-test10.java"
cat <<EOF > xg-test10.java
class TestCase {
    public TestCase() {
        ResourceBundle b = ResourceBundle.getBundle("test");
        GetTextBundle b2 = (GetTextBundle)b;
        // standard usage
        String test1 = b.getString("Test String 1");
        // gettext usage
        String test2 = b2.gettext("Test String 2");

        /* C style comment */
        String test3 = b.getString("Test String 3");

        // java "multiline" string
        String test4 = b.getString("Test " +
        "String " +
        "4");

        // empty string
        String test5 = b.getString("");
    }
}
EOF

tmpfiles="$tmpfiles xg-test10.po"
: ${XGETTEXT=xgettext}
${XGETTEXT} --omit-header --no-location -c -d xg-test10 xg-test10.java
test $? = 0 || { rm -fr $tmpfiles; exit 1; }

tmpfiles="$tmpfiles xg-test10.ok"
cat <<EOF > xg-test10.ok
#. standard usage
msgid "Test String 1"
msgstr ""

#. gettext usage
msgid "Test String 2"
msgstr ""

#. C style comment
msgid "Test String 3"
msgstr ""

#. java "multiline" string
msgid "Test String 4"
msgstr ""

#. empty string
msgid ""
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-test10.ok xg-test10.po
result=$?

rm -fr $tmpfiles

exit $result
