JAL-4217 - try to invokeAndWait on Desktop.closeAll() to avoid Jmol redraw blocking... reviews/merge/JAL-4262+JAL-4265+JAL-4269+JAL-4274+JAL-4277+JAL-4285
authorJames Procter <j.procter@dundee.ac.uk>
Wed, 20 Sep 2023 14:14:05 +0000 (15:14 +0100)
committerJames Procter <j.procter@dundee.ac.uk>
Wed, 20 Sep 2023 14:14:05 +0000 (15:14 +0100)
test/jalview/bin/CommandsTest.java

index 4d10c31..8dae8f3 100644 (file)
@@ -2,11 +2,14 @@ package jalview.bin;
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.nio.file.Files;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.swing.SwingUtilities;
+
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterMethod;
@@ -46,9 +49,26 @@ public class CommandsTest
   }
 
   @AfterMethod(alwaysRun = true)
-  public void tearDown()
+  public void tearDown() 
   {
-    Desktop.closeDesktop();
+    try
+    {
+      // occasionally we are blocked by Jmol redraws
+      SwingUtilities.invokeAndWait(new Runnable()
+      {
+
+        @Override
+        public void run()
+        {
+          Desktop.closeDesktop();
+        }
+      });
+    } catch (Exception foo)
+    {
+      System.err.println("Failed during teardown with exception");
+      foo.printStackTrace();
+    }
+
   }
 
   public static void callJalviewMain(String[] args)