Source Code Cross Referenced for TestPropertiesConfAccess.java in  » Development » Monolog » org » objectweb » util » monolog » file » monolog » 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 » Development » Monolog » org.objectweb.util.monolog.file.monolog 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (C) 2002
003:         */package org.objectweb.util.monolog.file.monolog;
004:
005:        import org.objectweb.util.monolog.TestHelper;
006:        import org.objectweb.util.monolog.TestSuite;
007:        import org.objectweb.util.monolog.wrapper.common.LevelImpl;
008:        import org.objectweb.util.monolog.api.BasicLevel;
009:        import org.objectweb.util.monolog.api.TopicalLogger;
010:        import org.objectweb.util.monolog.api.Level;
011:        import org.objectweb.util.monolog.api.Handler;
012:
013:        import java.util.Enumeration;
014:        import java.util.Properties;
015:        import java.util.Set;
016:        import java.util.Iterator;
017:        import java.util.Map;
018:        import java.util.StringTokenizer;
019:
020:        /**
021:         * This test is based on JUnit and verifies the PropertiesConfAccess class.
022:         *
023:         * @author Sebastien Chassande-Barrioz
024:         */
025:        public class TestPropertiesConfAccess extends TestHelper {
026:            /**
027:             * For running the TestPropertiesConfAccess suite standalone.
028:             */
029:            public static void main(String args[]) {
030:                if (args.length < 1) {
031:                    System.out.println("Syntax error !");
032:                    System.out
033:                            .println("java TestPropertiesConfAccess <logger factory class name>");
034:                    System.exit(1);
035:                }
036:                TestHelper.run(TestPropertiesConfAccess.class, new String[0],
037:                        new String[0], args[0]);
038:            }
039:
040:            /**
041:             * Return the test suite associated to this class.
042:             */
043:            public static TestSuite getTestSuite(String lfcn) {
044:                return TestHelper.getTestSuite(TestPropertiesConfAccess.class,
045:                        new String[0], new String[0], lfcn);
046:            }
047:
048:            /**
049:             * It tests the store method.
050:             */
051:            public void testStoreConf() {
052:                // Create monolog objects Logger, Handler, Level
053:                //==============================================
054:                try {
055:                    //------ Level ------//
056:
057:                    //level.DEBUG1 10001
058:                    assertNotNull("Bad definition", lef.defineLevel("DEBUG1",
059:                            BasicLevel.DEBUG + 1));
060:
061:                    //level.DEBUG2 "DEBUG + 2"
062:                    assertNotNull("Bad definition", lef.defineLevel("DEBUG2",
063:                            "DEBUG + 2"));
064:
065:                    //level.DEBUG2bis 10002
066:                    assertNotNull("Bad definition", lef.defineLevel(
067:                            "DEBUG2bis", BasicLevel.DEBUG + 2));
068:
069:                    //level.INFObis 20000
070:                    assertNotNull("Bad definition", lef.defineLevel("INFObis",
071:                            BasicLevel.INFO));
072:
073:                    //level.WARNbis WARN
074:                    assertNotNull("Bad definition", lef.defineLevel("WARNbis",
075:                            "WARN"));
076:
077:                    lef.defineLevel("FATAL", "50000");
078:
079:                    //------ Handler ------//
080:                    Handler h = hf.createHandler("handler_sys_out", "console");
081:                    h.setAttribute(Handler.OUTPUT_ATTRIBUTE, "System.out");
082:                    h.setAttribute(Handler.PATTERN_ATTRIBUTE, "%m%n");
083:                    h.setAttribute("activation", hf);
084:
085:                    h = hf.createHandler("Handler_file", "file");
086:                    h.setAttribute(Handler.OUTPUT_ATTRIBUTE, "toto.txt");
087:                    h.setAttribute(Handler.PATTERN_ATTRIBUTE, "%p %m%n");
088:                    h.setAttribute("activation", hf);
089:
090:                    h = hf.createHandler("Handler.rolling.file", "rollingfile");
091:                    h.setAttribute(Handler.OUTPUT_ATTRIBUTE, "toto");
092:                    h.setAttribute(Handler.MAX_SIZE_ATTRIBUTE, "300");
093:                    h.setAttribute(Handler.FILE_NUMBER_ATTRIBUTE, "2");
094:                    h.setAttribute(Handler.PATTERN_ATTRIBUTE, "%p - %m%n");
095:                    h.setAttribute("activation", hf);
096:
097:                    //------ Logger ------//
098:
099:                    TopicalLogger l = null;
100:                    //logger.root.level WARN
101:                    // or
102:                    //logger..level WARN
103:                    l = (TopicalLogger) lf.getLogger("");
104:                    l.setIntLevel(BasicLevel.WARN);
105:
106:                    //nothing required
107:                    l = (TopicalLogger) lf.getLogger("org.foo.bar");
108:
109:                    // logger.org.level FATAL
110:                    l = (TopicalLogger) lf.getLogger("org");
111:                    l.setIntLevel(BasicLevel.FATAL);
112:
113:                    // logger.org.foo.bar2.level INFO
114:                    l = (TopicalLogger) lf.getLogger("org.foo.bar2");
115:                    l.setIntLevel(BasicLevel.INFO);
116:
117:                    // logger.org.foo.bar3.topic.0 fr.inria.sardes3
118:                    // logger.org.foo.bar3.topic.1 fr.inrialpes.sardes3
119:                    l = (TopicalLogger) lf.getLogger("org.foo.bar3");
120:                    l.addTopic("fr.inria.sardes3");
121:                    l.addTopic("fr.inrialpes.sardes3");
122:
123:                    // logger.org.foo.bar4.level ERROR
124:                    // logger.org.foo.bar4.topic.0 fr.inria.sardes4
125:                    // logger.org.foo.bar4.topic.1 fr.inrialpes.sardes4
126:                    l = (TopicalLogger) lf.getLogger("org.foo.bar4");
127:                    l.setIntLevel(BasicLevel.ERROR);
128:                    l.addTopic("fr.inria.sardes4");
129:                    l.addTopic("fr.inrialpes.sardes4");
130:
131:                    //logger.org.foo.bar5.handler.0 Handler_file
132:                    l = (TopicalLogger) lf.getLogger("org.foo.bar5");
133:                    l.addHandler(hf.getHandler("Handler_file"));
134:
135:                    //logger.org.foo.bar6.handler.0 Handler_file
136:                    l = (TopicalLogger) lf.getLogger("org.foo.bar6");
137:                    l.addHandler(hf.getHandler("Handler_file"));
138:                    l.addHandler(hf.getHandler("Handler.rolling.file"));
139:                } catch (Exception e) {
140:                    e.printStackTrace();
141:                    fail(e.getMessage());
142:                }
143:                //System.out.println("Store in a properties variable:");
144:                // Store the configuration into a properties
145:                //==========================================
146:                Properties p = new Properties();
147:                try {
148:                    PropertiesConfAccess.store(p, lf, hf, lef);
149:                } catch (Exception e) {
150:                    e.printStackTrace();
151:                    fail(e.getMessage());
152:                }
153:
154:                // Check the properties
155:                //=====================
156:                //System.out.println("Check the properties variable:");
157:
158:                //------ Level ------//
159:                Set s = p.keySet();
160:                checkExist(p, s, "level.DEBUG1", String
161:                        .valueOf(BasicLevel.DEBUG + 1), "level: integer value");
162:                checkExist(p, s, "level.DEBUG2", "DEBUG + 2",
163:                        "level: string expr");
164:                checkExist(p, s, "level.DEBUG2bis", String
165:                        .valueOf(BasicLevel.DEBUG + 2),
166:                        "level: integer value, duplicat");
167:                checkExist(p, s, "level.INFObis", "20000", "level: value");
168:                checkExist(p, s, "level.WARNbis", "WARN", "level: value");
169:                checkUnExist(s, "level.FATAL", "level: predefined level");
170:
171:                //------ Handler ------//
172:                checkExist(p, s, "handler.handler_sys_out.type", "console",
173:                        "handler: bad console type");
174:                checkExist(p, s, "handler.handler_sys_out."
175:                        + Handler.OUTPUT_ATTRIBUTE, "System.out",
176:                        "handler: bad console output");
177:                checkExist(p, s, "handler.handler_sys_out."
178:                        + Handler.PATTERN_ATTRIBUTE, "%m%n",
179:                        "handler: bad console pattern");
180:
181:                checkExist(p, s, "handler.Handler_file.type", "file",
182:                        "handler: bad file type");
183:                checkExist(p, s, "handler.Handler_file."
184:                        + Handler.OUTPUT_ATTRIBUTE, "toto.txt",
185:                        "handler: bad file output");
186:                checkExist(p, s, "handler.Handler_file."
187:                        + Handler.PATTERN_ATTRIBUTE, "%p %m%n",
188:                        "handler: bad file pattern");
189:
190:                checkExist(p, s, "handler.Handler.rolling.file.type",
191:                        "rollingfile", "handler: bad rolling file type");
192:                checkExist(p, s, "handler.Handler.rolling.file."
193:                        + Handler.OUTPUT_ATTRIBUTE, "toto",
194:                        "handler: bad rolling file output");
195:                checkExist(p, s, "handler.Handler.rolling.file."
196:                        + Handler.PATTERN_ATTRIBUTE, "%p - %m%n",
197:                        "handler: bad rolling file pattern");
198:                checkExist(p, s, "handler.Handler.rolling.file."
199:                        + Handler.MAX_SIZE_ATTRIBUTE, "300",
200:                        "handler: bad rolling file max size");
201:                checkExist(p, s, "handler.Handler.rolling.file."
202:                        + Handler.FILE_NUMBER_ATTRIBUTE, "2",
203:                        "handler: bad rolling file number of file");
204:
205:                //------ Logger ------//
206:                checkUnExist(s, "logger.org.foo.bar.level", "just the name");
207:
208:                checkExist(p, s, "logger.org.level", "FATAL",
209:                        "logger: Simple name & Just level");
210:
211:                checkExist(p, s, "logger.org.foo.bar2.level", "INFO",
212:                        "logger: Dotted name & Just level");
213:
214:                checkBeginExist(p, "logger.org.foo.bar5.handler",
215:                        "Handler_file", "logger: Dotted name & Just handler");
216:
217:                checkBeginExist(p, "logger.org.foo.bar6.handler",
218:                        "Handler_file", "logger: Dotted name & Just handler");
219:                checkBeginExist(p, "logger.org.foo.bar6.handler",
220:                        "Handler.rolling.file",
221:                        "logger: Dotted name & Just handler");
222:
223:                checkBeginExist(p, "logger.org.foo.bar3.topic",
224:                        "fr.inria.sardes3",
225:                        "logger: Dotted name, no level, 2 topic: topic1");
226:                checkBeginExist(p, "logger.org.foo.bar3.topic",
227:                        "fr.inrialpes.sardes3",
228:                        "logger: Dotted name, no level, 2 topic: topic2");
229:
230:                checkExist(p, s, "logger.org.foo.bar4.level", "ERROR",
231:                        "logger: Dotted name, Just level, topic: level");
232:                checkBeginExist(p, "logger.org.foo.bar4.topic",
233:                        "fr.inria.sardes4",
234:                        "logger: Dotted name, ERROR level, 2 topic: topic1");
235:                checkBeginExist(p, "logger.org.foo.bar4.topic",
236:                        "fr.inrialpes.sardes4",
237:                        "logger: Dotted name, ERROR level, 2 topic: topic2");
238:
239:            }
240:
241:            /**
242:             * It tests the load method
243:             */
244:            public void testLoadConf() {
245:
246:                // Full a properties
247:                //==================
248:                Properties p = new Properties();
249:                //------ Level ------//
250:                p.setProperty("level.LOAD_DEBUG1", "DEBUG + 1");
251:
252:                p.setProperty("level.LOAD_DEBUG2", String
253:                        .valueOf(BasicLevel.DEBUG + 2));
254:
255:                //------ Handler ------//
256:                p.setProperty("handler.myhandler1.type", "console");
257:                p.setProperty("handler.myhandler1.output", "System.out");
258:                p.setProperty("handler.myhandler1.pattern", "%m%n");
259:
260:                p.setProperty("handler.test.load.myhandler2.type", "file");
261:                p.setProperty("handler.test.load.myhandler2.output",
262:                        "myhandler2.log");
263:                p
264:                        .setProperty("handler.test.load.myhandler2.pattern",
265:                                "=> %m%n");
266:
267:                p.setProperty("handler.test.load.myhandler3.type",
268:                        "rollingfile");
269:                p.setProperty("handler.test.load.myhandler3.output",
270:                        "myhandler3.log");
271:                p
272:                        .setProperty("handler.test.load.myhandler3.pattern",
273:                                "-> %m%n");
274:                p.setProperty("handler.test.load.myhandler3.fileNumber", "2");
275:                p.setProperty("handler.test.load.myhandler3.maxSize", "20");
276:
277:                //------ Logger ------//
278:                p.setProperty("logger.test.load.bar.level", "DEBUG");
279:
280:                p.setProperty("logger.test.load.foo.level", "LOAD_DEBUG1");
281:
282:                p.setProperty("logger.test.load.foo2.topic.0", "org.ow.foo");
283:                p.setProperty("logger.test.load.foo2.topic.1", "org.ow.foo2");
284:
285:                p.setProperty("logger.test.load.foo3.handler.0", "myhandler1");
286:
287:                p.setProperty("logger.test.load.foo4.handler.0",
288:                        "test.load.myhandler2");
289:                p.setProperty("logger.test.load.foo4.handler.1",
290:                        "test.load.myhandler3");
291:
292:                // Load the properties
293:                //==========================
294:                try {
295:                    PropertiesConfAccess.load(p, lf, hf, lef);
296:                } catch (Exception e) {
297:                    e.printStackTrace();
298:                    fail(e.getMessage());
299:                }
300:
301:                // Check the monolog objects
302:                //==========================
303:                //------ Level ------//
304:                Level le = null;
305:                le = lef.getLevel("LOAD_DEBUG1");
306:                assertNotNull("level: LOAD_DEBUG1: undefined", le);
307:                assertEquals("level: LOAD_DEBUG1: bad int value",
308:                        BasicLevel.DEBUG + 1, le.getIntValue());
309:                assertEquals("level: LOAD_DEBUG1: bad string expr",
310:                        "DEBUG + 1", ((LevelImpl) le).getStringValue());
311:
312:                le = lef.getLevel("LOAD_DEBUG2");
313:                assertNotNull("level: LOAD_DEBUG2: undefined", le);
314:                assertEquals("level: LOAD_DEBUG2: bad int value",
315:                        BasicLevel.DEBUG + 2, le.getIntValue());
316:                assertEquals("level: LOAD_DEBUG2: bad string expr", String
317:                        .valueOf(BasicLevel.DEBUG + 2), ((LevelImpl) le)
318:                        .getStringValue());
319:
320:                //------ Handler ------//
321:                Handler h = null;
322:                h = hf.getHandler("myhandler1");
323:                assertNotNull("handler: myhandler1: undefined", h);
324:                assertEquals(
325:                        "handler: myhandler1: bad type",
326:                        PropertiesConfAccess.HANDLER_TYPE_ATTRIBUTE_CONSOLE_VALUE,
327:                        h.getType());
328:                assertEquals("handler: myhandler1: bad output", "System.out", h
329:                        .getAttribute(Handler.OUTPUT_ATTRIBUTE));
330:                assertEquals("handler: myhandler1: bad pattern", "%m%n", h
331:                        .getAttribute(Handler.PATTERN_ATTRIBUTE));
332:
333:                h = hf.getHandler("test.load.myhandler2");
334:                assertNotNull("handler: test.load.myhandler2: undefined", h);
335:                assertEquals("handler: test.load.myhandler2: bad type",
336:                        PropertiesConfAccess.HANDLER_TYPE_ATTRIBUTE_FILE_VALUE,
337:                        h.getType());
338:                assertEquals("handler: test.load.myhandler2: bad output",
339:                        "myhandler2.log", h
340:                                .getAttribute(Handler.OUTPUT_ATTRIBUTE));
341:                assertEquals("handler: test.load.myhandler2: bad pattern",
342:                        "=> %m%n", h.getAttribute(Handler.PATTERN_ATTRIBUTE));
343:
344:                h = hf.getHandler("test.load.myhandler3");
345:                assertNotNull("handler: test.load.myhandler3: undefined", h);
346:                assertEquals(
347:                        "handler: test.load.myhandler3: bad type",
348:                        PropertiesConfAccess.HANDLER_TYPE_ATTRIBUTE_ROLLING_FILE_VALUE,
349:                        h.getType());
350:                assertEquals("handler: test.load.myhandler2: bad output",
351:                        "myhandler3.log", h
352:                                .getAttribute(Handler.OUTPUT_ATTRIBUTE));
353:                assertEquals("handler: test.load.myhandler2: bad pattern",
354:                        "-> %m%n", h.getAttribute(Handler.PATTERN_ATTRIBUTE));
355:                assertEquals("handler: test.load.myhandler2: bad file number",
356:                        "2", h.getAttribute(Handler.FILE_NUMBER_ATTRIBUTE));
357:                assertEquals("handler: test.load.myhandler2: bad max size",
358:                        "20", h.getAttribute(Handler.MAX_SIZE_ATTRIBUTE));
359:
360:                //------ Logger ------//
361:                TopicalLogger l = null;
362:                l = (TopicalLogger) lf.getLogger("test.load.bar");
363:                assertEquals("logger: test.load.bar: bad level",
364:                        BasicLevel.DEBUG, l.getCurrentIntLevel());
365:
366:                l = (TopicalLogger) lf.getLogger("test.load.foo");
367:                assertEquals("logger: test.load.foo: bad level",
368:                        BasicLevel.DEBUG + 1, l.getCurrentIntLevel());
369:
370:                l = (TopicalLogger) lf.getLogger("test.load.foo3");
371:                Handler[] hs = l.getHandler();
372:                assertNotNull("logger: test.load.foo3: handler list is null",
373:                        hs);
374:                assertEquals("logger: test.load.foo3: handler list is empty",
375:                        1, hs.length);
376:                assertEquals("logger: test.load.foo3: bad handler", hf
377:                        .getHandler("myhandler1"), hs[0]);
378:
379:                l = (TopicalLogger) lf.getLogger("test.load.foo4");
380:                hs = l.getHandler();
381:                assertNotNull("logger: test.load.foo4: handler list is null",
382:                        hs);
383:                assertEquals("logger: test.load.foo4: handler list is empty",
384:                        2, hs.length);
385:                assertNotNull(
386:                        "logger: test.load.foo4: handler element 0 is null",
387:                        hs[0]);
388:                assertNotNull(
389:                        "logger: test.load.foo4: handler element 1 is null",
390:                        hs[1]);
391:                if (!hs[0].equals(hf.getHandler("test.load.myhandler2"))
392:                        && !hs[1].equals(hf.getHandler("test.load.myhandler2"))) {
393:                    fail("logger: test.load.foo4: 'test.load.myhandler2' handler not found");
394:                }
395:                if (!hs[0].equals(hf.getHandler("test.load.myhandler3"))
396:                        && !hs[1].equals(hf.getHandler("test.load.myhandler3"))) {
397:                    fail("logger: test.load.foo4: 'test.load.myhandler3' handler not found");
398:                }
399:
400:                l = (TopicalLogger) lf.getLogger("test.load.foo2");
401:                String[] ts = l.getTopic();
402:                assertNotNull("logger: test.load.foo2: topic list is null", ts);
403:                assertEquals("logger: test.load.foo2: bad topic list size", 3,
404:                        ts.length);
405:                assertNotNull(
406:                        "logger: test.load.foo2: topic element 0 is null",
407:                        ts[0]);
408:                assertNotNull(
409:                        "logger: test.load.foo2: topic element 1 is null",
410:                        ts[1]);
411:                assertNotNull(
412:                        "logger: test.load.foo2: topic element 2 is null",
413:                        ts[2]);
414:                if (!ts[0].equals("test.load.foo2")
415:                        && !ts[1].equals("test.load.foo2")
416:                        && !ts[2].equals("test.load.foo2")) {
417:                    fail("logger: test.load.foo2: main topic not found");
418:                }
419:                if (!ts[0].equals("org.ow.foo") && !ts[1].equals("org.ow.foo")
420:                        && !ts[2].equals("org.ow.foo")) {
421:                    fail("logger: test.load.foo2: 'org.ow.foo' topic not found");
422:                }
423:                if (!ts[0].equals("org.ow.foo2")
424:                        && !ts[1].equals("org.ow.foo2")
425:                        && !ts[2].equals("org.ow.foo2")) {
426:                    fail("logger: test.load.foo2: 'org.ow.foo2' topic not found");
427:                }
428:            }
429:
430:            /**
431:             * It verifies that the couple (key, value) is available in a Properties.
432:             * @param p is the properties where to find the key and the value.
433:             * @param s is the key set of the properies p
434:             * @param key is the string which must be a key in the properties
435:             * @param value is the object which must be value associated to the key
436:             * @param msg is the error messageis the (key, value) is not found
437:             */
438:            public void checkExist(Properties p, Set s, String key,
439:                    String value, String msg) {
440:                boolean t = s.contains(key);
441:                if (!t) {
442:                    //printProperties(p);
443:                }
444:                assertTrue(msg + ": not found", t);
445:                assertEquals(msg + ": (" + key + ")bad value", value, p
446:                        .getProperty(key));
447:            }
448:
449:            /**
450:             * It verifies that a String is not available in a Set.
451:             * @param s is the set.
452:             * @param key is the string which must not be a key in the set
453:             * @param msg is the error messageis the (key, value) is found
454:             */
455:            public void checkUnExist(Set s, String key, String msg) {
456:                assertTrue(msg + ": found", !s.contains(key));
457:            }
458:
459:            public void checkBeginExist(Properties p, String key, String value,
460:                    String msg) {
461:                boolean found = false;
462:                debug("checkBeginExist( key=" + key + " / value=" + value);
463:                for (Enumeration e = p.keys(); e.hasMoreElements();) {
464:                    String cur = (String) e.nextElement();
465:                    debug("  cur=" + cur + " / val=" + p.getProperty(cur, ""));
466:                    if (cur.startsWith(key)) {
467:                        StringTokenizer st = new StringTokenizer(p.getProperty(
468:                                cur, ""), ", ", false);
469:                        while (st.hasMoreTokens()) {
470:                            String tok = st.nextToken();
471:                            if (tok.equals(value)) {
472:                                if (found) {
473:                                    fail(msg + "duplicated value: " + value);
474:                                } else {
475:                                    found = true;
476:                                }
477:                            }
478:                        }
479:                    }
480:                }
481:                if (!found) {
482:                    System.out.println("\n" + msg + ": not found");
483:                    this .printProperties(p);
484:                }
485:                assertTrue(msg + ": not found", found);
486:            }
487:
488:            public void printProperties(Properties p) {
489:                for (Iterator it = p.entrySet().iterator(); it.hasNext();) {
490:                    Map.Entry me = (Map.Entry) it.next();
491:                    System.out.println(me.getKey() + "=" + me.getValue());
492:                }
493:            }
494:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.