01: package org.slf4j.migrator.line;
02:
03: import org.slf4j.migrator.line.JCLRuleSet;
04: import org.slf4j.migrator.line.LineConverter;
05: import org.slf4j.migrator.line.Log4jRuleSet;
06:
07: import junit.framework.TestCase;
08:
09: public class NoConversionTest extends TestCase {
10:
11: /**
12: * This test shows that performing JCL to SLF4J conversion has no impact on
13: * Log4j implementation
14: */
15: public void testJclOverLog4jConversion() {
16: // running jcl to slf4j conversion
17: //JCLMatcher jclMatcher =
18: LineConverter jclLineConverter = new LineConverter(
19: new JCLRuleSet());
20: // no changes on log4j.LogManager import
21: assertEquals(
22: "import org.apache.log4j.LogManager;",
23: jclLineConverter
24: .getOneLineReplacement("import org.apache.log4j.LogManager;"));
25: // no changes on log4j.Logger import
26: assertEquals(
27: "import org.apache.log4j.Logger;",
28: jclLineConverter
29: .getOneLineReplacement("import org.apache.log4j.Logger;"));
30: // no changes on Logger instanciation using LogManager
31: assertEquals(
32: "Logger log = LogManager.getLogger(MyClass.class);",
33: jclLineConverter
34: .getOneLineReplacement("Logger log = LogManager.getLogger(MyClass.class);"));
35: // no changes on Logger instanciation using Logger.getLogger
36: assertEquals(
37: "public static Logger mylog1 = Logger.getLogger(MyClass.class);",
38: jclLineConverter
39: .getOneLineReplacement("public static Logger mylog1 = Logger.getLogger(MyClass.class);"));
40: }
41:
42: /**
43: * This test shows that performing Log4j to SLF4J conversion has no impact on
44: * JCL implementation
45: */
46: public void testLog4jOverJclConversion() {
47: // running log4j to slf4j conversion
48: LineConverter log4jConverter = new LineConverter(
49: new Log4jRuleSet());
50:
51: // no changes on LogFactory import
52: assertEquals(
53: "import org.apache.commons.logging.LogFactory;",
54: log4jConverter
55: .getOneLineReplacement("import org.apache.commons.logging.LogFactory;"));
56: // no changes on Log import
57: assertEquals(
58: "import org.apache.commons.logging.Log;",
59: log4jConverter
60: .getOneLineReplacement("import org.apache.commons.logging.Log;"));
61: // no changes on Log instanciation using Logfactory.getLog
62: assertEquals(
63: "public static Log mylog1 = LogFactory.getLog(MyClass.class);",
64: log4jConverter
65: .getOneLineReplacement("public static Log mylog1 = LogFactory.getLog(MyClass.class);"));
66: // no changes on log instanciation using LogFactory.getFactory().getInstance
67: assertEquals(
68: "public Log mylog=LogFactory.getFactory().getInstance(MyClass.class);",
69: log4jConverter
70: .getOneLineReplacement("public Log mylog=LogFactory.getFactory().getInstance(MyClass.class);"));
71:
72: }
73: }
|