Source Code Cross Referenced for Jdk14LoggerTestCase.java in  » Inversion-of-Control » DNA » org » codehaus » dna » impl » 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 » Inversion of Control » DNA » org.codehaus.dna.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) The DNA Group. All rights reserved.
003:         *
004:         * This software is published under the terms of the DNA
005:         * Software License version 1.1, a copy of which has been included
006:         * with this distribution in the LICENSE.txt file.
007:         */
008:        package org.codehaus.dna.impl;
009:
010:        import java.util.logging.Level;
011:
012:        import org.codehaus.dna.impl.Jdk14Logger;
013:
014:        import junit.framework.TestCase;
015:
016:        public class Jdk14LoggerTestCase extends TestCase {
017:            private MockLogger m_mockLogger;
018:
019:            public void testLogkitLoggerEmptyCtor() throws Exception {
020:                try {
021:                    new Jdk14Logger(null);
022:                } catch (NullPointerException npe) {
023:                    assertEquals("npe.getMessage()", "logger", npe.getMessage());
024:                }
025:            }
026:
027:            public void testJdk14LoggerGetChildLogger() throws Exception {
028:                final Jdk14Logger logger = createLogger(Level.FINE);
029:
030:                assertNotSame("logger.getChildLogger == logger", logger, logger
031:                        .getChildLogger("whatever"));
032:            }
033:
034:            public void testJdk14LoggerTraceEnabled() throws Exception {
035:                final Level level = Level.ALL;
036:                final Level type = Level.FINEST;
037:                final String message = "Meep!";
038:                final Throwable throwable = null;
039:                final boolean output = true;
040:
041:                final Jdk14Logger logger = createLogger(level);
042:                logger.trace(message);
043:                checkLogger(output, message, throwable, type);
044:            }
045:
046:            public void testJdk14LoggerTraceDisabled() throws Exception {
047:                final Level level = Level.OFF;
048:                final String message = "Meep!";
049:
050:                final Jdk14Logger logger = createLogger(level);
051:                logger.trace(message);
052:                checkLogger(false, null, null, null);
053:            }
054:
055:            public void testJdk14LoggerTraceWithExceptionEnabled()
056:                    throws Exception {
057:                final Level level = Level.ALL;
058:                final Level type = Level.FINEST;
059:                final String message = "Meep!";
060:                final Throwable throwable = new Throwable();
061:                final boolean output = true;
062:
063:                final Jdk14Logger logger = createLogger(level);
064:
065:                logger.trace(message, throwable);
066:                checkLogger(output, message, throwable, type);
067:            }
068:
069:            public void testJdk14LoggerTraceWithExceptionDisabled()
070:                    throws Exception {
071:                final Level level = Level.OFF;
072:                final String message = "Meep!";
073:                final Throwable throwable = new Throwable();
074:
075:                final Jdk14Logger logger = createLogger(level);
076:
077:                logger.trace(message, throwable);
078:                checkLogger(false, null, null, null);
079:            }
080:
081:            public void testJdk14LoggerDebugEnabled() throws Exception {
082:                final Level level = Level.ALL;
083:                final Level type = Level.FINE;
084:                final String message = "Meep!";
085:                final Throwable throwable = null;
086:                final boolean output = true;
087:
088:                final Jdk14Logger logger = createLogger(level);
089:                logger.debug(message);
090:                checkLogger(output, message, throwable, type);
091:            }
092:
093:            public void testJdk14LoggerDebugDisabled() throws Exception {
094:                final Level level = Level.OFF;
095:                final String message = "Meep!";
096:
097:                final Jdk14Logger logger = createLogger(level);
098:                logger.debug(message);
099:                checkLogger(false, null, null, null);
100:            }
101:
102:            public void testJdk14LoggerDebugWithExceptionEnabled()
103:                    throws Exception {
104:                final Level level = Level.ALL;
105:                final Level type = Level.FINE;
106:                final String message = "Meep!";
107:                final Throwable throwable = new Throwable();
108:                final boolean output = true;
109:
110:                final Jdk14Logger logger = createLogger(level);
111:                logger.debug(message, throwable);
112:                checkLogger(output, message, throwable, type);
113:            }
114:
115:            public void testJdk14LoggerDebugWithExceptionDisabled()
116:                    throws Exception {
117:                final Level level = Level.OFF;
118:                final String message = "Meep!";
119:                final Throwable throwable = new Throwable();
120:
121:                final Jdk14Logger logger = createLogger(level);
122:                logger.debug(message, throwable);
123:                checkLogger(false, null, null, null);
124:            }
125:
126:            public void testJdk14LoggerInfoEnabled() throws Exception {
127:                final Level level = Level.ALL;
128:                final Level type = Level.INFO;
129:                final String message = "Meep!";
130:                final Throwable throwable = null;
131:                final boolean output = true;
132:
133:                final Jdk14Logger logger = createLogger(level);
134:                logger.info(message);
135:                checkLogger(output, message, throwable, type);
136:            }
137:
138:            public void testJdk14LoggerInfoDisabled() throws Exception {
139:                final Level level = Level.OFF;
140:                final String message = "Meep!";
141:
142:                final Jdk14Logger logger = createLogger(level);
143:                logger.info(message);
144:                checkLogger(false, null, null, null);
145:            }
146:
147:            public void testJdk14LoggerInfoWithExceptionEnabled()
148:                    throws Exception {
149:                final Level level = Level.ALL;
150:                final Level type = Level.INFO;
151:                final String message = "Meep!";
152:                final Throwable throwable = new Throwable();
153:                final boolean output = true;
154:
155:                final Jdk14Logger logger = createLogger(level);
156:                logger.info(message, throwable);
157:                checkLogger(output, message, throwable, type);
158:            }
159:
160:            public void testJdk14LoggerInfoWithExceptionDisabled()
161:                    throws Exception {
162:                final Level level = Level.OFF;
163:                final String message = "Meep!";
164:                final Throwable throwable = new Throwable();
165:
166:                final Jdk14Logger logger = createLogger(level);
167:                logger.info(message, throwable);
168:                checkLogger(false, null, null, null);
169:            }
170:
171:            public void testJdk14LoggerWarnEnabled() throws Exception {
172:                final Level level = Level.ALL;
173:                final Level type = Level.WARNING;
174:                final String message = "Meep!";
175:                final Throwable throwable = null;
176:                final boolean output = true;
177:
178:                final Jdk14Logger logger = createLogger(level);
179:                logger.warn(message);
180:                checkLogger(output, message, throwable, type);
181:            }
182:
183:            public void testJdk14LoggerWarnDisabled() throws Exception {
184:                final Level level = Level.OFF;
185:                final String message = "Meep!";
186:
187:                final Jdk14Logger logger = createLogger(level);
188:                logger.warn(message);
189:                checkLogger(false, null, null, null);
190:            }
191:
192:            public void testJdk14LoggerWarnWithExceptionEnabled()
193:                    throws Exception {
194:                final Level level = Level.ALL;
195:                final Level type = Level.WARNING;
196:                final String message = "Meep!";
197:                final Throwable throwable = new Throwable();
198:                final boolean output = true;
199:
200:                final Jdk14Logger logger = createLogger(level);
201:                logger.warn(message, throwable);
202:                checkLogger(output, message, throwable, type);
203:            }
204:
205:            public void testJdk14LoggerWarnWithExceptionDisabled()
206:                    throws Exception {
207:                final Level level = Level.OFF;
208:                final String message = "Meep!";
209:                final Throwable throwable = new Throwable();
210:
211:                final Jdk14Logger logger = createLogger(level);
212:                logger.warn(message, throwable);
213:                checkLogger(false, null, null, null);
214:            }
215:
216:            public void testJdk14LoggerErrorEnabled() throws Exception {
217:                final Level level = Level.ALL;
218:                final Level type = Level.SEVERE;
219:                final String message = "Meep!";
220:                final Throwable throwable = null;
221:                final boolean output = true;
222:
223:                final Jdk14Logger logger = createLogger(level);
224:                logger.error(message);
225:                checkLogger(output, message, throwable, type);
226:            }
227:
228:            public void testJdk14LoggerErrorWithExceptionEnabled()
229:                    throws Exception {
230:                final Level level = Level.ALL;
231:                final Level type = Level.SEVERE;
232:                final String message = "Meep!";
233:                final Throwable throwable = new Throwable();
234:                final boolean output = true;
235:
236:                final Jdk14Logger logger = createLogger(level);
237:                logger.error(message, throwable);
238:                checkLogger(output, message, throwable, type);
239:            }
240:
241:            public void testConsoleLevelComparisonWithDebugEnabled()
242:                    throws Exception {
243:                final Jdk14Logger logger = createLogger(Level.FINEST);
244:
245:                assertEquals("logger.isTraceEnabled()", true, logger
246:                        .isTraceEnabled());
247:                assertEquals("logger.isDebugEnabled()", true, logger
248:                        .isDebugEnabled());
249:                assertEquals("logger.isInfoEnabled()", true, logger
250:                        .isInfoEnabled());
251:                assertEquals("logger.isWarnEnabled()", true, logger
252:                        .isWarnEnabled());
253:                assertEquals("logger.isErrorEnabled()", true, logger
254:                        .isErrorEnabled());
255:            }
256:
257:            public void testConsoleLevelComparisonWithInfoEnabled()
258:                    throws Exception {
259:                final Jdk14Logger logger = createLogger(Level.INFO);
260:
261:                assertEquals("logger.isTraceEnabled()", false, logger
262:                        .isTraceEnabled());
263:                assertEquals("logger.isDebugEnabled()", false, logger
264:                        .isDebugEnabled());
265:                assertEquals("logger.isInfoEnabled()", true, logger
266:                        .isInfoEnabled());
267:                assertEquals("logger.isWarnEnabled()", true, logger
268:                        .isWarnEnabled());
269:                assertEquals("logger.isErrorEnabled()", true, logger
270:                        .isErrorEnabled());
271:            }
272:
273:            public void testConsoleLevelComparisonWithWarnEnabled()
274:                    throws Exception {
275:                final Jdk14Logger logger = createLogger(Level.WARNING);
276:
277:                assertEquals("logger.isTraceEnabled()", false, logger
278:                        .isTraceEnabled());
279:                assertEquals("logger.isDebugEnabled()", false, logger
280:                        .isDebugEnabled());
281:                assertEquals("logger.isInfoEnabled()", false, logger
282:                        .isInfoEnabled());
283:                assertEquals("logger.isWarnEnabled()", true, logger
284:                        .isWarnEnabled());
285:                assertEquals("logger.isErrorEnabled()", true, logger
286:                        .isErrorEnabled());
287:            }
288:
289:            public void testConsoleLevelComparisonWithErrorEnabled()
290:                    throws Exception {
291:                final Jdk14Logger logger = createLogger(Level.SEVERE);
292:
293:                assertEquals("logger.isTraceEnabled()", false, logger
294:                        .isTraceEnabled());
295:                assertEquals("logger.isDebugEnabled()", false, logger
296:                        .isDebugEnabled());
297:                assertEquals("logger.isInfoEnabled()", false, logger
298:                        .isInfoEnabled());
299:                assertEquals("logger.isWarnEnabled()", false, logger
300:                        .isWarnEnabled());
301:                assertEquals("logger.isErrorEnabled()", true, logger
302:                        .isErrorEnabled());
303:            }
304:
305:            private Jdk14Logger createLogger(final Level priority) {
306:                m_mockLogger = new MockLogger(priority);
307:                return new Jdk14Logger(m_mockLogger);
308:            }
309:
310:            private void checkLogger(final boolean output,
311:                    final String message, final Throwable throwable,
312:                    final Level priority) {
313:                assertEquals("logger.m_message == message", message,
314:                        m_mockLogger.m_message);
315:                assertEquals("logger.m_output == output", output,
316:                        m_mockLogger.m_output);
317:                assertEquals("logger.m_throwable == null", throwable,
318:                        m_mockLogger.m_throwable);
319:                assertEquals("logger.m_priority == null", priority,
320:                        m_mockLogger.m_priority);
321:            }
322:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.