Search in sources :

Example 81 with DecimalFormatSymbols

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

the class DecimalFormatSymbolsTest method testSerializationCompatibility.

/**
     * @tests serialization/deserialization compatibility with RI6.
     */
public void testSerializationCompatibility() throws Exception {
    DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
    symbols.setExponentSeparator("EE");
    symbols.setNaN("NaN");
    SerializationTest.verifyGolden(this, symbols);
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols)

Example 82 with DecimalFormatSymbols

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

the class DecimalFormatSymbolsTest method test_RIHarmony_compatible.

/**
     * Assert that Harmony can correct read an instance that was created by
     * the Java 1.5 RI. The actual values may differ on Harmony and other JREs,
     * so we only assert the values that are known to be in the serialized data.
     */
public void test_RIHarmony_compatible() throws Exception {
    DecimalFormatSymbols dfs;
    ObjectInputStream i = null;
    try {
        i = new ObjectInputStream(getClass().getClassLoader().getResourceAsStream("serialization/org/apache/harmony/tests/java/text/DecimalFormatSymbols.ser"));
        dfs = (DecimalFormatSymbols) i.readObject();
    } finally {
        try {
            if (i != null) {
                i.close();
            }
        } catch (Exception e) {
        }
    }
    assertDecimalFormatSymbolsRIFrance(dfs);
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols) ObjectInputStream(java.io.ObjectInputStream)

Example 83 with DecimalFormatSymbols

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

the class DecimalFormatSymbolsTest method test_getInstance.

/**
     * @tests java.text.DecimalFormatSymbols#getInstance()
     */
public void test_getInstance() {
    assertEquals(new DecimalFormatSymbols(), DecimalFormatSymbols.getInstance());
    assertEquals(new DecimalFormatSymbols(Locale.getDefault()), DecimalFormatSymbols.getInstance());
    assertNotSame(DecimalFormatSymbols.getInstance(), DecimalFormatSymbols.getInstance());
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols)

Example 84 with DecimalFormatSymbols

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

the class DecimalFormatSymbolsTest method setUp.

/**
     * Sets up the fixture, for example, open a network connection. This method
     * is called before a test is executed.
     */
protected void setUp() {
    dfs = new DecimalFormatSymbols();
    dfsUS = new DecimalFormatSymbols(new Locale("en", "us"));
}
Also used : Locale(java.util.Locale) DecimalFormatSymbols(java.text.DecimalFormatSymbols)

Example 85 with DecimalFormatSymbols

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

the class DecimalFormatSymbolsTest method test_setCurrencyLjava_util_Currency.

/**
     * @tests java.text.DecimalFormatSymbols#setCurrency(java.util.Currency)
     */
public void test_setCurrencyLjava_util_Currency() {
    Locale locale = Locale.CANADA;
    DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat.getCurrencyInstance(locale)).getDecimalFormatSymbols();
    try {
        dfs.setCurrency(null);
        fail("Expected NullPointerException");
    } catch (NullPointerException e) {
    }
    Currency currency = Currency.getInstance("JPY");
    dfs.setCurrency(currency);
    assertTrue("Returned incorrect currency", currency == dfs.getCurrency());
    assertEquals("Returned incorrect currency symbol", currency.getSymbol(locale), dfs.getCurrencySymbol());
    assertTrue("Returned incorrect international currency symbol", currency.getCurrencyCode().equals(dfs.getInternationalCurrencySymbol()));
}
Also used : Locale(java.util.Locale) DecimalFormatSymbols(java.text.DecimalFormatSymbols) DecimalFormat(java.text.DecimalFormat) Currency(java.util.Currency)

Aggregations

DecimalFormatSymbols (java.text.DecimalFormatSymbols)133 DecimalFormat (java.text.DecimalFormat)93 NumberFormat (java.text.NumberFormat)14 Locale (java.util.Locale)13 ParseException (java.text.ParseException)8 BigDecimal (java.math.BigDecimal)7 Currency (java.util.Currency)7 ObjectInputStream (java.io.ObjectInputStream)6 Test (org.junit.Test)6 IOException (java.io.IOException)5 ParsePosition (java.text.ParsePosition)5 BufferedChecksumIndexInput (org.apache.lucene.store.BufferedChecksumIndexInput)5 ChecksumIndexInput (org.apache.lucene.store.ChecksumIndexInput)5 IndexInput (org.apache.lucene.store.IndexInput)5 BytesRefBuilder (org.apache.lucene.util.BytesRefBuilder)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 ObjectOutputStream (java.io.ObjectOutputStream)4 BytesRef (org.apache.lucene.util.BytesRef)4 ArrayList (java.util.ArrayList)3