4 import java.io.IOException;
6 import java.util.Properties;
8 import org.testng.Assert;
9 import org.testng.annotations.DataProvider;
10 import org.testng.annotations.Test;
12 import jalview.bin.ArgParser.Arg;
13 import jalview.bin.ArgParser.BootstrapArgs;
14 import jalview.util.FileUtils;
16 public class ArgParserTest
19 @Test(groups = "Functional", dataProvider = "argLines")
20 public void parseArgsAndSubValsTest(String commandLineArgs)
22 String[] args = commandLineArgs.split("\\s*");
23 ArgParser argparser = new ArgParser(args);
26 @Test(groups = "Functional", dataProvider = "argLines")
27 public void bootstrapArgsTest(String commandLineArgs, Arg a, String other)
29 String[] args = commandLineArgs.split("\\s+");
30 BootstrapArgs b = BootstrapArgs.getBootstrapArgs(args);
32 Assert.assertTrue(b.contains(a));
35 Properties bP = Cache.bootstrapProperties(b.get(Arg.PROPS));
36 Assert.assertTrue(other.equals(bP.get(Cache.BOOTSTRAP_TEST)));
38 else if (a == Arg.ARGFILE)
40 List<File> files = FileUtils.getFilesFromGlob(b.get(a));
41 boolean found = false;
44 File fo = new File(other);
47 if (fo.getCanonicalPath().equals(f.getCanonicalPath()))
52 } catch (IOException e)
56 Assert.assertTrue(found);
61 @Test(groups = "Functional", dataProvider = "argFiles")
62 public void argFilesTest(String commandLineArgs, Arg a)
64 String[] args = commandLineArgs.split("\\s+");
65 BootstrapArgs b = BootstrapArgs.getBootstrapArgs(args);
67 Assert.assertTrue(b.contains(a));
70 Properties bP = Cache.bootstrapProperties(b.get(Arg.PROPS));
71 Assert.assertTrue("true".equals(bP.get(Cache.BOOTSTRAP_TEST)));
76 @DataProvider(name = "argLines")
77 public Object[][] argLines()
79 return new Object[][] {
80 { "--debug --open=test/jalview/bin/argparser/test1.fa", Arg.DEBUG,
82 { "--open=test/jalview/bin/argparser/test1.fa --headless",
84 { "--open=test/jalview/bin/argparser/test1.fa --props=test/jalview/bin/argparser/testProps.jvprops",
86 { "--argfile=test/jalview/bin/argparser/argfile*.txt", Arg.ARGFILE,
87 "test/jalview/bin/argparser/argfile1.txt" } };
90 @DataProvider(name = "argFiles")
91 public Object[][] argFiles()
93 return new Object[][] {
94 { "--argfile=test/jalview/bin/argparser/argfile0.txt", Arg.OPEN,
95 "test/jalview/bin/argfiles/test1.fa" } };