From 73e00bb837f941b45364d920ef0300bae95f91d0 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 11 Mar 2019 16:30:12 +0000 Subject: [PATCH] JAL-1270 JAL-2416 JAL-2839 set alwaysRun=true in test AfterMethod! --- src/jalview/analysis/scoremodels/ScoreModels.java | 20 +++++++++++++++++++- test/jalview/analysis/FinderTest.java | 2 +- test/jalview/io/ScoreMatrixFileTest.java | 7 +++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/jalview/analysis/scoremodels/ScoreModels.java b/src/jalview/analysis/scoremodels/ScoreModels.java index 3cbd5f1..ebc9a26 100644 --- a/src/jalview/analysis/scoremodels/ScoreModels.java +++ b/src/jalview/analysis/scoremodels/ScoreModels.java @@ -41,12 +41,22 @@ public class ScoreModels private final ScoreMatrix DNA; - private static ScoreModels instance = new ScoreModels(); + private static ScoreModels instance; private Map models; + /** + * Answers the singleton instance of this class, with lazy initialisation + * (built-in score models are loaded on the first call to this method) + * + * @return + */ public static ScoreModels getInstance() { + if (instance == null) + { + instance = new ScoreModels(); + } return instance; } @@ -139,6 +149,14 @@ public class ScoreModels } /** + * Resets to just the built-in score models + */ + public void reset() + { + instance = new ScoreModels(); + } + + /** * Returns the default peptide or nucleotide score model, currently BLOSUM62 * or DNA * diff --git a/test/jalview/analysis/FinderTest.java b/test/jalview/analysis/FinderTest.java index e2a94ef..5f64b28 100644 --- a/test/jalview/analysis/FinderTest.java +++ b/test/jalview/analysis/FinderTest.java @@ -79,7 +79,7 @@ public class FinderTest al = av.getAlignment(); } - @AfterMethod + @AfterMethod(alwaysRun = true) public void tearDownAfterTest() { av.setSelectionGroup(null); diff --git a/test/jalview/io/ScoreMatrixFileTest.java b/test/jalview/io/ScoreMatrixFileTest.java index 97349b5..254feaa 100644 --- a/test/jalview/io/ScoreMatrixFileTest.java +++ b/test/jalview/io/ScoreMatrixFileTest.java @@ -13,11 +13,18 @@ import jalview.analysis.scoremodels.ScoreModels; import java.io.IOException; import java.net.MalformedURLException; +import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; public class ScoreMatrixFileTest { + @AfterMethod(alwaysRun=true) + public void tearDownAfterTest() + { + ScoreModels.getInstance().reset(); + } + /** * Test a successful parse of a (small) score matrix file * -- 1.7.10.2