@@ -31,78 +31,85 @@ public static void setup() throws Exception {
3131 }
3232
3333 @ Test
34- public void givenLoggerWithDefaultConfig_shouldLogToConsole () throws Exception {
34+ public void givenLoggerWithDefaultConfig_whenLogToConsole_thanOK () throws Exception {
3535 Logger logger = LogManager .getLogger (getClass ());
3636 Exception e = new RuntimeException ("This is only a test!" );
37+
3738 logger .info ("This is a simple message at INFO level. " + "It will be hidden." );
3839 logger .error ("This is a simple message at ERROR level. " + "This is the minimum visible level." , e );
3940 }
4041
4142 @ Test
42- public void givenLoggerWithConsoleConfig_shouldLogToConsoleInColors () throws Exception {
43+ public void givenLoggerWithConsoleConfig_whenLogToConsoleInColors_thanOK () throws Exception {
4344 Logger logger = LogManager .getLogger ("CONSOLE_PATTERN_APPENDER_MARKER" );
45+ Exception e = new RuntimeException ("This is only a test!" );
46+
4447 logger .trace ("This is a colored message at TRACE level." );
4548 logger .debug ("This is a colored message at DEBUG level. " + "This is the minimum visible level." );
4649 logger .info ("This is a colored message at INFO level." );
4750 logger .warn ("This is a colored message at WARN level." );
48- Exception e = new RuntimeException ("This is only a test!" );
4951 logger .error ("This is a colored message at ERROR level." , e );
5052 logger .fatal ("This is a colored message at FATAL level." );
5153 }
5254
5355 @ Test
54- public void givenLoggerWithConsoleConfig_shouldFilterByMarker () throws Exception {
56+ public void givenLoggerWithConsoleConfig_whenFilterByMarker_thanOK () throws Exception {
5557 Logger logger = LogManager .getLogger ("CONSOLE_PATTERN_APPENDER_MARKER" );
5658 Marker appError = MarkerManager .getMarker ("APP_ERROR" );
57- logger .error (appError , "This marker message at ERROR level should be hidden." );
5859 Marker connectionTrace = MarkerManager .getMarker ("CONN_TRACE" );
60+
61+ logger .error (appError , "This marker message at ERROR level should be hidden." );
5962 logger .trace (connectionTrace , "This is a marker message at TRACE level." );
6063 }
6164
6265 @ Test
63- public void givenLoggerWithConsoleConfig_shouldFilterByThreadContext () throws Exception {
66+ public void givenLoggerWithConsoleConfig_whenFilterByThreadContext_thanOK () throws Exception {
6467 Logger logger = LogManager .getLogger ("CONSOLE_PATTERN_APPENDER_THREAD_CONTEXT" );
6568 ThreadContext .put ("userId" , "1000" );
6669 logger .info ("This is a log-visible user login. Maybe from an admin account?" );
6770 ThreadContext .put ("userId" , "1001" );
6871 logger .info ("This is a log-invisible user login." );
69-
7072 }
7173
7274 @ Test
73- public void givenLoggerWithAsyncConfig_shouldLogToJsonFile () throws Exception {
75+ public void givenLoggerWithAsyncConfig_whenLogToJsonFile_thanOK () throws Exception {
7476 Logger logger = LogManager .getLogger ("ASYNC_JSON_FILE_APPENDER" );
77+
7578 final int count = 88 ;
7679 for (int i = 0 ; i < count ; i ++) {
7780 logger .info ("This is async JSON message #{} at INFO level." , count );
7881 }
82+
7983 long logEventsCount = Files .lines (Paths .get ("target/logfile.json" ))
8084 .count ();
8185 assertTrue (logEventsCount > 0 && logEventsCount <= count );
8286 }
8387
8488 @ Test
85- public void givenLoggerWithFailoverConfig_shouldLog () throws Exception {
89+ public void givenLoggerWithFailoverConfig_whenLog_thanOK () throws Exception {
8690 Logger logger = LogManager .getLogger ("FAIL_OVER_SYSLOG_APPENDER" );
91+ Exception e = new RuntimeException ("This is only a test!" );
92+
8793 logger .trace ("This is a syslog message at TRACE level." );
8894 logger .debug ("This is a syslog message at DEBUG level." );
8995 logger .info ("This is a syslog message at INFO level. This is the minimum visible level." );
9096 logger .warn ("This is a syslog message at WARN level." );
91- Exception e = new RuntimeException ("This is only a test!" );
9297 logger .error ("This is a syslog message at ERROR level." , e );
9398 logger .fatal ("This is a syslog message at FATAL level." );
9499 }
95100
96101 @ Test
97- public void givenLoggerWithJdbcConfig_shouldLogToDataSource () throws Exception {
102+ public void givenLoggerWithJdbcConfig_whenLogToDataSource_thanOK () throws Exception {
98103 Logger logger = LogManager .getLogger ("JDBC_APPENDER" );
104+
99105 final int count = 88 ;
100106 for (int i = 0 ; i < count ; i ++) {
101107 logger .info ("This is JDBC message #{} at INFO level." , count );
102108 }
103109 Connection connection = ConnectionFactory .getConnection ();
104110 ResultSet resultSet = connection .createStatement ()
105- .executeQuery ("SELECT COUNT(*) AS ROW_COUNT FROM logs" );
111+ .executeQuery ("SELECT COUNT(*) AS ROW_COUNT FROM logs" );
112+
106113 int logCount = 0 ;
107114 if (resultSet .next ()) {
108115 logCount = resultSet .getInt ("ROW_COUNT" );
@@ -111,8 +118,9 @@ public void givenLoggerWithJdbcConfig_shouldLogToDataSource() throws Exception {
111118 }
112119
113120 @ Test
114- public void givenLoggerWithRollingFileConfig_shouldLogToXMLFile () throws Exception {
121+ public void givenLoggerWithRollingFileConfig_whenLogToXMLFile_thanOK () throws Exception {
115122 Logger logger = LogManager .getLogger ("XML_ROLLING_FILE_APPENDER" );
123+
116124 final int count = 88 ;
117125 for (int i = 0 ; i < count ; i ++) {
118126 logger .info ("This is rolling file XML message #{} at INFO level." , i );
0 commit comments