import jalview.gui.JvOptionPane;
import jalview.util.ArrayUtils;
-@Test
public class CommandsTest
{
private static final String testfiles = "test/jalview/bin/argparser/testfiles";
public void commandsOpenTest(String cmdLine, boolean cmdArgs,
int numFrames, String[] sequences)
{
- String[] args = (cmdLine + " --gui").split("\\s+");
- callJalviewMain(args);
- Commands cmds = Jalview.getInstance().getCommands();
- Assert.assertNotNull(cmds);
- Assert.assertEquals(cmds.commandArgsProvided(), cmdArgs,
- "Commands were not provided in the args");
- Assert.assertEquals(cmds.argsWereParsed(), cmdArgs,
- "Overall command parse and operation is false");
+ try
+ {
+ String[] args = (cmdLine + " --gui").split("\\s+");
+ callJalviewMain(args);
+ Commands cmds = Jalview.getInstance().getCommands();
+ Assert.assertNotNull(cmds);
+ Assert.assertEquals(cmds.commandArgsProvided(), cmdArgs,
+ "Commands were not provided in the args");
+ Assert.assertEquals(cmds.argsWereParsed(), cmdArgs,
+ "Overall command parse and operation is false");
- Assert.assertEquals(Desktop.getAlignFrames().length, numFrames,
- "Wrong number of AlignFrames");
+ Assert.assertEquals(Desktop.getAlignFrames().length, numFrames,
+ "Wrong number of AlignFrames");
- if (sequences != null)
- {
- Set<String> openedSequenceNames = new HashSet<>();
- AlignFrame[] afs = Desktop.getAlignFrames();
- for (AlignFrame af : afs)
+ if (sequences != null)
{
- openedSequenceNames
- .addAll(af.getViewport().getAlignment().getSequenceNames());
- }
- for (String sequence : sequences)
- {
- Assert.assertTrue(openedSequenceNames.contains(sequence),
- "Sequence '" + sequence
- + "' was not found in opened alignment files: "
- + cmdLine + ".\nOpened sequence names are:\n"
- + String.join("\n", openedSequenceNames));
+ Set<String> openedSequenceNames = new HashSet<>();
+ AlignFrame[] afs = Desktop.getAlignFrames();
+ for (AlignFrame af : afs)
+ {
+ openedSequenceNames.addAll(
+ af.getViewport().getAlignment().getSequenceNames());
+ }
+ for (String sequence : sequences)
+ {
+ Assert.assertTrue(openedSequenceNames.contains(sequence),
+ "Sequence '" + sequence
+ + "' was not found in opened alignment files: "
+ + cmdLine + ".\nOpened sequence names are:\n"
+ + String.join("\n", openedSequenceNames));
+ }
}
- }
- Assert.assertFalse(
- lookForSequenceName("THIS_SEQUENCE_ID_DOESN'T_EXIST"));
+ Assert.assertFalse(
+ lookForSequenceName("THIS_SEQUENCE_ID_DOESN'T_EXIST"));
+ } catch (Exception x)
+ {
+ Assert.fail("Unexpected exception during commandsOpenTest", x);
+ } finally
+ {
+ tearDown();
+
+ }
}
@Test(groups = "Functional", dataProvider = "structureImageOutputFiles")
{
cleanupFiles(filenames);
String[] args = (cmdLine + " --gui").split("\\s+");
- callJalviewMain(args);
- Commands cmds = Jalview.getInstance().getCommands();
- Assert.assertNotNull(cmds);
- File lastFile = null;
- for (String filename : filenames)
+ try
{
- File file = new File(filename);
- Assert.assertTrue(file.exists(), "File '" + filename
- + "' was not created by '" + cmdLine + "'");
- Assert.assertTrue(file.isFile(), "File '" + filename
- + "' is not a file from '" + cmdLine + "'");
- Assert.assertTrue(Files.size(file.toPath()) > 0, "File '" + filename
- + "' has no content from '" + cmdLine + "'");
- // make sure the successive output files get bigger!
- if (lastFile != null)
- Assert.assertTrue(
- Files.size(file.toPath()) > Files.size(lastFile.toPath()));
+ callJalviewMain(args);
+ Commands cmds = Jalview.getInstance().getCommands();
+ Assert.assertNotNull(cmds);
+ File lastFile = null;
+ for (String filename : filenames)
+ {
+ File file = new File(filename);
+ Assert.assertTrue(file.exists(), "File '" + filename
+ + "' was not created by '" + cmdLine + "'");
+ Assert.assertTrue(file.isFile(), "File '" + filename
+ + "' is not a file from '" + cmdLine + "'");
+ Assert.assertTrue(Files.size(file.toPath()) > 0, "File '" + filename
+ + "' has no content from '" + cmdLine + "'");
+ // make sure the successive output files get bigger!
+ if (lastFile != null)
+ Assert.assertTrue(Files.size(file.toPath()) > Files
+ .size(lastFile.toPath()));
+ }
+ } catch (Exception x)
+ {
+ Assert.fail("Unexpected exception during structureImageOutputTest",
+ x);
+ } finally
+ {
+ cleanupFiles(filenames);
+ tearDown();
}
- cleanupFiles(filenames);
- tearDown();
}
@Test(groups = "Functional", dataProvider = "argfileOutputFiles")
{
cleanupFiles(filenames);
String[] args = (cmdLine + " --gui").split("\\s+");
+ try {
callJalviewMain(args);
Commands cmds = Jalview.getInstance().getCommands();
Assert.assertNotNull(cmds);
Assert.assertTrue(
Files.size(file.toPath()) > Files.size(lastFile.toPath()));
}
- cleanupFiles(filenames);
- tearDown();
+ } catch (Exception x)
+ {
+ Assert.fail("Unexpected exception during argFilesGlobAndSubstitutions",
+ x);
+ } finally
+ {
+ cleanupFiles(filenames);
+ tearDown();
+ }
}
@DataProvider(name = "structureImageOutputFiles")