Search in sources :

Example 31 with MessageFormat

use of java.text.MessageFormat in project j2objc by google.

the class MessageFormatTest method setUp.

protected void setUp() {
    defaultLocale = Locale.getDefault();
    Locale.setDefault(Locale.US);
    // test with repeating formats and max argument index < max offset
    String pattern = "A {3, number, currency} B {2, time} C {0, number, percent} D {4}  E {1,choice,0#off|1#on} F {0, date}";
    format1 = new MessageFormat(pattern);
    // test with max argument index > max offset
    pattern = "A {3, number, currency} B {8, time} C {0, number, percent} D {6}  E {1,choice,0#off|1#on} F {0, date}";
    format2 = new MessageFormat(pattern);
    // test with argument number being zero
    pattern = "A B C D E F";
    format3 = new MessageFormat(pattern);
}
Also used : MessageFormat(java.text.MessageFormat)

Example 32 with MessageFormat

use of java.text.MessageFormat in project j2objc by google.

the class MessageFormatTest method test_formatToCharacterIteratorLjava_lang_Object.

public void test_formatToCharacterIteratorLjava_lang_Object() {
    new Support_MessageFormat("test_formatToCharacterIteratorLjava_lang_Object").t_formatToCharacterIterator();
    try {
        new MessageFormat("{1, number}").formatToCharacterIterator(null);
        fail();
    } catch (NullPointerException expected) {
    }
    try {
        new MessageFormat("{0, time}").formatToCharacterIterator(new Object[] { "" });
        fail();
    } catch (IllegalArgumentException expected) {
    }
}
Also used : MessageFormat(java.text.MessageFormat)

Example 33 with MessageFormat

use of java.text.MessageFormat in project j2objc by google.

the class MessageFormatTest method test19011159.

// http://b/19011159
public void test19011159() {
    final String pattern = "ab{0,choice,0#1'2''3'''4''''.}yz";
    final MessageFormat format = new MessageFormat(pattern, Locale.ENGLISH);
    final Object[] zero0 = new Object[] { 0 };
    assertEquals("ab12'3'4''.yz", format.format(zero0));
}
Also used : MessageFormat(java.text.MessageFormat)

Example 34 with MessageFormat

use of java.text.MessageFormat in project j2objc by google.

the class MessageFormatTest method test_getLocale.

public void test_getLocale() throws Exception {
    Locale[] l = { Locale.FRANCE, Locale.KOREA, // Deliberately backwards.
    new Locale("FR", "fr"), new Locale("mk"), new Locale("mk", "MK"), Locale.US, // Deliberately nonsense.
    new Locale("#ru", "@31230") };
    String pattern = "getLocale test {0,number,#,####}";
    for (int i = 0; i < 0; i++) {
        MessageFormat mf = new MessageFormat(pattern, l[i]);
        Locale result = mf.getLocale();
        assertEquals(l[i], result);
        assertEquals(l[i].getLanguage(), result.getLanguage());
        assertEquals(l[i].getCountry(), result.getCountry());
    }
    MessageFormat mf = new MessageFormat(pattern);
    mf.setLocale(null);
    Locale result = mf.getLocale();
    assertEquals(null, result);
}
Also used : Locale(java.util.Locale) MessageFormat(java.text.MessageFormat)

Example 35 with MessageFormat

use of java.text.MessageFormat in project j2objc by google.

the class MessageFormatTest method checkSerialization.

private void checkSerialization(MessageFormat format) {
    try {
        ByteArrayOutputStream ba = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(ba);
        out.writeObject(format);
        out.close();
        ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(ba.toByteArray()));
        MessageFormat read = (MessageFormat) in.readObject();
        assertTrue("Not equal: " + format.toPattern(), format.equals(read));
    } catch (IOException e) {
        fail("Format: " + format.toPattern() + " caused IOException: " + e);
    } catch (ClassNotFoundException e) {
        fail("Format: " + format.toPattern() + " caused ClassNotFoundException: " + e);
    }
}
Also used : MessageFormat(java.text.MessageFormat) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

MessageFormat (java.text.MessageFormat)237 CertificateException (java.security.cert.CertificateException)27 KeyStoreException (java.security.KeyStoreException)23 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)22 UnrecoverableKeyException (java.security.UnrecoverableKeyException)22 Date (java.util.Date)22 UnrecoverableEntryException (java.security.UnrecoverableEntryException)21 CertStoreException (java.security.cert.CertStoreException)21 X509Certificate (java.security.cert.X509Certificate)17 File (java.io.File)14 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)13 Format (java.text.Format)12 Support_MessageFormat (tests.support.Support_MessageFormat)12 Certificate (java.security.cert.Certificate)10 ChoiceFormat (java.text.ChoiceFormat)10 DateFormat (java.text.DateFormat)10 MissingResourceException (java.util.MissingResourceException)10 SimpleDateFormat (java.text.SimpleDateFormat)9 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)9