JAL-2154 catch and report a failures when xrefed project didn’t seem to have associat...
authorJim Procter <jprocter@issues.jalview.org>
Fri, 26 Aug 2016 12:22:56 +0000 (13:22 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Fri, 26 Aug 2016 12:22:56 +0000 (13:22 +0100)
test/jalview/io/CrossRef2xmlTests.java

index 65c0d2b..67626c8 100644 (file)
@@ -53,6 +53,8 @@ public class CrossRef2xmlTests extends Jalview2xmlBase
   public void testRetrieveAndShowCrossref() throws Exception
   {
     List<String> failedXrefMenuItems = new ArrayList<String>();
+    List<String> failedProjectRecoveries = new ArrayList<String>();
+
     // for every set of db queries
     // retrieve db query
     // verify presence of expected xrefs
@@ -175,6 +177,15 @@ public class CrossRef2xmlTests extends Jalview2xmlBase
               Desktop.instance.closeAll_actionPerformed(null);
               pass3 = 0;
               // recover stored project
+              File storedProject = savedProjects.get(nextxref);
+              if (storedProject == null)
+              {
+                failedProjectRecoveries.add("Failed to store a view for '"
+                        + nextxref + "'");
+                continue;
+              }
+
+              // recover stored project
               AlignFrame af2 = new FileLoader(false)
                       .LoadFileWaitTillLoaded(savedProjects.get(nextxref)
                               .toString(), FormatAdapter.FILE);
@@ -273,6 +284,14 @@ public class CrossRef2xmlTests extends Jalview2xmlBase
                   {
                     Desktop.instance.closeAll_actionPerformed(null);
                     // recover stored project
+                    File storedProject = savedProjects.get(nextnextxref);
+                    if (storedProject == null)
+                    {
+                      failedProjectRecoveries
+                              .add("Failed to store a view for '"
+                                      + nextnextxref + "'");
+                      continue;
+                    }
                     AlignFrame af2 = new FileLoader(false)
                             .LoadFileWaitTillLoaded(
                                     savedProjects.get(nextnextxref)
@@ -359,13 +378,22 @@ public class CrossRef2xmlTests extends Jalview2xmlBase
     }
     if (failedXrefMenuItems.size() > 0)
     {
-      StringBuilder sb = new StringBuilder();
       for (String s : failedXrefMenuItems)
       {
-        sb.append(s + "\n");
+        System.err.println(s);
       }
       Assert.fail("Faulty xref menu (" + failedXrefMenuItems.size()
-              + " counts)\n" + sb.toString());
+              + " counts)");
+    }
+    if (failedProjectRecoveries.size() > 0)
+    {
+
+      for (String s : failedProjectRecoveries)
+      {
+        System.err.println(s);
+      }
+      Assert.fail("Didn't recover projects for some retrievals (did they retrieve ?) ("
+              + failedProjectRecoveries.size() + " counts)");
     }
   }