import jalview.gui.JvOptionPane;
import jalview.ws.utils.Worker;
-import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.util.ArrayList;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import io.github.classgraph.ClassGraph;
-import io.github.classgraph.ScanResult;
-
public class CommandLineOperations
{
private ArrayList<String> successfulCMDs = new ArrayList<>();
- private static ClassGraph scanner = null;
-
- private static String classpath = null;
-
- public synchronized static String getClassPath()
- {
- if (scanner == null)
- {
- scanner = new ClassGraph();
- ScanResult scan = scanner.scan();
- classpath = scan.getClasspath();
- }
- while (classpath == null)
- {
- try
- {
- Thread.sleep(10);
- } catch (InterruptedException x)
- {
-
- }
- }
- return classpath;
- }
- private Worker jalviewDesktopRunner(boolean withAwt, String cmd,
- int timeout)
- {
- // 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" : "")
- + " -classpath " + classpath + " jalview.bin.Jalview ";
- Process ls2_proc = null;
- Worker worker = null;
- try
- {
- ls2_proc = Runtime.getRuntime().exec(_cmd + cmd);
- } catch (IOException e1)
- {
- e1.printStackTrace();
- }
- if (ls2_proc != null)
- {
- BufferedReader outputReader = new BufferedReader(
- new InputStreamReader(ls2_proc.getInputStream()));
- BufferedReader errorReader = new BufferedReader(
- new InputStreamReader(ls2_proc.getErrorStream()));
- worker = new Worker(ls2_proc);
- worker.start();
- try
- {
- worker.join(timeout);
- } catch (InterruptedException e)
- {
- // e.printStackTrace();
- }
- worker.setOutputReader(outputReader);
- worker.setErrorReader(errorReader);
- }
- return worker;
- }
-
@BeforeTest(alwaysRun = true)
public void initialize()
{
String cmds = "nodisplay -open examples/uniref50.fa -sortbytree -props FILE -colour zappo "
+ "-jabaws http://www.compbio.dundee.ac.uk/jabaws -nosortbytree -dasserver nickname=www.test.com "
+ "-features examples/testdata/plantfdx.features -annotations examples/testdata/plantfdx.annotations -tree examples/testdata/uniref50_test_tree";
- Worker worker = jalviewDesktopRunner(true, cmds, SETUP_TIMEOUT);
+ Worker worker = Worker.jalviewDesktopRunner(true, cmds, SETUP_TIMEOUT);
String ln = null;
while ((ln = worker.getOutputReader().readLine()) != null)
{
public void setUpForCommandLineInputOperations() throws IOException
{
String cmds = "-open examples/uniref50.fa -noquestionnaire -nousagestats";
- Worker worker = jalviewDesktopRunner(false, cmds, SETUP_TIMEOUT);
+ Worker worker = Worker.jalviewDesktopRunner(false, cmds, SETUP_TIMEOUT);
String ln = null;
int count = 0;
while ((ln = worker.getErrorReader().readLine()) != null)
String cmd = harg + type + " " + fileName;
// System.out.println(">>>>>>>>>>>>>>>> Command : " + cmd);
File file = new File(fileName);
- Worker worker = jalviewDesktopRunner(withAWT, cmd, timeout);
+ Worker worker = Worker.jalviewDesktopRunner(withAWT, cmd, timeout);
FileAssert.assertFile(file, "Didn't create an output" + type
+ " file.[" + harg + "]");