From 9d2f810e3ab03655953ef7374df24ea2efe14812 Mon Sep 17 00:00:00 2001 From: "tomasz.kowalczewski" Date: Sat, 17 Jul 2021 13:49:14 +0200 Subject: [PATCH] Making test more stable - it can happen that there is some other unrelated log line (e.g. from [Finalizer] thread) so we can't assume there is exactly ONE result. --- .../tjahzi/log4j2/ProgrammaticConfigurationTest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/ProgrammaticConfigurationTest.java b/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/ProgrammaticConfigurationTest.java index 5a4ee07..80aa966 100644 --- a/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/ProgrammaticConfigurationTest.java +++ b/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/ProgrammaticConfigurationTest.java @@ -23,6 +23,7 @@ import org.testcontainers.junit.jupiter.Testcontainers; import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.Matchers.greaterThan; @Testcontainers public class ProgrammaticConfigurationTest { @@ -79,7 +80,7 @@ public class ProgrammaticConfigurationTest { .body("status", equalTo("success")) .body("data.result.size()", equalTo(1)) .body("data.result[0].stream.server", equalTo("127.0.0.1")) - .body("data.result[0].values.size()", equalTo(1)) + .body("data.result[0].values.size()", greaterThan(0)) .body( "data.result.values", hasItems( @@ -113,14 +114,15 @@ public class ProgrammaticConfigurationTest { .addAttribute("level", "ALL") ) .add( - builder.newLayout("PatternLayout"). - addAttribute("pattern", "%X{tid} [%t] %d{MM-dd HH:mm:ss.SSS} %5p %c{1} - %m%n%exception{full}") + builder.newLayout("PatternLayout") + .addAttribute("pattern", "%X{tid} [%t] %d{MM-dd HH:mm:ss.SSS} %5p %c{1} - %m%n%exception{full}") ) .addComponent( builder.newComponent("Header") .addAttribute("name", "server") .addAttribute("value", "127.0.0.1") - ).addComponent( + ) + .addComponent( builder.newComponent("Label") .addAttribute("name", "server") .addAttribute("value", "127.0.0.1")