Merge branch 'develop' into bug/JAL-2255_seq-fetcher-broken-on-linux
[jalview.git] / test / jalview / io / IdentifyFileTest.java
index c00cf06..3d800d8 100644 (file)
  */
 package jalview.io;
 
-import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertSame;
 import static org.testng.AssertJUnit.assertTrue;
 
+import jalview.gui.JvOptionPane;
+
 import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 public class IdentifyFileTest
 {
 
+  @BeforeClass(alwaysRun = true)
+  public void setUpJvOptionPane()
+  {
+    JvOptionPane.setInteractiveMode(false);
+    JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+  }
+
   @Test(groups = { "Functional" }, dataProvider = "identifyFiles")
-  public void testIdentify(String data, String expectedFileType)
+  public void testIdentify(String data, FileFormatI expectedFileType)
+          throws FileFormatException
   {
-    String protocol = AppletFormatAdapter.FILE;
+    DataSourceType protocol = DataSourceType.FILE;
     IdentifyFile ider = new IdentifyFile();
-    String actualFiletype = ider.identify(data, protocol);
-    Assert.assertEquals(actualFiletype, expectedFileType,
+    FileFormatI actualFiletype = ider.identify(data, protocol);
+    Assert.assertSame(actualFiletype, expectedFileType,
             "File identification Failed!");
   }
 
   /**
    * Additional tests for Jalview features file
+   * 
+   * @throws FileFormatException
    */
   @Test(groups = "Functional")
-  public void testIdentify_featureFile()
+  public void testIdentify_featureFile() throws FileFormatException
   {
     IdentifyFile ider = new IdentifyFile();
 
@@ -54,49 +67,49 @@ public class IdentifyFileTest
      */
     String data = "Iron-sulfur (2Fe-2S)\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
             + "Iron-phosphorus (2Fe-P)\tID_NOT_SPECIFIED\t2\t86\t87\tMETALLIC\n";
-    assertEquals(IdentifyFile.FeaturesFile,
-            ider.identify(data, AppletFormatAdapter.PASTE));
+    assertSame(FileFormat.Features,
+            ider.identify(data, DataSourceType.PASTE));
 
     /*
      * Jalview feature colour followed by GFF format feature data
      */
     data = "METAL\tcc9900\n" + "GFF\n"
             + "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\n";
-    assertEquals(IdentifyFile.FeaturesFile,
-            ider.identify(data, AppletFormatAdapter.PASTE));
+    assertSame(FileFormat.Features,
+            ider.identify(data, DataSourceType.PASTE));
 
     /*
      * Feature with '<' in the name (JAL-2098)
      */
     data = "kD < 3\tred\n" + "Low kD\tFER_CAPAA\t-1\t39\t39\tkD < 3\n";
-    assertEquals(IdentifyFile.FeaturesFile,
-            ider.identify(data, AppletFormatAdapter.PASTE));
+    assertSame(FileFormat.Features,
+            ider.identify(data, DataSourceType.PASTE));
   }
 
   @DataProvider(name = "identifyFiles")
   public Object[][] IdentifyFileDP()
   {
     return new Object[][] {
-        { "examples/example.json", "JSON" },
-        { "examples/plantfdx.fa", "FASTA" },
-        { "examples/dna_interleaved.phy", "PHYLIP" },
-        { "examples/2GIS.pdb", "PDB" },
-        { "examples/rf00031_folded.stk", "STH" },
-        { "examples/testdata/test.rnaml", "RNAML" },
-        { "examples/testdata/test.aln", "CLUSTAL" },
-        { "examples/testdata/test.pfam", "PFAM" },
-        { "examples/testdata/test.msf", "MSF" },
-        { "examples/testdata/test.pir", "PIR" },
-        { "examples/testdata/test.html", "HTML" },
-        { "examples/testdata/test.pileup", "PileUp" },
-        { "examples/testdata/test.blc", "BLC" },
-        { "examples/exampleFeatures.txt", IdentifyFile.FeaturesFile },
-        { "examples/testdata/simpleGff3.gff", IdentifyFile.FeaturesFile },
-        { "examples/testdata/test.jvp", "Jalview" },
-        { "examples/testdata/test.cif", "mmCIF" },
+        { "examples/example.json", FileFormat.Json },
+        { "examples/plantfdx.fa", FileFormat.Fasta },
+        { "examples/dna_interleaved.phy", FileFormat.Phylip },
+        { "examples/2GIS.pdb", FileFormat.PDB },
+        { "examples/rf00031_folded.stk", FileFormat.Stockholm },
+        { "examples/testdata/test.rnaml", FileFormat.Rnaml },
+        { "examples/testdata/test.aln", FileFormat.Clustal },
+        { "examples/testdata/test.pfam", FileFormat.Pfam },
+        { "examples/testdata/test.msf", FileFormat.MSF },
+        { "examples/testdata/test.pir", FileFormat.PIR },
+        { "examples/testdata/test.html", FileFormat.Html },
+        { "examples/testdata/test.pileup", FileFormat.Pileup },
+        { "examples/testdata/test.blc", FileFormat.BLC },
+        { "examples/exampleFeatures.txt", FileFormat.Features },
+        { "examples/testdata/simpleGff3.gff", FileFormat.Features },
+        { "examples/testdata/test.jvp", FileFormat.Jalview },
+        { "examples/testdata/test.cif", FileFormat.MMCif },
         {
             "examples/testdata/cullpdb_pc25_res3.0_R0.3_d150729_chains9361.fasta.15316",
-            "FASTA" },
+            FileFormat.Fasta },
 
     // { "examples/testdata/test.amsa", "AMSA" },
     // { "examples/test.jnet", "JnetFile" },