1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.util;
15
16 import org.junit.jupiter.api.Test;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import static org.junit.jupiter.api.Assertions.assertEquals;
22 public class LoggerNameUtilTest {
23
24 @Test
25 public void smoke0() {
26 List<String> witnessList = new ArrayList<String>();
27 witnessList.add("a");
28 witnessList.add("b");
29 witnessList.add("c");
30 List<String> partList = LoggerNameUtil.computeNameParts("a.b.c");
31 assertEquals(witnessList, partList);
32 }
33
34 @Test
35 public void smoke1() {
36 List<String> witnessList = new ArrayList<String>();
37 witnessList.add("com");
38 witnessList.add("foo");
39 witnessList.add("Bar");
40 List<String> partList = LoggerNameUtil.computeNameParts("com.foo.Bar");
41 assertEquals(witnessList, partList);
42 }
43
44 @Test
45 public void emptyStringShouldReturnAListContainingOneEmptyString() {
46 List<String> witnessList = new ArrayList<String>();
47 witnessList.add("");
48 List<String> partList = LoggerNameUtil.computeNameParts("");
49 assertEquals(witnessList, partList);
50 }
51
52 @Test
53 public void dotAtLastPositionShouldReturnAListWithAnEmptyStringAsLastElement() {
54 List<String> witnessList = new ArrayList<String>();
55 witnessList.add("com");
56 witnessList.add("foo");
57 witnessList.add("");
58
59 List<String> partList = LoggerNameUtil.computeNameParts("com.foo.");
60 assertEquals(witnessList, partList);
61 }
62
63 @Test
64 public void supportNestedClasses() {
65 List<String> witnessList = new ArrayList<String>();
66 witnessList.add("com");
67 witnessList.add("foo");
68 witnessList.add("Bar");
69 witnessList.add("Nested");
70
71 List<String> partList = LoggerNameUtil.computeNameParts("com.foo.Bar$Nested");
72 assertEquals(witnessList, partList);
73 }
74
75 @Test
76 public void supportNestedClassesWithNestedDot() {
77
78 List<String> witnessList = new ArrayList<String>();
79 witnessList.add("com");
80 witnessList.add("foo");
81 witnessList.add("Bar");
82 witnessList.add("Nested");
83 witnessList.add("dot");
84
85 List<String> partList = LoggerNameUtil.computeNameParts("com.foo.Bar$Nested.dot");
86 assertEquals(witnessList, partList);
87 }
88
89 @Test
90 public void supportNestedClassesAtBeginning() {
91 List<String> witnessList = new ArrayList<String>();
92 witnessList.add("foo");
93 witnessList.add("Nested");
94 witnessList.add("bar");
95
96 List<String> partList = LoggerNameUtil.computeNameParts("foo$Nested.bar");
97 assertEquals(witnessList, partList);
98 }
99
100 }