Merge branch 'features/JAL-2326_JOptionPane-refactoring' into develop
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Mon, 28 Nov 2016 16:02:32 +0000 (16:02 +0000)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Mon, 28 Nov 2016 16:02:32 +0000 (16:02 +0000)
12 files changed:
1  2 
test/jalview/analysis/ConservationTest.java
test/jalview/analysis/FinderTest.java
test/jalview/analysis/scoremodels/FeatureScoreModelTest.java
test/jalview/controller/AlignViewControllerTest.java
test/jalview/datamodel/ResidueCountTest.java
test/jalview/datamodel/SequenceFeatureTest.java
test/jalview/ext/android/SparseIntArrayTest.java
test/jalview/ext/android/SparseShortArrayTest.java
test/jalview/schemes/ResidueColourSchemeTest.java
test/jalview/util/FormatTest.java
test/jalview/util/PlatformTest.java
test/jalview/util/SparseCountTest.java

@@@ -1,23 -1,3 +1,23 @@@
 +/*
 + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
 + * Copyright (C) $$Year-Rel$$ The Jalview Authors
 + * 
 + * This file is part of Jalview.
 + * 
 + * Jalview is free software: you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License 
 + * as published by the Free Software Foundation, either version 3
 + * of the License, or (at your option) any later version.
 + *  
 + * Jalview is distributed in the hope that it will be useful, but 
 + * WITHOUT ANY WARRANTY; without even the implied warranty 
 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 + * PURPOSE.  See the GNU General Public License for more details.
 + * 
 + * You should have received a copy of the GNU General Public License
 + * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
 + * The Jalview Authors are detailed in the 'AUTHORS' file.
 + */
  package jalview.analysis;
  
  import static org.testng.Assert.assertEquals;
@@@ -25,16 -5,26 +25,26 @@@ import static org.testng.Assert.assertT
  
  import jalview.datamodel.Sequence;
  import jalview.datamodel.SequenceI;
+ import jalview.gui.JvOptionPane;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
+ import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  
  public class ConservationTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    @Test(groups = "Functional")
    public void testRecordConservation()
    {
@@@ -1,23 -1,3 +1,23 @@@
 +/*
 + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
 + * Copyright (C) $$Year-Rel$$ The Jalview Authors
 + * 
 + * This file is part of Jalview.
 + * 
 + * Jalview is free software: you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License 
 + * as published by the Free Software Foundation, either version 3
 + * of the License, or (at your option) any later version.
 + *  
 + * Jalview is distributed in the hope that it will be useful, but 
 + * WITHOUT ANY WARRANTY; without even the implied warranty 
 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 + * PURPOSE.  See the GNU General Public License for more details.
 + * 
 + * You should have received a copy of the GNU General Public License
 + * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
 + * The Jalview Authors are detailed in the 'AUTHORS' file.
 + */
  package jalview.analysis;
  
  import static org.testng.Assert.assertEquals;
@@@ -30,6 -10,7 +30,7 @@@ import jalview.datamodel.SearchResultMa
  import jalview.datamodel.SearchResultsI;
  import jalview.datamodel.Sequence;
  import jalview.gui.AlignFrame;
+ import jalview.gui.JvOptionPane;
  import jalview.io.FileLoader;
  import jalview.io.FormatAdapter;
  
@@@ -40,6 -21,13 +41,13 @@@ import org.testng.annotations.Test
  
  public class FinderTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    private AlignFrame af;
  
    private AlignmentI al;
@@@ -24,16 -24,24 +24,26 @@@ import jalview.datamodel.AlignmentI
  import jalview.datamodel.SequenceFeature;
  import jalview.datamodel.SequenceI;
  import jalview.gui.AlignFrame;
+ import jalview.gui.JvOptionPane;
  import jalview.io.FileLoader;
  import jalview.io.FormatAdapter;
  
 +import java.util.Arrays;
 +
  import org.testng.Assert;
+ import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  
  public class FeatureScoreModelTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    public static String alntestFile = "FER1_MESCR/72-76 DVYIL\nFER1_SPIOL/71-75 DVYIL\nFER3_RAPSA/21-25 DVYVL\nFER1_MAIZE/73-77 DVYIL\n";
  
    int[] sf1 = new int[] { 74, 74, 73, 73, 23, 23, -1, -1 };
                + "(" + s + ") should still be distinct from FER1_MAIZE (3)");
      }
    }
 +
 +  /**
 +   * Check findFeatureAt doesn't return contact features except at contact
 +   * points TODO:move to under the FeatureRendererModel test suite
 +   */
 +  @Test(groups = { "Functional" })
 +  public void testFindFeatureAt_PointFeature() throws Exception
 +  {
 +    String alignment = "a CCCCCCGGGGGGCCCCCC\n" + "b CCCCCCGGGGGGCCCCCC\n"
 +            + "c CCCCCCGGGGGGCCCCCC\n";
 +    AlignFrame af = new jalview.io.FileLoader(false)
 +            .LoadFileWaitTillLoaded(alignment, FormatAdapter.PASTE);
 +    SequenceI aseq = af.getViewport().getAlignment().getSequenceAt(0);
 +    SequenceFeature sf = null;
 +    sf = new SequenceFeature("disulphide bond", "", 2, 5, Float.NaN, "");
 +    aseq.addSequenceFeature(sf);
 +    Assert.assertTrue(sf.isContactFeature());
 +    af.refreshFeatureUI(true);
 +    af.getFeatureRenderer().setAllVisible(Arrays.asList("disulphide bond"));
 +    Assert.assertEquals(af.getFeatureRenderer().getDisplayedFeatureTypes()
 +            .size(), 1, "Should be just one feature type displayed");
 +    // step through and check for pointwise feature presence/absence
 +    Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 1)
 +            .size(), 0);
 +    // step through and check for pointwise feature presence/absence
 +    Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 2)
 +            .size(), 1);
 +    // step through and check for pointwise feature presence/absence
 +    Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 3)
 +            .size(), 0);
 +    // step through and check for pointwise feature presence/absence
 +    Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 4)
 +            .size(), 0);
 +    // step through and check for pointwise feature presence/absence
 +    Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 5)
 +            .size(), 1);
 +    // step through and check for pointwise feature presence/absence
 +    Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 6)
 +            .size(), 0);
 +  }
 +
  }
@@@ -32,23 -32,33 +32,33 @@@ import jalview.datamodel.SequenceFeatur
  import jalview.datamodel.SequenceGroup;
  import jalview.datamodel.SequenceI;
  import jalview.gui.AlignFrame;
+ import jalview.gui.JvOptionPane;
  import jalview.io.FileLoader;
  import jalview.io.FormatAdapter;
  
  import java.util.Arrays;
  import java.util.BitSet;
  
+ import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  
  public class AlignViewControllerTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    @Test(groups = "Functional")
    public void testFindColumnsWithFeature()
    {
 -    SequenceI seq1 = new Sequence("seq1", "aMMMaaaaaaaaaaaaaaaa");
 -    SequenceI seq2 = new Sequence("seq2", "aaaMMMMMMMaaaaaaaaaa");
 -    SequenceI seq3 = new Sequence("seq3", "aaaaaaaaaaMMMMMaaaaa");
 -    SequenceI seq4 = new Sequence("seq3", "aaaaaaaaaaaaaaaaaaaa");
 +    SequenceI seq1 = new Sequence("seq1", "-a-MMMaaaaaaaaaaaaaaaa");
 +    SequenceI seq2 = new Sequence("seq2", "aa--aMM-MMMMMaaaaaaaaaa");
 +    SequenceI seq3 = new Sequence("seq3", "abcab-caD-aaMMMMMaaaaa");
 +    SequenceI seq4 = new Sequence("seq4", "abc--abcaaaaaaaaaaaaaa");
  
      /*
       * features start/end are base 1
              null));
      seq3.addSequenceFeature(new SequenceFeature("Metal", "desc", 11, 15,
              0f, null));
 +    // disulfide bond is a 'contact feature' - only select its 'start' and 'end'
 +    seq3.addSequenceFeature(new SequenceFeature("disulfide bond", "desc", 8, 12,
 +            0f, null));
  
      /*
 -     * select the first three columns --> Metal in seq1 2-3
 +     * select the first five columns --> Metal in seq1 cols 4-5
       */
      SequenceGroup sg = new SequenceGroup();
      sg.setStartRes(0); // base 0
 -    sg.setEndRes(2);
 +    sg.setEndRes(4);
      sg.addSequence(seq1, false);
      sg.addSequence(seq2, false);
      sg.addSequence(seq3, false);
              bs);
      assertEquals(1, seqCount);
      assertEquals(2, bs.cardinality());
 -    assertTrue(bs.get(1));
 -    assertTrue(bs.get(2));
 +    assertTrue(bs.get(3)); // base 0
 +    assertTrue(bs.get(4));
  
      /*
 -     * select the first four columns: Metal in seq1 2:4, seq2 4:4
 +     * select the first seven columns: Metal in seq1 cols 4-6, seq2 cols 6-7 
       */
 -    sg.setEndRes(3);
 +    sg.setEndRes(6);
      bs.clear();
      seqCount = AlignViewController.findColumnsWithFeature("Metal", sg, bs);
      assertEquals(2, seqCount);
 -    assertEquals(3, bs.cardinality());
 -    assertTrue(bs.get(1));
 -    assertTrue(bs.get(2));
 +    assertEquals(4, bs.cardinality());
      assertTrue(bs.get(3));
 +    assertTrue(bs.get(4));
 +    assertTrue(bs.get(5));
 +    assertTrue(bs.get(6));
  
      /*
 -     * select column 11: Metal in seq3 only
 +     * select column 14: Metal in seq3 only
       */
 -    sg.setStartRes(10);
 -    sg.setEndRes(10);
 +    sg.setStartRes(13);
 +    sg.setEndRes(13);
      bs.clear();
      seqCount = AlignViewController.findColumnsWithFeature("Metal", sg, bs);
      assertEquals(1, seqCount);
      assertEquals(1, bs.cardinality());
 -    assertTrue(bs.get(10));
 +    assertTrue(bs.get(13));
  
      /*
 -     * select columns 16-20: no Metal feature
 +     * select columns 18-20: no Metal feature
       */
 -    sg.setStartRes(15);
 +    sg.setStartRes(17);
      sg.setEndRes(19);
      bs.clear();
      seqCount = AlignViewController.findColumnsWithFeature("Metal", sg, bs);
      assertEquals(0, bs.cardinality());
  
      /*
 +     * columns 11-13 should not match disulfide bond at 8/12
 +     */
 +    sg.setStartRes(10);
 +    sg.setEndRes(12);
 +    bs.clear();
 +    seqCount = AlignViewController.findColumnsWithFeature("disulfide bond",
 +            sg, bs);
 +    assertEquals(0, seqCount);
 +    assertEquals(0, bs.cardinality());
 +
 +    /*
 +     * columns 6-18 should match disulfide bond at columns 9, 14
 +     */
 +    sg.setStartRes(5);
 +    sg.setEndRes(17);
 +    bs.clear();
 +    seqCount = AlignViewController.findColumnsWithFeature("disulfide bond",
 +            sg, bs);
 +    assertEquals(1, seqCount);
 +    assertEquals(2, bs.cardinality());
 +    assertTrue(bs.get(8));
 +    assertTrue(bs.get(13));
 +
 +    /*
       * look for a feature that isn't there
       */
      sg.setStartRes(0);
@@@ -1,23 -1,3 +1,23 @@@
 +/*
 + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
 + * Copyright (C) $$Year-Rel$$ The Jalview Authors
 + * 
 + * This file is part of Jalview.
 + * 
 + * Jalview is free software: you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License 
 + * as published by the Free Software Foundation, either version 3
 + * of the License, or (at your option) any later version.
 + *  
 + * Jalview is distributed in the hope that it will be useful, but 
 + * WITHOUT ANY WARRANTY; without even the implied warranty 
 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 + * PURPOSE.  See the GNU General Public License for more details.
 + * 
 + * You should have received a copy of the GNU General Public License
 + * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
 + * The Jalview Authors are detailed in the 'AUTHORS' file.
 + */
  package jalview.datamodel;
  
  import static org.testng.Assert.assertEquals;
@@@ -25,12 -5,22 +25,22 @@@ import static org.testng.Assert.assertF
  import static org.testng.Assert.assertTrue;
  
  import jalview.datamodel.ResidueCount.SymbolCounts;
+ import jalview.gui.JvOptionPane;
  
  import org.junit.Assert;
+ import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  
  public class ResidueCountTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    /**
     * Test a mix of add and put for nucleotide counting
     */
@@@ -26,10 -26,21 +26,21 @@@ import static org.testng.AssertJUnit.as
  import static org.testng.AssertJUnit.assertSame;
  import static org.testng.AssertJUnit.assertTrue;
  
+ import jalview.gui.JvOptionPane;
+ import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  
  public class SequenceFeatureTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    @Test(groups = { "Functional" })
    public void testCopyConstructor()
    {
      sf1.setStatus("new");
      assertTrue(sf1.equals(sf2));
    }
 +
 +  @Test(groups = { "Functional" })
 +  public void testIsContactFeature()
 +  {
 +    SequenceFeature sf = new SequenceFeature("type", "desc", 22, 33, 12.5f,
 +            "group");
 +    assertFalse(sf.isContactFeature());
 +    sf.setType("");
 +    assertFalse(sf.isContactFeature());
 +    sf.setType(null);
 +    assertFalse(sf.isContactFeature());
 +    sf.setType("Disulfide Bond");
 +    assertTrue(sf.isContactFeature());
 +    sf.setType("disulfide bond");
 +    assertTrue(sf.isContactFeature());
 +    sf.setType("Disulphide Bond");
 +    assertTrue(sf.isContactFeature());
 +    sf.setType("disulphide bond");
 +    assertTrue(sf.isContactFeature());
 +  }
  }
@@@ -1,28 -1,11 +1,31 @@@
 +/*
 + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
 + * Copyright (C) $$Year-Rel$$ The Jalview Authors
 + * 
 + * This file is part of Jalview.
 + * 
 + * Jalview is free software: you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License 
 + * as published by the Free Software Foundation, either version 3
 + * of the License, or (at your option) any later version.
 + *  
 + * Jalview is distributed in the hope that it will be useful, but 
 + * WITHOUT ANY WARRANTY; without even the implied warranty 
 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 + * PURPOSE.  See the GNU General Public License for more details.
 + * 
 + * You should have received a copy of the GNU General Public License
 + * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
 + * The Jalview Authors are detailed in the 'AUTHORS' file.
 + */
  package jalview.ext.android;
  
  import static org.testng.Assert.assertEquals;
  import static org.testng.Assert.fail;
  
+ import jalview.gui.JvOptionPane;
+ import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  
  /*
   */
  public class SparseIntArrayTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    @Test(groups = "Functional")
    public void testPut()
    {
@@@ -1,32 -1,23 +1,43 @@@
 +/*
 + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
 + * Copyright (C) $$Year-Rel$$ The Jalview Authors
 + * 
 + * This file is part of Jalview.
 + * 
 + * Jalview is free software: you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License 
 + * as published by the Free Software Foundation, either version 3
 + * of the License, or (at your option) any later version.
 + *  
 + * Jalview is distributed in the hope that it will be useful, but 
 + * WITHOUT ANY WARRANTY; without even the implied warranty 
 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 + * PURPOSE.  See the GNU General Public License for more details.
 + * 
 + * You should have received a copy of the GNU General Public License
 + * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
 + * The Jalview Authors are detailed in the 'AUTHORS' file.
 + */
  package jalview.ext.android;
  
  import static org.testng.Assert.assertEquals;
  import static org.testng.Assert.fail;
  
+ import jalview.gui.JvOptionPane;
+ import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  
  public class SparseShortArrayTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    @Test(groups = "Functional")
    public void testPut()
    {
@@@ -1,23 -1,3 +1,23 @@@
 +/*
 + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
 + * Copyright (C) $$Year-Rel$$ The Jalview Authors
 + * 
 + * This file is part of Jalview.
 + * 
 + * Jalview is free software: you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License 
 + * as published by the Free Software Foundation, either version 3
 + * of the License, or (at your option) any later version.
 + *  
 + * Jalview is distributed in the hope that it will be useful, but 
 + * WITHOUT ANY WARRANTY; without even the implied warranty 
 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 + * PURPOSE.  See the GNU General Public License for more details.
 + * 
 + * You should have received a copy of the GNU General Public License
 + * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
 + * The Jalview Authors are detailed in the 'AUTHORS' file.
 + */
  package jalview.schemes;
  
  import static org.testng.AssertJUnit.assertEquals;
@@@ -27,13 -7,23 +27,23 @@@ import static org.testng.AssertJUnit.as
  import jalview.datamodel.Profile;
  import jalview.datamodel.ProfileI;
  import jalview.datamodel.Profiles;
+ import jalview.gui.JvOptionPane;
  
  import java.awt.Color;
  
+ import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  
  public class ResidueColourSchemeTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    @Test(groups = "Functional")
    public void testAboveThreshold()
    {
@@@ -1,31 -1,22 +1,42 @@@
 +/*
 + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
 + * Copyright (C) $$Year-Rel$$ The Jalview Authors
 + * 
 + * This file is part of Jalview.
 + * 
 + * Jalview is free software: you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License 
 + * as published by the Free Software Foundation, either version 3
 + * of the License, or (at your option) any later version.
 + *  
 + * Jalview is distributed in the hope that it will be useful, but 
 + * WITHOUT ANY WARRANTY; without even the implied warranty 
 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 + * PURPOSE.  See the GNU General Public License for more details.
 + * 
 + * You should have received a copy of the GNU General Public License
 + * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
 + * The Jalview Authors are detailed in the 'AUTHORS' file.
 + */
  package jalview.util;
  
  import static org.testng.Assert.assertEquals;
  
+ import jalview.gui.JvOptionPane;
+ import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  
  public class FormatTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    @Test(groups = "Functional")
    public void testAppendPercentage()
    {
@@@ -1,36 -1,27 +1,47 @@@
 +/*
 + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
 + * Copyright (C) $$Year-Rel$$ The Jalview Authors
 + * 
 + * This file is part of Jalview.
 + * 
 + * Jalview is free software: you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License 
 + * as published by the Free Software Foundation, either version 3
 + * of the License, or (at your option) any later version.
 + *  
 + * Jalview is distributed in the hope that it will be useful, but 
 + * WITHOUT ANY WARRANTY; without even the implied warranty 
 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 + * PURPOSE.  See the GNU General Public License for more details.
 + * 
 + * You should have received a copy of the GNU General Public License
 + * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
 + * The Jalview Authors are detailed in the 'AUTHORS' file.
 + */
  package jalview.util;
  
  import static org.testng.Assert.assertFalse;
  import static org.testng.Assert.assertTrue;
  
+ import jalview.gui.JvOptionPane;
  import java.awt.Button;
  import java.awt.Event;
  import java.awt.event.MouseEvent;
  
+ import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  
  public class PlatformTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    Button b = new Button();
  
    /**
@@@ -1,32 -1,23 +1,43 @@@
 +/*
 + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
 + * Copyright (C) $$Year-Rel$$ The Jalview Authors
 + * 
 + * This file is part of Jalview.
 + * 
 + * Jalview is free software: you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License 
 + * as published by the Free Software Foundation, either version 3
 + * of the License, or (at your option) any later version.
 + *  
 + * Jalview is distributed in the hope that it will be useful, but 
 + * WITHOUT ANY WARRANTY; without even the implied warranty 
 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 + * PURPOSE.  See the GNU General Public License for more details.
 + * 
 + * You should have received a copy of the GNU General Public License
 + * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
 + * The Jalview Authors are detailed in the 'AUTHORS' file.
 + */
  package jalview.util;
  
  import static org.testng.Assert.assertEquals;
  import static org.testng.Assert.assertFalse;
  import static org.testng.Assert.assertTrue;
  
+ import jalview.gui.JvOptionPane;
+ import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  public class SparseCountTest
  {
+   @BeforeClass(alwaysRun = true)
+   public void setUpJvOptionPane()
+   {
+     JvOptionPane.setInteractiveMode(false);
+     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+   }
    @Test(groups = "Functional")
    public void testAdd()
    {