JAL-4107 fix test compilation issues
[jalview.git] / test / jalview / ws / jabaws / DisorderAnnotExportImport.java
index 025c913..4602e93 100644 (file)
  */
 package jalview.ws.jabaws;
 
+import java.util.Locale;
 import static org.testng.AssertJUnit.assertNotNull;
 import static org.testng.AssertJUnit.assertTrue;
 
 import jalview.bin.Cache;
+import jalview.bin.Console;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.gui.JvOptionPane;
@@ -35,6 +37,7 @@ import jalview.io.StockholmFileTest;
 import jalview.ws.api.ServiceWithParameters;
 import jalview.ws.jws2.Jws2Discoverer;
 import jalview.ws.jws2.SeqAnnotationServiceCalcWorker;
+import jalview.ws.slivkaws.SlivkaWSDiscoverer;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -42,6 +45,7 @@ import java.util.List;
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 /*
@@ -73,7 +77,7 @@ public class DisorderAnnotExportImport
   public static void setUpBeforeClass() throws Exception
   {
     Cache.loadProperties("test/jalview/io/testProps.jvprops");
-    Cache.initLogger();
+    Console.initLogger();
     disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
 
     while (disc.isRunning())
@@ -82,10 +86,16 @@ public class DisorderAnnotExportImport
       Thread.sleep(100);
     }
 
+    SlivkaWSDiscoverer disc2 = SlivkaWSDiscoverer.getInstance();
+    disc2.startDiscoverer();
+    while (disc2.isRunning())
+    {
+      Thread.sleep(100);
+    }
     iupreds = new ArrayList<>();
-    for (ServiceWithParameters svc : disc.getServices())
+    for (ServiceWithParameters svc : disc2.getServices())
     {
-      if (svc.getNameURI().toLowerCase().contains("iupredws"))
+      if (svc.getNameURI().toLowerCase().contains("iupred"))
       {
         iupreds.add(svc);
       }
@@ -93,7 +103,8 @@ public class DisorderAnnotExportImport
     assertTrue("Couldn't discover any IUPred services to use to test.",
             iupreds.size() > 0);
     jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
-    af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.DataSourceType.FILE);
+    af = fl.LoadFileWaitTillLoaded(testseqs,
+            jalview.io.DataSourceType.FILE);
     assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
   }
 
@@ -107,14 +118,28 @@ public class DisorderAnnotExportImport
       af = null;
     }
   }
+  
+  @DataProvider(name="getIuPreds",parallel = false)
+  public static ServiceWithParameters[][] getIuPreds()
+  {
+    ServiceWithParameters[][] services = new ServiceWithParameters[iupreds
+            .size()][1];
+
+    int i = 0;
+    for (ServiceWithParameters iupred : iupreds)
+    {
+      services[i++][0] = iupred;
+    }
+    return services;
+  }
 
   /**
    * test for patches to JAL-1294
    */
-  @Test(groups = { "External", "Network" })
-  public void testDisorderAnnotExport()
+  @Test(groups = { "External", "Network" },dataProvider = "getIuPreds")
+  public void testDisorderAnnotExport(ServiceWithParameters iuPred)
   {
-    disorderClient = new SeqAnnotationServiceCalcWorker(iupreds.get(0), af, null,
+    disorderClient = new SeqAnnotationServiceCalcWorker(iuPred, af, null,
             null);
     af.getViewport().getCalcManager().startWorker(disorderClient);
     do
@@ -150,30 +175,24 @@ public class DisorderAnnotExportImport
   {
     try
     {
-      String aligfileout = FileFormat.Pfam.getWriter(al).print(
-              al.getSequencesArray(), true);
+      String aligfileout = FileFormat.Pfam.getWriter(al)
+              .print(al.getSequencesArray(), true);
       String anfileout = new AnnotationFile()
               .printAnnotationsForAlignment(al);
-      assertTrue(
-              "Test "
-                      + testname
-                      + "\nAlignment annotation file was not regenerated. Null string",
+      assertTrue("Test " + testname
+              + "\nAlignment annotation file was not regenerated. Null string",
               anfileout != null);
-      assertTrue(
-              "Test "
-                      + testname
-                      + "\nAlignment annotation file was not regenerated. Empty string",
+      assertTrue("Test " + testname
+              + "\nAlignment annotation file was not regenerated. Empty string",
               anfileout.length() > "JALVIEW_ANNOTATION".length());
 
-      System.out.println("Output annotation file:\n" + anfileout
-              + "\n<<EOF\n");
+      System.out.println(
+              "Output annotation file:\n" + anfileout + "\n<<EOF\n");
 
       AlignmentI al_new = new FormatAdapter().readFile(aligfileout,
               DataSourceType.PASTE, FileFormat.Pfam);
-      assertTrue(
-              "Test "
-                      + testname
-                      + "\nregenerated annotation file did not annotate alignment.",
+      assertTrue("Test " + testname
+              + "\nregenerated annotation file did not annotate alignment.",
               new AnnotationFile().readAnnotationFile(al_new, anfileout,
                       DataSourceType.PASTE));
 
@@ -185,8 +204,7 @@ public class DisorderAnnotExportImport
     {
       e.printStackTrace();
     }
-    Assert.fail("Test "
-            + testname
+    Assert.fail("Test " + testname
             + "\nCouldn't complete Annotation file roundtrip input/output/input test.");
   }