2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.gui.JvOptionPane;
24 import jalview.util.Worker;
27 import java.io.IOException;
28 import java.util.ArrayList;
30 import org.testng.Assert;
31 import org.testng.FileAssert;
32 import org.testng.annotations.BeforeClass;
33 import org.testng.annotations.BeforeTest;
34 import org.testng.annotations.DataProvider;
35 import org.testng.annotations.Test;
37 public class CommandLineOperations
40 @BeforeClass(alwaysRun = true)
41 public void setUpJvOptionPane()
43 JvOptionPane.setInteractiveMode(false);
44 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
47 private static final int TEST_TIMEOUT = 9000; // Note longer timeout needed on
48 // full test run than on
51 private static final int SETUP_TIMEOUT = 9000;
53 private static final int MINFILESIZE_SMALL = 2096;
55 private static final int MINFILESIZE_BIG = 4096;
57 private ArrayList<String> successfulCMDs = new ArrayList<>();
60 @BeforeTest(alwaysRun = true)
61 public void initialize()
63 new CommandLineOperations();
66 @BeforeTest(alwaysRun = true)
67 public void setUpForHeadlessCommandLineInputOperations()
70 String cmds = "nodisplay -open examples/uniref50.fa -sortbytree -props FILE -colour zappo "
71 + "-jabaws http://www.compbio.dundee.ac.uk/jabaws -nosortbytree -dasserver nickname=www.test.com "
72 + "-features examples/testdata/plantfdx.features -annotations examples/testdata/plantfdx.annotations -tree examples/testdata/uniref50_test_tree";
73 Worker worker = Worker.jalviewDesktopRunner(true, cmds, SETUP_TIMEOUT);
75 while ((ln = worker.getOutputReader().readLine()) != null)
77 System.out.println(ln);
78 successfulCMDs.add(ln);
82 @BeforeTest(alwaysRun = true)
83 public void setUpForCommandLineInputOperations() throws IOException
85 String cmds = "-open examples/uniref50.fa -noquestionnaire -nousagestats";
86 Worker worker = Worker.jalviewDesktopRunner(false, cmds, SETUP_TIMEOUT);
89 while ((ln = worker.getErrorReader().readLine()) != null)
91 System.out.println(ln);
92 successfulCMDs.add(ln);
98 if (worker != null && worker.getExitValue() == null)
100 worker.destroyProcess();
105 @Test(groups = { "Functional" }, dataProvider = "allInputOpearationsData")
106 public void testAllInputOperations(String expectedString,
109 Assert.assertTrue(successfulCMDs.contains(expectedString), failureMsg);
113 groups = { "Functional" },
114 dataProvider = "headlessModeOutputOperationsData")
115 public void testHeadlessModeOutputOperations(String harg, String type,
116 String fileName, boolean withAWT, int expectedMinFileSize,
119 String cmd = harg + type + " " + fileName;
120 // System.out.println(">>>>>>>>>>>>>>>> Command : " + cmd);
121 File file = new File(fileName);
122 Worker worker = Worker.jalviewDesktopRunner(withAWT, cmd, timeout);
124 FileAssert.assertFile(file, "Didn't create an output" + type
125 + " file.[" + harg + "]");
126 FileAssert.assertMinLength(new File(fileName), expectedMinFileSize);
127 if (worker != null && worker.getExitValue() == null)
129 worker.destroyProcess();
130 Assert.fail("Jalview did not exit after "
132 + " generation (try running test again to verify - timeout at "
133 + SETUP_TIMEOUT + "ms). ["
136 new File(fileName).delete();
139 @DataProvider(name = "allInputOpearationsData")
140 public Object[][] getHeadlessModeInputParams()
142 return new Object[][] {
143 // headless mode input operations
144 { "CMD [-color zappo] executed successfully!",
145 "Failed command : -color zappo" },
146 { "CMD [-props FILE] executed successfully!",
147 "Failed command : -props File" },
148 { "CMD [-sortbytree] executed successfully!",
149 "Failed command : -sortbytree" },
151 "CMD [-jabaws http://www.compbio.dundee.ac.uk/jabaws] executed successfully!",
152 "Failed command : -jabaws http://www.compbio.dundee.ac.uk/jabaws" },
153 { "CMD [-open examples/uniref50.fa] executed successfully!",
154 "Failed command : -open examples/uniref50.fa" },
155 { "CMD [-nosortbytree] executed successfully!",
156 "Failed command : -nosortbytree" },
157 { "CMD [-dasserver nickname=www.test.com] executed successfully!",
158 "Failed command : -dasserver nickname=www.test.com" },
160 "CMD [-features examples/testdata/plantfdx.features] executed successfully!",
161 "Failed command : -features examples/testdata/plantfdx.features" },
163 "CMD [-annotations examples/testdata/plantfdx.annotations] executed successfully!",
164 "Failed command : -annotations examples/testdata/plantfdx.annotations" },
166 "CMD [-tree examples/testdata/uniref50_test_tree] executed successfully!",
167 "Failed command : -tree examples/testdata/uniref50_test_tree" },
168 // non headless mode input operations
169 { "CMD [-nousagestats] executed successfully!",
170 "Failed command : -nousagestats" },
171 { "CMD [-noquestionnaire] executed successfully!",
172 "Failed command : -noquestionnaire nickname=www.test.com" } };
176 @DataProvider(name = "headlessModeOutputOperationsData")
177 public static Object[][] getHeadlessModeOutputParams()
179 return new Object[][] {
180 { "nodisplay -open examples/uniref50.fa", " -eps",
181 "test_uniref50_out.eps", true, MINFILESIZE_BIG, TEST_TIMEOUT },
182 { "nodisplay -open examples/uniref50.fa", " -eps",
183 "test_uniref50_out.eps", false, MINFILESIZE_BIG, TEST_TIMEOUT },
184 { "nogui -open examples/uniref50.fa", " -eps",
185 "test_uniref50_out.eps", true, MINFILESIZE_BIG, TEST_TIMEOUT },
186 { "nogui -open examples/uniref50.fa", " -eps",
187 "test_uniref50_out.eps", false, MINFILESIZE_BIG, TEST_TIMEOUT },
188 { "headless -open examples/uniref50.fa", " -eps",
189 "test_uniref50_out.eps", true, MINFILESIZE_BIG, TEST_TIMEOUT },
190 { "headless -open examples/uniref50.fa", " -svg",
191 "test_uniref50_out.svg", false, MINFILESIZE_BIG, TEST_TIMEOUT },
192 { "headless -open examples/uniref50.fa", " -png",
193 "test_uniref50_out.png", true, MINFILESIZE_BIG, TEST_TIMEOUT },
194 { "headless -open examples/uniref50.fa", " -html",
195 "test_uniref50_out.html", true, MINFILESIZE_BIG, TEST_TIMEOUT },
196 { "headless -open examples/uniref50.fa", " -fasta",
197 "test_uniref50_out.mfa", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
198 { "headless -open examples/uniref50.fa", " -clustal",
199 "test_uniref50_out.aln", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
200 { "headless -open examples/uniref50.fa", " -msf",
201 "test_uniref50_out.msf", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
202 { "headless -open examples/uniref50.fa", " -pileup",
203 "test_uniref50_out.aln", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
204 { "headless -open examples/uniref50.fa", " -pir",
205 "test_uniref50_out.pir", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
206 { "headless -open examples/uniref50.fa", " -pfam",
207 "test_uniref50_out.pfam", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
208 { "headless -open examples/uniref50.fa", " -blc",
209 "test_uniref50_out.blc", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
210 { "headless -open examples/uniref50.fa", " -jalview",
211 "test_uniref50_out.jvp", true, MINFILESIZE_SMALL, TEST_TIMEOUT }, };