From: gmungoc Date: Mon, 11 Mar 2019 16:30:12 +0000 (+0000) Subject: JAL-1270 JAL-2416 JAL-2839 set alwaysRun=true in test AfterMethod! X-Git-Tag: Release_2_11_0~17^2~47^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=73e00bb837f941b45364d920ef0300bae95f91d0;p=jalview.git JAL-1270 JAL-2416 JAL-2839 set alwaysRun=true in test AfterMethod! --- 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 *