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


001:        /**
002:         * Copyright (C) 2002
003:         */package org.objectweb.util.monolog;
004:
005:        import org.objectweb.util.monolog.api.BasicLevel;
006:        import org.objectweb.util.monolog.api.LevelFactory;
007:        import org.objectweb.util.monolog.api.Level;
008:        import junit.framework.TestCase;
009:        import junit.textui.TestRunner;
010:
011:        /**
012:         * It verifies a Level implementation and a LevelFactory implementation.
013:         *
014:         * @author Sebastien Chassande-Barrioz
015:         */
016:        public class TestLevel extends TestCase {
017:
018:            /**
019:             * This constant field contains the list of the setter name needed to
020:             * initialize this class.
021:             */
022:            public static final String[] SETTER_METHODS = { "setLevelFactoryClassName" };
023:
024:            protected LevelFactory lf = null;
025:
026:            private Level l = null;
027:
028:            public TestLevel() {
029:                super ("");
030:            }
031:
032:            /**
033:             * It assigns the LevelFactory class name. This method tries to get an
034:             * instance with this class name.
035:             */
036:            public void setLevelFactoryClassName(String lfcn) {
037:                try {
038:                    lf = (LevelFactory) Class.forName(lfcn).newInstance();
039:                } catch (ClassCastException e) {
040:                    throw new UnsupportedOperationException(
041:                            "The specified class is not a Level factory: "
042:                                    + lfcn);
043:                } catch (Exception e) {
044:                    throw new UnsupportedOperationException(
045:                            "Level factory class is not availlable: " + lfcn);
046:                }
047:            }
048:
049:            /**
050:             * For running the TestLevel suite standalone. A particular TestSuite is
051:             * used to initialized the class instance by setter methods.
052:             * One parameter is required:
053:             * <ul>
054:             * <li>a LevelFactory class name</li>
055:             * </ul>
056:             */
057:            public static void main(String args[]) {
058:                if (args.length < 1) {
059:                    System.out.println("Syntax error !");
060:                    System.out
061:                            .println("java TestLevel <level factory class name>");
062:                    System.exit(12);
063:                }
064:                Object[] params = { args[0] };
065:                try {
066:                    TestSuite suite = new TestSuite(TestLevel.class,
067:                            SETTER_METHODS, params);
068:                    TestRunner.run(suite);
069:                } catch (Exception e) {
070:                    e.printStackTrace();
071:                }
072:            }
073:
074:            public static TestSuite getTestSuite(String lfcn) {
075:                Object[] params = { lfcn };
076:                try {
077:                    return new TestSuite(TestLevel.class, SETTER_METHODS,
078:                            params);
079:                } catch (Exception e) {
080:                    e.printStackTrace();
081:                    return null;
082:                }
083:            }
084:
085:            // ------ TEST METHODS ------ //
086:            //----------------------------//
087:
088:            /**
089:             * This method tests if it is possible to define a LevelConf with a
090:             * predefined level and the + operator: DEBUG + 1
091:             */
092:            public void testInterLevelDef() {
093:                assertEquals("Predefined level unreconized", BasicLevel.DEBUG,
094:                        lf.getLevel("DEBUG").getIntValue());
095:                l = lf.defineLevel("MY_LEVEL", "DEBUG + 1");
096:                assertNotNull("Null level", l);
097:                assertEquals("intermediate level definition",
098:                        BasicLevel.DEBUG + 1, l.getIntValue());
099:            }
100:
101:            /**
102:             * This method tests if it is possible to define a LevelConf with an
103:             * other level and the + operator:
104:             * <ul>
105:             * <li>MY_LEVEL = DEBUG + 1</li>
106:             * <li>MY_LEVEL2 = MY_LEVEL + 1</li>
107:             * </ul>
108:             */
109:            public void testInterLevelDefWithOther() {
110:                lf.defineLevel("MY_LEVEL", "DEBUG + 1");
111:                l = lf.defineLevel("MY_LEVEL2", "MY_LEVEL + 1");
112:                assertEquals(
113:                        "intermediate level definition based on another intermediate level",
114:                        BasicLevel.DEBUG + 2, l.getIntValue());
115:            }
116:
117:            /**
118:             * This method tests if it is possible to define a LevelConf with a
119:             * predefined level and the minus operator: DEBUG + 1
120:             */
121:            public void testInterLevelDefByMinus() {
122:                l = lf.defineLevel("TOTO", "DEBUG - 1");
123:                assertEquals("intermediate level definition minus operator",
124:                        BasicLevel.DEBUG - 1, l.getIntValue());
125:            }
126:
127:            /**
128:             * This method tests if it is possible to define a LevelConf with a
129:             * predefined level, the + operator and a number with several figures:
130:             * DEBUG + 156
131:             */
132:            public void testInterLevelDefWithFigures() {
133:                l = lf.defineLevel("TOTO2", "INFO +156 ");
134:                assertEquals(
135:                        "intermediate level definition, number with several figures",
136:                        BasicLevel.INFO + 156, l.getIntValue());
137:            }
138:
139:            /**
140:             * This method tests if it is possible to define a LevelConf with a
141:             * predefined level witten with a combinaison of lower case and upper case
142:             * and the + operator: InFO + 1
143:             */
144:            public void testInterLevelWithLowerCase() {
145:                l = lf.defineLevel("TOTO3", "   InFO + 1 ");
146:                assertEquals(
147:                        "intermediate level definition, level name with lower case",
148:                        BasicLevel.INFO + 1, l.getIntValue());
149:            }
150:
151:            /**
152:             * This method tests if it is possible to define a LevelConf with just a
153:             * number.
154:             */
155:            public void testInterLevelJustNb() {
156:                l = lf.defineLevel("TOTO4", "23455");
157:                assertEquals(
158:                        "intermediate level definition, level value is just a number",
159:                        23455, l.getIntValue());
160:                l = lf.defineLevel("TOTO7", 23455);
161:                assertEquals(
162:                        "intermediate level definition, level value is just a number",
163:                        23455, l.getIntValue());
164:
165:            }
166:
167:            /**
168:             * This method tests if it is possible to define a LevelConf with just an
169:             * other level.
170:             */
171:            public void testInterLevelJustOther() {
172:                lf.defineLevel("TOTO3", "   InFO + 1 ");
173:                l = lf.defineLevel("TOTO5", "TOTO3");
174:                assertEquals(
175:                        "intermediate level definition, level value is just another intermediate level",
176:                        BasicLevel.INFO + 1, l.getIntValue());
177:            }
178:
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.