3253-omnibus save
[jalview.git] / test / jalview / project / Jalview2xmlTests.java
index 9e2f7de..eef44de 100644 (file)
@@ -32,7 +32,7 @@ import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.api.FeatureColourI;
 import jalview.api.ViewStyleI;
-import jalview.bin.Instance;
+import jalview.bin.Jalview;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenSequences;
@@ -69,6 +69,7 @@ import jalview.schemes.RNAHelicesColour;
 import jalview.schemes.StrandColourScheme;
 import jalview.schemes.TCoffeeColourScheme;
 import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureMapping;
 import jalview.util.matcher.Condition;
 import jalview.viewmodel.AlignmentViewport;
 
@@ -91,6 +92,12 @@ import org.testng.annotations.Test;
 public class Jalview2xmlTests extends Jalview2xmlBase
 {
 
+  @BeforeClass(alwaysRun = true)
+  public void setUpJalviewSynchonization()
+  {
+    Jalview.setSynchronous(true);
+  }
+
   @Override
   @BeforeClass(alwaysRun = true)
   public void setUpJvOptionPane()
@@ -120,7 +127,6 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     assertTrue(af.isSaveAlignmentSuccessful(),
             "Failed to store as a project.");
     af.closeMenuItem_actionPerformed(true);
-    af = null;
     af = new FileLoader().LoadFileWaitTillLoaded(tfile,
             DataSourceType.FILE);
     assertNotNull(af, "Failed to import new project");
@@ -155,15 +161,13 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     assertNotNull(
             ColourSchemeProperty.getColourScheme(viewport,
                     viewport.getAlignment(),
-                    viewport.getGlobalColourScheme()
-                            .getSchemeName()),
+                    viewport.getGlobalColourScheme().getSchemeName()),
             "Recognise T-Coffee score from string");
 
     af.saveAlignment(tfile, FileFormat.Jalview);
     assertTrue(af.isSaveAlignmentSuccessful(),
             "Failed to store as a project.");
     af.closeMenuItem_actionPerformed(true);
-    af = null;
     af = new FileLoader().LoadFileWaitTillLoaded(tfile,
             DataSourceType.FILE);
     assertNotNull(af, "Failed to import new project");
@@ -295,10 +299,10 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     // count number of PDB mappings the structure selection manager holds -
     String pdbFile = af.getCurrentView().getStructureSelectionManager()
             .findFileForPDBId("1A70");
-    assertEquals(
-            af.getCurrentView().getStructureSelectionManager()
-                    .getMapping(pdbFile).length,
-            2, "Expected only two mappings for 1A70");
+    StructureMapping[] x = af.getCurrentView()
+            .getStructureSelectionManager()//
+            .getMapping(pdbFile);
+    assertEquals(x.length, 2, "Expected only two mappings for 1A70");
 
   }
 
@@ -406,8 +410,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" }, enabled = true)
   public void testStoreAndRecoverExpandedviews() throws Exception
   {
-    Instance.getDesktop().closeAll_actionPerformed(null);
-
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/exampleFile_2_7.jar", DataSourceType.FILE);
     Assert.assertEquals(Desktop.getAlignFrames().length, 1);
@@ -434,7 +437,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the expanded view state", e);
     }
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -445,9 +448,8 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     Assert.assertEquals(Desktop.getAlignFrames().length,
             Desktop.getAlignmentPanels(
                     af.getViewport().getSequenceSetId()).length);
-    Assert.assertEquals(
-            Desktop.getAlignmentPanels(
-                    af.getViewport().getSequenceSetId()).length,
+    Assert.assertEquals(Desktop
+            .getAlignmentPanels(af.getViewport().getSequenceSetId()).length,
             oldviews);
   }
 
@@ -460,7 +462,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverReferenceSeqSettings() throws Exception
   {
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/exampleFile_2_7.jar", DataSourceType.FILE);
     assertNotNull(af, "Didn't read in the example file correctly.");
@@ -499,7 +501,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the expanded view state", e);
     }
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -593,7 +595,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverGroupRepSeqs() throws Exception
   {
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/uniref50.fa", DataSourceType.FILE);
     assertNotNull(af, "Didn't read in the example file correctly.");
@@ -668,7 +670,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the expanded view state", e);
     }
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -713,7 +715,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverPDBEntry() throws Exception
   {
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     String exampleFile = "examples/3W5V.pdb";
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(exampleFile,
             DataSourceType.FILE);
@@ -762,7 +764,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the state", e);
     }
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -813,7 +815,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverColourThresholds() throws IOException
   {
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/uniref50.fa", DataSourceType.FILE);
 
@@ -873,7 +875,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
             ".jvp");
     tfile.deleteOnExit();
     new Jalview2XML(false).saveState(tfile);
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
             DataSourceType.FILE);
     Assert.assertNotNull(af, "Failed to reload project");
@@ -1082,9 +1084,9 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testMergeDatasetsforManyViews() throws IOException
   {
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
 
-    // complex project - one dataset, several views on several alignments
+    // complex project - one dataset, several views on several alignment
     AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
             "examples/testdata/projects/manyViews.jvp",
             DataSourceType.FILE);
@@ -1126,7 +1128,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = "Functional")
   public void testPcaViewAssociation() throws IOException
   {
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     final String PCAVIEWNAME = "With PCA";
     // create a new tempfile
     File tempfile = File.createTempFile("jvPCAviewAssoc", "jvp");
@@ -1160,10 +1162,10 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     }
 
     // load again.
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             tempfile.getCanonicalPath(), DataSourceType.FILE);
-    JInternalFrame[] frames = Instance.getDesktop().getAllFrames();
+    JInternalFrame[] frames = Desktop.getInstance().getAllFrames();
     // PCA and the tabbed alignment view should be the only two windows on the
     // desktop
     assertEquals(frames.length, 2,