1 |
|
package org.europa.together.application; |
2 |
|
|
3 |
|
import java.io.File; |
4 |
|
import java.io.IOException; |
5 |
|
import org.europa.together.JUnit5Preperator; |
6 |
|
import org.europa.together.business.Logger; |
7 |
|
import org.europa.together.domain.LogLevel; |
8 |
|
import org.europa.together.service.LoggingService; |
9 |
|
import org.europa.together.utils.Constraints; |
10 |
|
import org.junit.jupiter.api.AfterAll; |
11 |
|
import org.junit.jupiter.api.AfterEach; |
12 |
|
import static org.junit.jupiter.api.Assertions.*; |
13 |
|
import org.junit.jupiter.api.Assumptions; |
14 |
|
import org.junit.jupiter.api.BeforeAll; |
15 |
|
import org.junit.jupiter.api.BeforeEach; |
16 |
|
import org.junit.jupiter.api.Test; |
17 |
|
import org.junit.jupiter.api.extension.ExtendWith; |
18 |
|
import org.springframework.test.context.ContextConfiguration; |
19 |
|
import org.springframework.test.context.junit.jupiter.SpringExtension; |
20 |
|
|
21 |
|
@SuppressWarnings("unchecked") |
22 |
|
@ExtendWith({JUnit5Preperator.class}) |
23 |
|
@ExtendWith(SpringExtension.class) |
24 |
|
@ContextConfiguration(locations = {"/applicationContext.xml"}) |
|
|
| 100% |
Uncovered Elements: 0 (53) |
Complexity: 14 |
Complexity Density: 0.36 |
|
25 |
|
public class LogbackLoggerTest { |
26 |
|
|
27 |
|
private static final Logger LOGGER = new LogbackLogger(LogbackLoggerTest.class); |
28 |
|
|
29 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
30 |
1 |
@BeforeAll... |
31 |
|
static void setUp() { |
32 |
1 |
Assumptions.assumeTrue(true, "Assumtion failed."); |
33 |
|
|
34 |
1 |
LOGGER.log("Assumptions passed ...\n\n", LogLevel.DEBUG); |
35 |
|
} |
36 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
37 |
1 |
@AfterAll... |
38 |
|
static void tearDown() { |
39 |
|
} |
40 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
41 |
10 |
@BeforeEach... |
42 |
|
void testCaseInitialization() { |
43 |
|
} |
44 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
45 |
10 |
@AfterEach... |
46 |
|
void testCaseTermination() { |
47 |
|
} |
48 |
|
|
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
50 |
1 |
@Test... |
51 |
|
void constructor() { |
52 |
1 |
LOGGER.log("TEST CASE: constructor", LogLevel.DEBUG); |
53 |
|
|
54 |
1 |
Logger test_01 = new LogbackLogger(Logger.class); |
55 |
1 |
assertNotNull(test_01); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
58 |
1 |
@Test... |
59 |
|
void fallbackConstructor() throws IOException { |
60 |
1 |
LOGGER.log("TEST CASE: fallbackConstructor", LogLevel.DEBUG); |
61 |
|
|
62 |
1 |
LoggingService service = new LoggingService(); |
63 |
1 |
service.createLogConfiguration(); |
64 |
|
|
65 |
1 |
File config = new File(Constraints.SYSTEM_APP_DIR + "/logback.xml"); |
66 |
1 |
assertTrue(config.exists()); |
67 |
1 |
Logger test_02 = new LogbackLogger(Logger.class); |
68 |
1 |
assertNotNull(test_02); |
69 |
|
|
70 |
|
|
71 |
1 |
config.delete(); |
72 |
1 |
assertFalse(config.exists()); |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
75 |
1 |
@Test... |
76 |
|
void failLog() throws Exception { |
77 |
1 |
LOGGER.log("TEST CASE: faiLog", LogLevel.DEBUG); |
78 |
|
|
79 |
1 |
Logger logger = new LogbackLogger(Logger.class); |
80 |
1 |
assertThrows(Exception.class, () -> { |
81 |
1 |
logger.log("console logging test: trace", null); |
82 |
|
}); |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
85 |
1 |
@Test... |
86 |
|
void logTrace() { |
87 |
1 |
LOGGER.log("TEST CASE: logTrace", LogLevel.DEBUG); |
88 |
|
|
89 |
1 |
Logger logger = new LogbackLogger(Logger.class); |
90 |
1 |
assertEquals(LogLevel.TRACE, logger.log("console logging test: trace", LogLevel.TRACE)); |
91 |
|
} |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
93 |
1 |
@Test... |
94 |
|
void logDebug() { |
95 |
1 |
LOGGER.log("TEST CASE: logDebug", LogLevel.DEBUG); |
96 |
|
|
97 |
1 |
Logger logger = new LogbackLogger(Logger.class); |
98 |
1 |
assertEquals(LogLevel.DEBUG, logger.log("console logging test: debug", LogLevel.DEBUG)); |
99 |
|
} |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
101 |
1 |
@Test... |
102 |
|
void logInfo() { |
103 |
1 |
LOGGER.log("TEST CASE: logInfo", LogLevel.DEBUG); |
104 |
|
|
105 |
1 |
Logger logger = new LogbackLogger(Logger.class); |
106 |
1 |
assertEquals(LogLevel.INFO, logger.log("console logging test: info", LogLevel.INFO)); |
107 |
|
} |
108 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
109 |
1 |
@Test... |
110 |
|
void logWarn() { |
111 |
1 |
LOGGER.log("TEST CASE: logWarn", LogLevel.DEBUG); |
112 |
|
|
113 |
1 |
Logger logger = new LogbackLogger(Logger.class); |
114 |
1 |
assertEquals(LogLevel.WARN, logger.log("console logging test: warn", LogLevel.WARN)); |
115 |
|
} |
116 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
117 |
1 |
@Test... |
118 |
|
void logError() { |
119 |
1 |
LOGGER.log("TEST CASE: logError", LogLevel.DEBUG); |
120 |
|
|
121 |
1 |
Logger logger = new LogbackLogger(Logger.class); |
122 |
1 |
assertEquals(LogLevel.ERROR, logger.log("console logging test: error", LogLevel.ERROR)); |
123 |
|
} |
124 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
125 |
1 |
@Test... |
126 |
|
void catchException() { |
127 |
1 |
LOGGER.log("TEST CASE: catchException", LogLevel.DEBUG); |
128 |
|
|
129 |
1 |
Logger logger = new LogbackLogger(Logger.class); |
130 |
1 |
assertEquals("Logging exception test.", |
131 |
|
logger.catchException(new Exception("Logging exception test."))); |
132 |
|
} |
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
134 |
1 |
@Test... |
135 |
|
void catchNullpointerException() { |
136 |
1 |
LOGGER.log("TEST CASE: catchNullpointerException", LogLevel.DEBUG); |
137 |
|
|
138 |
1 |
Logger logger = new LogbackLogger(Logger.class); |
139 |
1 |
assertEquals("Logging exception test.", |
140 |
|
logger.catchException(new NullPointerException("Logging exception test."))); |
141 |
|
} |
142 |
|
|
143 |
|
} |