Source Code Cross Referenced for TestDataConfiguration.java in  » Library » Apache-commons-configuration-1.4-src » org » apache » commons » configuration » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons configuration 1.4 src » org.apache.commons.configuration 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Licensed to the Apache Software Foundation (ASF) under one or more
0003:         * contributor license agreements.  See the NOTICE file distributed with
0004:         * this work for additional information regarding copyright ownership.
0005:         * The ASF licenses this file to You under the Apache License, Version 2.0
0006:         * (the "License"); you may not use this file except in compliance with
0007:         * the License.  You may obtain a copy of the License at
0008:         *
0009:         *     http://www.apache.org/licenses/LICENSE-2.0
0010:         *
0011:         * Unless required by applicable law or agreed to in writing, software
0012:         * distributed under the License is distributed on an "AS IS" BASIS,
0013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         * See the License for the specific language governing permissions and
0015:         * limitations under the License.
0016:         */
0017:
0018:        package org.apache.commons.configuration;
0019:
0020:        import java.awt.*;
0021:        import java.math.BigDecimal;
0022:        import java.math.BigInteger;
0023:        import java.net.URL;
0024:        import java.text.DateFormat;
0025:        import java.text.SimpleDateFormat;
0026:        import java.util.ArrayList;
0027:        import java.util.Calendar;
0028:        import java.util.Date;
0029:        import java.util.List;
0030:        import java.util.Locale;
0031:
0032:        import junit.framework.TestCase;
0033:        import junitx.framework.ArrayAssert;
0034:        import junitx.framework.ListAssert;
0035:
0036:        /**
0037:         * @author Emmanuel Bourg
0038:         * @version $Revision: 439648 $, $Date: 2006-09-02 22:42:10 +0200 (Sa, 02 Sep 2006) $
0039:         */
0040:        public class TestDataConfiguration extends TestCase {
0041:            private DataConfiguration conf;
0042:
0043:            protected void setUp() throws Exception {
0044:                conf = new DataConfiguration(new BaseConfiguration());
0045:
0046:                // empty value
0047:                conf.addProperty("empty", "");
0048:
0049:                // lists of boolean
0050:                conf.addProperty("boolean.list1", "true");
0051:                conf.addProperty("boolean.list1", "false");
0052:                conf.addProperty("boolean.list2", "true, false");
0053:                conf.addProperty("boolean.list3", Boolean.TRUE);
0054:                conf.addProperty("boolean.list3", Boolean.FALSE);
0055:                conf.addProperty("boolean.list4", new Boolean[] { Boolean.TRUE,
0056:                        Boolean.FALSE });
0057:                conf
0058:                        .addProperty("boolean.list5", new boolean[] { true,
0059:                                false });
0060:                List booleans = new ArrayList();
0061:                booleans.add(Boolean.TRUE);
0062:                booleans.add(Boolean.FALSE);
0063:                conf.addProperty("boolean.list6", booleans);
0064:                conf.addProperty("boolean.string", "true");
0065:                conf.addProperty("boolean.object", Boolean.TRUE);
0066:                conf.addProperty("boolean.list.interpolated",
0067:                        "${boolean.string},false");
0068:
0069:                // lists of bytes
0070:                conf.addProperty("byte.list1", "1");
0071:                conf.addProperty("byte.list1", "2");
0072:                conf.addProperty("byte.list2", "1, 2");
0073:                conf.addProperty("byte.list3", new Byte("1"));
0074:                conf.addProperty("byte.list3", new Byte("2"));
0075:                conf.addProperty("byte.list4", new Byte[] { new Byte("1"),
0076:                        new Byte("2") });
0077:                conf.addProperty("byte.list5", new byte[] { 1, 2 });
0078:                List bytes = new ArrayList();
0079:                bytes.add(new Byte("1"));
0080:                bytes.add(new Byte("2"));
0081:                conf.addProperty("byte.list6", bytes);
0082:                conf.addProperty("byte.string", "1");
0083:                conf.addProperty("byte.object", new Byte("1"));
0084:                conf.addProperty("byte.list.interpolated", "${byte.string},2");
0085:
0086:                // lists of shorts
0087:                conf.addProperty("short.list1", "1");
0088:                conf.addProperty("short.list1", "2");
0089:                conf.addProperty("short.list2", "1, 2");
0090:                conf.addProperty("short.list3", new Short("1"));
0091:                conf.addProperty("short.list3", new Short("2"));
0092:                conf.addProperty("short.list4", new Short[] { new Short("1"),
0093:                        new Short("2") });
0094:                conf.addProperty("short.list5", new short[] { 1, 2 });
0095:                List shorts = new ArrayList();
0096:                shorts.add(new Short("1"));
0097:                shorts.add(new Short("2"));
0098:                conf.addProperty("short.list6", shorts);
0099:                conf.addProperty("short.string", "1");
0100:                conf.addProperty("short.object", new Short("1"));
0101:                conf
0102:                        .addProperty("short.list.interpolated",
0103:                                "${short.string},2");
0104:
0105:                // lists of integers
0106:                conf.addProperty("integer.list1", "1");
0107:                conf.addProperty("integer.list1", "2");
0108:                conf.addProperty("integer.list2", "1, 2");
0109:                conf.addProperty("integer.list3", new Integer("1"));
0110:                conf.addProperty("integer.list3", new Integer("2"));
0111:                conf.addProperty("integer.list4", new Integer[] {
0112:                        new Integer("1"), new Integer("2") });
0113:                conf.addProperty("integer.list5", new int[] { 1, 2 });
0114:                List integers = new ArrayList();
0115:                integers.add(new Integer("1"));
0116:                integers.add(new Integer("2"));
0117:                conf.addProperty("integer.list6", integers);
0118:                conf.addProperty("integer.string", "1");
0119:                conf.addProperty("integer.object", new Integer("1"));
0120:                conf.addProperty("integer.list.interpolated",
0121:                        "${integer.string},2");
0122:
0123:                // lists of longs
0124:                conf.addProperty("long.list1", "1");
0125:                conf.addProperty("long.list1", "2");
0126:                conf.addProperty("long.list2", "1, 2");
0127:                conf.addProperty("long.list3", new Long("1"));
0128:                conf.addProperty("long.list3", new Long("2"));
0129:                conf.addProperty("long.list4", new Long[] { new Long("1"),
0130:                        new Long("2") });
0131:                conf.addProperty("long.list5", new long[] { 1, 2 });
0132:                List longs = new ArrayList();
0133:                longs.add(new Long("1"));
0134:                longs.add(new Long("2"));
0135:                conf.addProperty("long.list6", longs);
0136:                conf.addProperty("long.string", "1");
0137:                conf.addProperty("long.object", new Long("1"));
0138:                conf.addProperty("long.list.interpolated", "${long.string},2");
0139:
0140:                // lists of floats
0141:                conf.addProperty("float.list1", "1");
0142:                conf.addProperty("float.list1", "2");
0143:                conf.addProperty("float.list2", "1, 2");
0144:                conf.addProperty("float.list3", new Float("1"));
0145:                conf.addProperty("float.list3", new Float("2"));
0146:                conf.addProperty("float.list4", new Float[] { new Float("1"),
0147:                        new Float("2") });
0148:                conf.addProperty("float.list5", new float[] { 1, 2 });
0149:                List floats = new ArrayList();
0150:                floats.add(new Float("1"));
0151:                floats.add(new Float("2"));
0152:                conf.addProperty("float.list6", floats);
0153:                conf.addProperty("float.string", "1");
0154:                conf.addProperty("float.object", new Float("1"));
0155:                conf
0156:                        .addProperty("float.list.interpolated",
0157:                                "${float.string},2");
0158:
0159:                // lists of doubles
0160:                conf.addProperty("double.list1", "1");
0161:                conf.addProperty("double.list1", "2");
0162:                conf.addProperty("double.list2", "1, 2");
0163:                conf.addProperty("double.list3", new Double("1"));
0164:                conf.addProperty("double.list3", new Double("2"));
0165:                conf.addProperty("double.list4", new Double[] {
0166:                        new Double("1"), new Double("2") });
0167:                conf.addProperty("double.list5", new double[] { 1, 2 });
0168:                List doubles = new ArrayList();
0169:                doubles.add(new Double("1"));
0170:                doubles.add(new Double("2"));
0171:                conf.addProperty("double.list6", doubles);
0172:                conf.addProperty("double.string", "1");
0173:                conf.addProperty("double.object", new Double("1"));
0174:                conf.addProperty("double.list.interpolated",
0175:                        "${double.string},2");
0176:
0177:                // lists of big integers
0178:                conf.addProperty("biginteger.list1", "1");
0179:                conf.addProperty("biginteger.list1", "2");
0180:                conf.addProperty("biginteger.list2", "1, 2");
0181:                conf.addProperty("biginteger.list3", new BigInteger("1"));
0182:                conf.addProperty("biginteger.list3", new BigInteger("2"));
0183:                conf.addProperty("biginteger.list4", new BigInteger[] {
0184:                        new BigInteger("1"), new BigInteger("2") });
0185:                List bigintegers = new ArrayList();
0186:                bigintegers.add(new BigInteger("1"));
0187:                bigintegers.add(new BigInteger("2"));
0188:                conf.addProperty("biginteger.list6", bigintegers);
0189:                conf.addProperty("biginteger.string", "1");
0190:                conf.addProperty("biginteger.object", new BigInteger("1"));
0191:                conf.addProperty("biginteger.list.interpolated",
0192:                        "${biginteger.string},2");
0193:
0194:                // lists of big decimals
0195:                conf.addProperty("bigdecimal.list1", "1");
0196:                conf.addProperty("bigdecimal.list1", "2");
0197:                conf.addProperty("bigdecimal.list2", "1, 2");
0198:                conf.addProperty("bigdecimal.list3", new BigDecimal("1"));
0199:                conf.addProperty("bigdecimal.list3", new BigDecimal("2"));
0200:                conf.addProperty("bigdecimal.list4", new BigDecimal[] {
0201:                        new BigDecimal("1"), new BigDecimal("2") });
0202:                List bigdecimals = new ArrayList();
0203:                bigdecimals.add(new BigDecimal("1"));
0204:                bigdecimals.add(new BigDecimal("2"));
0205:                conf.addProperty("bigdecimal.list6", bigdecimals);
0206:                conf.addProperty("bigdecimal.string", "1");
0207:                conf.addProperty("bigdecimal.object", new BigDecimal("1"));
0208:                conf.addProperty("bigdecimal.list.interpolated",
0209:                        "${bigdecimal.string},2");
0210:
0211:                // URLs
0212:                String url1 = "http://jakarta.apache.org";
0213:                String url2 = "http://www.apache.org";
0214:                conf.addProperty("url.string", url1);
0215:                conf.addProperty("url.string.interpolated", "${url.string}");
0216:                conf.addProperty("url.object", new URL(url1));
0217:                conf.addProperty("url.list1", url1);
0218:                conf.addProperty("url.list1", url2);
0219:                conf.addProperty("url.list2", url1 + ", " + url2);
0220:                conf.addProperty("url.list3", new URL(url1));
0221:                conf.addProperty("url.list3", new URL(url2));
0222:                conf.addProperty("url.list4", new URL[] { new URL(url1),
0223:                        new URL(url2) });
0224:                List urls = new ArrayList();
0225:                urls.add(new URL(url1));
0226:                urls.add(new URL(url2));
0227:                conf.addProperty("url.list6", urls);
0228:                conf.addProperty("url.list.interpolated", "${url.string},"
0229:                        + url2);
0230:
0231:                // Locales
0232:                conf.addProperty("locale.string", "fr");
0233:                conf.addProperty("locale.string.interpolated",
0234:                        "${locale.string}");
0235:                conf.addProperty("locale.object", Locale.FRENCH);
0236:                conf.addProperty("locale.list1", "fr");
0237:                conf.addProperty("locale.list1", "de");
0238:                conf.addProperty("locale.list2", "fr, de");
0239:                conf.addProperty("locale.list3", Locale.FRENCH);
0240:                conf.addProperty("locale.list3", Locale.GERMAN);
0241:                conf.addProperty("locale.list4", new Locale[] { Locale.FRENCH,
0242:                        Locale.GERMAN });
0243:                List locales = new ArrayList();
0244:                locales.add(Locale.FRENCH);
0245:                locales.add(Locale.GERMAN);
0246:                conf.addProperty("locale.list6", locales);
0247:                conf.addProperty("locale.list.interpolated",
0248:                        "${locale.string},de");
0249:
0250:                // Colors
0251:                String color1 = "FF0000";
0252:                String color2 = "0000FF";
0253:                conf.addProperty("color.string", color1);
0254:                conf
0255:                        .addProperty("color.string.interpolated",
0256:                                "${color.string}");
0257:                conf.addProperty("color.object", Color.red);
0258:                conf.addProperty("color.list1", color1);
0259:                conf.addProperty("color.list1", color2);
0260:                conf.addProperty("color.list2", color1 + ", " + color2);
0261:                conf.addProperty("color.list3", Color.red);
0262:                conf.addProperty("color.list3", Color.blue);
0263:                conf.addProperty("color.list4", new Color[] { Color.red,
0264:                        Color.blue });
0265:                List colors = new ArrayList();
0266:                colors.add(Color.red);
0267:                colors.add(Color.blue);
0268:                conf.addProperty("color.list6", colors);
0269:                conf.addProperty("color.list.interpolated", "${color.string},"
0270:                        + color2);
0271:
0272:                // Dates & Calendars
0273:                String pattern = "yyyy-MM-dd";
0274:                DateFormat format = new SimpleDateFormat(pattern);
0275:                conf.setProperty(DataConfiguration.DATE_FORMAT_KEY, pattern);
0276:
0277:                Date date1 = format.parse("2004-01-01");
0278:                Date date2 = format.parse("2004-12-31");
0279:                Calendar calendar1 = Calendar.getInstance();
0280:                calendar1.setTime(date1);
0281:                Calendar calendar2 = Calendar.getInstance();
0282:                calendar2.setTime(date2);
0283:
0284:                conf.addProperty("date.string", "2004-01-01");
0285:                conf.addProperty("date.string.interpolated", "${date.string}");
0286:                conf.addProperty("date.object", date1);
0287:                conf.addProperty("date.list1", "2004-01-01");
0288:                conf.addProperty("date.list1", "2004-12-31");
0289:                conf.addProperty("date.list2", "2004-01-01, 2004-12-31");
0290:                conf.addProperty("date.list3", date1);
0291:                conf.addProperty("date.list3", date2);
0292:                conf.addProperty("date.list4", new Date[] { date1, date2 });
0293:                conf.addProperty("date.list5", new Calendar[] { calendar1,
0294:                        calendar2 });
0295:                List dates = new ArrayList();
0296:                dates.add(date1);
0297:                dates.add(date2);
0298:                conf.addProperty("date.list6", dates);
0299:                conf.addProperty("date.list.interpolated",
0300:                        "${date.string},2004-12-31");
0301:
0302:                conf.addProperty("calendar.string", "2004-01-01");
0303:                conf.addProperty("calendar.string.interpolated",
0304:                        "${calendar.string}");
0305:                conf.addProperty("calendar.object", calendar1);
0306:                conf.addProperty("calendar.list1", "2004-01-01");
0307:                conf.addProperty("calendar.list1", "2004-12-31");
0308:                conf.addProperty("calendar.list2", "2004-01-01, 2004-12-31");
0309:                conf.addProperty("calendar.list3", calendar1);
0310:                conf.addProperty("calendar.list3", calendar2);
0311:                conf.addProperty("calendar.list4", new Calendar[] { calendar1,
0312:                        calendar2 });
0313:                conf.addProperty("calendar.list5", new Date[] { date1, date2 });
0314:                List calendars = new ArrayList();
0315:                calendars.add(date1);
0316:                calendars.add(date2);
0317:                conf.addProperty("calendar.list6", calendars);
0318:                conf.addProperty("calendar.list.interpolated",
0319:                        "${calendar.string},2004-12-31");
0320:            }
0321:
0322:            public void testGetBooleanArray() {
0323:                // missing list
0324:                boolean[] defaultValue = new boolean[] { false, true };
0325:                ArrayAssert.assertEquals(defaultValue, conf.getBooleanArray(
0326:                        "boolean.list", defaultValue));
0327:
0328:                boolean[] expected = new boolean[] { true, false };
0329:
0330:                // list of strings
0331:                ArrayAssert.assertEquals(expected, conf
0332:                        .getBooleanArray("boolean.list1"));
0333:
0334:                // list of strings, comma separated
0335:                ArrayAssert.assertEquals(expected, conf
0336:                        .getBooleanArray("boolean.list2"));
0337:
0338:                // list of Boolean objects
0339:                ArrayAssert.assertEquals(expected, conf
0340:                        .getBooleanArray("boolean.list3"));
0341:
0342:                // array of Boolean objects
0343:                ArrayAssert.assertEquals(expected, conf
0344:                        .getBooleanArray("boolean.list4"));
0345:
0346:                // array of boolean primitives
0347:                ArrayAssert.assertEquals(expected, conf
0348:                        .getBooleanArray("boolean.list5"));
0349:
0350:                // list of Boolean objects
0351:                ArrayAssert.assertEquals(expected, conf
0352:                        .getBooleanArray("boolean.list6"));
0353:
0354:                // list of interpolated values
0355:                ArrayAssert.assertEquals(expected, conf
0356:                        .getBooleanArray("boolean.list.interpolated"));
0357:
0358:                // single boolean values
0359:                ArrayAssert.assertEquals(new boolean[] { true }, conf
0360:                        .getBooleanArray("boolean.string"));
0361:                ArrayAssert.assertEquals(new boolean[] { true }, conf
0362:                        .getBooleanArray("boolean.object"));
0363:
0364:                // empty array
0365:                ArrayAssert.assertEquals(new boolean[] {}, conf
0366:                        .getBooleanArray("empty"));
0367:            }
0368:
0369:            public void testGetBooleanList() {
0370:                // missing list
0371:                ListAssert.assertEquals(null, conf.getBooleanList(
0372:                        "boolean.list", null));
0373:
0374:                List expected = new ArrayList();
0375:                expected.add(Boolean.TRUE);
0376:                expected.add(Boolean.FALSE);
0377:
0378:                // list of strings
0379:                ListAssert.assertEquals(expected, conf
0380:                        .getBooleanList("boolean.list1"));
0381:
0382:                // list of strings, comma separated
0383:                ListAssert.assertEquals(expected, conf
0384:                        .getBooleanList("boolean.list2"));
0385:
0386:                // list of Boolean objects
0387:                ListAssert.assertEquals(expected, conf
0388:                        .getBooleanList("boolean.list3"));
0389:
0390:                // array of Boolean objects
0391:                ListAssert.assertEquals(expected, conf
0392:                        .getBooleanList("boolean.list4"));
0393:
0394:                // array of boolean primitives
0395:                ListAssert.assertEquals(expected, conf
0396:                        .getBooleanList("boolean.list5"));
0397:
0398:                // list of Boolean objects
0399:                ListAssert.assertEquals(expected, conf
0400:                        .getBooleanList("boolean.list6"));
0401:
0402:                // list of interpolated values
0403:                ListAssert.assertEquals(expected, conf
0404:                        .getBooleanList("boolean.list.interpolated"));
0405:
0406:                // single boolean values
0407:                expected = new ArrayList();
0408:                expected.add(Boolean.TRUE);
0409:                ListAssert.assertEquals(expected, conf
0410:                        .getBooleanList("boolean.string"));
0411:                ListAssert.assertEquals(expected, conf
0412:                        .getBooleanList("boolean.object"));
0413:
0414:                // empty list
0415:                ListAssert.assertEquals(new ArrayList(), conf
0416:                        .getBooleanList("empty"));
0417:            }
0418:
0419:            public void testGetByteArray() {
0420:                // missing list
0421:                byte[] defaultValue = new byte[] { 1, 2 };
0422:                ArrayAssert.assertEquals(defaultValue, conf.getByteArray(
0423:                        "byte.list", defaultValue));
0424:
0425:                byte[] expected = new byte[] { 1, 2 };
0426:
0427:                // list of strings
0428:                ArrayAssert.assertEquals(expected, conf
0429:                        .getByteArray("byte.list1"));
0430:
0431:                // list of strings, comma separated
0432:                ArrayAssert.assertEquals(expected, conf
0433:                        .getByteArray("byte.list2"));
0434:
0435:                // list of Byte objects
0436:                ArrayAssert.assertEquals(expected, conf
0437:                        .getByteArray("byte.list3"));
0438:
0439:                // array of Byte objects
0440:                ArrayAssert.assertEquals(expected, conf
0441:                        .getByteArray("byte.list4"));
0442:
0443:                // array of byte primitives
0444:                ArrayAssert.assertEquals(expected, conf
0445:                        .getByteArray("byte.list5"));
0446:
0447:                // list of Byte objects
0448:                ArrayAssert.assertEquals(expected, conf
0449:                        .getByteArray("byte.list6"));
0450:
0451:                // list of interpolated values
0452:                ArrayAssert.assertEquals(expected, conf
0453:                        .getByteArray("byte.list.interpolated"));
0454:
0455:                // single byte values
0456:                ArrayAssert.assertEquals(new byte[] { 1 }, conf
0457:                        .getByteArray("byte.string"));
0458:                ArrayAssert.assertEquals(new byte[] { 1 }, conf
0459:                        .getByteArray("byte.object"));
0460:
0461:                // empty array
0462:                ArrayAssert.assertEquals(new byte[] {}, conf
0463:                        .getByteArray("empty"));
0464:            }
0465:
0466:            public void testGetByteList() {
0467:                // missing list
0468:                ListAssert.assertEquals(null, conf.getByteList("byte.list",
0469:                        null));
0470:
0471:                List expected = new ArrayList();
0472:                expected.add(new Byte("1"));
0473:                expected.add(new Byte("2"));
0474:
0475:                // list of strings
0476:                ListAssert.assertEquals(expected, conf
0477:                        .getByteList("byte.list1"));
0478:
0479:                // list of strings, comma separated
0480:                ListAssert.assertEquals(expected, conf
0481:                        .getByteList("byte.list2"));
0482:
0483:                // list of Byte objects
0484:                ListAssert.assertEquals(expected, conf
0485:                        .getByteList("byte.list3"));
0486:
0487:                // array of Byte objects
0488:                ListAssert.assertEquals(expected, conf
0489:                        .getByteList("byte.list4"));
0490:
0491:                // array of byte primitives
0492:                ListAssert.assertEquals(expected, conf
0493:                        .getByteList("byte.list5"));
0494:
0495:                // list of Byte objects
0496:                ListAssert.assertEquals(expected, conf
0497:                        .getByteList("byte.list6"));
0498:
0499:                // list of interpolated values
0500:                ListAssert.assertEquals(expected, conf
0501:                        .getByteList("byte.list.interpolated"));
0502:
0503:                // single byte values
0504:                expected = new ArrayList();
0505:                expected.add(new Byte("1"));
0506:                ListAssert.assertEquals(expected, conf
0507:                        .getByteList("byte.string"));
0508:                ListAssert.assertEquals(expected, conf
0509:                        .getByteList("byte.object"));
0510:
0511:                // empty list
0512:                ListAssert.assertEquals(new ArrayList(), conf
0513:                        .getByteList("empty"));
0514:            }
0515:
0516:            public void testGetShortArray() {
0517:                // missing list
0518:                short[] defaultValue = new short[] { 2, 1 };
0519:                ArrayAssert.assertEquals(defaultValue, conf.getShortArray(
0520:                        "short.list", defaultValue));
0521:
0522:                short[] expected = new short[] { 1, 2 };
0523:
0524:                // list of strings
0525:                ArrayAssert.assertEquals(expected, conf
0526:                        .getShortArray("short.list1"));
0527:
0528:                // list of strings, comma separated
0529:                ArrayAssert.assertEquals(expected, conf
0530:                        .getShortArray("short.list2"));
0531:
0532:                // list of Byte objects
0533:                ArrayAssert.assertEquals(expected, conf
0534:                        .getShortArray("short.list3"));
0535:
0536:                // array of Byte objects
0537:                ArrayAssert.assertEquals(expected, conf
0538:                        .getShortArray("short.list4"));
0539:
0540:                // array of byte primitives
0541:                ArrayAssert.assertEquals(expected, conf
0542:                        .getShortArray("short.list5"));
0543:
0544:                // list of Byte objects
0545:                ArrayAssert.assertEquals(expected, conf
0546:                        .getShortArray("short.list6"));
0547:
0548:                // list of interpolated values
0549:                ArrayAssert.assertEquals(expected, conf
0550:                        .getShortArray("short.list.interpolated"));
0551:
0552:                // single byte values
0553:                ArrayAssert.assertEquals(new short[] { 1 }, conf
0554:                        .getShortArray("short.string"));
0555:                ArrayAssert.assertEquals(new short[] { 1 }, conf
0556:                        .getShortArray("short.object"));
0557:
0558:                // empty array
0559:                ArrayAssert.assertEquals(new short[] {}, conf
0560:                        .getShortArray("empty"));
0561:            }
0562:
0563:            public void testGetShortList() {
0564:                // missing list
0565:                ListAssert.assertEquals(null, conf.getShortList("short.list",
0566:                        null));
0567:
0568:                List expected = new ArrayList();
0569:                expected.add(new Short("1"));
0570:                expected.add(new Short("2"));
0571:
0572:                // list of strings
0573:                ListAssert.assertEquals(expected, conf
0574:                        .getShortList("short.list1"));
0575:
0576:                // list of strings, comma separated
0577:                ListAssert.assertEquals(expected, conf
0578:                        .getShortList("short.list2"));
0579:
0580:                // list of Short objects
0581:                ListAssert.assertEquals(expected, conf
0582:                        .getShortList("short.list3"));
0583:
0584:                // array of Short objects
0585:                ListAssert.assertEquals(expected, conf
0586:                        .getShortList("short.list4"));
0587:
0588:                // array of short primitives
0589:                ListAssert.assertEquals(expected, conf
0590:                        .getShortList("short.list5"));
0591:
0592:                // list of Short objects
0593:                ListAssert.assertEquals(expected, conf
0594:                        .getShortList("short.list6"));
0595:
0596:                // list of interpolated values
0597:                ListAssert.assertEquals(expected, conf
0598:                        .getShortList("short.list.interpolated"));
0599:
0600:                // single short values
0601:                expected = new ArrayList();
0602:                expected.add(new Short("1"));
0603:                ListAssert.assertEquals(expected, conf
0604:                        .getShortList("short.string"));
0605:                ListAssert.assertEquals(expected, conf
0606:                        .getShortList("short.object"));
0607:
0608:                // empty list
0609:                ListAssert.assertEquals(new ArrayList(), conf
0610:                        .getShortList("empty"));
0611:            }
0612:
0613:            public void testGetIntegerArray() {
0614:                // missing list
0615:                int[] defaultValue = new int[] { 2, 1 };
0616:                ArrayAssert.assertEquals(defaultValue, conf.getIntArray(
0617:                        "integer.list", defaultValue));
0618:
0619:                int[] expected = new int[] { 1, 2 };
0620:
0621:                // list of strings
0622:                ArrayAssert.assertEquals(expected, conf
0623:                        .getIntArray("integer.list1"));
0624:
0625:                // list of strings, comma separated
0626:                ArrayAssert.assertEquals(expected, conf
0627:                        .getIntArray("integer.list2"));
0628:
0629:                // list of Integer objects
0630:                ArrayAssert.assertEquals(expected, conf
0631:                        .getIntArray("integer.list3"));
0632:
0633:                // array of Integer objects
0634:                ArrayAssert.assertEquals(expected, conf
0635:                        .getIntArray("integer.list4"));
0636:
0637:                // array of int primitives
0638:                ArrayAssert.assertEquals(expected, conf
0639:                        .getIntArray("integer.list5"));
0640:
0641:                // list of Integer objects
0642:                ArrayAssert.assertEquals(expected, conf
0643:                        .getIntArray("integer.list6"));
0644:
0645:                // list of interpolated values
0646:                ArrayAssert.assertEquals(expected, conf
0647:                        .getIntArray("integer.list.interpolated"));
0648:
0649:                // single int values
0650:                ArrayAssert.assertEquals(new int[] { 1 }, conf
0651:                        .getIntArray("integer.string"));
0652:                ArrayAssert.assertEquals(new int[] { 1 }, conf
0653:                        .getIntArray("integer.object"));
0654:
0655:                // empty array
0656:                ArrayAssert.assertEquals(new int[] {}, conf
0657:                        .getIntArray("empty"));
0658:            }
0659:
0660:            public void testGetIntegerList() {
0661:                // missing list
0662:                ListAssert.assertEquals(null, conf.getIntegerList(
0663:                        "integer.list", null));
0664:
0665:                List expected = new ArrayList();
0666:                expected.add(new Integer("1"));
0667:                expected.add(new Integer("2"));
0668:
0669:                // list of strings
0670:                ListAssert.assertEquals(expected, conf
0671:                        .getIntegerList("integer.list1"));
0672:
0673:                // list of strings, comma separated
0674:                ListAssert.assertEquals(expected, conf
0675:                        .getIntegerList("integer.list2"));
0676:
0677:                // list of Integer objects
0678:                ListAssert.assertEquals(expected, conf
0679:                        .getIntegerList("integer.list3"));
0680:
0681:                // array of Integer objects
0682:                ListAssert.assertEquals(expected, conf
0683:                        .getIntegerList("integer.list4"));
0684:
0685:                // array of int primitives
0686:                ListAssert.assertEquals(expected, conf
0687:                        .getIntegerList("integer.list5"));
0688:
0689:                // list of Integer objects
0690:                ListAssert.assertEquals(expected, conf
0691:                        .getIntegerList("integer.list6"));
0692:
0693:                // list of interpolated values
0694:                ListAssert.assertEquals(expected, conf
0695:                        .getIntegerList("integer.list.interpolated"));
0696:
0697:                // single int values
0698:                expected = new ArrayList();
0699:                expected.add(new Integer("1"));
0700:                ListAssert.assertEquals(expected, conf
0701:                        .getIntegerList("integer.string"));
0702:                ListAssert.assertEquals(expected, conf
0703:                        .getIntegerList("integer.object"));
0704:
0705:                // empty list
0706:                ListAssert.assertEquals(new ArrayList(), conf
0707:                        .getIntegerList("empty"));
0708:            }
0709:
0710:            public void testGetLongArray() {
0711:                // missing list
0712:                long[] defaultValue = new long[] { 2, 1 };
0713:                ArrayAssert.assertEquals(defaultValue, conf.getLongArray(
0714:                        "long.list", defaultValue));
0715:
0716:                long[] expected = new long[] { 1, 2 };
0717:
0718:                // list of strings
0719:                ArrayAssert.assertEquals(expected, conf
0720:                        .getLongArray("long.list1"));
0721:
0722:                // list of strings, comma separated
0723:                ArrayAssert.assertEquals(expected, conf
0724:                        .getLongArray("long.list2"));
0725:
0726:                // list of Long objects
0727:                ArrayAssert.assertEquals(expected, conf
0728:                        .getLongArray("long.list3"));
0729:
0730:                // array of Long objects
0731:                ArrayAssert.assertEquals(expected, conf
0732:                        .getLongArray("long.list4"));
0733:
0734:                // array of long primitives
0735:                ArrayAssert.assertEquals(expected, conf
0736:                        .getLongArray("long.list5"));
0737:
0738:                // list of Long objects
0739:                ArrayAssert.assertEquals(expected, conf
0740:                        .getLongArray("long.list6"));
0741:
0742:                // list of interpolated values
0743:                ArrayAssert.assertEquals(expected, conf
0744:                        .getLongArray("long.list.interpolated"));
0745:
0746:                // single long values
0747:                ArrayAssert.assertEquals(new long[] { 1 }, conf
0748:                        .getLongArray("long.string"));
0749:                ArrayAssert.assertEquals(new long[] { 1 }, conf
0750:                        .getLongArray("long.object"));
0751:
0752:                // empty array
0753:                ArrayAssert.assertEquals(new long[] {}, conf
0754:                        .getLongArray("empty"));
0755:            }
0756:
0757:            public void testGetLongList() {
0758:                // missing list
0759:                ListAssert.assertEquals(null, conf.getLongList("long.list",
0760:                        null));
0761:
0762:                List expected = new ArrayList();
0763:                expected.add(new Long("1"));
0764:                expected.add(new Long("2"));
0765:
0766:                // list of strings
0767:                ListAssert.assertEquals(expected, conf
0768:                        .getLongList("long.list1"));
0769:
0770:                // list of strings, comma separated
0771:                ListAssert.assertEquals(expected, conf
0772:                        .getLongList("long.list2"));
0773:
0774:                // list of Long objects
0775:                ListAssert.assertEquals(expected, conf
0776:                        .getLongList("long.list3"));
0777:
0778:                // array of Long objects
0779:                ListAssert.assertEquals(expected, conf
0780:                        .getLongList("long.list4"));
0781:
0782:                // array of long primitives
0783:                ListAssert.assertEquals(expected, conf
0784:                        .getLongList("long.list5"));
0785:
0786:                // list of Long objects
0787:                ListAssert.assertEquals(expected, conf
0788:                        .getLongList("long.list6"));
0789:
0790:                // list of interpolated values
0791:                ListAssert.assertEquals(expected, conf
0792:                        .getLongList("long.list.interpolated"));
0793:
0794:                // single long values
0795:                expected = new ArrayList();
0796:                expected.add(new Long("1"));
0797:                ListAssert.assertEquals(expected, conf
0798:                        .getLongList("long.string"));
0799:                ListAssert.assertEquals(expected, conf
0800:                        .getLongList("long.object"));
0801:
0802:                // empty list
0803:                ListAssert.assertEquals(new ArrayList(), conf
0804:                        .getLongList("empty"));
0805:            }
0806:
0807:            public void testGetFloatArray() {
0808:                // missing list
0809:                float[] defaultValue = new float[] { 2, 1 };
0810:                ArrayAssert.assertEquals(defaultValue, conf.getFloatArray(
0811:                        "float.list", defaultValue), 0);
0812:
0813:                float[] expected = new float[] { 1, 2 };
0814:
0815:                // list of strings
0816:                ArrayAssert.assertEquals(expected, conf
0817:                        .getFloatArray("float.list1"), 0);
0818:
0819:                // list of strings, comma separated
0820:                ArrayAssert.assertEquals(expected, conf
0821:                        .getFloatArray("float.list2"), 0);
0822:
0823:                // list of Float objects
0824:                ArrayAssert.assertEquals(expected, conf
0825:                        .getFloatArray("float.list3"), 0);
0826:
0827:                // array of Float objects
0828:                ArrayAssert.assertEquals(expected, conf
0829:                        .getFloatArray("float.list4"), 0);
0830:
0831:                // array of float primitives
0832:                ArrayAssert.assertEquals(expected, conf
0833:                        .getFloatArray("float.list5"), 0);
0834:
0835:                // list of Float objects
0836:                ArrayAssert.assertEquals(expected, conf
0837:                        .getFloatArray("float.list6"), 0);
0838:
0839:                // list of interpolated values
0840:                ArrayAssert.assertEquals(expected, conf
0841:                        .getFloatArray("float.list.interpolated"), 0);
0842:
0843:                // single float values
0844:                ArrayAssert.assertEquals(new float[] { 1 }, conf
0845:                        .getFloatArray("float.string"), 0);
0846:                ArrayAssert.assertEquals(new float[] { 1 }, conf
0847:                        .getFloatArray("float.object"), 0);
0848:
0849:                // empty array
0850:                ArrayAssert.assertEquals(new float[] {}, conf
0851:                        .getFloatArray("empty"), 0);
0852:            }
0853:
0854:            public void testGetFloatList() {
0855:                // missing list
0856:                ListAssert.assertEquals(null, conf.getFloatList("float.list",
0857:                        null));
0858:
0859:                List expected = new ArrayList();
0860:                expected.add(new Float("1"));
0861:                expected.add(new Float("2"));
0862:
0863:                // list of strings
0864:                ListAssert.assertEquals(expected, conf
0865:                        .getFloatList("float.list1"));
0866:
0867:                // list of strings, comma separated
0868:                ListAssert.assertEquals(expected, conf
0869:                        .getFloatList("float.list2"));
0870:
0871:                // list of Float objects
0872:                ListAssert.assertEquals(expected, conf
0873:                        .getFloatList("float.list3"));
0874:
0875:                // array of Float objects
0876:                ListAssert.assertEquals(expected, conf
0877:                        .getFloatList("float.list4"));
0878:
0879:                // array of float primitives
0880:                ListAssert.assertEquals(expected, conf
0881:                        .getFloatList("float.list5"));
0882:
0883:                // list of Float objects
0884:                ListAssert.assertEquals(expected, conf
0885:                        .getFloatList("float.list6"));
0886:
0887:                // list of interpolated values
0888:                ListAssert.assertEquals(expected, conf
0889:                        .getFloatList("float.list.interpolated"));
0890:
0891:                // single float values
0892:                expected = new ArrayList();
0893:                expected.add(new Float("1"));
0894:                ListAssert.assertEquals(expected, conf
0895:                        .getFloatList("float.string"));
0896:                ListAssert.assertEquals(expected, conf
0897:                        .getFloatList("float.object"));
0898:
0899:                // empty list
0900:                ListAssert.assertEquals(new ArrayList(), conf
0901:                        .getFloatList("empty"));
0902:            }
0903:
0904:            public void testGetDoubleArray() {
0905:                // missing list
0906:                double[] defaultValue = new double[] { 2, 1 };
0907:                ArrayAssert.assertEquals(defaultValue, conf.getDoubleArray(
0908:                        "double.list", defaultValue), 0);
0909:
0910:                double[] expected = new double[] { 1, 2 };
0911:
0912:                // list of strings
0913:                ArrayAssert.assertEquals(expected, conf
0914:                        .getDoubleArray("double.list1"), 0);
0915:
0916:                // list of strings, comma separated
0917:                ArrayAssert.assertEquals(expected, conf
0918:                        .getDoubleArray("double.list2"), 0);
0919:
0920:                // list of Double objects
0921:                ArrayAssert.assertEquals(expected, conf
0922:                        .getDoubleArray("double.list3"), 0);
0923:
0924:                // array of Double objects
0925:                ArrayAssert.assertEquals(expected, conf
0926:                        .getDoubleArray("double.list4"), 0);
0927:
0928:                // array of double primitives
0929:                ArrayAssert.assertEquals(expected, conf
0930:                        .getDoubleArray("double.list5"), 0);
0931:
0932:                // list of Double objects
0933:                ArrayAssert.assertEquals(expected, conf
0934:                        .getDoubleArray("double.list6"), 0);
0935:
0936:                // list of interpolated values
0937:                ArrayAssert.assertEquals(expected, conf
0938:                        .getDoubleArray("double.list.interpolated"), 0);
0939:
0940:                // single double values
0941:                ArrayAssert.assertEquals(new double[] { 1 }, conf
0942:                        .getDoubleArray("double.string"), 0);
0943:                ArrayAssert.assertEquals(new double[] { 1 }, conf
0944:                        .getDoubleArray("double.object"), 0);
0945:
0946:                // empty array
0947:                ArrayAssert.assertEquals(new double[] {}, conf
0948:                        .getDoubleArray("empty"), 0);
0949:            }
0950:
0951:            public void testGetDoubleList() {
0952:                // missing list
0953:                ListAssert.assertEquals(null, conf.getDoubleList("double.list",
0954:                        null));
0955:
0956:                List expected = new ArrayList();
0957:                expected.add(new Double("1"));
0958:                expected.add(new Double("2"));
0959:
0960:                // list of strings
0961:                ListAssert.assertEquals(expected, conf
0962:                        .getDoubleList("double.list1"));
0963:
0964:                // list of strings, comma separated
0965:                ListAssert.assertEquals(expected, conf
0966:                        .getDoubleList("double.list2"));
0967:
0968:                // list of Double objects
0969:                ListAssert.assertEquals(expected, conf
0970:                        .getDoubleList("double.list3"));
0971:
0972:                // array of Double objects
0973:                ListAssert.assertEquals(expected, conf
0974:                        .getDoubleList("double.list4"));
0975:
0976:                // array of double primitives
0977:                ListAssert.assertEquals(expected, conf
0978:                        .getDoubleList("double.list5"));
0979:
0980:                // list of Double objects
0981:                ListAssert.assertEquals(expected, conf
0982:                        .getDoubleList("double.list6"));
0983:
0984:                // list of interpolated values
0985:                ListAssert.assertEquals(expected, conf
0986:                        .getDoubleList("double.list.interpolated"));
0987:
0988:                // single double values
0989:                expected = new ArrayList();
0990:                expected.add(new Double("1"));
0991:                ListAssert.assertEquals(expected, conf
0992:                        .getDoubleList("double.string"));
0993:                ListAssert.assertEquals(expected, conf
0994:                        .getDoubleList("double.object"));
0995:
0996:                // empty list
0997:                ListAssert.assertEquals(new ArrayList(), conf
0998:                        .getDoubleList("empty"));
0999:            }
1000:
1001:            public void testGetBigIntegerArray() {
1002:                // missing list
1003:                BigInteger[] defaultValue = new BigInteger[] {
1004:                        new BigInteger("2"), new BigInteger("1") };
1005:                ArrayAssert.assertEquals(defaultValue, conf.getBigIntegerArray(
1006:                        "biginteger.list", defaultValue));
1007:
1008:                BigInteger[] expected = new BigInteger[] { new BigInteger("1"),
1009:                        new BigInteger("2") };
1010:
1011:                // list of strings
1012:                ArrayAssert.assertEquals(expected, conf
1013:                        .getBigIntegerArray("biginteger.list1"));
1014:
1015:                // list of strings, comma separated
1016:                ArrayAssert.assertEquals(expected, conf
1017:                        .getBigIntegerArray("biginteger.list2"));
1018:
1019:                // list of BigInteger objects
1020:                ArrayAssert.assertEquals(expected, conf
1021:                        .getBigIntegerArray("biginteger.list3"));
1022:
1023:                // array of BigInteger objects
1024:                ArrayAssert.assertEquals(expected, conf
1025:                        .getBigIntegerArray("biginteger.list4"));
1026:
1027:                // list of BigInteger objects
1028:                ArrayAssert.assertEquals(expected, conf
1029:                        .getBigIntegerArray("biginteger.list6"));
1030:
1031:                // list of interpolated values
1032:                ArrayAssert.assertEquals(expected, conf
1033:                        .getBigIntegerArray("biginteger.list.interpolated"));
1034:
1035:                // single BigInteger values
1036:                ArrayAssert.assertEquals(
1037:                        new BigInteger[] { new BigInteger("1") }, conf
1038:                                .getBigIntegerArray("biginteger.string"));
1039:                ArrayAssert.assertEquals(
1040:                        new BigInteger[] { new BigInteger("1") }, conf
1041:                                .getBigIntegerArray("biginteger.object"));
1042:
1043:                // empty array
1044:                ArrayAssert.assertEquals(new BigInteger[] {}, conf
1045:                        .getBigIntegerArray("empty"));
1046:            }
1047:
1048:            public void testGetBigIntegerList() {
1049:                // missing list
1050:                ListAssert.assertEquals(null, conf.getBigIntegerList(
1051:                        "biginteger.list", null));
1052:
1053:                List expected = new ArrayList();
1054:                expected.add(new BigInteger("1"));
1055:                expected.add(new BigInteger("2"));
1056:
1057:                // list of strings
1058:                ListAssert.assertEquals(expected, conf
1059:                        .getBigIntegerList("biginteger.list1"));
1060:
1061:                // list of strings, comma separated
1062:                ListAssert.assertEquals(expected, conf
1063:                        .getBigIntegerList("biginteger.list2"));
1064:
1065:                // list of BigInteger objects
1066:                ListAssert.assertEquals(expected, conf
1067:                        .getBigIntegerList("biginteger.list3"));
1068:
1069:                // array of BigInteger objects
1070:                ListAssert.assertEquals(expected, conf
1071:                        .getBigIntegerList("biginteger.list4"));
1072:
1073:                // list of BigInteger objects
1074:                ListAssert.assertEquals(expected, conf
1075:                        .getBigIntegerList("biginteger.list6"));
1076:
1077:                // list of interpolated values
1078:                ListAssert.assertEquals(expected, conf
1079:                        .getBigIntegerList("biginteger.list.interpolated"));
1080:
1081:                // single BigInteger values
1082:                expected = new ArrayList();
1083:                expected.add(new BigInteger("1"));
1084:                ListAssert.assertEquals(expected, conf
1085:                        .getBigIntegerList("biginteger.string"));
1086:                ListAssert.assertEquals(expected, conf
1087:                        .getBigIntegerList("biginteger.object"));
1088:
1089:                // empty list
1090:                ListAssert.assertEquals(new ArrayList(), conf
1091:                        .getBigIntegerList("empty"));
1092:            }
1093:
1094:            public void testGetBigDecimalArray() {
1095:                // missing list
1096:                BigDecimal[] defaultValue = new BigDecimal[] {
1097:                        new BigDecimal("2"), new BigDecimal("1") };
1098:                ArrayAssert.assertEquals(defaultValue, conf.getBigDecimalArray(
1099:                        "bigdecimal.list", defaultValue));
1100:
1101:                BigDecimal[] expected = new BigDecimal[] { new BigDecimal("1"),
1102:                        new BigDecimal("2") };
1103:
1104:                // list of strings
1105:                ArrayAssert.assertEquals(expected, conf
1106:                        .getBigDecimalArray("bigdecimal.list1"));
1107:
1108:                // list of strings, comma separated
1109:                ArrayAssert.assertEquals(expected, conf
1110:                        .getBigDecimalArray("bigdecimal.list2"));
1111:
1112:                // list of BigDecimal objects
1113:                ArrayAssert.assertEquals(expected, conf
1114:                        .getBigDecimalArray("bigdecimal.list3"));
1115:
1116:                // array of BigDecimal objects
1117:                ArrayAssert.assertEquals(expected, conf
1118:                        .getBigDecimalArray("bigdecimal.list4"));
1119:
1120:                // list of BigDecimal objects
1121:                ArrayAssert.assertEquals(expected, conf
1122:                        .getBigDecimalArray("bigdecimal.list6"));
1123:
1124:                // list of interpolated values
1125:                ArrayAssert.assertEquals(expected, conf
1126:                        .getBigDecimalArray("bigdecimal.list.interpolated"));
1127:
1128:                // single BigDecimal values
1129:                ArrayAssert.assertEquals(
1130:                        new BigDecimal[] { new BigDecimal("1") }, conf
1131:                                .getBigDecimalArray("bigdecimal.string"));
1132:                ArrayAssert.assertEquals(
1133:                        new BigDecimal[] { new BigDecimal("1") }, conf
1134:                                .getBigDecimalArray("bigdecimal.object"));
1135:
1136:                // empty array
1137:                ArrayAssert.assertEquals(new BigDecimal[] {}, conf
1138:                        .getBigDecimalArray("empty"));
1139:            }
1140:
1141:            public void testGetBigDecimalList() {
1142:                // missing list
1143:                ListAssert.assertEquals(null, conf.getBigDecimalList(
1144:                        "bigdecimal.list", null));
1145:
1146:                List expected = new ArrayList();
1147:                expected.add(new BigDecimal("1"));
1148:                expected.add(new BigDecimal("2"));
1149:
1150:                // list of strings
1151:                ListAssert.assertEquals(expected, conf
1152:                        .getBigDecimalList("bigdecimal.list1"));
1153:
1154:                // list of strings, comma separated
1155:                ListAssert.assertEquals(expected, conf
1156:                        .getBigDecimalList("bigdecimal.list2"));
1157:
1158:                // list of BigDecimal objects
1159:                ListAssert.assertEquals(expected, conf
1160:                        .getBigDecimalList("bigdecimal.list3"));
1161:
1162:                // array of BigDecimal objects
1163:                ListAssert.assertEquals(expected, conf
1164:                        .getBigDecimalList("bigdecimal.list4"));
1165:
1166:                // list of BigDecimal objects
1167:                ListAssert.assertEquals(expected, conf
1168:                        .getBigDecimalList("bigdecimal.list6"));
1169:
1170:                // list of interpolated values
1171:                ListAssert.assertEquals(expected, conf
1172:                        .getBigDecimalList("bigdecimal.list.interpolated"));
1173:
1174:                // single BigDecimal values
1175:                expected = new ArrayList();
1176:                expected.add(new BigDecimal("1"));
1177:                ListAssert.assertEquals(expected, conf
1178:                        .getBigDecimalList("bigdecimal.string"));
1179:                ListAssert.assertEquals(expected, conf
1180:                        .getBigDecimalList("bigdecimal.object"));
1181:
1182:                // empty list
1183:                ListAssert.assertEquals(new ArrayList(), conf
1184:                        .getBigDecimalList("empty"));
1185:            }
1186:
1187:            public void testGetURL() throws Exception {
1188:                // missing URL
1189:                URL defaultValue = new URL("http://www.google.com");
1190:                assertEquals(defaultValue, conf.getURL("url", defaultValue));
1191:
1192:                URL expected = new URL("http://jakarta.apache.org");
1193:
1194:                // URL string
1195:                assertEquals(expected, conf.getURL("url.string"));
1196:
1197:                // URL object
1198:                assertEquals(expected, conf.getURL("url.object"));
1199:
1200:                // interpolated value
1201:                assertEquals(expected, conf.getURL("url.string.interpolated"));
1202:            }
1203:
1204:            public void testGetURLArray() throws Exception {
1205:                // missing list
1206:                URL[] defaultValue = new URL[] {
1207:                        new URL("http://www.apache.org"),
1208:                        new URL("http://jakarta.apache.org") };
1209:                ArrayAssert.assertEquals(defaultValue, conf.getURLArray(
1210:                        "url.list", defaultValue));
1211:
1212:                URL[] expected = new URL[] {
1213:                        new URL("http://jakarta.apache.org"),
1214:                        new URL("http://www.apache.org") };
1215:
1216:                // list of strings
1217:                ArrayAssert.assertEquals(expected, conf
1218:                        .getURLArray("url.list1"));
1219:
1220:                // list of strings, comma separated
1221:                ArrayAssert.assertEquals(expected, conf
1222:                        .getURLArray("url.list2"));
1223:
1224:                // list of URL objects
1225:                ArrayAssert.assertEquals(expected, conf
1226:                        .getURLArray("url.list3"));
1227:
1228:                // array of URL objects
1229:                ArrayAssert.assertEquals(expected, conf
1230:                        .getURLArray("url.list4"));
1231:
1232:                // list of URL objects
1233:                ArrayAssert.assertEquals(expected, conf
1234:                        .getURLArray("url.list6"));
1235:
1236:                // list of interpolated values
1237:                ArrayAssert.assertEquals(expected, conf
1238:                        .getURLArray("url.list.interpolated"));
1239:
1240:                // single URL values
1241:                ArrayAssert.assertEquals(new URL[] { new URL(
1242:                        "http://jakarta.apache.org") }, conf
1243:                        .getURLArray("url.string"));
1244:                ArrayAssert.assertEquals(new URL[] { new URL(
1245:                        "http://jakarta.apache.org") }, conf
1246:                        .getURLArray("url.object"));
1247:
1248:                // empty array
1249:                ArrayAssert.assertEquals(new URL[] {}, conf
1250:                        .getURLArray("empty"));
1251:            }
1252:
1253:            public void testGetURLList() throws Exception {
1254:                // missing list
1255:                ListAssert
1256:                        .assertEquals(null, conf.getURLList("url.list", null));
1257:
1258:                List expected = new ArrayList();
1259:                expected.add(new URL("http://jakarta.apache.org"));
1260:                expected.add(new URL("http://www.apache.org"));
1261:
1262:                // list of strings
1263:                ListAssert.assertEquals(expected, conf.getURLList("url.list1"));
1264:
1265:                // list of strings, comma separated
1266:                ListAssert.assertEquals(expected, conf.getURLList("url.list2"));
1267:
1268:                // list of URL objects
1269:                ListAssert.assertEquals(expected, conf.getURLList("url.list3"));
1270:
1271:                // array of URL objects
1272:                ListAssert.assertEquals(expected, conf.getURLList("url.list4"));
1273:
1274:                // list of URL objects
1275:                ListAssert.assertEquals(expected, conf.getURLList("url.list6"));
1276:
1277:                // list of interpolated values
1278:                ListAssert.assertEquals(expected, conf
1279:                        .getURLList("url.list.interpolated"));
1280:
1281:                // single URL values
1282:                expected = new ArrayList();
1283:                expected.add(new URL("http://jakarta.apache.org"));
1284:                ListAssert
1285:                        .assertEquals(expected, conf.getURLList("url.string"));
1286:                ListAssert
1287:                        .assertEquals(expected, conf.getURLList("url.object"));
1288:
1289:                // empty list
1290:                ListAssert.assertEquals(new ArrayList(), conf
1291:                        .getURLList("empty"));
1292:            }
1293:
1294:            public void testGetLocale() {
1295:                // language
1296:                conf.setProperty("locale", "fr");
1297:                assertEquals("language", new Locale("fr", ""), conf
1298:                        .getLocale("locale"));
1299:
1300:                // language + variant
1301:                conf.setProperty("locale", "fr__POSIX");
1302:                assertEquals("language + variant",
1303:                        new Locale("fr", "", "POSIX"), conf.getLocale("locale"));
1304:
1305:                // country
1306:                conf.setProperty("locale", "_FR");
1307:                assertEquals("country", new Locale("", "FR"), conf
1308:                        .getLocale("locale"));
1309:
1310:                // country + variant
1311:                conf.setProperty("locale", "_FR_WIN");
1312:                assertEquals("country + variant", new Locale("", "FR", "WIN"),
1313:                        conf.getLocale("locale"));
1314:
1315:                // language + country
1316:                conf.setProperty("locale", "fr_FR");
1317:                assertEquals("language + country", new Locale("fr", "FR"), conf
1318:                        .getLocale("locale"));
1319:
1320:                // language + country + variant
1321:                conf.setProperty("locale", "fr_FR_MAC");
1322:                assertEquals("language + country + variant", new Locale("fr",
1323:                        "FR", "MAC"), conf.getLocale("locale"));
1324:
1325:                // default value
1326:                conf.setProperty("locale", "fr");
1327:                assertEquals("Existing key with default value", Locale.FRENCH,
1328:                        conf.getLocale("locale", Locale.GERMAN));
1329:                assertEquals("Missing key with default value", Locale.GERMAN,
1330:                        conf.getLocale("localeNotInConfig", Locale.GERMAN));
1331:
1332:                // interpolated value
1333:                assertEquals(Locale.FRENCH, conf
1334:                        .getLocale("locale.string.interpolated"));
1335:            }
1336:
1337:            public void testGetLocaleArray() throws Exception {
1338:                // missing list
1339:                Locale[] defaultValue = new Locale[] { Locale.GERMAN,
1340:                        Locale.FRENCH };
1341:                ArrayAssert.assertEquals(defaultValue, conf.getLocaleArray(
1342:                        "locale.list", defaultValue));
1343:
1344:                Locale[] expected = new Locale[] { Locale.FRENCH, Locale.GERMAN };
1345:
1346:                // list of strings
1347:                ArrayAssert.assertEquals(expected, conf
1348:                        .getLocaleArray("locale.list1"));
1349:
1350:                // list of strings, comma separated
1351:                ArrayAssert.assertEquals(expected, conf
1352:                        .getLocaleArray("locale.list2"));
1353:
1354:                // list of Locale objects
1355:                ArrayAssert.assertEquals(expected, conf
1356:                        .getLocaleArray("locale.list3"));
1357:
1358:                // array of Locale objects
1359:                ArrayAssert.assertEquals(expected, conf
1360:                        .getLocaleArray("locale.list4"));
1361:
1362:                // list of Locale objects
1363:                ArrayAssert.assertEquals(expected, conf
1364:                        .getLocaleArray("locale.list6"));
1365:
1366:                // list of interpolated values
1367:                ArrayAssert.assertEquals(expected, conf
1368:                        .getLocaleArray("locale.list.interpolated"));
1369:
1370:                // single Locale values
1371:                ArrayAssert.assertEquals(new Locale[] { Locale.FRENCH }, conf
1372:                        .getLocaleArray("locale.string"));
1373:                ArrayAssert.assertEquals(new Locale[] { Locale.FRENCH }, conf
1374:                        .getLocaleArray("locale.object"));
1375:
1376:                // empty array
1377:                ArrayAssert.assertEquals(new Locale[] {}, conf
1378:                        .getLocaleArray("empty"));
1379:            }
1380:
1381:            public void testGetLocaleList() throws Exception {
1382:                // missing list
1383:                ListAssert.assertEquals(null, conf.getLocaleList("locale.list",
1384:                        null));
1385:
1386:                List expected = new ArrayList();
1387:                expected.add(Locale.FRENCH);
1388:                expected.add(Locale.GERMAN);
1389:
1390:                // list of strings
1391:                ListAssert.assertEquals(expected, conf
1392:                        .getLocaleList("locale.list1"));
1393:
1394:                // list of strings, comma separated
1395:                ListAssert.assertEquals(expected, conf
1396:                        .getLocaleList("locale.list2"));
1397:
1398:                // list of Locale objects
1399:                ListAssert.assertEquals(expected, conf
1400:                        .getLocaleList("locale.list3"));
1401:
1402:                // array of Locale objects
1403:                ListAssert.assertEquals(expected, conf
1404:                        .getLocaleList("locale.list4"));
1405:
1406:                // list of Locale objects
1407:                ListAssert.assertEquals(expected, conf
1408:                        .getLocaleList("locale.list6"));
1409:
1410:                // list of interpolated values
1411:                ListAssert.assertEquals(expected, conf
1412:                        .getLocaleList("locale.list.interpolated"));
1413:
1414:                // single Locale values
1415:                expected = new ArrayList();
1416:                expected.add(Locale.FRENCH);
1417:                ListAssert.assertEquals(expected, conf
1418:                        .getLocaleList("locale.string"));
1419:                ListAssert.assertEquals(expected, conf
1420:                        .getLocaleList("locale.object"));
1421:
1422:                // empty list
1423:                ListAssert.assertEquals(new ArrayList(), conf
1424:                        .getLocaleList("empty"));
1425:            }
1426:
1427:            public void testGetColor() {
1428:                // RRGGBB
1429:                conf.setProperty("color", "FF0000");
1430:                assertEquals("color", Color.red, conf.getColor("color"));
1431:
1432:                // #RRGGBB
1433:                conf.setProperty("color", "#00FF00");
1434:                assertEquals("color", Color.green, conf.getColor("color"));
1435:
1436:                // #RRGGBBAA
1437:                conf.setProperty("color", "#01030507");
1438:                Color color = conf.getColor("color");
1439:                assertNotNull("null color", color);
1440:                assertEquals("red", 1, color.getRed());
1441:                assertEquals("green", 3, color.getGreen());
1442:                assertEquals("blue", 5, color.getBlue());
1443:                assertEquals("alpha", 7, color.getAlpha());
1444:
1445:                // interpolated value
1446:                assertEquals(Color.red, conf
1447:                        .getColor("color.string.interpolated"));
1448:            }
1449:
1450:            public void testGetColorArray() throws Exception {
1451:                // missing list
1452:                Color[] defaultValue = new Color[] { Color.red, Color.blue };
1453:                ArrayAssert.assertEquals(defaultValue, conf.getColorArray(
1454:                        "color.list", defaultValue));
1455:
1456:                Color[] expected = new Color[] { Color.red, Color.blue };
1457:
1458:                // list of strings
1459:                ArrayAssert.assertEquals(expected, conf
1460:                        .getColorArray("color.list1"));
1461:
1462:                // list of strings, comma separated
1463:                ArrayAssert.assertEquals(expected, conf
1464:                        .getColorArray("color.list2"));
1465:
1466:                // list of Color objects
1467:                ArrayAssert.assertEquals(expected, conf
1468:                        .getColorArray("color.list3"));
1469:
1470:                // array of Color objects
1471:                ArrayAssert.assertEquals(expected, conf
1472:                        .getColorArray("color.list4"));
1473:
1474:                // list of Color objects
1475:                ArrayAssert.assertEquals(expected, conf
1476:                        .getColorArray("color.list6"));
1477:
1478:                // list of interpolated values
1479:                ArrayAssert.assertEquals(expected, conf
1480:                        .getColorArray("color.list.interpolated"));
1481:
1482:                // single Color values
1483:                ArrayAssert.assertEquals(new Color[] { Color.red }, conf
1484:                        .getColorArray("color.string"));
1485:                ArrayAssert.assertEquals(new Color[] { Color.red }, conf
1486:                        .getColorArray("color.object"));
1487:
1488:                // empty array
1489:                ArrayAssert.assertEquals(new Color[] {}, conf
1490:                        .getColorArray("empty"));
1491:            }
1492:
1493:            public void testGetColorList() throws Exception {
1494:                // missing list
1495:                ListAssert.assertEquals(null, conf.getColorList("color.list",
1496:                        null));
1497:
1498:                List expected = new ArrayList();
1499:                expected.add(Color.red);
1500:                expected.add(Color.blue);
1501:
1502:                // list of strings
1503:                ListAssert.assertEquals(expected, conf
1504:                        .getColorList("color.list1"));
1505:
1506:                // list of strings, comma separated
1507:                ListAssert.assertEquals(expected, conf
1508:                        .getColorList("color.list2"));
1509:
1510:                // list of Color objects
1511:                ListAssert.assertEquals(expected, conf
1512:                        .getColorList("color.list3"));
1513:
1514:                // array of Color objects
1515:                ListAssert.assertEquals(expected, conf
1516:                        .getColorList("color.list4"));
1517:
1518:                // list of Color objects
1519:                ListAssert.assertEquals(expected, conf
1520:                        .getColorList("color.list6"));
1521:
1522:                // list of interpolated values
1523:                ListAssert.assertEquals(expected, conf
1524:                        .getColorList("color.list.interpolated"));
1525:
1526:                // single Color values
1527:                expected = new ArrayList();
1528:                expected.add(Color.red);
1529:                ListAssert.assertEquals(expected, conf
1530:                        .getColorList("color.string"));
1531:                ListAssert.assertEquals(expected, conf
1532:                        .getColorList("color.object"));
1533:
1534:                // empty list
1535:                ListAssert.assertEquals(new ArrayList(), conf
1536:                        .getColorList("empty"));
1537:            }
1538:
1539:            public void testGetDate() throws Exception {
1540:                DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
1541:
1542:                // missing Date
1543:                Date defaultValue = new Date();
1544:                assertEquals(defaultValue, conf.getDate("date", defaultValue));
1545:
1546:                Date expected = format.parse("2004-01-01");
1547:
1548:                // Date string
1549:                assertEquals(expected, conf.getDate("date.string"));
1550:
1551:                // Date object
1552:                assertEquals(expected, conf.getDate("date.object"));
1553:
1554:                // Calendar object
1555:                assertEquals(expected, conf.getDate("calendar.object"));
1556:
1557:                // interpolated value
1558:                assertEquals(expected, conf.getDate("date.string.interpolated"));
1559:            }
1560:
1561:            public void testGetDateArray() throws Exception {
1562:                DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
1563:                Date date1 = format.parse("2004-01-01");
1564:                Date date2 = format.parse("2004-12-31");
1565:
1566:                // missing list
1567:                Date[] defaultValue = new Date[] { date2, date1 };
1568:                ArrayAssert.assertEquals(defaultValue, conf.getDateArray(
1569:                        "date.list", defaultValue));
1570:
1571:                Date[] expected = new Date[] { date1, date2 };
1572:
1573:                // list of strings
1574:                ArrayAssert.assertEquals(expected, conf
1575:                        .getDateArray("date.list1"));
1576:
1577:                // list of strings, comma separated
1578:                ArrayAssert.assertEquals(expected, conf
1579:                        .getDateArray("date.list2"));
1580:
1581:                // list of Date objects
1582:                ArrayAssert.assertEquals(expected, conf
1583:                        .getDateArray("date.list3"));
1584:
1585:                // array of Date objects
1586:                ArrayAssert.assertEquals(expected, conf
1587:                        .getDateArray("date.list4"));
1588:
1589:                // list of Calendar objects
1590:                ArrayAssert.assertEquals(expected, conf
1591:                        .getDateArray("date.list5"));
1592:
1593:                // list of Date objects
1594:                ArrayAssert.assertEquals(expected, conf
1595:                        .getDateArray("date.list6"));
1596:
1597:                // list of interpolated values
1598:                ArrayAssert.assertEquals(expected, conf
1599:                        .getDateArray("date.list.interpolated"));
1600:
1601:                // single Date values
1602:                ArrayAssert.assertEquals(new Date[] { date1 }, conf
1603:                        .getDateArray("date.string"));
1604:                ArrayAssert.assertEquals(new Date[] { date1 }, conf
1605:                        .getDateArray("date.object"));
1606:
1607:                // empty array
1608:                ArrayAssert.assertEquals(new Date[] {}, conf
1609:                        .getDateArray("empty"));
1610:            }
1611:
1612:            public void testGetDateArrayWithFormat() throws Exception {
1613:                DateFormat format = new SimpleDateFormat("MM/dd/yyyy");
1614:                Date date1 = format.parse("01/01/2004");
1615:                Date date2 = format.parse("12/31/2004");
1616:                Date[] expected = new Date[] { date1, date2 };
1617:
1618:                conf.addProperty("date.format", "01/01/2004");
1619:                conf.addProperty("date.format", "12/31/2004");
1620:                ArrayAssert.assertEquals("Wrong dates with format", expected,
1621:                        conf.getDateArray("date.format", "MM/dd/yyyy"));
1622:            }
1623:
1624:            public void testGetDateList() throws Exception {
1625:                DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
1626:                Date date1 = format.parse("2004-01-01");
1627:                Date date2 = format.parse("2004-12-31");
1628:
1629:                // missing list
1630:                ListAssert.assertEquals(null, conf.getDateList("date.list",
1631:                        (List) null));
1632:
1633:                List expected = new ArrayList();
1634:                expected.add(date1);
1635:                expected.add(date2);
1636:
1637:                // list of strings
1638:                ListAssert.assertEquals(expected, conf
1639:                        .getDateList("date.list1"));
1640:
1641:                // list of strings, comma separated
1642:                ListAssert.assertEquals(expected, conf
1643:                        .getDateList("date.list2"));
1644:
1645:                // list of Date objects
1646:                ListAssert.assertEquals(expected, conf
1647:                        .getDateList("date.list3"));
1648:
1649:                // array of Date objects
1650:                ListAssert.assertEquals(expected, conf
1651:                        .getDateList("date.list4"));
1652:
1653:                // list of Calendar objects
1654:                ListAssert.assertEquals(expected, conf
1655:                        .getDateList("date.list5"));
1656:
1657:                // list of Date objects
1658:                ListAssert.assertEquals(expected, conf
1659:                        .getDateList("date.list6"));
1660:
1661:                // list of interpolated values
1662:                ListAssert.assertEquals(expected, conf
1663:                        .getDateList("date.list.interpolated"));
1664:
1665:                // single Date values
1666:                expected = new ArrayList();
1667:                expected.add(date1);
1668:                ListAssert.assertEquals(expected, conf
1669:                        .getDateList("date.string"));
1670:                ListAssert.assertEquals(expected, conf
1671:                        .getDateList("date.object"));
1672:
1673:                // empty list
1674:                ListAssert.assertEquals(new ArrayList(), conf
1675:                        .getDateList("empty"));
1676:            }
1677:
1678:            public void testGetCalendar() throws Exception {
1679:                DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
1680:
1681:                // missing Date
1682:                Calendar defaultValue = Calendar.getInstance();
1683:                defaultValue.setTime(new Date());
1684:                assertEquals(defaultValue, conf.getCalendar("calendar",
1685:                        defaultValue));
1686:
1687:                Calendar expected = Calendar.getInstance();
1688:                expected.setTime(format.parse("2004-01-01"));
1689:
1690:                // Calendar string
1691:                assertEquals(expected, conf.getCalendar("calendar.string"));
1692:
1693:                // Calendar object
1694:                assertEquals(expected, conf.getCalendar("calendar.object"));
1695:
1696:                // Date object
1697:                assertEquals(expected, conf.getCalendar("date.object"));
1698:
1699:                // interpolated value
1700:                assertEquals(expected, conf
1701:                        .getCalendar("calendar.string.interpolated"));
1702:            }
1703:
1704:            public void testGetCalendarArray() throws Exception {
1705:                DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
1706:                Date date1 = format.parse("2004-01-01");
1707:                Date date2 = format.parse("2004-12-31");
1708:                Calendar calendar1 = Calendar.getInstance();
1709:                calendar1.setTime(date1);
1710:                Calendar calendar2 = Calendar.getInstance();
1711:                calendar2.setTime(date2);
1712:
1713:                // missing list
1714:                Calendar[] defaultValue = new Calendar[] { calendar2, calendar1 };
1715:                ArrayAssert.assertEquals(defaultValue, conf.getCalendarArray(
1716:                        "calendar.list", defaultValue));
1717:
1718:                Calendar[] expected = new Calendar[] { calendar1, calendar2 };
1719:
1720:                // list of strings
1721:                ArrayAssert.assertEquals(expected, conf
1722:                        .getCalendarArray("calendar.list1"));
1723:
1724:                // list of strings, comma separated
1725:                ArrayAssert.assertEquals(expected, conf
1726:                        .getCalendarArray("calendar.list2"));
1727:
1728:                // list of Calendar objects
1729:                ArrayAssert.assertEquals(expected, conf
1730:                        .getCalendarArray("calendar.list3"));
1731:
1732:                // array of Calendar objects
1733:                ArrayAssert.assertEquals(expected, conf
1734:                        .getCalendarArray("calendar.list4"));
1735:
1736:                // list of Date objects
1737:                ArrayAssert.assertEquals(expected, conf
1738:                        .getCalendarArray("calendar.list5"));
1739:
1740:                // list of Calendar objects
1741:                ArrayAssert.assertEquals(expected, conf
1742:                        .getCalendarArray("calendar.list6"));
1743:
1744:                // list of interpolated values
1745:                ArrayAssert.assertEquals(expected, conf
1746:                        .getCalendarArray("calendar.list.interpolated"));
1747:
1748:                // single Calendar values
1749:                ArrayAssert.assertEquals(new Calendar[] { calendar1 }, conf
1750:                        .getCalendarArray("calendar.string"));
1751:                ArrayAssert.assertEquals(new Calendar[] { calendar1 }, conf
1752:                        .getCalendarArray("calendar.object"));
1753:
1754:                // empty array
1755:                ArrayAssert.assertEquals(new Calendar[] {}, conf
1756:                        .getCalendarArray("empty"));
1757:            }
1758:
1759:            public void testGetCalendarList() throws Exception {
1760:                DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
1761:                Date date1 = format.parse("2004-01-01");
1762:                Date date2 = format.parse("2004-12-31");
1763:                Calendar calendar1 = Calendar.getInstance();
1764:                calendar1.setTime(date1);
1765:                Calendar calendar2 = Calendar.getInstance();
1766:                calendar2.setTime(date2);
1767:
1768:                // missing list
1769:                ListAssert.assertEquals(null, conf.getCalendarList(
1770:                        "calendar.list", (List) null));
1771:
1772:                List expected = new ArrayList();
1773:                expected.add(calendar1);
1774:                expected.add(calendar2);
1775:
1776:                // list of strings
1777:                ListAssert.assertEquals(expected, conf
1778:                        .getCalendarList("calendar.list1"));
1779:
1780:                // list of strings, comma separated
1781:                ListAssert.assertEquals(expected, conf
1782:                        .getCalendarList("calendar.list2"));
1783:
1784:                // list of Calendar objects
1785:                ListAssert.assertEquals(expected, conf
1786:                        .getCalendarList("calendar.list3"));
1787:
1788:                // array of Calendar objects
1789:                ListAssert.assertEquals(expected, conf
1790:                        .getCalendarList("calendar.list4"));
1791:
1792:                // list of Date objects
1793:                ListAssert.assertEquals(expected, conf
1794:                        .getCalendarList("calendar.list5"));
1795:
1796:                // list of Calendar objects
1797:                ListAssert.assertEquals(expected, conf
1798:                        .getCalendarList("calendar.list6"));
1799:
1800:                // list of interpolated values
1801:                ListAssert.assertEquals(expected, conf
1802:                        .getCalendarList("calendar.list.interpolated"));
1803:
1804:                // single Calendar values
1805:                expected = new ArrayList();
1806:                expected.add(calendar1);
1807:                ListAssert.assertEquals(expected, conf
1808:                        .getCalendarList("date.string"));
1809:                ListAssert.assertEquals(expected, conf
1810:                        .getCalendarList("date.object"));
1811:
1812:                // empty list
1813:                ListAssert.assertEquals(new ArrayList(), conf
1814:                        .getCalendarList("empty"));
1815:            }
1816:
1817:            public void testConversionException() {
1818:                conf.addProperty("key1", new Object());
1819:                conf.addProperty("key2", "xxxxxx");
1820:
1821:                try {
1822:                    conf.getBooleanArray("key1");
1823:                    fail("getBooleanArray didn't throw a ConversionException");
1824:                } catch (ConversionException e) {
1825:                    // expected
1826:                }
1827:
1828:                try {
1829:                    conf.getBooleanArray("key2");
1830:                    fail("getBooleanArray didn't throw a ConversionException");
1831:                } catch (ConversionException e) {
1832:                    // expected
1833:                }
1834:
1835:                try {
1836:                    conf.getBooleanList("key1");
1837:                    fail("getBooleanList didn't throw a ConversionException");
1838:                } catch (ConversionException e) {
1839:                    // expected
1840:                }
1841:
1842:                try {
1843:                    conf.getBooleanList("key2");
1844:                    fail("getBooleanList didn't throw a ConversionException");
1845:                } catch (ConversionException e) {
1846:                    // expected
1847:                }
1848:
1849:                try {
1850:                    conf.getByteArray("key1");
1851:                    fail("getByteArray didn't throw a ConversionException");
1852:                } catch (ConversionException e) {
1853:                    // expected
1854:                }
1855:
1856:                try {
1857:                    conf.getByteArray("key2");
1858:                    fail("getByteArray didn't throw a ConversionException");
1859:                } catch (ConversionException e) {
1860:                    // expected
1861:                }
1862:
1863:                try {
1864:                    conf.getByteList("key1");
1865:                    fail("getByteList didn't throw a ConversionException");
1866:                } catch (ConversionException e) {
1867:                    // expected
1868:                }
1869:
1870:                try {
1871:                    conf.getByteList("key2");
1872:                    fail("getByteList didn't throw a ConversionException");
1873:                } catch (ConversionException e) {
1874:                    // expected
1875:                }
1876:
1877:                try {
1878:                    conf.getShortArray("key1");
1879:                    fail("getShortArray didn't throw a ConversionException");
1880:                } catch (ConversionException e) {
1881:                    // expected
1882:                }
1883:
1884:                try {
1885:                    conf.getShortArray("key2");
1886:                    fail("getShortArray didn't throw a ConversionException");
1887:                } catch (ConversionException e) {
1888:                    // expected
1889:                }
1890:
1891:                try {
1892:                    conf.getShortList("key1");
1893:                    fail("getShortList didn't throw a ConversionException");
1894:                } catch (ConversionException e) {
1895:                    // expected
1896:                }
1897:
1898:                try {
1899:                    conf.getShortList("key2");
1900:                    fail("getShortList didn't throw a ConversionException");
1901:                } catch (ConversionException e) {
1902:                    // expected
1903:                }
1904:
1905:                try {
1906:                    conf.getIntArray("key1");
1907:                    fail("getIntArray didn't throw a ConversionException");
1908:                } catch (ConversionException e) {
1909:                    // expected
1910:                }
1911:
1912:                try {
1913:                    conf.getIntArray("key2");
1914:                    fail("getIntArray didn't throw a ConversionException");
1915:                } catch (ConversionException e) {
1916:                    // expected
1917:                }
1918:
1919:                try {
1920:                    conf.getIntegerList("key1");
1921:                    fail("getIntegerList didn't throw a ConversionException");
1922:                } catch (ConversionException e) {
1923:                    // expected
1924:                }
1925:
1926:                try {
1927:                    conf.getIntegerList("key2");
1928:                    fail("getIntegerList didn't throw a ConversionException");
1929:                } catch (ConversionException e) {
1930:                    // expected
1931:                }
1932:
1933:                try {
1934:                    conf.getLongArray("key1");
1935:                    fail("getLongArray didn't throw a ConversionException");
1936:                } catch (ConversionException e) {
1937:                    // expected
1938:                }
1939:
1940:                try {
1941:                    conf.getLongArray("key2");
1942:                    fail("getLongArray didn't throw a ConversionException");
1943:                } catch (ConversionException e) {
1944:                    // expected
1945:                }
1946:
1947:                try {
1948:                    conf.getLongList("key1");
1949:                    fail("getLongList didn't throw a ConversionException");
1950:                } catch (ConversionException e) {
1951:                    // expected
1952:                }
1953:
1954:                try {
1955:                    conf.getLongList("key2");
1956:                    fail("getLongList didn't throw a ConversionException");
1957:                } catch (ConversionException e) {
1958:                    // expected
1959:                }
1960:
1961:                try {
1962:                    conf.getFloatArray("key1");
1963:                    fail("getFloatArray didn't throw a ConversionException");
1964:                } catch (ConversionException e) {
1965:                    // expected
1966:                }
1967:
1968:                try {
1969:                    conf.getFloatArray("key2");
1970:                    fail("getFloatArray didn't throw a ConversionException");
1971:                } catch (ConversionException e) {
1972:                    // expected
1973:                }
1974:
1975:                try {
1976:                    conf.getFloatList("key1");
1977:                    fail("getFloatList didn't throw a ConversionException");
1978:                } catch (ConversionException e) {
1979:                    // expected
1980:                }
1981:
1982:                try {
1983:                    conf.getFloatList("key2");
1984:                    fail("getFloatList didn't throw a ConversionException");
1985:                } catch (ConversionException e) {
1986:                    // expected
1987:                }
1988:
1989:                try {
1990:                    conf.getDoubleArray("key1");
1991:                    fail("getDoubleArray didn't throw a ConversionException");
1992:                } catch (ConversionException e) {
1993:                    // expected
1994:                }
1995:
1996:                try {
1997:                    conf.getDoubleArray("key2");
1998:                    fail("getDoubleArray didn't throw a ConversionException");
1999:                } catch (ConversionException e) {
2000:                    // expected
2001:                }
2002:
2003:                try {
2004:                    conf.getDoubleList("key1");
2005:                    fail("getDoubleList didn't throw a ConversionException");
2006:                } catch (ConversionException e) {
2007:                    // expected
2008:                }
2009:
2010:                try {
2011:                    conf.getDoubleList("key2");
2012:                    fail("getDoubleList didn't throw a ConversionException");
2013:                } catch (ConversionException e) {
2014:                    // expected
2015:                }
2016:
2017:                try {
2018:                    conf.getBigIntegerArray("key1");
2019:                    fail("getBigIntegerArray didn't throw a ConversionException");
2020:                } catch (ConversionException e) {
2021:                    // expected
2022:                }
2023:
2024:                try {
2025:                    conf.getBigIntegerArray("key2");
2026:                    fail("getBigIntegerArray didn't throw a ConversionException");
2027:                } catch (ConversionException e) {
2028:                    // expected
2029:                }
2030:
2031:                try {
2032:                    conf.getBigIntegerList("key1");
2033:                    fail("getBigIntegerList didn't throw a ConversionException");
2034:                } catch (ConversionException e) {
2035:                    // expected
2036:                }
2037:
2038:                try {
2039:                    conf.getBigIntegerList("key2");
2040:                    fail("getBigIntegerList didn't throw a ConversionException");
2041:                } catch (ConversionException e) {
2042:                    // expected
2043:                }
2044:
2045:                try {
2046:                    conf.getBigDecimalArray("key1");
2047:                    fail("getBigDecimalArray didn't throw a ConversionException");
2048:                } catch (ConversionException e) {
2049:                    // expected
2050:                }
2051:
2052:                try {
2053:                    conf.getBigDecimalArray("key2");
2054:                    fail("getBigDecimalArray didn't throw a ConversionException");
2055:                } catch (ConversionException e) {
2056:                    // expected
2057:                }
2058:
2059:                try {
2060:                    conf.getBigDecimalList("key1");
2061:                    fail("getBigDecimalList didn't throw a ConversionException");
2062:                } catch (ConversionException e) {
2063:                    // expected
2064:                }
2065:
2066:                try {
2067:                    conf.getBigDecimalList("key2");
2068:                    fail("getBigDecimalList didn't throw a ConversionException");
2069:                } catch (ConversionException e) {
2070:                    // expected
2071:                }
2072:
2073:                try {
2074:                    conf.getURLArray("key1");
2075:                    fail("getURLArray didn't throw a ConversionException");
2076:                } catch (ConversionException e) {
2077:                    // expected
2078:                }
2079:
2080:                try {
2081:                    conf.getURLArray("key2");
2082:                    fail("getURLArray didn't throw a ConversionException");
2083:                } catch (ConversionException e) {
2084:                    // expected
2085:                }
2086:
2087:                try {
2088:                    conf.getURLList("key1");
2089:                    fail("getURLList didn't throw a ConversionException");
2090:                } catch (ConversionException e) {
2091:                    // expected
2092:                }
2093:
2094:                try {
2095:                    conf.getURLList("key2");
2096:                    fail("getURLList didn't throw a ConversionException");
2097:                } catch (ConversionException e) {
2098:                    // expected
2099:                }
2100:
2101:                try {
2102:                    conf.getLocaleArray("key1");
2103:                    fail("getLocaleArray didn't throw a ConversionException");
2104:                } catch (ConversionException e) {
2105:                    // expected
2106:                }
2107:
2108:                try {
2109:                    conf.getLocaleArray("key2");
2110:                    fail("getLocaleArray didn't throw a ConversionException");
2111:                } catch (ConversionException e) {
2112:                    // expected
2113:                }
2114:
2115:                try {
2116:                    conf.getLocaleList("key1");
2117:                    fail("getLocaleList didn't throw a ConversionException");
2118:                } catch (ConversionException e) {
2119:                    // expected
2120:                }
2121:
2122:                try {
2123:                    conf.getLocaleList("key2");
2124:                    fail("getLocaleList didn't throw a ConversionException");
2125:                } catch (ConversionException e) {
2126:                    // expected
2127:                }
2128:
2129:                try {
2130:                    conf.getColorArray("key1");
2131:                    fail("getColorArray didn't throw a ConversionException");
2132:                } catch (ConversionException e) {
2133:                    // expected
2134:                }
2135:
2136:                try {
2137:                    conf.getColorArray("key2");
2138:                    fail("getColorArray didn't throw a ConversionException");
2139:                } catch (ConversionException e) {
2140:                    // expected
2141:                }
2142:
2143:                try {
2144:                    conf.getColorList("key1");
2145:                    fail("getColorList didn't throw a ConversionException");
2146:                } catch (ConversionException e) {
2147:                    // expected
2148:                }
2149:
2150:                try {
2151:                    conf.getColorList("key2");
2152:                    fail("getColorList didn't throw a ConversionException");
2153:                } catch (ConversionException e) {
2154:                    // expected
2155:                }
2156:
2157:                try {
2158:                    conf.getDateArray("key1");
2159:                    fail("getDateArray didn't throw a ConversionException");
2160:                } catch (ConversionException e) {
2161:                    // expected
2162:                }
2163:
2164:                try {
2165:                    conf.getDateArray("key2");
2166:                    fail("getDateArray didn't throw a ConversionException");
2167:                } catch (ConversionException e) {
2168:                    // expected
2169:                }
2170:
2171:                try {
2172:                    conf.getDateList("key1");
2173:                    fail("getDateList didn't throw a ConversionException");
2174:                } catch (ConversionException e) {
2175:                    // expected
2176:                }
2177:
2178:                try {
2179:                    conf.getDateList("key2");
2180:                    fail("getDateList didn't throw a ConversionException");
2181:                } catch (ConversionException e) {
2182:                    // expected
2183:                }
2184:
2185:                try {
2186:                    conf.getCalendarArray("key1");
2187:                    fail("getCalendarArray didn't throw a ConversionException");
2188:                } catch (ConversionException e) {
2189:                    // expected
2190:                }
2191:
2192:                try {
2193:                    conf.getCalendarArray("key2");
2194:                    fail("getCalendarArray didn't throw a ConversionException");
2195:                } catch (ConversionException e) {
2196:                    // expected
2197:                }
2198:
2199:                try {
2200:                    conf.getCalendarList("key1");
2201:                    fail("getCalendarList didn't throw a ConversionException");
2202:                } catch (ConversionException e) {
2203:                    // expected
2204:                }
2205:
2206:                try {
2207:                    conf.getCalendarList("key2");
2208:                    fail("getCalendarList didn't throw a ConversionException");
2209:                } catch (ConversionException e) {
2210:                    // expected
2211:                }
2212:            }
2213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.