JAL-4313 Clamp start and end ranges to array size
[jalview.git] / test / jalview / project / Jalview2xmlTests.java
index f0fbfc4..527a1a3 100644 (file)
@@ -33,6 +33,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import javax.swing.JInternalFrame;
@@ -66,6 +67,7 @@ import jalview.datamodel.features.FeatureMatcher;
 import jalview.datamodel.features.FeatureMatcherSet;
 import jalview.datamodel.features.FeatureMatcherSetI;
 import jalview.gui.AlignFrame;
+import jalview.gui.AlignViewport;
 import jalview.gui.AlignmentPanel;
 import jalview.gui.Desktop;
 import jalview.gui.JvOptionPane;
@@ -91,9 +93,8 @@ import jalview.util.MapList;
 import jalview.util.matcher.Condition;
 import jalview.viewmodel.AlignmentViewport;
 import jalview.viewmodel.seqfeatures.FeatureRendererModel;
-
+import jalview.ws.sifts.SiftsSettings;
 import junit.extensions.PA;
-
 @Test(singleThreaded = true)
 public class Jalview2xmlTests extends Jalview2xmlBase
 {
@@ -287,6 +288,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     assertEquals(Desktop.getAlignFrames().length,
             1 + origCount,
             "Didn't gather the views in the example file.");
+
   }
 
   /**
@@ -297,11 +299,21 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void noDuplicatePdbMappingsMade() throws Exception
   {
+    boolean oldmws = SiftsSettings.isMapWithSifts();
+    SiftsSettings.setMapWithSifts(false);
     StructureImportSettings.setProcessSecondaryStructure(true);
     StructureImportSettings.setVisibleChainAnnotation(true);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/exampleFile_2_7.jar", DataSourceType.FILE);
     assertNotNull(af, "Didn't read in the example file correctly.");
+    // TODO JAL-4107 - we need to wait a sec here whilst PDB mappings are
+    // instantiated on the alignment
+    // TODO JAL-4107 - should LoadFileWaitTillLoaded not return till *after* all
+    // that business is done ?
+    
+    try {
+      Thread.sleep(1000);
+    } catch (InterruptedException foo) {}
 
     // locate Jmol viewer
     // count number of PDB mappings the structure selection manager holds -
@@ -311,6 +323,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
             af.getCurrentView().getStructureSelectionManager()
                     .getMapping(pdbFile).length,
             2, "Expected only two mappings for 1A70");
+    SiftsSettings.setMapWithSifts(oldmws);
 
   }
 
@@ -812,6 +825,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
               "Mismatch PDBEntry 'Type'");
       Assert.assertNotNull(recov.getFile(),
               "Recovered PDBEntry should have a non-null file entry");
+      Assert.assertEquals(recov.getFile().toLowerCase(Locale.ENGLISH).lastIndexOf("pdb"),recov.getFile().length()-3, "Recovered PDBEntry file should have PDB suffix");
     }
   }