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.applicationProperties.clear();
32 Cache.loadProperties("test/jalview/testProps.jvprops");
35 @BeforeClass(alwaysRun = true)
36 public void setUpJvOptionPane()
38 JvOptionPane.setInteractiveMode(false);
39 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
42 @AfterMethod(alwaysRun = true)
43 public void tearDown()
45 if (Desktop.instance != null)
46 Desktop.instance.closeAll_actionPerformed(null);
49 @Test(groups = "Functional", dataProvider = "cmdLines")
50 public void commandsOpenTest(String cmdLine, String sequence)
52 String[] args = cmdLine.split("\\s+");
54 Commands cmds = Jalview.getInstance().getCommands();
55 Assert.assertNotNull(cmds);
56 Assert.assertTrue(cmds.commandArgsProvided(),
57 "Commands were not provided in the args");
58 Assert.assertTrue(cmds.argsWereParsed(),
59 "Overall command parse and operation is false");
63 Assert.assertTrue(lookForSequenceName(sequence),
64 "Sequence '" + sequence
65 + "' was not found in opened alignment files: "
69 System.out.println("##### GOT TO END");
72 public static boolean lookForSequenceName(String sequenceName)
74 AlignFrame[] afs = Desktop.getAlignFrames();
75 for (AlignFrame af : afs)
77 for (String name : af.getViewport().getAlignment().getSequenceNames())
79 if (sequenceName.equals(name))
88 @DataProvider(name = "cmdLines")
89 public Object[][] cmdLines()
91 return new Object[][] { { "--open=examples/uniref50.fa", "FER1_SPIOL" },
92 { "--argfile=test/jalview/bin/argparser/argfile0.txt", null } };