Merge branch 'spike/relaunch_memsetingds' into spikes/jim
[jalview.git] / test / jalview / bin / CommandLineOperations.java
index b81facf..a017fcf 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.bin;
 
 import jalview.gui.JvOptionPane;
+import jalview.ws.utils.Worker;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -48,7 +49,7 @@ public class CommandLineOperations
     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
   }
 
-  private static final int TEST_TIMEOUT = 4500; // Note longer timeout needed on
+  private static final int TEST_TIMEOUT = 9000; // Note longer timeout needed on
                                                 // full test run than on
                                                 // individual tests
 
@@ -60,61 +61,6 @@ public class CommandLineOperations
 
   private ArrayList<String> successfulCMDs = new ArrayList<>();
 
-  /***
-   * from
-   * http://stackoverflow.com/questions/808276/how-to-add-a-timeout-value-when
-   * -using-javas-runtime-exec
-   * 
-   * @author jimp
-   * 
-   */
-  private static class Worker extends Thread
-  {
-    private final Process process;
-
-    private BufferedReader outputReader;
-
-    private BufferedReader errorReader;
-
-    private Integer exit;
-
-    private Worker(Process process)
-    {
-      this.process = process;
-    }
-
-    @Override
-    public void run()
-    {
-      try
-      {
-        exit = process.waitFor();
-      } catch (InterruptedException ignore)
-      {
-        return;
-      }
-    }
-
-    public BufferedReader getOutputReader()
-    {
-      return outputReader;
-    }
-
-    public void setOutputReader(BufferedReader outputReader)
-    {
-      this.outputReader = outputReader;
-    }
-
-    public BufferedReader getErrorReader()
-    {
-      return errorReader;
-    }
-
-    public void setErrorReader(BufferedReader errorReader)
-    {
-      this.errorReader = errorReader;
-    }
-  }
 
   private static ClassGraph scanner = null;
 
@@ -217,11 +163,10 @@ public class CommandLineOperations
         break;
       }
     }
-    if (worker != null && worker.exit == null)
+    if (worker != null && worker.getExitValue() == null)
     {
-      worker.interrupt();
-      Thread.currentThread().interrupt();
-      worker.process.destroy();
+      worker.destroyProcess();
+
     }
   }
 
@@ -247,11 +192,9 @@ public class CommandLineOperations
     FileAssert.assertFile(file, "Didn't create an output" + type
             + " file.[" + harg + "]");
     FileAssert.assertMinLength(new File(fileName), expectedMinFileSize);
-    if (worker != null && worker.exit == null)
+    if (worker != null && worker.getExitValue() == null)
     {
-      worker.interrupt();
-      Thread.currentThread().interrupt();
-      worker.process.destroy();
+      worker.destroyProcess();
       Assert.fail("Jalview did not exit after "
               + type
               + " generation (try running test again to verify - timeout at "