From d4c8494b345205df137f502287d79437f1d787a5 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 1 Sep 2024 19:01:44 +0200 Subject: [PATCH] Silence engine startup and shutdown messages in tests --- .../sosengine/base/srctests/TestBase.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/base/src/test/java/de/staropensource/sosengine/base/srctests/TestBase.java b/base/src/test/java/de/staropensource/sosengine/base/srctests/TestBase.java index 5df680c..ac13f7b 100644 --- a/base/src/test/java/de/staropensource/sosengine/base/srctests/TestBase.java +++ b/base/src/test/java/de/staropensource/sosengine/base/srctests/TestBase.java @@ -20,7 +20,9 @@ package de.staropensource.sosengine.base.srctests; import de.staropensource.sosengine.base.Engine; +import de.staropensource.sosengine.base.EngineConfiguration; import de.staropensource.sosengine.base.EngineInternals; +import de.staropensource.sosengine.base.type.InternalAccessArea; import de.staropensource.sosengine.unittest.UnitLogger; import lombok.Getter; import org.junit.jupiter.api.AfterAll; @@ -94,9 +96,13 @@ public class TestBase { */ @BeforeEach void initializeEngine() { - if (doInitialization && Engine.getInstance() == null) { + if (Engine.getInstance() == null && doInitialization) { + logger.diag("Initializing engine"); + System.getProperties().setProperty("sosengine.base.loggerLevel", "crash"); new Engine(); + EngineConfiguration.getInstance().loadDefaultConfiguration(); EngineInternals.getInstance().setShutdownHandler(exitCode -> {}); + EngineInternals.getInstance().restrictAccess(InternalAccessArea.SHUTDOWN_HANDLER_UPDATE); } } @@ -105,7 +111,10 @@ public class TestBase { */ @AfterAll static void shutdownEngine() { - if (Engine.getInstance() != null) + if (Engine.getInstance() != null) { + System.getProperties().setProperty("sosengine.base.loggerLevel", "crash"); + EngineConfiguration.getInstance().loadConfiguration(); Engine.getInstance().shutdown(); + } } }