1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.spi;
15
16 import org.junit.jupiter.api.Test;
17
18 import java.util.Arrays;
19
20 import static org.junit.jupiter.api.Assertions.assertEquals;
21 import static org.junit.jupiter.api.Assertions.assertNotNull;
22 import static org.junit.jupiter.api.Assertions.assertTrue;
23
24 public class CallerDataTest {
25
26 @Test
27 public void testBasic() {
28 Throwable t = new Throwable();
29 StackTraceElement[] steArray = t.getStackTrace();
30
31 StackTraceElement[] cda = CallerData.extract(t, CallerDataTest.class.getName(), 100, null);
32 Arrays.stream(cda).forEach( ste -> System.out.println(ste));
33 assertNotNull(cda);
34 assertTrue(cda.length > 0);
35 assertEquals(steArray.length - 1, cda.length);
36 }
37
38
39
40
41
42
43 @Test
44 public void testDeferredProcessing() {
45 StackTraceElement[] cda = CallerData.extract(new Throwable(), "com.inexistent.foo", 10, null);
46 assertNotNull(cda);
47 assertEquals(0, cda.length);
48 }
49
50 }