use of joptsimple.OptionSet in project spring-framework by spring-projects.
the class JOptCommandLinePropertySourceTests method withRequiredArg_andMultipleArgsPresent_usingDelimiter.
@Test
public void withRequiredArg_andMultipleArgsPresent_usingDelimiter() {
OptionParser parser = new OptionParser();
parser.accepts("foo").withRequiredArg().withValuesSeparatedBy(',');
OptionSet options = parser.parse("--foo=bar,baz,biz");
CommandLinePropertySource<?> ps = new JOptCommandLinePropertySource(options);
assertEquals(Arrays.asList("bar", "baz", "biz"), ps.getOptionValues("foo"));
assertThat(ps.getProperty("foo"), equalTo("bar,baz,biz"));
}
use of joptsimple.OptionSet in project spring-framework by spring-projects.
the class JOptCommandLinePropertySourceTests method withRequiredArg_ofTypeEnum.
@Test
public void withRequiredArg_ofTypeEnum() {
OptionParser parser = new OptionParser();
parser.accepts("o1").withRequiredArg().ofType(OptionEnum.class);
OptionSet options = parser.parse("--o1=VAL_1");
PropertySource<?> ps = new JOptCommandLinePropertySource(options);
assertThat(ps.getProperty("o1"), equalTo("VAL_1"));
}
use of joptsimple.OptionSet in project spring-framework by spring-projects.
the class JOptCommandLinePropertySourceTests method withMissingOption.
@Test
public void withMissingOption() {
OptionParser parser = new OptionParser();
parser.accepts("foo").withRequiredArg().withValuesSeparatedBy(',');
// <-- no options whatsoever
OptionSet options = parser.parse();
PropertySource<?> ps = new JOptCommandLinePropertySource(options);
assertThat(ps.getProperty("foo"), nullValue());
}
use of joptsimple.OptionSet in project spring-framework by spring-projects.
the class JOptCommandLinePropertySourceTests method withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent.
@Test
public void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() {
OptionParser parser = new OptionParser();
parser.acceptsAll(Arrays.asList("o1", "option1")).withRequiredArg();
parser.accepts("o2");
OptionSet optionSet = parser.parse("--o1=v1", "--o2");
EnumerablePropertySource<?> ps = new JOptCommandLinePropertySource(optionSet);
assertThat(ps.containsProperty("nonOptionArgs"), is(false));
assertThat(ps.containsProperty("o1"), is(true));
assertThat(ps.containsProperty("o2"), is(true));
assertThat(ps.containsProperty("nonOptionArgs"), is(false));
assertThat(ps.getProperty("nonOptionArgs"), nullValue());
assertThat(ps.getPropertyNames().length, is(2));
}
use of joptsimple.OptionSet in project spring-framework by spring-projects.
the class JOptCommandLinePropertySourceTests method withNoArg.
@Test
public void withNoArg() {
OptionParser parser = new OptionParser();
parser.accepts("o1");
parser.accepts("o2");
OptionSet options = parser.parse("--o1");
PropertySource<?> ps = new JOptCommandLinePropertySource(options);
assertThat(ps.containsProperty("o1"), is(true));
assertThat(ps.containsProperty("o2"), is(false));
assertThat((String) ps.getProperty("o1"), equalTo(""));
assertThat(ps.getProperty("o2"), nullValue());
}
Aggregations