JAL-3949 fixed failing commandlinetests due to more output and line count limit
[jalview.git] / test / jalview / bin / CommandLineOperations.java
index 716b504..4323699 100644 (file)
@@ -29,6 +29,8 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 
 import org.testng.Assert;
@@ -52,7 +54,7 @@ public class CommandLineOperations
     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
   }
 
-  private static final int TEST_TIMEOUT = 9000; // Note longer timeout needed
+  private static final int TEST_TIMEOUT = 10500; // Note longer timeout needed
                                                 // on
                                                 // full test run than on
                                                 // individual tests
@@ -127,6 +129,8 @@ public class CommandLineOperations
 
   private static String modules = null;
 
+  private static String java_exe = null;
+
   public synchronized static String getClassPath()
   {
     if (scanner == null)
@@ -139,6 +143,9 @@ public class CommandLineOperations
       {
         modules.concat(mr.getName());
       }
+      java_exe = System.getProperty("java.home") + File.separator + "bin"
+              + File.separator + "java";
+
     }
     while (classpath == null)
     {
@@ -159,7 +166,8 @@ public class CommandLineOperations
     // Note: JAL-3065 - don't include quotes for lib/* because the arguments are
     // not expanded by the shell
     String classpath = getClassPath();
-    String _cmd = "java " + (withAwt ? "-Djava.awt.headless=true" : "")
+    String _cmd = java_exe + " "
+            + (withAwt ? "-Djava.awt.headless=true" : "")
             + " -classpath " + classpath
             + (modules.length() > 2 ? "--add-modules=\"" + modules + "\""
                     : "")
@@ -194,6 +202,20 @@ public class CommandLineOperations
     return worker;
   }
 
+  @Test(groups = { "Functional" })
+  public void reportCurrentWorkingDirectory()
+  {
+    try
+    {
+      Path currentRelativePath = Paths.get("");
+      String s = currentRelativePath.toAbsolutePath().toString();
+      System.out.println("Test CWD is " + s);
+    } catch (Exception q)
+    {
+      q.printStackTrace();
+    }
+  }
+
   @BeforeTest(alwaysRun = true)
   public void initialize()
   {
@@ -231,7 +253,7 @@ public class CommandLineOperations
     {
       System.out.println(ln);
       successfulCMDs.add(ln);
-      if (++count > 5)
+      if (++count > 50)
       {
         break;
       }
@@ -253,7 +275,7 @@ public class CommandLineOperations
 
   @Test(
     groups =
-    { "Functional", "testben" },
+    { "Functional" },
     dataProvider = "headlessModeOutputOperationsData")
   public void testHeadlessModeOutputOperations(String harg, String type,
           String fileName, boolean withAWT, int expectedMinFileSize,
@@ -265,8 +287,7 @@ public class CommandLineOperations
     file.deleteOnExit();
     Worker worker = getJalviewDesktopRunner(withAWT, cmd, timeout);
     assertNotNull(worker, "worker is null");
-    String msg = "Didn't create an output" + type + " file at '"
-            + file.getAbsolutePath() + "'.[" + harg + "]";
+    String msg = "Didn't create an output" + type + " file.[" + harg + "]";
     assertTrue(file.exists(), msg);
     FileAssert.assertFile(file, msg);
     FileAssert.assertMinLength(file, expectedMinFileSize);