23
23
24
24
package com .iluwatar .module ;
25
25
26
- import org .junit .jupiter .api .Test ;
27
- import org .slf4j .Logger ;
28
- import org .slf4j .LoggerFactory ;
26
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
27
+ import static org .junit .jupiter .api .Assertions .assertNull ;
29
28
30
29
import java .io .BufferedReader ;
31
30
import java .io .FileNotFoundException ;
32
31
import java .io .FileReader ;
33
32
import java .io .IOException ;
34
-
35
- import static org .junit . jupiter . api . Assertions . assertEquals ;
36
- import static org .junit . jupiter . api . Assertions . assertNull ;
33
+ import org . junit . jupiter . api . Test ;
34
+ import org .slf4j . Logger ;
35
+ import org .slf4j . LoggerFactory ;
37
36
38
37
/**
39
38
* The Module pattern can be considered a Creational pattern and a Structural pattern. It manages
@@ -58,14 +57,14 @@ public final class FileLoggerModuleTest {
58
57
59
58
/**
60
59
* This test verify that 'MESSAGE' is perfectly printed in output file
61
- *
60
+ *
62
61
* @throws IOException if program is not able to find log files (output.txt and error.txt)
63
62
*/
64
63
@ Test
65
64
public void testFileMessage () throws IOException {
66
65
67
66
/* Get singletong instance of File Logger Module */
68
- final FileLoggerModule fileLoggerModule = FileLoggerModule .getSingleton ();
67
+ final var fileLoggerModule = FileLoggerModule .getSingleton ();
69
68
70
69
/* Prepare the essential sub modules, to perform the sequence of jobs */
71
70
fileLoggerModule .prepare ();
@@ -82,14 +81,14 @@ public void testFileMessage() throws IOException {
82
81
83
82
/**
84
83
* This test verify that nothing is printed in output file
85
- *
84
+ *
86
85
* @throws IOException if program is not able to find log files (output.txt and error.txt)
87
86
*/
88
87
@ Test
89
88
public void testNoFileMessage () throws IOException {
90
89
91
- /* Get singletong instance of File Logger Module */
92
- final FileLoggerModule fileLoggerModule = FileLoggerModule .getSingleton ();
90
+ /* Get singleton instance of File Logger Module */
91
+ final var fileLoggerModule = FileLoggerModule .getSingleton ();
93
92
94
93
/* Prepare the essential sub modules, to perform the sequence of jobs */
95
94
fileLoggerModule .prepare ();
@@ -103,15 +102,15 @@ public void testNoFileMessage() throws IOException {
103
102
104
103
/**
105
104
* This test verify that 'ERROR' is perfectly printed in error file
106
- *
105
+ *
107
106
* @throws FileNotFoundException if program is not able to find log files (output.txt and
108
- * error.txt)
107
+ * error.txt)
109
108
*/
110
109
@ Test
111
110
public void testFileErrorMessage () throws FileNotFoundException {
112
111
113
112
/* Get singletong instance of File Logger Module */
114
- final FileLoggerModule fileLoggerModule = FileLoggerModule .getSingleton ();
113
+ final var fileLoggerModule = FileLoggerModule .getSingleton ();
115
114
116
115
/* Prepare the essential sub modules, to perform the sequence of jobs */
117
116
fileLoggerModule .prepare ();
@@ -122,21 +121,21 @@ public void testFileErrorMessage() throws FileNotFoundException {
122
121
/* Test if 'Message' is printed in file */
123
122
assertEquals (ERROR , readFirstLine (ERROR_FILE ));
124
123
125
- /* Unprepare to cleanup the modules */
124
+ /* Un-prepare to cleanup the modules */
126
125
fileLoggerModule .unprepare ();
127
126
}
128
127
129
128
/**
130
129
* This test verify that nothing is printed in error file
131
- *
130
+ *
132
131
* @throws FileNotFoundException if program is not able to find log files (output.txt and
133
- * error.txt)
132
+ * error.txt)
134
133
*/
135
134
@ Test
136
135
public void testNoFileErrorMessage () throws FileNotFoundException {
137
136
138
137
/* Get singletong instance of File Logger Module */
139
- final FileLoggerModule fileLoggerModule = FileLoggerModule .getSingleton ();
138
+ final var fileLoggerModule = FileLoggerModule .getSingleton ();
140
139
141
140
/* Prepare the essential sub modules, to perform the sequence of jobs */
142
141
fileLoggerModule .prepare ();
@@ -150,14 +149,14 @@ public void testNoFileErrorMessage() throws FileNotFoundException {
150
149
151
150
/**
152
151
* Utility method to read first line of a file
153
- *
152
+ *
154
153
* @param file as file name to be read
155
154
* @return a string value as first line in file
156
155
*/
157
- private static final String readFirstLine (final String file ) {
156
+ private static String readFirstLine (final String file ) {
158
157
159
158
String firstLine = null ;
160
- try (BufferedReader bufferedReader = new BufferedReader (new FileReader (file ))) {
159
+ try (var bufferedReader = new BufferedReader (new FileReader (file ))) {
161
160
162
161
while (bufferedReader .ready ()) {
163
162
0 commit comments