5 import org.testng.Assert;
6 import org.testng.annotations.AfterMethod;
7 import org.testng.annotations.BeforeClass;
8 import org.testng.annotations.DataProvider;
9 import org.testng.annotations.Test;
11 import jalview.gui.AlignFrame;
12 import jalview.gui.Desktop;
13 import jalview.gui.JvOptionPane;
15 @Test(singleThreaded = true)
16 public class CommandsTest
18 @BeforeClass(alwaysRun = true)
19 public static void setUpBeforeClass() throws Exception
21 Cache.loadProperties("test/jalview/gui/quitProps.jvprops");
22 Date oneHourFromNow = new Date(
23 System.currentTimeMillis() + 3600 * 1000);
24 Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED", oneHourFromNow);
27 @BeforeClass(alwaysRun = true)
28 public void setUpJvOptionPane()
30 JvOptionPane.setInteractiveMode(false);
31 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
34 @AfterMethod(alwaysRun = true)
35 public void tearDown()
37 Desktop.instance.closeAll_actionPerformed(null);
40 @Test(groups = "Functional", dataProvider = "cmdLines")
41 public void commandsOpenTest(String cmdLine, String sequence)
43 String[] args = cmdLine.split("\\s+");
45 Commands cmds = Jalview.getInstance().getCommands();
46 Assert.assertNotNull(cmds);
47 Assert.assertTrue(cmds.commandArgsProvided(),
48 "Commands were not provided in the args");
49 Assert.assertTrue(cmds.argsWereParsed(),
50 "Overall command parse and operation is false");
54 Assert.assertTrue(lookForSequenceName(sequence),
55 "Sequence '" + sequence
56 + "' was not found in opened alignment files: "
60 System.out.println("##### GOT TO END");
63 public static boolean lookForSequenceName(String sequenceName)
65 AlignFrame[] afs = Desktop.getAlignFrames();
66 for (AlignFrame af : afs)
68 for (String name : af.getViewport().getAlignment().getSequenceNames())
70 if (sequenceName.equals(name))
79 @DataProvider(name = "cmdLines")
80 public Object[][] cmdLines()
82 return new Object[][] { { "--open=examples/uniref50.fa", "FER1_SPIOL" },
83 { "--argfile=test/jalview/bin/argparser/argfile0.txt", null } };