5 import org.testng.Assert;
6 import org.testng.annotations.AfterClass;
7 import org.testng.annotations.AfterMethod;
8 import org.testng.annotations.BeforeClass;
9 import org.testng.annotations.DataProvider;
10 import org.testng.annotations.Test;
12 import jalview.gui.AlignFrame;
13 import jalview.gui.Desktop;
14 import jalview.gui.JvOptionPane;
16 @Test(singleThreaded = true)
17 public class CommandsTest
19 @BeforeClass(alwaysRun = true)
20 public static void setUpBeforeClass() throws Exception
22 Cache.loadProperties("test/jalview/gui/quitProps.jvprops");
23 Date oneHourFromNow = new Date(
24 System.currentTimeMillis() + 3600 * 1000);
25 Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED", oneHourFromNow);
28 @AfterClass(alwaysRun = true)
29 public static void resetProps()
31 Cache.loadProperties("test/jalview/testProps.jvprops");
34 @BeforeClass(alwaysRun = true)
35 public void setUpJvOptionPane()
37 JvOptionPane.setInteractiveMode(false);
38 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
41 @AfterMethod(alwaysRun = true)
42 public void tearDown()
44 if (Desktop.instance != null)
45 Desktop.instance.closeAll_actionPerformed(null);
48 @Test(groups = "Functional", dataProvider = "cmdLines")
49 public void commandsOpenTest(String cmdLine, String sequence)
51 String[] args = cmdLine.split("\\s+");
53 Commands cmds = Jalview.getInstance().getCommands();
54 Assert.assertNotNull(cmds);
55 Assert.assertTrue(cmds.commandArgsProvided(),
56 "Commands were not provided in the args");
57 Assert.assertTrue(cmds.argsWereParsed(),
58 "Overall command parse and operation is false");
62 Assert.assertTrue(lookForSequenceName(sequence),
63 "Sequence '" + sequence
64 + "' was not found in opened alignment files: "
69 public static boolean lookForSequenceName(String sequenceName)
71 AlignFrame[] afs = Desktop.getAlignFrames();
72 for (AlignFrame af : afs)
74 for (String name : af.getViewport().getAlignment().getSequenceNames())
76 if (sequenceName.equals(name))
85 @DataProvider(name = "cmdLines")
86 public Object[][] cmdLines()
88 return new Object[][] { { "--open=examples/uniref50.fa", "FER1_SPIOL" },
89 { "--argfile=test/jalview/bin/argparser/argfile0.txt", null } };