Search in sources :

Example 46 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 47 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 48 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 49 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 50 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)690 LogMessage (org.apache.qpid.server.logging.LogMessage)105 CertificateException (java.security.cert.CertificateException)52 KeyStoreException (java.security.KeyStoreException)48 IOException (java.io.IOException)47 UnrecoverableKeyException (java.security.UnrecoverableKeyException)46 UnrecoverableEntryException (java.security.UnrecoverableEntryException)43 CertStoreException (java.security.cert.CertStoreException)43 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)33 X509Certificate (java.security.cert.X509Certificate)30 ArrayList (java.util.ArrayList)27 ResourceBundle (java.util.ResourceBundle)27 Date (java.util.Date)23 Locale (java.util.Locale)22 File (java.io.File)21 Certificate (java.security.cert.Certificate)19 PrivateKey (java.security.PrivateKey)16 Format (java.text.Format)16 MissingResourceException (java.util.MissingResourceException)16 HashMap (java.util.HashMap)15