Skip to content

Commit

Permalink
reset logging level
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Meech committed Jul 18, 2024
1 parent 9f1a200 commit f9f3635
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/test/java/de/embl/schwab/crosshair/CrosshairTest.java
Original file line number Diff line number Diff line change
@@ -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.*;
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, CustomMesh> currentStl = STLResourceLoader.loadSTL("invalid.stl");
assertNull(currentStl);

logger.setLevel(loggerLevel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit f9f3635

Please sign in to comment.