Source Code Cross Referenced for Log4jRuleSetTest.java in  » Development » SLF4J » org » slf4j » migrator » line » 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 » SLF4J » org.slf4j.migrator.line 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.slf4j.migrator.line;
002:
003:        import java.util.Arrays;
004:
005:        import org.slf4j.migrator.line.LineConverter;
006:        import org.slf4j.migrator.line.Log4jRuleSet;
007:
008:        import junit.framework.TestCase;
009:
010:        public class Log4jRuleSetTest extends TestCase {
011:
012:            LineConverter log4jConverter = new LineConverter(new Log4jRuleSet());
013:
014:            public void testImportReplacement() {
015:                // LogFactory import replacement
016:                assertEquals(
017:                        "import org.slf4j.LoggerFactory;",
018:                        log4jConverter
019:                                .getOneLineReplacement("import org.apache.log4j.LogManager;"));
020:                // Log import replacement
021:                assertTrue(Arrays.equals(new String[] {
022:                        "import org.slf4j.Logger;",
023:                        "import org.slf4j.LoggerFactory;" }, log4jConverter
024:                        .getReplacement("import org.apache.log4j.Logger;")));
025:            }
026:
027:            public void testLogManagerGetLoggerReplacement() {
028:                // Logger declaration and instanciation without modifier
029:                assertEquals(
030:                        " Logger l = LoggerFactory.getLogger(MyClass.class);",
031:                        log4jConverter
032:                                .getOneLineReplacement(" Logger l = LogManager.getLogger(MyClass.class);"));
033:                // Logger declaration and instanciation with one modifier
034:                assertEquals(
035:                        "public Logger mylog=LoggerFactory.getLogger(MyClass.class);",
036:                        log4jConverter
037:                                .getOneLineReplacement("public Logger mylog=LogManager.getLogger(MyClass.class);"));
038:                // Logger declaration and instanciation with two modifier
039:                assertEquals(
040:                        "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);",
041:                        log4jConverter
042:                                .getOneLineReplacement("public static Logger mylog1 = LogManager.getLogger(MyClass.class);"));
043:                // Logger declaration and instanciation with two modifier and comment at the
044:                // end of line
045:                assertEquals(
046:                        "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);//logger instanciation and declaration",
047:                        log4jConverter
048:                                .getOneLineReplacement("public static Logger mylog1 = LogManager.getLogger(MyClass.class);//logger instanciation and declaration"));
049:                // Logger instanciation without declaration and comment at the end of line
050:                assertEquals(
051:                        " myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation",
052:                        log4jConverter
053:                                .getOneLineReplacement(" myLog = LogManager.getLogger(MyClass.class);//logger instanciation"));
054:                // commented Logger declaration and instanciation with two modifier
055:                assertEquals(
056:                        "//public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);",
057:                        log4jConverter
058:                                .getOneLineReplacement("//public static Logger mylog1 = LogManager.getLogger(MyClass.class);"));
059:                // commented Logger instanciation without declaration
060:                assertEquals(
061:                        "// myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation",
062:                        log4jConverter
063:                                .getOneLineReplacement("// myLog = LogManager.getLogger(MyClass.class);//logger instanciation"));
064:            }
065:
066:            public void testLoggerGetLoggerReplacement() {
067:                // Logger declaration and instanciation without modifier
068:                assertEquals(
069:                        "Logger l = LoggerFactory.getLogger(MyClass.class);",
070:                        log4jConverter
071:                                .getOneLineReplacement("Logger l = Logger.getLogger(MyClass.class);"));
072:                // Logger declaration and instanciation with one modifier
073:                assertEquals(
074:                        "public Logger mylog=LoggerFactory.getLogger(MyClass.class);",
075:                        log4jConverter
076:                                .getOneLineReplacement("public Logger mylog=Logger.getLogger(MyClass.class);"));
077:                // Logger declaration and instanciation with modifiers
078:                assertEquals(
079:                        "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);",
080:                        log4jConverter
081:                                .getOneLineReplacement("public static Logger mylog1 = Logger.getLogger(MyClass.class);"));
082:                // Logger declaration and instanciation with two modifier and comment at the
083:                // end of line
084:                assertEquals(
085:                        "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class); // logger instanciation and declaration",
086:                        log4jConverter
087:                                .getOneLineReplacement("public static Logger mylog1 = Logger.getLogger(MyClass.class); // logger instanciation and declaration"));
088:                // Logger instanciation without declaration and comment at the end of line
089:                assertEquals(
090:                        " myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation",
091:                        log4jConverter
092:                                .getOneLineReplacement(" myLog = Logger.getLogger(MyClass.class);//logger instanciation"));
093:                // commented Logger declaration and instanciation with two modifier
094:                assertEquals(
095:                        "//public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);",
096:                        log4jConverter
097:                                .getOneLineReplacement("//public static Logger mylog1 = Logger.getLogger(MyClass.class);"));
098:                // commented Logger instanciation without declaration
099:                assertEquals(
100:                        "// myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation",
101:                        log4jConverter
102:                                .getOneLineReplacement("// myLog = Logger.getLogger(MyClass.class);//logger instanciation"));
103:            }
104:
105:            public void testLogDeclarationReplacement() {
106:                // simple Logger declaration
107:                assertEquals("Logger mylog;", log4jConverter
108:                        .getOneLineReplacement("Logger mylog;"));
109:                // Logger declaration with a modifier
110:                assertEquals("private Logger mylog;", log4jConverter
111:                        .getOneLineReplacement("private Logger mylog;"));
112:
113:                // Logger declaration with modifiers
114:                assertEquals(
115:                        "public static final Logger myLog;",
116:                        log4jConverter
117:                                .getOneLineReplacement("public static final Logger myLog;"));
118:                // Logger declaration with modifiers and comment at the end of line
119:                assertEquals(
120:                        "public Logger myLog;//logger declaration",
121:                        log4jConverter
122:                                .getOneLineReplacement("public Logger myLog;//logger declaration"));
123:                // commented Logger declaration
124:                assertEquals("//private Logger myLog;", log4jConverter
125:                        .getOneLineReplacement("//private Logger myLog;"));
126:            }
127:
128:            public void testMultiLineReplacement() {
129:                // Logger declaration on a line
130:                assertEquals("protected Logger log =", log4jConverter
131:                        .getOneLineReplacement("protected Logger log ="));
132:
133:                // Logger instanciation on the next line
134:                assertEquals(
135:                        " LoggerFactory.getLogger(MyComponent.class);",
136:                        log4jConverter
137:                                .getOneLineReplacement(" LogManager.getLogger(MyComponent.class);"));
138:                // Logger declaration on a line
139:                assertEquals("protected Logger log ", log4jConverter
140:                        .getOneLineReplacement("protected Logger log "));
141:                // Logger instanciation on the next line
142:                assertEquals(
143:                        " = LoggerFactory.getLogger(MyComponent.class);",
144:                        log4jConverter
145:                                .getOneLineReplacement(" = LogManager.getLogger(MyComponent.class);"));
146:            }
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.