forked from qos-ch/slf4j
/
SimpleLoggingTest.java
72 lines (59 loc) · 1.33 KB
/
SimpleLoggingTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package org.slf4j.n;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.slf4j.n.SimpleLogging.error;
/**
* This test isn't really testing very much, yet. ;)
*/
public class SimpleLoggingTest {
@Test
public void testCallerClass()
{
String callerClass=SimpleLogging.resolveCallerClass(1);
assertEquals(SimpleLoggingTest.class.getName(), callerClass);
}
@Test
public void testIsErrorEnabled()
{
assertTrue(SimpleLogging.isErrorEnabled());
}
@Test
public void testError()
{
error("Test! {}", "foo");
}
@Test
public void testCallingLogger()
{
Logger logger = SimpleLogging.getCallingLogger();
logger.error("CallingLogger-Test! {}", "foo");
Runnable r=new Runnable() {
public void run() {
Logger logger = SimpleLogging.getCallingLogger();
logger.error("CallingLogger-InnerTest! {}", "foo");
}
};
r.run();
B b=new B();
b.foo();
}
public class A
{
private final Logger logger = SimpleLogging.getCallingLogger();
public void foo()
{
logger.warn("A.foo");
}
}
public class B
extends A
{
private final Logger logger = SimpleLogging.getCallingLogger();
public void foo()
{
super.foo();
logger.warn("B.foo");
}
}
}