DecimalFormatSymbolsTest.java revision 561ee011997c6c2f1befbfaa9d5f0a99771c1d63
1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package org.apache.harmony.text.tests.java.text; 19 20import java.io.ByteArrayInputStream; 21import java.io.ByteArrayOutputStream; 22import java.io.File; 23import java.io.ObjectInputStream; 24import java.io.ObjectOutputStream; 25import java.net.URL; 26import java.text.DecimalFormat; 27import java.text.DecimalFormatSymbols; 28import java.text.NumberFormat; 29import java.util.Currency; 30import java.util.Locale; 31import java.util.ServiceConfigurationError; 32 33import junit.framework.TestCase; 34 35import org.apache.harmony.testframework.serialization.SerializationTest; 36import org.apache.harmony.text.tests.java.text.MockedDecimalFormatSymbolsProvider.MockedDecimalFormatSymbols; 37 38public class DecimalFormatSymbolsTest extends TestCase { 39 40 DecimalFormatSymbols dfs; 41 42 DecimalFormatSymbols dfsUS; 43 44 /** 45 * @tests java.text.DecimalFormatSymbols#DecimalFormatSymbols() 46 */ 47 public void test_Constructor() { 48 // Test for method java.text.DecimalFormatSymbols() 49 // Used in tests 50 } 51 52 /** 53 * @tests java.text.DecimalFormatSymbols#DecimalFormatSymbols(java.util.Locale) 54 */ 55 public void test_ConstructorLjava_util_Locale() { 56 DecimalFormatSymbols dfs = new DecimalFormatSymbols(new Locale("en", 57 "us")); 58 assertEquals("Returned incorrect symbols", '%', dfs.getPercent()); 59 } 60 61 62 /** 63 * @tests java.text.DecimalFormatSymbols#getAvailableLocales() 64 */ 65 public void test_getAvailableLocales_no_provider() throws Exception { 66 Locale[] locales = DecimalFormatSymbols.getAvailableLocales(); 67 assertNotNull(locales); 68 // must contain Locale.US 69 boolean flag = false; 70 for (Locale locale : locales) { 71 if (locale.equals(Locale.US)) { 72 flag = true; 73 break; 74 } 75 } 76 assertTrue(flag); 77 } 78 79 /** 80 * @tests java.text.DecimalFormatSymbols#getAvailableLocales() 81 */ 82 public void test_getAvailableLocales_correct_provider() throws Exception { 83 URL path1 = new File("src/test/resources/provider/correct").toURL(); 84 URL path2 = new File("resources/provider/correct").toURL(); 85 LoadLocaleProviderTestHelper helper = new LoadLocaleProviderTestHelper( 86 new URL[] { path1, path2 }) { 87 @Override 88 public void test() { 89 Locale[] locales = DecimalFormatSymbols.getAvailableLocales(); 90 assertNotNull(locales); 91 // must contain mock Locale 92 boolean flag = false; 93 for (Locale locale : locales) { 94 if (locale.getLanguage().equals("mock")) { 95 flag = true; 96 break; 97 } 98 } 99 assertTrue(flag); 100 } 101 102 }; 103 104 if (helper.getThrowable() != null) { 105 throw new Exception(helper.getThrowable()); 106 } 107 } 108 109 /** 110 * @tests java.text.DecimalFormatSymbols#getAvailableLocales() 111 */ 112 public void test_getAvailableLocales_wrong_provider() throws Exception { 113 URL path1 = new File("src/test/resources/provider/wrong").toURL(); 114 URL path2 = new File("resources/provider/wrong").toURL(); 115 LoadLocaleProviderTestHelper helper = new LoadLocaleProviderTestHelper( 116 new URL[] { path1, path2 }) { 117 @Override 118 public void test() { 119 try { 120 DecimalFormatSymbols.getAvailableLocales(); 121 fail("Should throw ServiceConfigurationError"); 122 } catch (ServiceConfigurationError e) { 123 // expected 124 } 125 } 126 }; 127 128 if (helper.getThrowable() != null) { 129 throw new Exception(helper.getThrowable()); 130 } 131 } 132 133 /** 134 * @tests java.text.DecimalFormatSymbols#getInstance() 135 */ 136 public void test_getInstance() { 137 assertEquals(new DecimalFormatSymbols(), DecimalFormatSymbols.getInstance()); 138 assertEquals(new DecimalFormatSymbols(Locale.getDefault()), 139 DecimalFormatSymbols.getInstance()); 140 141 assertNotSame(DecimalFormatSymbols.getInstance(), DecimalFormatSymbols.getInstance()); 142 } 143 144 /** 145 * @tests java.text.DecimalFormatSymbols#getInstance(Locale) 146 */ 147 public void test_getInstanceLjava_util_Locale() { 148 try { 149 DecimalFormatSymbols.getInstance(null); 150 fail("Should throw NullPointerException"); 151 } catch (NullPointerException e) { 152 // expected 153 } 154 155 assertEquals(new DecimalFormatSymbols(Locale.GERMANY), DecimalFormatSymbols 156 .getInstance(Locale.GERMANY)); 157 158 Locale locale = new Locale("not exist language", "not exist country"); 159 DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(locale); 160 assertNotNull(symbols); 161 assertEquals(DecimalFormatSymbols.getInstance(), symbols); 162 } 163 164 /** 165 * @tests java.text.DecimalFormatSymbols#getInstance(Locale) 166 */ 167 public void test_getInstanceLjava_util_Locale_no_provider() { 168 try { 169 DecimalFormatSymbols.getInstance(null); 170 fail("Should throw NullPointerException"); 171 } catch (NullPointerException e) { 172 // expected 173 } 174 175 assertEquals(new DecimalFormatSymbols(Locale.GERMANY), DecimalFormatSymbols 176 .getInstance(Locale.GERMANY)); 177 178 Locale locale = new Locale("not exist language", "not exist country"); 179 DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(locale); 180 assertNotNull(symbols); 181 assertEquals(DecimalFormatSymbols.getInstance(), symbols); 182 } 183 184 /** 185 * @tests java.text.DecimalFormatSymbols#getInstance(Locale) 186 */ 187 public void test_getInstanceLjava_util_Locale_correct_provider() 188 throws Exception { 189 URL path1 = new File("src/test/resources/provider/correct").toURL(); 190 URL path2 = new File("resources/provider/correct").toURL(); 191 LoadLocaleProviderTestHelper helper = new LoadLocaleProviderTestHelper( 192 new URL[] { path1, path2 }) { 193 @Override 194 public void test() { 195 DecimalFormatSymbols symbols = DecimalFormatSymbols 196 .getInstance(new Locale("Mock")); 197 assertTrue(symbols instanceof MockedDecimalFormatSymbols); 198 199 } 200 }; 201 202 if (helper.getThrowable() != null) { 203 throw new Exception(helper.getThrowable()); 204 } 205 } 206 207 /** 208 * @tests java.text.DecimalFormatSymbols#getInstance(Locale) 209 */ 210 public void test_getInstanceLjava_util_Locale_wrong_provider() 211 throws Exception { 212 URL path1 = new File("src/test/resources/provider/wrong").toURL(); 213 URL path2 = new File("resources/provider/wrong").toURL(); 214 LoadLocaleProviderTestHelper helper = new LoadLocaleProviderTestHelper( 215 new URL[] { path1, path2 }) { 216 @Override 217 public void test() { 218 try { 219 DecimalFormatSymbols symbols = DecimalFormatSymbols 220 .getInstance(new Locale("Mock")); 221 fail("Should throw ServiceConfigurationError"); 222 } catch (ServiceConfigurationError e) { 223 // expected 224 } 225 } 226 }; 227 228 if (helper.getThrowable() != null) { 229 throw new Exception(helper.getThrowable()); 230 } 231 } 232 233 /** 234 * @tests java.text.DecimalFormatSymbols#equals(java.lang.Object) 235 */ 236 public void test_equalsLjava_lang_Object() { 237 assertTrue("Equal objects returned false", dfs.equals(dfs.clone())); 238 dfs.setDigit('B'); 239 assertTrue("Un-Equal objects returned true", !dfs 240 .equals(new DecimalFormatSymbols())); 241 242 } 243 244 /** 245 * @tests java.text.DecimalFormatSymbols#getCurrency() 246 */ 247 public void test_getCurrency() { 248 Currency currency = Currency.getInstance("USD"); 249 assertEquals("Returned incorrect currency", 250 dfsUS.getCurrency(), currency); 251 252 Currency currK = Currency.getInstance("KRW"); 253 Currency currX = Currency.getInstance("XXX"); 254 Currency currE = Currency.getInstance("EUR"); 255 // Currency currF = Currency.getInstance("FRF"); 256 257 DecimalFormatSymbols dfs1 = new DecimalFormatSymbols(new Locale("ko", 258 "KR")); 259 assertTrue("Test1: Returned incorrect currency", 260 dfs1.getCurrency() == currK); 261 assertEquals("Test1: Returned incorrect currencySymbol", "\u20a9", dfs1 262 .getCurrencySymbol()); 263 assertEquals("Test1: Returned incorrect intlCurrencySymbol", "KRW", 264 dfs1.getInternationalCurrencySymbol()); 265 266 dfs1 = new DecimalFormatSymbols(new Locale("", "KR")); 267 assertTrue("Test2: Returned incorrect currency", 268 dfs1.getCurrency() == currK); 269 assertEquals("Test2: Returned incorrect currencySymbol", "\u20a9", dfs1 270 .getCurrencySymbol()); 271 assertEquals("Test2: Returned incorrect intlCurrencySymbol", "KRW", 272 dfs1.getInternationalCurrencySymbol()); 273 274 dfs1 = new DecimalFormatSymbols(new Locale("ko", "")); 275 assertTrue("Test3: Returned incorrect currency", 276 dfs1.getCurrency() == currX); 277 assertEquals("Test3: Returned incorrect currencySymbol", "\u00a4", dfs1 278 .getCurrencySymbol()); 279 assertEquals("Test3: Returned incorrect intlCurrencySymbol", "XXX", 280 dfs1.getInternationalCurrencySymbol()); 281 282 dfs1 = new DecimalFormatSymbols(new Locale("fr", "FR")); 283 assertTrue("Test4: Returned incorrect currency", 284 dfs1.getCurrency() == currE); 285 assertEquals("Test4: Returned incorrect currencySymbol", "\u20ac", dfs1 286 .getCurrencySymbol()); 287 assertEquals("Test4: Returned incorrect intlCurrencySymbol", "EUR", 288 dfs1.getInternationalCurrencySymbol()); 289 290 // RI fails these tests since it doesn't have the PREEURO variant 291 // dfs1 = new DecimalFormatSymbols(new Locale("fr", "FR","PREEURO")); 292 // assertTrue("Test5: Returned incorrect currency", dfs1.getCurrency() 293 // == currF); 294 // assertTrue("Test5: Returned incorrect currencySymbol", 295 // dfs1.getCurrencySymbol().equals("F")); 296 // assertTrue("Test5: Returned incorrect intlCurrencySymbol", 297 // dfs1.getInternationalCurrencySymbol().equals("FRF")); 298 } 299 300 /** 301 * @tests java.text.DecimalFormatSymbols#getCurrencySymbol() 302 */ 303 public void test_getCurrencySymbol() { 304 assertEquals("Returned incorrect currencySymbol", "$", dfsUS 305 .getCurrencySymbol()); 306 } 307 308 /** 309 * @tests java.text.DecimalFormatSymbols#getDecimalSeparator() 310 */ 311 public void test_getDecimalSeparator() { 312 dfs.setDecimalSeparator('*'); 313 assertEquals("Returned incorrect DecimalSeparator symbol", '*', dfs 314 .getDecimalSeparator()); 315 } 316 317 /** 318 * @tests java.text.DecimalFormatSymbols#getDigit() 319 */ 320 public void test_getDigit() { 321 dfs.setDigit('*'); 322 assertEquals("Returned incorrect Digit symbol", '*', dfs.getDigit()); 323 } 324 325 /** 326 * @tests java.text.DecimalFormatSymbols#getExponentSeparator() 327 */ 328 public void test_getExponentSeparator() { 329 dfs.setExponentSeparator("EE"); 330 assertEquals("Returned incorrect Exponent Separator symbol", "EE", dfs 331 .getExponentSeparator()); 332 } 333 334 /** 335 * @tests java.text.DecimalFormatSymbols#getGroupingSeparator() 336 */ 337 public void test_getGroupingSeparator() { 338 dfs.setGroupingSeparator('*'); 339 assertEquals("Returned incorrect GroupingSeparator symbol", '*', dfs 340 .getGroupingSeparator()); 341 } 342 343 /** 344 * @tests java.text.DecimalFormatSymbols#getInfinity() 345 */ 346 public void test_getInfinity() { 347 dfs.setInfinity("&"); 348 assertTrue("Returned incorrect Infinity symbol", 349 dfs.getInfinity() == "&"); 350 } 351 352 /** 353 * @tests java.text.DecimalFormatSymbols#getInternationalCurrencySymbol() 354 */ 355 public void test_getInternationalCurrencySymbol() { 356 assertEquals("Returned incorrect InternationalCurrencySymbol", "USD", 357 dfsUS.getInternationalCurrencySymbol()); 358 } 359 360 /** 361 * @tests java.text.DecimalFormatSymbols#getMinusSign() 362 */ 363 public void test_getMinusSign() { 364 dfs.setMinusSign('&'); 365 assertEquals("Returned incorrect MinusSign symbol", '&', dfs 366 .getMinusSign()); 367 } 368 369 /** 370 * @tests java.text.DecimalFormatSymbols#getNaN() 371 */ 372 public void test_getNaN() { 373 dfs.setNaN("NAN!!"); 374 assertEquals("Returned incorrect nan symbol", "NAN!!", dfs.getNaN()); 375 } 376 377 /** 378 * @tests java.text.DecimalFormatSymbols#getPatternSeparator() 379 */ 380 public void test_getPatternSeparator() { 381 dfs.setPatternSeparator('X'); 382 assertEquals("Returned incorrect PatternSeparator symbol", 'X', dfs 383 .getPatternSeparator()); 384 } 385 386 /** 387 * @tests java.text.DecimalFormatSymbols#getPercent() 388 */ 389 public void test_getPercent() { 390 dfs.setPercent('*'); 391 assertEquals("Returned incorrect Percent symbol", '*', dfs.getPercent()); 392 } 393 394 /** 395 * @tests java.text.DecimalFormatSymbols#getPerMill() 396 */ 397 public void test_getPerMill() { 398 dfs.setPerMill('#'); 399 assertEquals("Returned incorrect PerMill symbol", '#', dfs.getPerMill()); 400 } 401 402 /** 403 * @tests java.text.DecimalFormatSymbols#getZeroDigit() 404 */ 405 public void test_getZeroDigit() { 406 dfs.setZeroDigit('*'); 407 assertEquals("Returned incorrect ZeroDigit symbol", '*', dfs 408 .getZeroDigit()); 409 } 410 411 /** 412 * @tests java.text.DecimalFormatSymbols#setCurrency(java.util.Currency) 413 */ 414 public void test_setCurrencyLjava_util_Currency() { 415 Locale locale = Locale.CANADA; 416 DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat 417 .getCurrencyInstance(locale)).getDecimalFormatSymbols(); 418 419 try { 420 dfs.setCurrency(null); 421 fail("Expected NullPointerException"); 422 } catch (NullPointerException e) { 423 } 424 425 Currency currency = Currency.getInstance("JPY"); 426 dfs.setCurrency(currency); 427 428 assertTrue("Returned incorrect currency", currency == dfs.getCurrency()); 429 assertEquals("Returned incorrect currency symbol", currency.getSymbol( 430 locale), dfs.getCurrencySymbol()); 431 assertTrue("Returned incorrect international currency symbol", currency 432 .getCurrencyCode().equals(dfs.getInternationalCurrencySymbol())); 433 } 434 435 /** 436 * @tests java.text.DecimalFormatSymbols#setDecimalSeparator(char) 437 */ 438 public void test_setDecimalSeparatorC() { 439 dfs.setDecimalSeparator('*'); 440 assertEquals("Returned incorrect DecimalSeparator symbol", '*', dfs 441 .getDecimalSeparator()); 442 } 443 444 /** 445 * @tests java.text.DecimalFormatSymbols#setDigit(char) 446 */ 447 public void test_setDigitC() { 448 dfs.setDigit('*'); 449 assertEquals("Returned incorrect Digit symbol", '*', dfs.getDigit()); 450 } 451 452 /** 453 * @tests java.text.DecimalFormatSymbols#setExponentSeparator(String) 454 */ 455 public void test_setExponentSeparator() { 456 try { 457 dfs.setExponentSeparator(null); 458 fail("Should throw NullPointerException"); 459 } catch (NullPointerException e) { 460 // expected 461 } 462 463 dfs.setExponentSeparator(""); 464 assertEquals("Returned incorrect Exponent Separator symbol", "", dfs 465 .getExponentSeparator()); 466 467 dfs.setExponentSeparator("what ever you want"); 468 assertEquals("Returned incorrect Exponent Separator symbol", 469 "what ever you want", dfs.getExponentSeparator()); 470 471 dfs.setExponentSeparator(" E "); 472 assertEquals("Returned incorrect Exponent Separator symbol", " E ", dfs 473 .getExponentSeparator()); 474 } 475 476 /** 477 * @tests java.text.DecimalFormatSymbols#setGroupingSeparator(char) 478 */ 479 public void test_setGroupingSeparatorC() { 480 dfs.setGroupingSeparator('*'); 481 assertEquals("Returned incorrect GroupingSeparator symbol", '*', dfs 482 .getGroupingSeparator()); 483 } 484 485 /** 486 * @tests java.text.DecimalFormatSymbols#setInfinity(java.lang.String) 487 */ 488 public void test_setInfinityLjava_lang_String() { 489 dfs.setInfinity("&"); 490 assertTrue("Returned incorrect Infinity symbol", 491 dfs.getInfinity() == "&"); 492 } 493 494 /** 495 * @tests java.text.DecimalFormatSymbols#setInternationalCurrencySymbol(java.lang.String) 496 */ 497 public void test_setInternationalCurrencySymbolLjava_lang_String() { 498 Locale locale = Locale.CANADA; 499 DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat 500 .getCurrencyInstance(locale)).getDecimalFormatSymbols(); 501 Currency currency = Currency.getInstance("JPY"); 502 dfs.setInternationalCurrencySymbol(currency.getCurrencyCode()); 503 504 assertTrue("Test1: Returned incorrect currency", currency == dfs 505 .getCurrency()); 506 assertEquals("Test1: Returned incorrect currency symbol", currency 507 .getSymbol(locale), dfs.getCurrencySymbol()); 508 assertTrue("Test1: Returned incorrect international currency symbol", 509 currency.getCurrencyCode().equals( 510 dfs.getInternationalCurrencySymbol())); 511 512 dfs.setInternationalCurrencySymbol("bogus"); 513 // RI support this legacy country code 514 // assertNotNull("Test2: Returned incorrect currency", dfs.getCurrency()); 515 assertEquals("Test2: Returned incorrect international currency symbol", 516 "bogus", dfs.getInternationalCurrencySymbol()); 517 } 518 519 /** 520 * @tests java.text.DecimalFormatSymbols#setMinusSign(char) 521 */ 522 public void test_setMinusSignC() { 523 dfs.setMinusSign('&'); 524 assertEquals("Returned incorrect MinusSign symbol", '&', dfs 525 .getMinusSign()); 526 } 527 528 /** 529 * @tests java.text.DecimalFormatSymbols#setNaN(java.lang.String) 530 */ 531 public void test_setNaNLjava_lang_String() { 532 dfs.setNaN("NAN!!"); 533 assertEquals("Returned incorrect nan symbol", "NAN!!", dfs.getNaN()); 534 } 535 536 /** 537 * @tests java.text.DecimalFormatSymbols#setPatternSeparator(char) 538 */ 539 public void test_setPatternSeparatorC() { 540 dfs.setPatternSeparator('X'); 541 assertEquals("Returned incorrect PatternSeparator symbol", 'X', dfs 542 .getPatternSeparator()); 543 } 544 545 /** 546 * @tests java.text.DecimalFormatSymbols#setPercent(char) 547 */ 548 public void test_setPercentC() { 549 dfs.setPercent('*'); 550 assertEquals("Returned incorrect Percent symbol", '*', dfs.getPercent()); 551 } 552 553 /** 554 * @tests java.text.DecimalFormatSymbols#setPerMill(char) 555 */ 556 public void test_setPerMillC() { 557 dfs.setPerMill('#'); 558 assertEquals("Returned incorrect PerMill symbol", '#', dfs.getPerMill()); 559 } 560 561 /** 562 * @tests java.text.DecimalFormatSymbols#setZeroDigit(char) 563 */ 564 public void test_setZeroDigitC() { 565 dfs.setZeroDigit('*'); 566 assertEquals("Set incorrect ZeroDigit symbol", '*', dfs.getZeroDigit()); 567 } 568 569 /** 570 * Sets up the fixture, for example, open a network connection. This method 571 * is called before a test is executed. 572 */ 573 protected void setUp() { 574 dfs = new DecimalFormatSymbols(); 575 dfsUS = new DecimalFormatSymbols(new Locale("en", "us")); 576 } 577 578 /** 579 * Tears down the fixture, for example, close a network connection. This 580 * method is called after a test is executed. 581 */ 582 protected void tearDown() { 583 } 584 585 // Test serialization mechanism of DecimalFormatSymbols 586 public void test_serialization() throws Exception { 587 DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.FRANCE); 588 Currency currency = symbols.getCurrency(); 589 assertNotNull(currency); 590 591 // serialize 592 ByteArrayOutputStream byteOStream = new ByteArrayOutputStream(); 593 ObjectOutputStream objectOStream = new ObjectOutputStream(byteOStream); 594 objectOStream.writeObject(symbols); 595 596 // and deserialize 597 ObjectInputStream objectIStream = new ObjectInputStream( 598 new ByteArrayInputStream(byteOStream.toByteArray())); 599 DecimalFormatSymbols symbolsD = (DecimalFormatSymbols) objectIStream 600 .readObject(); 601 602 // The associated currency will not persist 603 currency = symbolsD.getCurrency(); 604 assertNotNull(currency); 605 } 606 607 /** 608 * Assert that Harmony can correct read an instance that was created by 609 * the Java 1.5 RI. The actual values may differ on Harmony and other JREs, 610 * so we only assert the values that are known to be in the serialized data. 611 */ 612 public void test_RIHarmony_compatible() throws Exception { 613 DecimalFormatSymbols dfs; 614 ObjectInputStream i = null; 615 try { 616 i = new ObjectInputStream(getClass().getClassLoader().getResourceAsStream( 617 "/serialization/java/text/DecimalFormatSymbols.ser")); 618 dfs = (DecimalFormatSymbols) i.readObject(); 619 } finally { 620 try { 621 if (i != null) { 622 i.close(); 623 } 624 } catch (Exception e) { 625 } 626 } 627 assertDecimalFormatSymbolsRIFrance(dfs); 628 } 629 630 static void assertDecimalFormatSymbolsRIFrance(DecimalFormatSymbols dfs) { 631 // Values based on Java 1.5 RI DecimalFormatSymbols for Locale.FRANCE 632 /* 633 * currency = [EUR] 634 * currencySymbol = [€][U+20ac] 635 * decimalSeparator = [,][U+002c] 636 * digit = [#][U+0023] 637 * groupingSeparator = [ ][U+00a0] 638 * infinity = [∞][U+221e] 639 * internationalCurrencySymbol = [EUR] 640 * minusSign = [-][U+002d] 641 * monetaryDecimalSeparator = [,][U+002c] 642 * naN = [�][U+fffd] 643 * patternSeparator = [;][U+003b] 644 * perMill = [‰][U+2030] 645 * percent = [%][U+0025] 646 * zeroDigit = [0][U+0030] 647 */ 648 assertEquals("EUR", dfs.getCurrency().getCurrencyCode()); 649 assertEquals("\u20AC", dfs.getCurrencySymbol()); 650 assertEquals(',', dfs.getDecimalSeparator()); 651 assertEquals('#', dfs.getDigit()); 652 assertEquals('\u00a0', dfs.getGroupingSeparator()); 653 assertEquals("\u221e", dfs.getInfinity()); 654 assertEquals("EUR", dfs.getInternationalCurrencySymbol()); 655 assertEquals('-', dfs.getMinusSign()); 656 assertEquals(',', dfs.getMonetaryDecimalSeparator()); 657 // RI's default NaN is U+FFFD, Harmony's is based on ICU 658 assertEquals("\uFFFD", dfs.getNaN()); 659 assertEquals('\u003b', dfs.getPatternSeparator()); 660 assertEquals('\u2030', dfs.getPerMill()); 661 assertEquals('%', dfs.getPercent()); 662 assertEquals('0', dfs.getZeroDigit()); 663 } 664 665 /** 666 * @tests serialization/deserialization compatibility with RI6. 667 */ 668 public void testSerializationCompatibility() throws Exception { 669 DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US); 670 symbols.setExponentSeparator("EE"); 671 symbols.setNaN("NaN"); 672 SerializationTest.verifyGolden(this, symbols); 673 } 674 675 /** 676 * @tests serialization/deserialization compatibility. 677 */ 678 public void testSerializationSelf() throws Exception { 679 DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.ITALIAN); 680 SerializationTest.verifySelf(symbols); 681 } 682} 683