+
+ @Test(groups = "Functional", dataProvider = "allLinkedIdsData")
+ public void allLinkedIdsTest(String pwd, String commandLineArgs, Arg a,
+ String[] values, String[] nonvalues)
+ {
+ String userDir = System.getProperty("user.dir");
+ if (pwd != null)
+ {
+ File pwdFile = new File(pwd);
+ System.setProperty("user.dir", pwdFile.getAbsolutePath());
+ }
+ String[] args = commandLineArgs.split("\\s+");
+ ArgParser argparser = new ArgParser(args);
+
+ int num = values.length;
+ List<String> linkedIds = argparser.getLinkedIds();
+ Assert.assertEquals(linkedIds.size(), num,
+ "Wrong number of linkedIds: " + linkedIds.toString());
+ for (int i = 0; i < num; i++)
+ {
+ String value = values[i];
+ String linkedId = linkedIds.get(i);
+ ArgValuesMap avm = argparser.getLinkedArgs(linkedId);
+ if (value == null)
+ {
+ Assert.assertTrue(avm.containsArg(a),
+ "Arg value for " + a.argString()
+ + " not applied correctly to linkedId '" + linkedId
+ + "'");
+ }
+ else
+ {
+ ArgValues avs = avm.getArgValues(a);
+ ArgValue av = avs.getArgValue();
+ String v = av.getValue();
+ value = new File(value).getPath();
+ Assert.assertEquals(v, value, "Arg value for " + a.argString()
+ + " not applied correctly to linkedId '" + linkedId + "'");
+ }
+ }
+
+ System.setProperty("user.dir", userDir);
+ }
+
+ @DataProvider(name = "allLinkedIdsData")
+ public Object[][] allLinkedIdsData()
+ {
+ return new Object[][] {
+ //
+ /*
+ */
+ { null,
+ "--open=test/jalview/bin/argparser/testfiles/*.fa --substitutions --all --image={dirname}/{basename}.png --close",
+ Arg.CLOSE, new String[]
+ { null, null, null },
+ null },
+ { null,
+ "--open=test/jalview/bin/argparser/testfiles/*.fa --substitutions --all --output={dirname}/{basename}.stk --close",
+ Arg.OUTPUT, new String[]
+ { "test/jalview/bin/argparser/testfiles/test1.stk",
+ "test/jalview/bin/argparser/testfiles/test2.stk",
+ "test/jalview/bin/argparser/testfiles/test3.stk", },
+ null },
+ { null,
+ "--open=test/jalview/bin/argparser/testfiles/*.fa --substitutions --all --image={dirname}/{basename}.png --close",
+ Arg.IMAGE, new String[]
+ { "test/jalview/bin/argparser/testfiles/test1.png",
+ "test/jalview/bin/argparser/testfiles/test2.png",
+ "test/jalview/bin/argparser/testfiles/test3.png", },
+ null },
+ /*
+ * Find a way to change pwd reliably -- need to match "*.fa" against some files!
+ { "test/jalview/bin/argparser/testfiles",
+
+ "--open=*.fa --image={dirname}/{basename}.png --close",
+ Arg.IMAGE, new String[]
+ { "./test1.png", "./test2.png", "./test3.png", }, null },
+ */
+ //
+ };
+ }
+
+ @Test(groups = "Functional", dataProvider = "bootstrapArgsData")
+ public void bootstrapArgsValuesAndHeadlessModeTest(String commandLineArgs,
+ Arg a, String valS, boolean valB, boolean headlessValue)
+ {
+ String[] args = commandLineArgs.split("\\s+");
+ BootstrapArgs bsa = BootstrapArgs.getBootstrapArgs(args);
+ if (a != null)
+ {
+ if (valS != null)
+ {
+ Assert.assertEquals(bsa.getValue(a), valS,
+ "BootstrapArg " + a.argString()
+ + " value does not match expected '" + valS + "'");
+ }
+ else
+ {
+ Assert.assertEquals(bsa.getBoolean(a), valB,
+ "Boolean/Unary value of BootstrapArg " + a.argString()
+ + "' is not the expected '" + valB + "'");
+ }
+ }
+
+ boolean isHeadless = bsa.isHeadless();
+ Assert.assertEquals(isHeadless, headlessValue,
+ "Assumed headless setting '" + isHeadless + "' is wrong.");
+ }
+
+ @DataProvider(name = "bootstrapArgsData")
+ public Object[][] bootstrapArgsData()
+ {
+ return new Object[][] {
+ /*
+ * cmdline args
+ * Arg (null if only testing headless)
+ * String value if there is one (null otherwise)
+ * boolean value if String value is null
+ * expected value of isHeadless()
+ */
+ /*
+ */
+ { "--open thisway.fa --output thatway.fa --jabaws https://forwardsandbackwards.com/",
+ Arg.JABAWS, "https://forwardsandbackwards.com/", false, true },
+ { "--help-all --open thisway.fa --output thatway.fa --jabaws https://forwardsandbackwards.com/",
+ Arg.HELP, null, true, true },
+ { "--help-all --nonews --open thisway.fa --output thatway.fa --jabaws https://forwardsandbackwards.com/",
+ Arg.NEWS, null, false, true },
+ { "--help --nonews --open thisway.fa --output thatway.fa --jabaws https://forwardsandbackwards.com/",
+ Arg.NEWS, null, false, true },
+ { "--help-opening --nonews --open thisway.fa --output thatway.fa --jabaws https://forwardsandbackwards.com/",
+ Arg.NEWS, null, false, true },
+ { "--nonews --open thisway.fa --output thatway.fa --jabaws https://forwardsandbackwards.com/",
+ Arg.NEWS, null, false, true },
+ { "--open thisway.fa --image thatway.png", null, null, false,
+ true },
+ { "--open thisway.fa --output thatway.png", null, null, false,
+ true },
+ { "--open thisway.fa --image thatway.png --noheadless", null, null,
+ false, false },
+ { "--open thisway.fa --output thatway.png --noheadless", null, null,
+ false, false },
+ { "--open thisway.fa --image thatway.png --gui", null, null, false,
+ false },
+ { "--open thisway.fa --output thatway.png --gui", null, null, false,
+ false },
+ // --gui takes precedence
+ { "--open thisway.fa --image thatway.png --gui --headless", null,
+ null, false, false },
+ { "--open thisway.fa --output thatway.png --gui --headless", null,
+ null, false, false },
+ //
+ };
+ }
+
+}
\ No newline at end of file