package jalview.bin; import java.util.Date; import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import jalview.gui.AlignFrame; import jalview.gui.Desktop; import jalview.gui.JvOptionPane; @Test(singleThreaded = true) public class CommandsTest { @BeforeClass(alwaysRun = true) public static void setUpBeforeClass() throws Exception { Cache.loadProperties("test/jalview/gui/quitProps.jvprops"); Date oneHourFromNow = new Date( System.currentTimeMillis() + 3600 * 1000); Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED", oneHourFromNow); } @BeforeClass(alwaysRun = true) public void setUpJvOptionPane() { JvOptionPane.setInteractiveMode(false); JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); } @AfterMethod(alwaysRun = true) public void tearDown() { Desktop.instance.closeAll_actionPerformed(null); } @Test(groups = "Functional", dataProvider = "cmdLines") public void commandsOpenTest(String cmdLine, String sequence) { String[] args = cmdLine.split("\\s+"); Jalview.main(args); Commands cmds = Jalview.getInstance().getCommands(); Assert.assertNotNull(cmds); Assert.assertTrue(cmds.commandArgsProvided(), "Commands were not provided in the args"); Assert.assertTrue(cmds.argsWereParsed(), "Overall command parse and operation is false"); if (sequence != null) { Assert.assertTrue(lookForSequenceName(sequence), "Sequence '" + sequence + "' was not found in opened alignment files: " + cmdLine); } System.out.println("##### GOT TO END"); } public static boolean lookForSequenceName(String sequenceName) { AlignFrame[] afs = Desktop.getAlignFrames(); for (AlignFrame af : afs) { for (String name : af.getViewport().getAlignment().getSequenceNames()) { if (sequenceName.equals(name)) { return true; } } } return false; } @DataProvider(name = "cmdLines") public Object[][] cmdLines() { return new Object[][] { { "--open=examples/uniref50.fa", "FER1_SPIOL" }, { "--argfile=test/jalview/bin/argparser/argfile0.txt", null } }; } }