From d1fa759d0a76c10d34b4e349984833d8399b0990 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Wed, 21 Aug 2024 21:26:25 +0200 Subject: [PATCH] Ensure engine shutdown after running tests --- .../sosengine/base/srctests/TestBase.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 74e4dca..4ad7766 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,8 +20,10 @@ package de.staropensource.sosengine.base.srctests; import de.staropensource.sosengine.base.Engine; +import de.staropensource.sosengine.base.EngineInternals; import de.staropensource.sosengine.unittests.UnitLogger; import lombok.Getter; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import java.util.Locale; @@ -92,7 +94,18 @@ public class TestBase { */ @BeforeEach void initializeEngine() { - if (doInitialization && Engine.getInstance() == null) + if (doInitialization && Engine.getInstance() == null) { new Engine(); + EngineInternals.getInstance().setShutdownHandler(exitCode -> {}); + } + } + + /** + * Shuts the engine down after running tests. + */ + @AfterAll + static void shutdownEngine() { + if (Engine.getInstance() != null) + Engine.getInstance().shutdown(); } }