/** * Search for a prefix that is the long name of an option (-Xmx512m) * * @param token */ private String getLongPrefix(String token) { String t = Util.stripLeadingHyphens(token); int i; String opt = null; for (i = t.length() - 2; i > 1; i--) { String prefix = t.substring(0, i); if (options.hasLongOption(prefix)) { opt = prefix; break; } } return opt; }
/** * Search for a prefix that is the long name of an option (-Xmx512m) * * @param token */ private String getLongPrefix(String token) { String t = Util.stripLeadingHyphens(token); int i; String opt = null; for (i = t.length() - 2; i > 1; i--) { String prefix = t.substring(0, i); if (options.hasLongOption(prefix)) { opt = prefix; break; } } return opt; }
@Test public void testRequiredOptions() { // Test that the only required metric options are metric tools options. Options options = new Options(); options.addOption(MetricTools.OPT_TOOL); for (Option option : MetricTools.OPTIONS.getOptions()) { if (option.isRequired()) { Assert.assertTrue("Required option not allowed in specific tools", options.hasLongOption(option.getLongOpt())); } } } }