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;
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
}
- private static final int TEST_TIMEOUT = 9000; // Note longer timeout needed
+ private static final int TEST_TIMEOUT = 12500; // Note longer timeout needed
// on
// full test run than on
// individual tests
private static String modules = null;
+ private static String java_exe = null;
+
public synchronized static String getClassPath()
{
if (scanner == null)
{
modules.concat(mr.getName());
}
+ java_exe = System.getProperty("java.home") + File.separator + "bin"
+ + File.separator + "java";
+
}
while (classpath == null)
{
// 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 + "\""
: "")
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()
{
public void setUpForCommandLineInputOperations() throws IOException
{
String cmds = "-open examples/uniref50.fa -noquestionnaire -nousagestats";
- Worker worker = getJalviewDesktopRunner(false, cmds, SETUP_TIMEOUT);
- String ln = null;
- int count = 0;
- while ((ln = worker.getErrorReader().readLine()) != null)
+ final Worker worker = getJalviewDesktopRunner(false, cmds,
+ SETUP_TIMEOUT);
+
+
+ // number of lines expected on STDERR when Jalview starts up normally
+ // may need to adjust this if Jalview is excessively noisy ?
+ final int STDERR_SETUPLINES=50;
+
+ // thread monitors stderr - bails after SETUP_TIMEOUT or when
+ // STDERR_SETUPLINES have been read
+ Thread runner = new Thread(new Runnable()
{
- System.out.println(ln);
- successfulCMDs.add(ln);
- if (++count > 5)
+ public void run()
+ {
+ String ln = null;
+ int count = 0;
+ try
+ {
+ while ((ln = worker.getErrorReader().readLine()) != null)
+ {
+ System.out.println(ln);
+ successfulCMDs.add(ln);
+ if (++count > STDERR_SETUPLINES)
+ {
+ break;
+ }
+ }
+ } catch (Exception e)
+ {
+ System.err.println(
+ "Unexpected Exception reading stderr from the Jalview process");
+ e.printStackTrace();
+ }
+ }
+ });
+ long t = System.currentTimeMillis() + SETUP_TIMEOUT;
+ runner.start();
+ while (!runner.isInterrupted() && System.currentTimeMillis() < t)
+ {
+ try
+ {
+ Thread.sleep(500);
+ } catch (InterruptedException e)
{
- break;
}
}
+ runner.interrupt();
if (worker != null && worker.exit == null)
{
worker.interrupt();
@Test(
groups =
- { "Functional", "testben" },
+ { "Functional" },
dataProvider = "headlessModeOutputOperationsData")
public void testHeadlessModeOutputOperations(String harg, String type,
String fileName, boolean withAWT, int expectedMinFileSize,
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);