diff --git a/src/test/java/de/embl/schwab/crosshair/CrosshairTest.java b/src/test/java/de/embl/schwab/crosshair/CrosshairTest.java index f903caf..0341bdf 100644 --- a/src/test/java/de/embl/schwab/crosshair/CrosshairTest.java +++ b/src/test/java/de/embl/schwab/crosshair/CrosshairTest.java @@ -1,6 +1,7 @@ package de.embl.schwab.crosshair; import de.embl.cba.bdv.utils.sources.LazySpimSource; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import javax.swing.*; @@ -11,13 +12,21 @@ class CrosshairTest { + private Crosshair crosshair; + + @AfterEach + void tearDown() { + crosshair.getUniverse().close(); + crosshair.getBdvHandle().close(); + } + @Test void openCrosshairFromBdv() { ClassLoader classLoader = this.getClass().getClassLoader(); File xray = new File(classLoader.getResource("exampleBlock.xml").getFile()); final LazySpimSource imageSource = new LazySpimSource("raw", xray.getAbsolutePath()); - Crosshair crosshair = new Crosshair(imageSource); + crosshair = new Crosshair(imageSource); // Check successfully created crosshair controls, bdv window + 3D viewer assertNotNull(crosshair.getCrosshairFrame()); diff --git a/src/test/java/de/embl/schwab/crosshair/io/STLResourceLoaderTest.java b/src/test/java/de/embl/schwab/crosshair/io/STLResourceLoaderTest.java index 309d6fd..a5b1341 100644 --- a/src/test/java/de/embl/schwab/crosshair/io/STLResourceLoaderTest.java +++ b/src/test/java/de/embl/schwab/crosshair/io/STLResourceLoaderTest.java @@ -25,9 +25,12 @@ void loadSTL(String modelName) { void loadInvalidSTL() { // Disable logging to keep the test logs clean (we're expecting an error here) Logger logger = (Logger) LoggerFactory.getLogger(STLResourceLoader.class); + Level loggerLevel = logger.getLevel(); logger.setLevel(Level.OFF); Map currentStl = STLResourceLoader.loadSTL("invalid.stl"); assertNull(currentStl); + + logger.setLevel(loggerLevel); } } \ No newline at end of file diff --git a/src/test/java/de/embl/schwab/crosshair/legacy/OldFormatSettingsReaderTest.java b/src/test/java/de/embl/schwab/crosshair/legacy/OldFormatSettingsReaderTest.java index 4c98c5b..32b0da1 100644 --- a/src/test/java/de/embl/schwab/crosshair/legacy/OldFormatSettingsReaderTest.java +++ b/src/test/java/de/embl/schwab/crosshair/legacy/OldFormatSettingsReaderTest.java @@ -37,11 +37,13 @@ void readSettings() { void readInvalidSettings( @TempDir Path tempDir ) { // Disable logging to keep the test logs clean (we're expecting an error here) Logger logger = (Logger) LoggerFactory.getLogger(OldFormatSettingsReader.class); + Level loggerLevel = logger.getLevel(); logger.setLevel(Level.OFF); File invalidJsonPath = tempDir.resolve( "invalid.json" ).toFile(); OldFormatSettings settings = oldFormatSettingsReader.readSettings( invalidJsonPath.getAbsolutePath() ); - assertNull( settings ); + + logger.setLevel(loggerLevel); } } \ No newline at end of file diff --git a/src/test/java/de/embl/schwab/crosshair/settings/SettingsReaderTest.java b/src/test/java/de/embl/schwab/crosshair/settings/SettingsReaderTest.java index b2cbdf0..9235ee3 100644 --- a/src/test/java/de/embl/schwab/crosshair/settings/SettingsReaderTest.java +++ b/src/test/java/de/embl/schwab/crosshair/settings/SettingsReaderTest.java @@ -44,11 +44,13 @@ void readSettings() { void readInvalidSettings( @TempDir Path tempDir ) { // Disable logging to keep the test logs clean (we're expecting an error here) Logger logger = (Logger) LoggerFactory.getLogger(SettingsReader.class); + Level loggerLevel = logger.getLevel(); logger.setLevel(Level.OFF); File invalidJsonPath = tempDir.resolve( "invalid.json" ).toFile(); Settings settings = settingsReader.readSettings( invalidJsonPath.getAbsolutePath() ); - assertNull( settings ); + + logger.setLevel(loggerLevel); } } \ No newline at end of file diff --git a/src/test/java/de/embl/schwab/crosshair/solution/SolutionReaderTest.java b/src/test/java/de/embl/schwab/crosshair/solution/SolutionReaderTest.java index 9264675..e38f4ab 100644 --- a/src/test/java/de/embl/schwab/crosshair/solution/SolutionReaderTest.java +++ b/src/test/java/de/embl/schwab/crosshair/solution/SolutionReaderTest.java @@ -41,11 +41,13 @@ void readSolution() { void readInvalidSolution( @TempDir Path tempDir ) { // Disable logging to keep the test logs clean (we're expecting an error here) Logger logger = (Logger) LoggerFactory.getLogger(SolutionReader.class); + Level loggerLevel = logger.getLevel(); logger.setLevel(Level.OFF); File invalidJsonPath = tempDir.resolve( "invalid.json" ).toFile(); Solution solution = solutionReader.readSolution( invalidJsonPath.getAbsolutePath() ); - assertNull( solution ); + + logger.setLevel(loggerLevel); } } \ No newline at end of file