Skip to content

Commit 1d4d269

Browse files
committed
added new unit test for FileFormatter
1 parent 616fdf7 commit 1d4d269

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

imagetool/src/test/java/com/oracle/weblogic/imagetool/logging/FileFormatterTest.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,34 @@
33

44
package com.oracle.weblogic.imagetool.logging;
55

6+
import java.util.logging.Level;
7+
import java.util.logging.LogRecord;
8+
69
import org.junit.jupiter.api.Test;
710

8-
import static org.junit.jupiter.api.Assertions.assertEquals;
11+
import static org.junit.jupiter.api.Assertions.assertTrue;
912

1013

1114
class FileFormatterTest {
1215

1316
@Test
1417
void format() {
15-
assertEquals(true, true);
18+
FileFormatter formatter = new FileFormatter();
19+
LogRecord logRecord = new LogRecord(Level.INFO, "message goes here");
20+
21+
String logMessage = formatter.format(logRecord);
22+
assertTrue(logMessage.startsWith("####"));
23+
assertTrue(logMessage.endsWith("<message goes here>\n"));
24+
}
25+
26+
@Test
27+
void formatWithColor() {
28+
FileFormatter formatter = new FileFormatter();
29+
String initialValue = "message [[brightred: goes]] here";
30+
LogRecord logRecord = new LogRecord(Level.INFO, initialValue);
31+
32+
String logMessage = formatter.format(logRecord);
33+
// color should be removed for non-console logging
34+
assertTrue(logMessage.endsWith("<message goes here>\n"));
1635
}
1736
}

0 commit comments

Comments
 (0)