Home | History | Annotate | Line # | Download | only in tests
      1 #!/bin/sh
      2 #
      3 # Some tests for java support
      4 #
      5 
      6 tmpfiles=""
      7 trap 'rm -fr $tmpfiles' 1 2 3 15
      8 
      9 tmpfiles="$tmpfiles xg-j-1.java"
     10 cat <<EOF > xg-j-1.java
     11 class TestCase {
     12     public TestCase() {
     13         ResourceBundle b = ResourceBundle.getBundle("test");
     14         GetTextBundle b2 = (GetTextBundle)b;
     15         // standard usage
     16         String test1 = b.getString("Test String 1");
     17         // gettext usage
     18         String test2 = b2.gettext("Test String 2");
     19 
     20         /* C style comment */
     21         String test3 = b.getString("Test String 3");
     22 
     23         // java "multiline" string
     24         String test4 = b.getString("Test " +
     25         "String " +
     26         "4");
     27 
     28         // empty string
     29         String test5 = b.getString("");
     30     }
     31 }
     32 EOF
     33 
     34 tmpfiles="$tmpfiles xg-j-1.po"
     35 : ${XGETTEXT=xgettext}
     36 ${XGETTEXT} --omit-header --no-location -c -d xg-j-1 xg-j-1.java
     37 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
     38 
     39 tmpfiles="$tmpfiles xg-j-1.ok"
     40 cat <<EOF > xg-j-1.ok
     41 #. standard usage
     42 msgid "Test String 1"
     43 msgstr ""
     44 
     45 #. gettext usage
     46 msgid "Test String 2"
     47 msgstr ""
     48 
     49 #. C style comment
     50 msgid "Test String 3"
     51 msgstr ""
     52 
     53 #. java "multiline" string
     54 msgid "Test String 4"
     55 msgstr ""
     56 
     57 #. empty string
     58 msgid ""
     59 msgstr ""
     60 EOF
     61 
     62 : ${DIFF=diff}
     63 ${DIFF} xg-j-1.ok xg-j-1.po
     64 result=$?
     65 
     66 rm -fr $tmpfiles
     67 
     68 exit $result
     69