Skip to content

Commit

Permalink
#2099: reverted
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed May 28, 2023
1 parent b44cfbe commit 367e1bf
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions eo-maven-plugin/src/test/java/org/eolang/maven/LogFormatTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@

import com.jcabi.log.Logger;
import java.io.IOException;
import java.util.Arrays;
import java.util.Optional;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.junitpioneer.jupiter.StdIo;
import org.junitpioneer.jupiter.StdOut;
import org.junitpioneer.jupiter.WritesStdIo;

/**
* Tests of the log4j logger messages format.
Expand All @@ -43,7 +44,7 @@
* this class are relatively fast, it does not significantly impact overall performance.
* We disable parallelism by using the {@link Execution} annotation with
* {@link ExecutionMode#SAME_THREAD}. DO NOT REMOVE THAT ANNOTATION!
*
*
* @since 0.28.11
*/
@Execution(ExecutionMode.SAME_THREAD)
Expand All @@ -55,26 +56,27 @@ class LogFormatTest {
private static final String FORMAT =
"^\\d{2}:\\d{2}:\\d{2} \\[INFO] org.eolang.maven.LogFormatTest: Wake up, Neo...";

@Test
@StdIo
@WritesStdIo
@Test
void printsFormattedMessage(final StdOut out) throws IOException {
final String message = "Wake up, Neo...";
Logger.info(this, message);
out.flush();
final String[] lines = out.capturedLines();
final Optional<String> log = Arrays.stream(out.capturedLines())
.filter(s -> s.contains(message))
.findFirst();
MatcherAssert.assertThat(
lines.length,
Matchers.greaterThan(0)
String.format("Log message '%s' not found", message),
log.isPresent(),
Matchers.is(true)
);
MatcherAssert.assertThat(lines[0], Matchers.containsString(message));
MatcherAssert.assertThat(
String.format(
"Expected message '%s', but log was:\n '%s'",
lines[0],
log.get(),
LogFormatTest.FORMAT
),
lines[0],
log.get(),
Matchers.matchesPattern(LogFormatTest.FORMAT)
);
}
Expand Down

0 comments on commit 367e1bf

Please sign in to comment.