Merge branch 'features/JAL-2326_JOptionPane-refactoring' into develop
[jalview.git] / test / jalview / ws / jabaws / DisorderAnnotExportImport.java
index 58aa019..94a5fe0 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  */
 package jalview.ws.jabaws;
 
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
 
+import jalview.bin.Cache;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
+import jalview.gui.JvOptionPane;
 import jalview.io.AnnotationFile;
 import jalview.io.FormatAdapter;
 import jalview.io.StockholmFileTest;
@@ -34,12 +34,25 @@ import jalview.ws.jws2.AADisorderClient;
 import jalview.ws.jws2.Jws2Discoverer;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
 
+@Test(groups = { "External" })
 public class DisorderAnnotExportImport
 {
+
+  @BeforeClass(alwaysRun = true)
+  public void setUpJvOptionPane()
+  {
+    JvOptionPane.setInteractiveMode(false);
+    JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+  }
+
   public static String testseqs = "examples/uniref50.fa";
 
   public static Jws2Discoverer disc;
@@ -50,11 +63,11 @@ public class DisorderAnnotExportImport
 
   public static jalview.gui.AlignFrame af = null;
 
-  @BeforeClass
+  @BeforeClass(inheritGroups = true)
   public static void setUpBeforeClass() throws Exception
   {
-
-    jalview.bin.Cache.initLogger();
+    Cache.loadProperties("test/jalview/io/testProps.jvprops");
+    Cache.initLogger();
     disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
     iupreds = new ArrayList<Jws2Instance>();
     for (Jws2Instance svc : disc.getServices())
@@ -71,13 +84,14 @@ public class DisorderAnnotExportImport
     assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
   }
 
-  @AfterClass
+  @AfterClass(alwaysRun = true)
   public static void tearDownAfterClass() throws Exception
   {
     if (af != null)
     {
       af.setVisible(false);
       af.dispose();
+      af = null;
     }
   }
 
@@ -100,32 +114,32 @@ public class DisorderAnnotExportImport
       ;
     } while (af.getViewport().getCalcManager().isWorking());
     AlignmentI orig_alig = af.getViewport().getAlignment();
-    // NOTE: Consensus annotation row cannot be exported and reimported faithfully - so we remove them
+    // NOTE: Consensus annotation row cannot be exported and reimported
+    // faithfully - so we remove them
     List<AlignmentAnnotation> toremove = new ArrayList<AlignmentAnnotation>();
-    for (AlignmentAnnotation aa:orig_alig.getAlignmentAnnotation())
+    for (AlignmentAnnotation aa : orig_alig.getAlignmentAnnotation())
     {
       if (aa.autoCalculated)
       {
         toremove.add(aa);
       }
     }
-    for (AlignmentAnnotation aa:toremove)
+    for (AlignmentAnnotation aa : toremove)
     {
       orig_alig.deleteAnnotation(aa);
     }
-    testAnnotationFileIO("Testing IUPred Annotation IO", orig_alig);
+    checkAnnotationFileIO("Testing IUPred Annotation IO", orig_alig);
 
   }
 
-  public static void testAnnotationFileIO(String testname, AlignmentI al)
+  static void checkAnnotationFileIO(String testname, AlignmentI al)
   {
     try
     {
       String aligfileout = new FormatAdapter().formatSequences("PFAM",
               al.getSequencesArray());
-      String anfileout = new AnnotationFile().printAnnotations(
-              al.getAlignmentAnnotation(), al.getGroups(),
-              al.getProperties());
+      String anfileout = new AnnotationFile()
+              .printAnnotationsForAlignment(al);
       assertTrue(
               "Test "
                       + testname
@@ -150,13 +164,13 @@ public class DisorderAnnotExportImport
                       FormatAdapter.PASTE));
 
       // test for consistency in io
-      StockholmFileTest.testAlignmentEquivalence(al, al_new);
+      StockholmFileTest.testAlignmentEquivalence(al, al_new, true);
       return;
     } catch (Exception e)
     {
       e.printStackTrace();
     }
-    fail("Test "
+    Assert.fail("Test "
             + testname
             + "\nCouldn't complete Annotation file roundtrip input/output/input test.");
   }