ParsedOptions implements CaliperOptions { public static ParsedOptions from(String[] args, boolean requireBenchmarkClassName) throws InvalidCommandException { ParsedOptions options = new ParsedOptions(args, requireBenchmarkClassName); CommandLineParser<ParsedOptions> parser = CommandLineParser.forClass(ParsedOptions.class); try { parser.parseAndInject(args, options); } catch (InvalidCommandException e) { e.setUsage(USAGE); throw e; } return options; } private  ParsedOptions(String[] args, boolean requireBenchmarkClassName); static ParsedOptions from(String[] args, boolean requireBenchmarkClassName); @Override ImmutableList<String> allArgs(); @Override boolean dryRun(); @Override int localPort(); @Override ImmutableSet<String> benchmarkMethodNames(); @Override boolean printConfiguration(); @Override int trialsPerScenario(); @Override ShortDuration timeLimit(); @Override String runName(); @Override String deviceName(); @Override ImmutableSet<String> vmNames(); @Override ImmutableSet<String> instrumentNames(); @Override ImmutableSetMultimap<String, String> userParameters(); @Override ImmutableSetMultimap<String, String> vmArguments(); @Override ImmutableMap<String, String> configProperties(); @Override Optional<String> workerClasspath(String vmType); @Override File caliperDirectory(); @Override File caliperConfigFile(); @Override ImmutableList<String> adbArgs(); @Override boolean printWorkerLog(); @Override String benchmarkClassName(); @Override String toString();  }
@Test public void testNoOptions_RequireBenchmarkClassName() { try { ParsedOptions.from(new String[] {}, true); fail(); } catch (InvalidCommandException expected) { assertEquals("No benchmark class specified", expected.getMessage()); } }
@Test public void testTooManyArguments_RequireBenchmarkClassName() { try { ParsedOptions.from(new String[] {"a", "b"}, true); fail(); } catch (InvalidCommandException expected) { assertEquals("Extra stuff, expected only class name: [a, b]", expected.getMessage()); } }
@Test public void testTooManyArguments_DoNotRequireBenchmarkClassName() { try { ParsedOptions.from(new String[] {"a", "b"}, false); fail(); } catch (InvalidCommandException expected) { assertEquals( "Extra stuff, did not expect non-option arguments: [a, b]", expected.getMessage()); } }
@Test public void testHelp() throws InvalidCommandException { try { ParsedOptions.from(new String[] {"--help"}, true); fail(); } catch (DisplayUsageException expected) { } }
@Test public void testVmNames_doNotAllowAt() { try { ParsedOptions.from(new String[] {"-m", "foo@bar"}, false); fail(); } catch (InvalidCommandException expected) { assertThat(expected).hasMessageThat().contains("'@'"); } }
@Test public void testDeviceName_doNotAllowAt() { try { ParsedOptions.from(new String[] {"-e", "foo@bar"}, false); fail(); } catch (InvalidCommandException expected) { assertThat(expected).hasMessageThat().contains("'@'"); } }
@Test public void testWorkerClasspaths_bothDefaultAndSpecificIllegal() { try { ParsedOptions.from( new String[] {"--worker-classpath=classpath", "--worker-classpath-jvm=classpath"}, false); fail(); } catch (InvalidCommandException expected) { } }