1 16 17 package org.apache.commons.configuration; 18 19 import java.awt.Color ; 20 import java.math.BigDecimal ; 21 import java.math.BigInteger ; 22 import java.net.URL ; 23 import java.util.ArrayList ; 24 import java.util.List ; 25 import java.util.Locale ; 26 import java.util.Date ; 27 import java.util.Calendar ; 28 import java.text.DateFormat ; 29 import java.text.SimpleDateFormat ; 30 31 import junit.framework.TestCase; 32 import junitx.framework.ArrayAssert; 33 import junitx.framework.ListAssert; 34 35 39 public class TestDataConfiguration extends TestCase 40 { 41 private DataConfiguration conf; 42 43 protected void setUp() throws Exception 44 { 45 conf = new DataConfiguration(new BaseConfiguration()); 46 47 conf.addProperty("empty", ""); 49 50 conf.addProperty("boolean.list1", "true"); 52 conf.addProperty("boolean.list1", "false"); 53 conf.addProperty("boolean.list2", "true, false"); 54 conf.addProperty("boolean.list3", Boolean.TRUE); 55 conf.addProperty("boolean.list3", Boolean.FALSE); 56 conf.addProperty("boolean.list4", new Boolean [] { Boolean.TRUE, Boolean.FALSE }); 57 conf.addProperty("boolean.list5", new boolean[] { true, false }); 58 List booleans = new ArrayList (); 59 booleans.add(Boolean.TRUE); 60 booleans.add(Boolean.FALSE); 61 conf.addProperty("boolean.list6", booleans); 62 conf.addProperty("boolean.string", "true"); 63 conf.addProperty("boolean.object", Boolean.TRUE); 64 65 conf.addProperty("byte.list1", "1"); 67 conf.addProperty("byte.list1", "2"); 68 conf.addProperty("byte.list2", "1, 2"); 69 conf.addProperty("byte.list3", new Byte ("1")); 70 conf.addProperty("byte.list3", new Byte ("2")); 71 conf.addProperty("byte.list4", new Byte [] { new Byte ("1"), new Byte ("2") }); 72 conf.addProperty("byte.list5", new byte[] { 1, 2 }); 73 List bytes = new ArrayList (); 74 bytes.add(new Byte ("1")); 75 bytes.add(new Byte ("2")); 76 conf.addProperty("byte.list6", bytes); 77 conf.addProperty("byte.string", "1"); 78 conf.addProperty("byte.object", new Byte ("1")); 79 80 conf.addProperty("short.list1", "1"); 82 conf.addProperty("short.list1", "2"); 83 conf.addProperty("short.list2", "1, 2"); 84 conf.addProperty("short.list3", new Short ("1")); 85 conf.addProperty("short.list3", new Short ("2")); 86 conf.addProperty("short.list4", new Short [] { new Short ("1"), new Short ("2") }); 87 conf.addProperty("short.list5", new short[] { 1, 2 }); 88 List shorts = new ArrayList (); 89 shorts.add(new Short ("1")); 90 shorts.add(new Short ("2")); 91 conf.addProperty("short.list6", shorts); 92 conf.addProperty("short.string", "1"); 93 conf.addProperty("short.object", new Short ("1")); 94 95 conf.addProperty("integer.list1", "1"); 97 conf.addProperty("integer.list1", "2"); 98 conf.addProperty("integer.list2", "1, 2"); 99 conf.addProperty("integer.list3", new Integer ("1")); 100 conf.addProperty("integer.list3", new Integer ("2")); 101 conf.addProperty("integer.list4", new Integer [] { new Integer ("1"), new Integer ("2") }); 102 conf.addProperty("integer.list5", new int[] { 1, 2 }); 103 List integers = new ArrayList (); 104 integers.add(new Integer ("1")); 105 integers.add(new Integer ("2")); 106 conf.addProperty("integer.list6", integers); 107 conf.addProperty("integer.string", "1"); 108 conf.addProperty("integer.object", new Integer ("1")); 109 110 conf.addProperty("long.list1", "1"); 112 conf.addProperty("long.list1", "2"); 113 conf.addProperty("long.list2", "1, 2"); 114 conf.addProperty("long.list3", new Long ("1")); 115 conf.addProperty("long.list3", new Long ("2")); 116 conf.addProperty("long.list4", new Long [] { new Long ("1"), new Long ("2") }); 117 conf.addProperty("long.list5", new long[] { 1, 2 }); 118 List longs = new ArrayList (); 119 longs.add(new Long ("1")); 120 longs.add(new Long ("2")); 121 conf.addProperty("long.list6", longs); 122 conf.addProperty("long.string", "1"); 123 conf.addProperty("long.object", new Long ("1")); 124 125 conf.addProperty("float.list1", "1"); 127 conf.addProperty("float.list1", "2"); 128 conf.addProperty("float.list2", "1, 2"); 129 conf.addProperty("float.list3", new Float ("1")); 130 conf.addProperty("float.list3", new Float ("2")); 131 conf.addProperty("float.list4", new Float [] { new Float ("1"), new Float ("2") }); 132 conf.addProperty("float.list5", new float[] { 1, 2 }); 133 List floats = new ArrayList (); 134 floats.add(new Float ("1")); 135 floats.add(new Float ("2")); 136 conf.addProperty("float.list6", floats); 137 conf.addProperty("float.string", "1"); 138 conf.addProperty("float.object", new Float ("1")); 139 140 conf.addProperty("double.list1", "1"); 142 conf.addProperty("double.list1", "2"); 143 conf.addProperty("double.list2", "1, 2"); 144 conf.addProperty("double.list3", new Double ("1")); 145 conf.addProperty("double.list3", new Double ("2")); 146 conf.addProperty("double.list4", new Double [] { new Double ("1"), new Double ("2") }); 147 conf.addProperty("double.list5", new double[] { 1, 2 }); 148 List doubles = new ArrayList (); 149 doubles.add(new Double ("1")); 150 doubles.add(new Double ("2")); 151 conf.addProperty("double.list6", doubles); 152 conf.addProperty("double.string", "1"); 153 conf.addProperty("double.object", new Double ("1")); 154 155 conf.addProperty("biginteger.list1", "1"); 157 conf.addProperty("biginteger.list1", "2"); 158 conf.addProperty("biginteger.list2", "1, 2"); 159 conf.addProperty("biginteger.list3", new BigInteger ("1")); 160 conf.addProperty("biginteger.list3", new BigInteger ("2")); 161 conf.addProperty("biginteger.list4", new BigInteger [] { new BigInteger ("1"), new BigInteger ("2") }); 162 List bigintegers = new ArrayList (); 163 bigintegers.add(new BigInteger ("1")); 164 bigintegers.add(new BigInteger ("2")); 165 conf.addProperty("biginteger.list6", bigintegers); 166 conf.addProperty("biginteger.string", "1"); 167 conf.addProperty("biginteger.object", new BigInteger ("1")); 168 169 conf.addProperty("bigdecimal.list1", "1"); 171 conf.addProperty("bigdecimal.list1", "2"); 172 conf.addProperty("bigdecimal.list2", "1, 2"); 173 conf.addProperty("bigdecimal.list3", new BigDecimal ("1")); 174 conf.addProperty("bigdecimal.list3", new BigDecimal ("2")); 175 conf.addProperty("bigdecimal.list4", new BigDecimal [] { new BigDecimal ("1"), new BigDecimal ("2") }); 176 List bigdecimals = new ArrayList (); 177 bigdecimals.add(new BigDecimal ("1")); 178 bigdecimals.add(new BigDecimal ("2")); 179 conf.addProperty("bigdecimal.list6", bigdecimals); 180 conf.addProperty("bigdecimal.string", "1"); 181 conf.addProperty("bigdecimal.object", new BigDecimal ("1")); 182 183 conf.addProperty("url.string", "http://jakarta.apache.org"); 185 conf.addProperty("url.object", new URL ("http://jakarta.apache.org")); 186 conf.addProperty("url.list1", "http://jakarta.apache.org"); 187 conf.addProperty("url.list1", "http://www.apache.org"); 188 conf.addProperty("url.list2", "http://jakarta.apache.org, http://www.apache.org"); 189 conf.addProperty("url.list3", new URL ("http://jakarta.apache.org")); 190 conf.addProperty("url.list3", new URL ("http://www.apache.org")); 191 conf.addProperty("url.list4", new URL [] { new URL ("http://jakarta.apache.org"), new URL ("http://www.apache.org") }); 192 List urls = new ArrayList (); 193 urls.add(new URL ("http://jakarta.apache.org")); 194 urls.add(new URL ("http://www.apache.org")); 195 conf.addProperty("url.list6", urls); 196 197 conf.addProperty("locale.string", "fr"); 199 conf.addProperty("locale.object", Locale.FRENCH); 200 conf.addProperty("locale.list1", "fr"); 201 conf.addProperty("locale.list1", "de"); 202 conf.addProperty("locale.list2", "fr, de"); 203 conf.addProperty("locale.list3", Locale.FRENCH); 204 conf.addProperty("locale.list3", Locale.GERMAN); 205 conf.addProperty("locale.list4", new Locale [] { Locale.FRENCH, Locale.GERMAN }); 206 List locales = new ArrayList (); 207 locales.add(Locale.FRENCH); 208 locales.add(Locale.GERMAN); 209 conf.addProperty("locale.list6", locales); 210 211 conf.addProperty("color.string", "FF0000"); 213 conf.addProperty("color.object", Color.red); 214 conf.addProperty("color.list1", "FF0000"); 215 conf.addProperty("color.list1", "0000FF"); 216 conf.addProperty("color.list2", "FF0000, 0000FF"); 217 conf.addProperty("color.list3", Color.red); 218 conf.addProperty("color.list3", Color.blue); 219 conf.addProperty("color.list4", new Color [] { Color.red, Color.blue }); 220 List colors = new ArrayList (); 221 colors.add(Color.red); 222 colors.add(Color.blue); 223 conf.addProperty("color.list6", colors); 224 225 String pattern = "yyyy-MM-dd"; 227 DateFormat format = new SimpleDateFormat (pattern); 228 conf.setProperty(DataConfiguration.DATE_FORMAT_KEY, pattern); 229 230 Date date1 = format.parse("2004-01-01"); 231 Date date2 = format.parse("2004-12-31"); 232 Calendar calendar1 = Calendar.getInstance(); 233 calendar1.setTime(date1); 234 Calendar calendar2 = Calendar.getInstance(); 235 calendar2.setTime(date2); 236 237 conf.addProperty("date.string", "2004-01-01"); 238 conf.addProperty("date.object", date1); 239 conf.addProperty("date.list1", "2004-01-01"); 240 conf.addProperty("date.list1", "2004-12-31"); 241 conf.addProperty("date.list2", "2004-01-01, 2004-12-31"); 242 conf.addProperty("date.list3", date1); 243 conf.addProperty("date.list3", date2); 244 conf.addProperty("date.list4", new Date [] { date1, date2 }); 245 conf.addProperty("date.list5", new Calendar [] { calendar1, calendar2 }); 246 List dates = new ArrayList (); 247 dates.add(date1); 248 dates.add(date2); 249 conf.addProperty("date.list6", dates); 250 251 conf.addProperty("calendar.string", "2004-01-01"); 252 conf.addProperty("calendar.object", calendar1); 253 conf.addProperty("calendar.list1", "2004-01-01"); 254 conf.addProperty("calendar.list1", "2004-12-31"); 255 conf.addProperty("calendar.list2", "2004-01-01, 2004-12-31"); 256 conf.addProperty("calendar.list3", calendar1); 257 conf.addProperty("calendar.list3", calendar2); 258 conf.addProperty("calendar.list4", new Calendar [] { calendar1, calendar2 }); 259 conf.addProperty("calendar.list5", new Date [] { date1, date2 }); 260 List calendars = new ArrayList (); 261 calendars.add(date1); 262 calendars.add(date2); 263 conf.addProperty("calendar.list6", calendars); 264 } 265 266 public void testGetBooleanArray() 267 { 268 boolean[] defaultValue = new boolean[] { false, true }; 270 ArrayAssert.assertEquals(defaultValue, conf.getBooleanArray("boolean.list", defaultValue)); 271 272 boolean[] expected = new boolean[] { true, false }; 273 274 ArrayAssert.assertEquals(expected, conf.getBooleanArray("boolean.list1")); 276 277 ArrayAssert.assertEquals(expected, conf.getBooleanArray("boolean.list2")); 279 280 ArrayAssert.assertEquals(expected, conf.getBooleanArray("boolean.list3")); 282 283 ArrayAssert.assertEquals(expected, conf.getBooleanArray("boolean.list4")); 285 286 ArrayAssert.assertEquals(expected, conf.getBooleanArray("boolean.list5")); 288 289 ArrayAssert.assertEquals(expected, conf.getBooleanArray("boolean.list6")); 291 292 ArrayAssert.assertEquals(new boolean[] { true }, conf.getBooleanArray("boolean.string")); 294 ArrayAssert.assertEquals(new boolean[] { true }, conf.getBooleanArray("boolean.object")); 295 296 ArrayAssert.assertEquals(new boolean[] { }, conf.getBooleanArray("empty")); 298 } 299 300 public void testGetBooleanList() 301 { 302 ListAssert.assertEquals(null, conf.getBooleanList("boolean.list", null)); 304 305 List expected = new ArrayList (); 306 expected.add(Boolean.TRUE); 307 expected.add(Boolean.FALSE); 308 309 ListAssert.assertEquals(expected, conf.getBooleanList("boolean.list1")); 311 312 ListAssert.assertEquals(expected, conf.getBooleanList("boolean.list2")); 314 315 ListAssert.assertEquals(expected, conf.getBooleanList("boolean.list3")); 317 318 ListAssert.assertEquals(expected, conf.getBooleanList("boolean.list4")); 320 321 ListAssert.assertEquals(expected, conf.getBooleanList("boolean.list5")); 323 324 ListAssert.assertEquals(expected, conf.getBooleanList("boolean.list6")); 326 327 expected = new ArrayList (); 329 expected.add(Boolean.TRUE); 330 ListAssert.assertEquals(expected, conf.getBooleanList("boolean.string")); 331 ListAssert.assertEquals(expected, conf.getBooleanList("boolean.object")); 332 333 ListAssert.assertEquals(new ArrayList (), conf.getBooleanList("empty")); 335 } 336 337 public void testGetByteArray() 338 { 339 byte[] defaultValue = new byte[] { 1, 2}; 341 ArrayAssert.assertEquals(defaultValue, conf.getByteArray("byte.list", defaultValue)); 342 343 byte[] expected = new byte[] { 1, 2 }; 344 345 ArrayAssert.assertEquals(expected, conf.getByteArray("byte.list1")); 347 348 ArrayAssert.assertEquals(expected, conf.getByteArray("byte.list2")); 350 351 ArrayAssert.assertEquals(expected, conf.getByteArray("byte.list3")); 353 354 ArrayAssert.assertEquals(expected, conf.getByteArray("byte.list4")); 356 357 ArrayAssert.assertEquals(expected, conf.getByteArray("byte.list5")); 359 360 ArrayAssert.assertEquals(expected, conf.getByteArray("byte.list6")); 362 363 ArrayAssert.assertEquals(new byte[] { 1 }, conf.getByteArray("byte.string")); 365 ArrayAssert.assertEquals(new byte[] { 1 }, conf.getByteArray("byte.object")); 366 367 ArrayAssert.assertEquals(new byte[] { }, conf.getByteArray("empty")); 369 } 370 371 public void testGetByteList() 372 { 373 ListAssert.assertEquals(null, conf.getByteList("byte.list", null)); 375 376 List expected = new ArrayList (); 377 expected.add(new Byte ("1")); 378 expected.add(new Byte ("2")); 379 380 ListAssert.assertEquals(expected, conf.getByteList("byte.list1")); 382 383 ListAssert.assertEquals(expected, conf.getByteList("byte.list2")); 385 386 ListAssert.assertEquals(expected, conf.getByteList("byte.list3")); 388 389 ListAssert.assertEquals(expected, conf.getByteList("byte.list4")); 391 392 ListAssert.assertEquals(expected, conf.getByteList("byte.list5")); 394 395 ListAssert.assertEquals(expected, conf.getByteList("byte.list6")); 397 398 expected = new ArrayList (); 400 expected.add(new Byte ("1")); 401 ListAssert.assertEquals(expected, conf.getByteList("byte.string")); 402 ListAssert.assertEquals(expected, conf.getByteList("byte.object")); 403 404 ListAssert.assertEquals(new ArrayList (), conf.getByteList("empty")); 406 } 407 408 public void testGetShortArray() 409 { 410 short[] defaultValue = new short[] { 2, 1}; 412 ArrayAssert.assertEquals(defaultValue, conf.getShortArray("short.list", defaultValue)); 413 414 short[] expected = new short[] { 1, 2 }; 415 416 ArrayAssert.assertEquals(expected, conf.getShortArray("short.list1")); 418 419 ArrayAssert.assertEquals(expected, conf.getShortArray("short.list2")); 421 422 ArrayAssert.assertEquals(expected, conf.getShortArray("short.list3")); 424 425 ArrayAssert.assertEquals(expected, conf.getShortArray("short.list4")); 427 428 ArrayAssert.assertEquals(expected, conf.getShortArray("short.list5")); 430 431 ArrayAssert.assertEquals(expected, conf.getShortArray("short.list6")); 433 434 ArrayAssert.assertEquals(new short[] { 1 }, conf.getShortArray("short.string")); 436 ArrayAssert.assertEquals(new short[] { 1 }, conf.getShortArray("short.object")); 437 438 ArrayAssert.assertEquals(new short[] { }, conf.getShortArray("empty")); 440 } 441 442 public void testGetShortList() 443 { 444 ListAssert.assertEquals(null, conf.getShortList("short.list", null)); 446 447 List expected = new ArrayList (); 448 expected.add(new Short ("1")); 449 expected.add(new Short ("2")); 450 451 ListAssert.assertEquals(expected, conf.getShortList("short.list1")); 453 454 ListAssert.assertEquals(expected, conf.getShortList("short.list2")); 456 457 ListAssert.assertEquals(expected, conf.getShortList("short.list3")); 459 460 ListAssert.assertEquals(expected, conf.getShortList("short.list4")); 462 463 ListAssert.assertEquals(expected, conf.getShortList("short.list5")); 465 466 ListAssert.assertEquals(expected, conf.getShortList("short.list6")); 468 469 expected = new ArrayList (); 471 expected.add(new Short ("1")); 472 ListAssert.assertEquals(expected, conf.getShortList("short.string")); 473 ListAssert.assertEquals(expected, conf.getShortList("short.object")); 474 475 ListAssert.assertEquals(new ArrayList (), conf.getShortList("empty")); 477 } 478 479 public void testGetIntegerArray() 480 { 481 int[] defaultValue = new int[] { 2, 1}; 483 ArrayAssert.assertEquals(defaultValue, conf.getIntArray("integer.list", defaultValue)); 484 485 int[] expected = new int[] { 1, 2 }; 486 487 ArrayAssert.assertEquals(expected, conf.getIntArray("integer.list1")); 489 490 ArrayAssert.assertEquals(expected, conf.getIntArray("integer.list2")); 492 493 ArrayAssert.assertEquals(expected, conf.getIntArray("integer.list3")); 495 496 ArrayAssert.assertEquals(expected, conf.getIntArray("integer.list4")); 498 499 ArrayAssert.assertEquals(expected, conf.getIntArray("integer.list5")); 501 502 ArrayAssert.assertEquals(expected, conf.getIntArray("integer.list6")); 504 505 ArrayAssert.assertEquals(new int[] { 1 }, conf.getIntArray("integer.string")); 507 ArrayAssert.assertEquals(new int[] { 1 }, conf.getIntArray("integer.object")); 508 509 ArrayAssert.assertEquals(new int[] { }, conf.getIntArray("empty")); 511 } 512 513 public void testGetIntegerList() 514 { 515 ListAssert.assertEquals(null, conf.getIntegerList("integer.list", null)); 517 518 List expected = new ArrayList (); 519 expected.add(new Integer ("1")); 520 expected.add(new Integer ("2")); 521 522 ListAssert.assertEquals(expected, conf.getIntegerList("integer.list1")); 524 525 ListAssert.assertEquals(expected, conf.getIntegerList("integer.list2")); 527 528 ListAssert.assertEquals(expected, conf.getIntegerList("integer.list3")); 530 531 ListAssert.assertEquals(expected, conf.getIntegerList("integer.list4")); 533 534 ListAssert.assertEquals(expected, conf.getIntegerList("integer.list5")); 536 537 ListAssert.assertEquals(expected, conf.getIntegerList("integer.list6")); 539 540 expected = new ArrayList (); 542 expected.add(new Integer ("1")); 543 ListAssert.assertEquals(expected, conf.getIntegerList("integer.string")); 544 ListAssert.assertEquals(expected, conf.getIntegerList("integer.object")); 545 546 ListAssert.assertEquals(new ArrayList (), conf.getIntegerList("empty")); 548 } 549 550 public void testGetLongArray() 551 { 552 long[] defaultValue = new long[] { 2, 1}; 554 ArrayAssert.assertEquals(defaultValue, conf.getLongArray("long.list", defaultValue)); 555 556 long[] expected = new long[] { 1, 2 }; 557 558 ArrayAssert.assertEquals(expected, conf.getLongArray("long.list1")); 560 561 ArrayAssert.assertEquals(expected, conf.getLongArray("long.list2")); 563 564 ArrayAssert.assertEquals(expected, conf.getLongArray("long.list3")); 566 567 ArrayAssert.assertEquals(expected, conf.getLongArray("long.list4")); 569 570 ArrayAssert.assertEquals(expected, conf.getLongArray("long.list5")); 572 573 ArrayAssert.assertEquals(expected, conf.getLongArray("long.list6")); 575 576 ArrayAssert.assertEquals(new long[] { 1 }, conf.getLongArray("long.string")); 578 ArrayAssert.assertEquals(new long[] { 1 }, conf.getLongArray("long.object")); 579 580 ArrayAssert.assertEquals(new long[] { }, conf.getLongArray("empty")); 582 } 583 584 public void testGetLongList() 585 { 586 ListAssert.assertEquals(null, conf.getLongList("long.list", null)); 588 589 List expected = new ArrayList (); 590 expected.add(new Long ("1")); 591 expected.add(new Long ("2")); 592 593 ListAssert.assertEquals(expected, conf.getLongList("long.list1")); 595 596 ListAssert.assertEquals(expected, conf.getLongList("long.list2")); 598 599 ListAssert.assertEquals(expected, conf.getLongList("long.list3")); 601 602 ListAssert.assertEquals(expected, conf.getLongList("long.list4")); 604 605 ListAssert.assertEquals(expected, conf.getLongList("long.list5")); 607 608 ListAssert.assertEquals(expected, conf.getLongList("long.list6")); 610 611 expected = new ArrayList (); 613 expected.add(new Long ("1")); 614 ListAssert.assertEquals(expected, conf.getLongList("long.string")); 615 ListAssert.assertEquals(expected, conf.getLongList("long.object")); 616 617 ListAssert.assertEquals(new ArrayList (), conf.getLongList("empty")); 619 } 620 621 public void testGetFloatArray() 622 { 623 float[] defaultValue = new float[] { 2, 1}; 625 ArrayAssert.assertEquals(defaultValue, conf.getFloatArray("float.list", defaultValue), 0); 626 627 float[] expected = new float[] { 1, 2 }; 628 629 ArrayAssert.assertEquals(expected, conf.getFloatArray("float.list1"), 0); 631 632 ArrayAssert.assertEquals(expected, conf.getFloatArray("float.list2"), 0); 634 635 ArrayAssert.assertEquals(expected, conf.getFloatArray("float.list3"), 0); 637 638 ArrayAssert.assertEquals(expected, conf.getFloatArray("float.list4"), 0); 640 641 ArrayAssert.assertEquals(expected, conf.getFloatArray("float.list5"), 0); 643 644 ArrayAssert.assertEquals(expected, conf.getFloatArray("float.list6"), 0); 646 647 ArrayAssert.assertEquals(new float[] { 1 }, conf.getFloatArray("float.string"), 0); 649 ArrayAssert.assertEquals(new float[] { 1 }, conf.getFloatArray("float.object"), 0); 650 651 ArrayAssert.assertEquals(new float[] { }, conf.getFloatArray("empty"), 0); 653 } 654 655 public void testGetFloatList() 656 { 657 ListAssert.assertEquals(null, conf.getFloatList("float.list", null)); 659 660 List expected = new ArrayList (); 661 expected.add(new Float ("1")); 662 expected.add(new Float ("2")); 663 664 ListAssert.assertEquals(expected, conf.getFloatList("float.list1")); 666 667 ListAssert.assertEquals(expected, conf.getFloatList("float.list2")); 669 670 ListAssert.assertEquals(expected, conf.getFloatList("float.list3")); 672 673 ListAssert.assertEquals(expected, conf.getFloatList("float.list4")); 675 676 ListAssert.assertEquals(expected, conf.getFloatList("float.list5")); 678 679 ListAssert.assertEquals(expected, conf.getFloatList("float.list6")); 681 682 expected = new ArrayList (); 684 expected.add(new Float ("1")); 685 ListAssert.assertEquals(expected, conf.getFloatList("float.string")); 686 ListAssert.assertEquals(expected, conf.getFloatList("float.object")); 687 688 ListAssert.assertEquals(new ArrayList (), conf.getFloatList("empty")); 690 } 691 692 public void testGetDoubleArray() 693 { 694 double[] defaultValue = new double[] { 2, 1 }; 696 ArrayAssert.assertEquals(defaultValue, conf.getDoubleArray("double.list", defaultValue), 0); 697 698 double[] expected = new double[] { 1, 2 }; 699 700 ArrayAssert.assertEquals(expected, conf.getDoubleArray("double.list1"), 0); 702 703 ArrayAssert.assertEquals(expected, conf.getDoubleArray("double.list2"), 0); 705 706 ArrayAssert.assertEquals(expected, conf.getDoubleArray("double.list3"), 0); 708 709 ArrayAssert.assertEquals(expected, conf.getDoubleArray("double.list4"), 0); 711 712 ArrayAssert.assertEquals(expected, conf.getDoubleArray("double.list5"), 0); 714 715 ArrayAssert.assertEquals(expected, conf.getDoubleArray("double.list6"), 0); 717 718 ArrayAssert.assertEquals(new double[] { 1 }, conf.getDoubleArray("double.string"), 0); 720 ArrayAssert.assertEquals(new double[] { 1 }, conf.getDoubleArray("double.object"), 0); 721 722 ArrayAssert.assertEquals(new double[] { }, conf.getDoubleArray("empty"), 0); 724 } 725 726 public void testGetDoubleList() 727 { 728 ListAssert.assertEquals(null, conf.getDoubleList("double.list", null)); 730 731 List expected = new ArrayList (); 732 expected.add(new Double ("1")); 733 expected.add(new Double ("2")); 734 735 ListAssert.assertEquals(expected, conf.getDoubleList("double.list1")); 737 738 ListAssert.assertEquals(expected, conf.getDoubleList("double.list2")); 740 741 ListAssert.assertEquals(expected, conf.getDoubleList("double.list3")); 743 744 ListAssert.assertEquals(expected, conf.getDoubleList("double.list4")); 746 747 ListAssert.assertEquals(expected, conf.getDoubleList("double.list5")); 749 750 ListAssert.assertEquals(expected, conf.getDoubleList("double.list6")); 752 753 expected = new ArrayList (); 755 expected.add(new Double ("1")); 756 ListAssert.assertEquals(expected, conf.getDoubleList("double.string")); 757 ListAssert.assertEquals(expected, conf.getDoubleList("double.object")); 758 759 ListAssert.assertEquals(new ArrayList (), conf.getDoubleList("empty")); 761 } 762 763 public void testGetBigIntegerArray() 764 { 765 BigInteger [] defaultValue = new BigInteger [] { new BigInteger ("2"), new BigInteger ("1") }; 767 ArrayAssert.assertEquals(defaultValue, conf.getBigIntegerArray("biginteger.list", defaultValue)); 768 769 BigInteger [] expected = new BigInteger [] { new BigInteger ("1"), new BigInteger ("2") }; 770 771 ArrayAssert.assertEquals(expected, conf.getBigIntegerArray("biginteger.list1")); 773 774 ArrayAssert.assertEquals(expected, conf.getBigIntegerArray("biginteger.list2")); 776 777 ArrayAssert.assertEquals(expected, conf.getBigIntegerArray("biginteger.list3")); 779 780 ArrayAssert.assertEquals(expected, conf.getBigIntegerArray("biginteger.list4")); 782 783 ArrayAssert.assertEquals(expected, conf.getBigIntegerArray("biginteger.list6")); 785 786 ArrayAssert.assertEquals(new BigInteger [] { new BigInteger ("1") }, conf.getBigIntegerArray("biginteger.string")); 788 ArrayAssert.assertEquals(new BigInteger [] { new BigInteger ("1") }, conf.getBigIntegerArray("biginteger.object")); 789 790 ArrayAssert.assertEquals(new BigInteger [] { }, conf.getBigIntegerArray("empty")); 792 } 793 794 public void testGetBigIntegerList() 795 { 796 ListAssert.assertEquals(null, conf.getBigIntegerList("biginteger.list", null)); 798 799 List expected = new ArrayList (); 800 expected.add(new BigInteger ("1")); 801 expected.add(new BigInteger ("2")); 802 803 ListAssert.assertEquals(expected, conf.getBigIntegerList("biginteger.list1")); 805 806 ListAssert.assertEquals(expected, conf.getBigIntegerList("biginteger.list2")); 808 809 ListAssert.assertEquals(expected, conf.getBigIntegerList("biginteger.list3")); 811 812 ListAssert.assertEquals(expected, conf.getBigIntegerList("biginteger.list4")); 814 815 ListAssert.assertEquals(expected, conf.getBigIntegerList("biginteger.list6")); 817 818 expected = new ArrayList (); 820 expected.add(new BigInteger ("1")); 821 ListAssert.assertEquals(expected, conf.getBigIntegerList("biginteger.string")); 822 ListAssert.assertEquals(expected, conf.getBigIntegerList("biginteger.object")); 823 824 ListAssert.assertEquals(new ArrayList (), conf.getBigIntegerList("empty")); 826 } 827 828 public void testGetBigDecimalArray() 829 { 830 BigDecimal [] defaultValue = new BigDecimal [] { new BigDecimal ("2"), new BigDecimal ("1") }; 832 ArrayAssert.assertEquals(defaultValue, conf.getBigDecimalArray("bigdecimal.list", defaultValue)); 833 834 BigDecimal [] expected = new BigDecimal [] { new BigDecimal ("1"), new BigDecimal ("2") }; 835 836 ArrayAssert.assertEquals(expected, conf.getBigDecimalArray("bigdecimal.list1")); 838 839 ArrayAssert.assertEquals(expected, conf.getBigDecimalArray("bigdecimal.list2")); 841 842 ArrayAssert.assertEquals(expected, conf.getBigDecimalArray("bigdecimal.list3")); 844 845 ArrayAssert.assertEquals(expected, conf.getBigDecimalArray("bigdecimal.list4")); 847 848 ArrayAssert.assertEquals(expected, conf.getBigDecimalArray("bigdecimal.list6")); 850 851 ArrayAssert.assertEquals(new BigDecimal [] { new BigDecimal ("1") }, conf.getBigDecimalArray("bigdecimal.string")); 853 ArrayAssert.assertEquals(new BigDecimal [] { new BigDecimal ("1") }, conf.getBigDecimalArray("bigdecimal.object")); 854 855 ArrayAssert.assertEquals(new BigDecimal [] { }, conf.getBigDecimalArray("empty")); 857 } 858 859 public void testGetBigDecimalList() 860 { 861 ListAssert.assertEquals(null, conf.getBigDecimalList("bigdecimal.list", null)); 863 864 List expected = new ArrayList (); 865 expected.add(new BigDecimal ("1")); 866 expected.add(new BigDecimal ("2")); 867 868 ListAssert.assertEquals(expected, conf.getBigDecimalList("bigdecimal.list1")); 870 871 ListAssert.assertEquals(expected, conf.getBigDecimalList("bigdecimal.list2")); 873 874 ListAssert.assertEquals(expected, conf.getBigDecimalList("bigdecimal.list3")); 876 877 ListAssert.assertEquals(expected, conf.getBigDecimalList("bigdecimal.list4")); 879 880 ListAssert.assertEquals(expected, conf.getBigDecimalList("bigdecimal.list6")); 882 883 expected = new ArrayList (); 885 expected.add(new BigDecimal ("1")); 886 ListAssert.assertEquals(expected, conf.getBigDecimalList("bigdecimal.string")); 887 ListAssert.assertEquals(expected, conf.getBigDecimalList("bigdecimal.object")); 888 889 ListAssert.assertEquals(new ArrayList (), conf.getBigDecimalList("empty")); 891 } 892 893 public void testGetURL() throws Exception 894 { 895 URL defaultValue = new URL ("http://www.google.com"); 897 assertEquals(defaultValue, conf.getURL("url", defaultValue)); 898 899 URL expected = new URL ("http://jakarta.apache.org"); 900 901 assertEquals(expected, conf.getURL("url.string")); 903 904 assertEquals(expected, conf.getURL("url.object")); 906 } 907 908 public void testGetURLArray() throws Exception 909 { 910 URL [] defaultValue = new URL [] { new URL ("http://www.apache.org"), new URL ("http://jakarta.apache.org") }; 912 ArrayAssert.assertEquals(defaultValue, conf.getURLArray("url.list", defaultValue)); 913 914 URL [] expected = new URL [] { new URL ("http://jakarta.apache.org"), new URL ("http://www.apache.org") }; 915 916 ArrayAssert.assertEquals(expected, conf.getURLArray("url.list1")); 918 919 ArrayAssert.assertEquals(expected, conf.getURLArray("url.list2")); 921 922 ArrayAssert.assertEquals(expected, conf.getURLArray("url.list3")); 924 925 ArrayAssert.assertEquals(expected, conf.getURLArray("url.list4")); 927 928 ArrayAssert.assertEquals(expected, conf.getURLArray("url.list6")); 930 931 ArrayAssert.assertEquals(new URL [] { new URL ("http://jakarta.apache.org") }, conf.getURLArray("url.string")); 933 ArrayAssert.assertEquals(new URL [] { new URL ("http://jakarta.apache.org") }, conf.getURLArray("url.object")); 934 935 ArrayAssert.assertEquals(new URL [] { }, conf.getURLArray("empty")); 937 } 938 939 public void testGetURLList() throws Exception 940 { 941 ListAssert.assertEquals(null, conf.getURLList("url.list", null)); 943 944 List expected = new ArrayList (); 945 expected.add(new URL ("http://jakarta.apache.org")); 946 expected.add(new URL ("http://www.apache.org")); 947 948 ListAssert.assertEquals(expected, conf.getURLList("url.list1")); 950 951 ListAssert.assertEquals(expected, conf.getURLList("url.list2")); 953 954 ListAssert.assertEquals(expected, conf.getURLList("url.list3")); 956 957 ListAssert.assertEquals(expected, conf.getURLList("url.list4")); 959 960 ListAssert.assertEquals(expected, conf.getURLList("url.list6")); 962 963 expected = new ArrayList (); 965 expected.add(new URL ("http://www.apache.org")); 966 ListAssert.assertEquals(expected, conf.getURLList("url.string")); 967 ListAssert.assertEquals(expected, conf.getURLList("url.object")); 968 969 ListAssert.assertEquals(new ArrayList (), conf.getURLList("empty")); 971 } 972 973 public void testGetLocale() 974 { 975 conf.setProperty("locale", "fr"); 977 assertEquals("language", new Locale ("fr", ""), conf.getLocale("locale")); 978 979 conf.setProperty("locale", "fr__POSIX"); 981 assertEquals("language + variant", new Locale ("fr", "", "POSIX"), conf.getLocale("locale")); 982 983 conf.setProperty("locale", "_FR"); 985 assertEquals("country", new Locale ("", "FR"), conf.getLocale("locale")); 986 987 conf.setProperty("locale", "_FR_WIN"); 989 assertEquals("country + variant", new Locale ("", "FR", "WIN"), conf.getLocale("locale")); 990 991 conf.setProperty("locale", "fr_FR"); 993 assertEquals("language + country", new Locale ("fr", "FR"), conf.getLocale("locale")); 994 995 conf.setProperty("locale", "fr_FR_MAC"); 997 assertEquals("language + country + variant", new Locale ("fr", "FR", "MAC"), conf.getLocale("locale")); 998 999 conf.setProperty("locale", "fr"); 1001 assertEquals("Existing key with default value", Locale.FRENCH, conf.getLocale("locale", Locale.GERMAN)); 1002 assertEquals("Missing key with default value", Locale.GERMAN, conf.getLocale("localeNotInConfig", Locale.GERMAN)); 1003 } 1004 1005 public void testGetLocaleArray() throws Exception 1006 { 1007 Locale [] defaultValue = new Locale [] { Locale.GERMAN, Locale.FRENCH }; 1009 ArrayAssert.assertEquals(defaultValue, conf.getLocaleArray("locale.list", defaultValue)); 1010 1011 Locale [] expected = new Locale [] { Locale.FRENCH, Locale.GERMAN }; 1012 1013 ArrayAssert.assertEquals(expected, conf.getLocaleArray("locale.list1")); 1015 1016 ArrayAssert.assertEquals(expected, conf.getLocaleArray("locale.list2")); 1018 1019 ArrayAssert.assertEquals(expected, conf.getLocaleArray("locale.list3")); 1021 1022 ArrayAssert.assertEquals(expected, conf.getLocaleArray("locale.list4")); 1024 1025 ArrayAssert.assertEquals(expected, conf.getLocaleArray("locale.list6")); 1027 1028 ArrayAssert.assertEquals(new Locale [] { Locale.FRENCH }, conf.getLocaleArray("locale.string")); 1030 ArrayAssert.assertEquals(new Locale [] { Locale.FRENCH }, conf.getLocaleArray("locale.object")); 1031 1032 ArrayAssert.assertEquals(new Locale [] { }, conf.getLocaleArray("empty")); 1034 } 1035 1036 public void testGetLocaleList() throws Exception 1037 { 1038 ListAssert.assertEquals(null, conf.getLocaleList("locale.list", null)); 1040 1041 List expected = new ArrayList (); 1042 expected.add(Locale.FRENCH); 1043 expected.add(Locale.GERMAN); 1044 1045 ListAssert.assertEquals(expected, conf.getLocaleList("locale.list1")); 1047 1048 ListAssert.assertEquals(expected, conf.getLocaleList("locale.list2")); 1050 1051 ListAssert.assertEquals(expected, conf.getLocaleList("locale.list3")); 1053 1054 ListAssert.assertEquals(expected, conf.getLocaleList("locale.list4")); 1056 1057 ListAssert.assertEquals(expected, conf.getLocaleList("locale.list6")); 1059 1060 expected = new ArrayList (); 1062 expected.add(Locale.FRENCH); 1063 ListAssert.assertEquals(expected, conf.getLocaleList("locale.string")); 1064 ListAssert.assertEquals(expected, conf.getLocaleList("locale.object")); 1065 1066 ListAssert.assertEquals(new ArrayList (), conf.getLocaleList("empty")); 1068 } 1069 1070 public void testGetColor() 1071 { 1072 conf.setProperty("color", "FF0000"); 1074 assertEquals("color", Color.red, conf.getColor("color")); 1075 1076 conf.setProperty("color", "#00FF00"); 1078 assertEquals("color", Color.green, conf.getColor("color")); 1079 1080 conf.setProperty("color", "#01030507"); 1082 Color color = conf.getColor("color"); 1083 assertNotNull("null color", color); 1084 assertEquals("red", 1, color.getRed()); 1085 assertEquals("green", 3, color.getGreen()); 1086 assertEquals("blue", 5, color.getBlue()); 1087 assertEquals("alpha", 7, color.getAlpha()); 1088 } 1089 1090 public void testGetColorArray() throws Exception 1091 { 1092 Color [] defaultValue = new Color [] { Color.red, Color.blue }; 1094 ArrayAssert.assertEquals(defaultValue, conf.getColorArray("color.list", defaultValue)); 1095 1096 Color [] expected = new Color [] { Color.red, Color.blue }; 1097 1098 ArrayAssert.assertEquals(expected, conf.getColorArray("color.list1")); 1100 1101 ArrayAssert.assertEquals(expected, conf.getColorArray("color.list2")); 1103 1104 ArrayAssert.assertEquals(expected, conf.getColorArray("color.list3")); 1106 1107 ArrayAssert.assertEquals(expected, conf.getColorArray("color.list4")); 1109 1110 ArrayAssert.assertEquals(expected, conf.getColorArray("color.list6")); 1112 1113 ArrayAssert.assertEquals(new Color [] { Color.red }, conf.getColorArray("color.string")); 1115 ArrayAssert.assertEquals(new Color [] { Color.red }, conf.getColorArray("color.object")); 1116 1117 ArrayAssert.assertEquals(new Color [] { }, conf.getColorArray("empty")); 1119 } 1120 1121 public void testGetColorList() throws Exception 1122 { 1123 ListAssert.assertEquals(null, conf.getColorList("color.list", null)); 1125 1126 List expected = new ArrayList (); 1127 expected.add(Color.red); 1128 expected.add(Color.blue); 1129 1130 ListAssert.assertEquals(expected, conf.getColorList("color.list1")); 1132 1133 ListAssert.assertEquals(expected, conf.getColorList("color.list2")); 1135 1136 ListAssert.assertEquals(expected, conf.getColorList("color.list3")); 1138 1139 ListAssert.assertEquals(expected, conf.getColorList("color.list4")); 1141 1142 ListAssert.assertEquals(expected, conf.getColorList("color.list6")); 1144 1145 expected = new ArrayList (); 1147 expected.add(Color.red); 1148 ListAssert.assertEquals(expected, conf.getColorList("color.string")); 1149 ListAssert.assertEquals(expected, conf.getColorList("color.object")); 1150 1151 ListAssert.assertEquals(new ArrayList (), conf.getColorList("empty")); 1153 } 1154 1155 public void testGetDate() throws Exception 1156 { 1157 DateFormat format = new SimpleDateFormat ("yyyy-MM-dd"); 1158 1159 Date defaultValue = new Date (); 1161 assertEquals(defaultValue, conf.getDate("date", defaultValue)); 1162 1163 Date expected = format.parse("2004-01-01"); 1164 1165 assertEquals(expected, conf.getDate("date.string")); 1167 1168 assertEquals(expected, conf.getDate("date.object")); 1170 1171 assertEquals(expected, conf.getDate("calendar.object")); 1173 } 1174 1175 public void testGetDateArray() throws Exception 1176 { 1177 DateFormat format = new SimpleDateFormat ("yyyy-MM-dd"); 1178 Date date1 = format.parse("2004-01-01"); 1179 Date date2 = format.parse("2004-12-31"); 1180 1181 Date [] defaultValue = new Date [] { date2, date1 }; 1183 ArrayAssert.assertEquals(defaultValue, conf.getDateArray("date.list", defaultValue)); 1184 1185 Date [] expected = new Date [] { date1, date2 }; 1186 1187 ArrayAssert.assertEquals(expected, conf.getDateArray("date.list1")); 1189 1190 ArrayAssert.assertEquals(expected, conf.getDateArray("date.list2")); 1192 1193 ArrayAssert.assertEquals(expected, conf.getDateArray("date.list3")); 1195 1196 ArrayAssert.assertEquals(expected, conf.getDateArray("date.list4")); 1198 1199 ArrayAssert.assertEquals(expected, conf.getDateArray("date.list5")); 1201 1202 ArrayAssert.assertEquals(expected, conf.getDateArray("date.list6")); 1204 1205 ArrayAssert.assertEquals(new Date [] { date1 }, conf.getDateArray("date.string")); 1207 ArrayAssert.assertEquals(new Date [] { date1 }, conf.getDateArray("date.object")); 1208 1209 ArrayAssert.assertEquals(new Date [] { }, conf.getDateArray("empty")); 1211 } 1212 1213 public void testGetDateList() throws Exception 1214 { 1215 DateFormat format = new SimpleDateFormat ("yyyy-MM-dd"); 1216 Date date1 = format.parse("2004-01-01"); 1217 Date date2 = format.parse("2004-12-31"); 1218 1219 ListAssert.assertEquals(null, conf.getDateList("date.list", (List ) null)); 1221 1222 List expected = new ArrayList (); 1223 expected.add(date1); 1224 expected.add(date2); 1225 1226 ListAssert.assertEquals(expected, conf.getDateList("date.list1")); 1228 1229 ListAssert.assertEquals(expected, conf.getDateList("date.list2")); 1231 1232 ListAssert.assertEquals(expected, conf.getDateList("date.list3")); 1234 1235 ListAssert.assertEquals(expected, conf.getDateList("date.list4")); 1237 1238 ListAssert.assertEquals(expected, conf.getDateList("date.list5")); 1240 1241 ListAssert.assertEquals(expected, conf.getDateList("date.list6")); 1243 1244 expected = new ArrayList (); 1246 expected.add(date1); 1247 ListAssert.assertEquals(expected, conf.getDateList("date.string")); 1248 ListAssert.assertEquals(expected, conf.getDateList("date.object")); 1249 1250 ListAssert.assertEquals(new ArrayList (), conf.getDateList("empty")); 1252 } 1253 1254 public void testGetCalendar() throws Exception 1255 { 1256 DateFormat format = new SimpleDateFormat ("yyyy-MM-dd"); 1257 1258 Calendar defaultValue = Calendar.getInstance(); 1260 defaultValue.setTime(new Date ()); 1261 assertEquals(defaultValue, conf.getCalendar("calendar", defaultValue)); 1262 1263 Calendar expected = Calendar.getInstance(); 1264 expected.setTime(format.parse("2004-01-01")); 1265 1266 assertEquals(expected, conf.getCalendar("calendar.string")); 1268 1269 assertEquals(expected, conf.getCalendar("calendar.object")); 1271 1272 assertEquals(expected, conf.getCalendar("date.object")); 1274 } 1275 1276 1277 public void testGetCalendarArray() throws Exception 1278 { 1279 DateFormat format = new SimpleDateFormat ("yyyy-MM-dd"); 1280 Date date1 = format.parse("2004-01-01"); 1281 Date date2 = format.parse("2004-12-31"); 1282 Calendar calendar1 = Calendar.getInstance(); 1283 calendar1.setTime(date1); 1284 Calendar calendar2 = Calendar.getInstance(); 1285 calendar2.setTime(date2); 1286 1287 Calendar [] defaultValue = new Calendar [] { calendar2, calendar1 }; 1289 ArrayAssert.assertEquals(defaultValue, conf.getCalendarArray("calendar.list", defaultValue)); 1290 1291 Calendar [] expected = new Calendar [] { calendar1, calendar2 }; 1292 1293 ArrayAssert.assertEquals(expected, conf.getCalendarArray("calendar.list1")); 1295 1296 ArrayAssert.assertEquals(expected, conf.getCalendarArray("calendar.list2")); 1298 1299 ArrayAssert.assertEquals(expected, conf.getCalendarArray("calendar.list3")); 1301 1302 ArrayAssert.assertEquals(expected, conf.getCalendarArray("calendar.list4")); 1304 1305 ArrayAssert.assertEquals(expected, conf.getCalendarArray("calendar.list5")); 1307 1308 ArrayAssert.assertEquals(expected, conf.getCalendarArray("calendar.list6")); 1310 1311 ArrayAssert.assertEquals(new Calendar [] { calendar1 }, conf.getCalendarArray("calendar.string")); 1313 ArrayAssert.assertEquals(new Calendar [] { calendar1 }, conf.getCalendarArray("calendar.object")); 1314 1315 ArrayAssert.assertEquals(new Calendar [] { }, conf.getCalendarArray("empty")); 1317 } 1318 1319 public void testGetCalendarList() throws Exception 1320 { 1321 DateFormat format = new SimpleDateFormat ("yyyy-MM-dd"); 1322 Date date1 = format.parse("2004-01-01"); 1323 Date date2 = format.parse("2004-12-31"); 1324 Calendar calendar1 = Calendar.getInstance(); 1325 calendar1.setTime(date1); 1326 Calendar calendar2 = Calendar.getInstance(); 1327 calendar2.setTime(date2); 1328 1329 ListAssert.assertEquals(null, conf.getCalendarList("calendar.list", (List ) null)); 1331 1332 List expected = new ArrayList (); 1333 expected.add(calendar1); 1334 expected.add(calendar2); 1335 1336 ListAssert.assertEquals(expected, conf.getCalendarList("calendar.list1")); 1338 1339 ListAssert.assertEquals(expected, conf.getCalendarList("calendar.list2")); 1341 1342 ListAssert.assertEquals(expected, conf.getCalendarList("calendar.list3")); 1344 1345 ListAssert.assertEquals(expected, conf.getCalendarList("calendar.list4")); 1347 1348 ListAssert.assertEquals(expected, conf.getCalendarList("calendar.list5")); 1350 1351 ListAssert.assertEquals(expected, conf.getCalendarList("calendar.list6")); 1353 1354 expected = new ArrayList (); 1356 expected.add(calendar1); 1357 ListAssert.assertEquals(expected, conf.getCalendarList("date.string")); 1358 ListAssert.assertEquals(expected, conf.getCalendarList("date.object")); 1359 1360 ListAssert.assertEquals(new ArrayList (), conf.getCalendarList("empty")); 1362 } 1363 1364 public void testConversionException() 1365 { 1366 conf.addProperty("key1", new Object ()); 1367 conf.addProperty("key2", "xxxxxx"); 1368 1369 try 1370 { 1371 conf.getBooleanArray("key1"); 1372 fail("getBooleanArray didn't throw a ConversionException"); 1373 } 1374 catch (ConversionException e) 1375 { 1376 } 1378 1379 try 1380 { 1381 conf.getBooleanArray("key2"); 1382 fail("getBooleanArray didn't throw a ConversionException"); 1383 } 1384 catch (ConversionException e) 1385 { 1386 } 1388 1389 try 1390 { 1391 conf.getBooleanList("key1"); 1392 fail("getBooleanList didn't throw a ConversionException"); 1393 } 1394 catch (ConversionException e) 1395 { 1396 } 1398 1399 try 1400 { 1401 conf.getBooleanList("key2"); 1402 fail("getBooleanList didn't throw a ConversionException"); 1403 } 1404 catch (ConversionException e) 1405 { 1406 } 1408 1409 try 1410 { 1411 conf.getByteArray("key1"); 1412 fail("getByteArray didn't throw a ConversionException"); 1413 } 1414 catch (ConversionException e) 1415 { 1416 } 1418 1419 try 1420 { 1421 conf.getByteArray("key2"); 1422 fail("getByteArray didn't throw a ConversionException"); 1423 } 1424 catch (ConversionException e) 1425 { 1426 } 1428 1429 try 1430 { 1431 conf.getByteList("key1"); 1432 fail("getByteList didn't throw a ConversionException"); 1433 } 1434 catch (ConversionException e) 1435 { 1436 } 1438 1439 try 1440 { 1441 conf.getByteList("key2"); 1442 fail("getByteList didn't throw a ConversionException"); 1443 } 1444 catch (ConversionException e) 1445 { 1446 } 1448 1449 try 1450 { 1451 conf.getShortArray("key1"); 1452 fail("getShortArray didn't throw a ConversionException"); 1453 } 1454 catch (ConversionException e) 1455 { 1456 } 1458 1459 try 1460 { 1461 conf.getShortArray("key2"); 1462 fail("getShortArray didn't throw a ConversionException"); 1463 } 1464 catch (ConversionException e) 1465 { 1466 } 1468 1469 try 1470 { 1471 conf.getShortList("key1"); 1472 fail("getShortList didn't throw a ConversionException"); 1473 } 1474 catch (ConversionException e) 1475 { 1476 } 1478 1479 try 1480 { 1481 conf.getShortList("key2"); 1482 fail("getShortList didn't throw a ConversionException"); 1483 } 1484 catch (ConversionException e) 1485 { 1486 } 1488 1489 try 1490 { 1491 conf.getIntArray("key1"); 1492 fail("getIntArray didn't throw a ConversionException"); 1493 } 1494 catch (ConversionException e) 1495 { 1496 } 1498 1499 try 1500 { 1501 conf.getIntArray("key2"); 1502 fail("getIntArray didn't throw a ConversionException"); 1503 } 1504 catch (ConversionException e) 1505 { 1506 } 1508 1509 try 1510 { 1511 conf.getIntegerList("key1"); 1512 fail("getIntegerList didn't throw a ConversionException"); 1513 } 1514 catch (ConversionException e) 1515 { 1516 } 1518 1519 try 1520 { 1521 conf.getIntegerList("key2"); 1522 fail("getIntegerList didn't throw a ConversionException"); 1523 } 1524 catch (ConversionException e) 1525 { 1526 } 1528 1529 try 1530 { 1531 conf.getLongArray("key1"); 1532 fail("getLongArray didn't throw a ConversionException"); 1533 } 1534 catch (ConversionException e) 1535 { 1536 } 1538 1539 try 1540 { 1541 conf.getLongArray("key2"); 1542 fail("getLongArray didn't throw a ConversionException"); 1543 } 1544 catch (ConversionException e) 1545 { 1546 } 1548 1549 try 1550 { 1551 conf.getLongList("key1"); 1552 fail("getLongList didn't throw a ConversionException"); 1553 } 1554 catch (ConversionException e) 1555 { 1556 } 1558 1559 try 1560 { 1561 conf.getLongList("key2"); 1562 fail("getLongList didn't throw a ConversionException"); 1563 } 1564 catch (ConversionException e) 1565 { 1566 } 1568 1569 try 1570 { 1571 conf.getFloatArray("key1"); 1572 fail("getFloatArray didn't throw a ConversionException"); 1573 } 1574 catch (ConversionException e) 1575 { 1576 } 1578 1579 try 1580 { 1581 conf.getFloatArray("key2"); 1582 fail("getFloatArray didn't throw a ConversionException"); 1583 } 1584 catch (ConversionException e) 1585 { 1586 } 1588 1589 try 1590 { 1591 conf.getFloatList("key1"); 1592 fail("getFloatList didn't throw a ConversionException"); 1593 } 1594 catch (ConversionException e) 1595 { 1596 } 1598 1599 try 1600 { 1601 conf.getFloatList("key2"); 1602 fail("getFloatList didn't throw a ConversionException"); 1603 } 1604 catch (ConversionException e) 1605 { 1606 } 1608 1609 try 1610 { 1611 conf.getDoubleArray("key1"); 1612 fail("getDoubleArray didn't throw a ConversionException"); 1613 } 1614 catch (ConversionException e) 1615 { 1616 } 1618 1619 try 1620 { 1621 conf.getDoubleArray("key2"); 1622 fail("getDoubleArray didn't throw a ConversionException"); 1623 } 1624 catch (ConversionException e) 1625 { 1626 } 1628 1629 try 1630 { 1631 conf.getDoubleList("key1"); 1632 fail("getDoubleList didn't throw a ConversionException"); 1633 } 1634 catch (ConversionException e) 1635 { 1636 } 1638 1639 try 1640 { 1641 conf.getDoubleList("key2"); 1642 fail("getDoubleList didn't throw a ConversionException"); 1643 } 1644 catch (ConversionException e) 1645 { 1646 } 1648 1649 try 1650 { 1651 conf.getBigIntegerArray("key1"); 1652 fail("getBigIntegerArray didn't throw a ConversionException"); 1653 } 1654 catch (ConversionException e) 1655 { 1656 } 1658 1659 try 1660 { 1661 conf.getBigIntegerArray("key2"); 1662 fail("getBigIntegerArray didn't throw a ConversionException"); 1663 } 1664 catch (ConversionException e) 1665 { 1666 } 1668 1669 try 1670 { 1671 conf.getBigIntegerList("key1"); 1672 fail("getBigIntegerList didn't throw a ConversionException"); 1673 } 1674 catch (ConversionException e) 1675 { 1676 } 1678 1679 try 1680 { 1681 conf.getBigIntegerList("key2"); 1682 fail("getBigIntegerList didn't throw a ConversionException"); 1683 } 1684 catch (ConversionException e) 1685 { 1686 } 1688 1689 try 1690 { 1691 conf.getBigDecimalArray("key1"); 1692 fail("getBigDecimalArray didn't throw a ConversionException"); 1693 } 1694 catch (ConversionException e) 1695 { 1696 } 1698 1699 try 1700 { 1701 conf.getBigDecimalArray("key2"); 1702 fail("getBigDecimalArray didn't throw a ConversionException"); 1703 } 1704 catch (ConversionException e) 1705 { 1706 } 1708 1709 try 1710 { 1711 conf.getBigDecimalList("key1"); 1712 fail("getBigDecimalList didn't throw a ConversionException"); 1713 } 1714 catch (ConversionException e) 1715 { 1716 } 1718 1719 try 1720 { 1721 conf.getBigDecimalList("key2"); 1722 fail("getBigDecimalList didn't throw a ConversionException"); 1723 } 1724 catch (ConversionException e) 1725 { 1726 } 1728 1729 try 1730 { 1731 conf.getURLArray("key1"); 1732 fail("getURLArray didn't throw a ConversionException"); 1733 } 1734 catch (ConversionException e) 1735 { 1736 } 1738 1739 try 1740 { 1741 conf.getURLArray("key2"); 1742 fail("getURLArray didn't throw a ConversionException"); 1743 } 1744 catch (ConversionException e) 1745 { 1746 } 1748 1749 try 1750 { 1751 conf.getURLList("key1"); 1752 fail("getURLList didn't throw a ConversionException"); 1753 } 1754 catch (ConversionException e) 1755 { 1756 } 1758 1759 try 1760 { 1761 conf.getURLList("key2"); 1762 fail("getURLList didn't throw a ConversionException"); 1763 } 1764 catch (ConversionException e) 1765 { 1766 } 1768 1769 try 1770 { 1771 conf.getLocaleArray("key1"); 1772 fail("getLocaleArray didn't throw a ConversionException"); 1773 } 1774 catch (ConversionException e) 1775 { 1776 } 1778 1779 try 1780 { 1781 conf.getLocaleArray("key2"); 1782 fail("getLocaleArray didn't throw a ConversionException"); 1783 } 1784 catch (ConversionException e) 1785 { 1786 } 1788 1789 try 1790 { 1791 conf.getLocaleList("key1"); 1792 fail("getLocaleList didn't throw a ConversionException"); 1793 } 1794 catch (ConversionException e) 1795 { 1796 } 1798 1799 try 1800 { 1801 conf.getLocaleList("key2"); 1802 fail("getLocaleList didn't throw a ConversionException"); 1803 } 1804 catch (ConversionException e) 1805 { 1806 } 1808 1809 try 1810 { 1811 conf.getColorArray("key1"); 1812 fail("getColorArray didn't throw a ConversionException"); 1813 } 1814 catch (ConversionException e) 1815 { 1816 } 1818 1819 try 1820 { 1821 conf.getColorArray("key2"); 1822 fail("getColorArray didn't throw a ConversionException"); 1823 } 1824 catch (ConversionException e) 1825 { 1826 } 1828 1829 try 1830 { 1831 conf.getColorList("key1"); 1832 fail("getColorList didn't throw a ConversionException"); 1833 } 1834 catch (ConversionException e) 1835 { 1836 } 1838 1839 try 1840 { 1841 conf.getColorList("key2"); 1842 fail("getColorList didn't throw a ConversionException"); 1843 } 1844 catch (ConversionException e) 1845 { 1846 } 1848 1849 try 1850 { 1851 conf.getDateArray("key1"); 1852 fail("getDateArray didn't throw a ConversionException"); 1853 } 1854 catch (ConversionException e) 1855 { 1856 } 1858 1859 try 1860 { 1861 conf.getDateArray("key2"); 1862 fail("getDateArray didn't throw a ConversionException"); 1863 } 1864 catch (ConversionException e) 1865 { 1866 } 1868 1869 try 1870 { 1871 conf.getDateList("key1"); 1872 fail("getDateList didn't throw a ConversionException"); 1873 } 1874 catch (ConversionException e) 1875 { 1876 } 1878 1879 try 1880 { 1881 conf.getDateList("key2"); 1882 fail("getDateList didn't throw a ConversionException"); 1883 } 1884 catch (ConversionException e) 1885 { 1886 } 1888 1889 try 1890 { 1891 conf.getCalendarArray("key1"); 1892 fail("getCalendarArray didn't throw a ConversionException"); 1893 } 1894 catch (ConversionException e) 1895 { 1896 } 1898 1899 try 1900 { 1901 conf.getCalendarArray("key2"); 1902 fail("getCalendarArray didn't throw a ConversionException"); 1903 } 1904 catch (ConversionException e) 1905 { 1906 } 1908 1909 try 1910 { 1911 conf.getCalendarList("key1"); 1912 fail("getCalendarList didn't throw a ConversionException"); 1913 } 1914 catch (ConversionException e) 1915 { 1916 } 1918 1919 try 1920 { 1921 conf.getCalendarList("key2"); 1922 fail("getCalendarList didn't throw a ConversionException"); 1923 } 1924 catch (ConversionException e) 1925 { 1926 } 1928 } 1929} 1930 | Popular Tags |