Ensure engine shutdown after running tests
All checks were successful
build-and-test / test (push) Successful in 3m27s
build-and-test / generate-javadoc (push) Successful in 3m30s
build-and-test / build (push) Successful in 4m28s

This commit is contained in:
JeremyStar™ 2024-08-21 21:26:25 +02:00
parent 6a2a18095b
commit d1fa759d0a
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -20,8 +20,10 @@
package de.staropensource.sosengine.base.srctests; package de.staropensource.sosengine.base.srctests;
import de.staropensource.sosengine.base.Engine; import de.staropensource.sosengine.base.Engine;
import de.staropensource.sosengine.base.EngineInternals;
import de.staropensource.sosengine.unittests.UnitLogger; import de.staropensource.sosengine.unittests.UnitLogger;
import lombok.Getter; import lombok.Getter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import java.util.Locale; import java.util.Locale;
@ -92,7 +94,18 @@ public class TestBase {
*/ */
@BeforeEach @BeforeEach
void initializeEngine() { void initializeEngine() {
if (doInitialization && Engine.getInstance() == null) if (doInitialization && Engine.getInstance() == null) {
new Engine(); new Engine();
EngineInternals.getInstance().setShutdownHandler(exitCode -> {});
}
}
/**
* Shuts the engine down after running tests.
*/
@AfterAll
static void shutdownEngine() {
if (Engine.getInstance() != null)
Engine.getInstance().shutdown();
} }
} }