Search in sources :

Example 6 with OptionSet

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"));
}
Also used : OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser) Test(org.junit.Test)

Example 7 with OptionSet

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"));
}
Also used : OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser) Test(org.junit.Test)

Example 8 with OptionSet

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());
}
Also used : OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser) Test(org.junit.Test)

Example 9 with OptionSet

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));
}
Also used : OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser) Test(org.junit.Test)

Example 10 with OptionSet

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());
}
Also used : OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser) Test(org.junit.Test)

Aggregations

OptionSet (joptsimple.OptionSet)121 OptionParser (joptsimple.OptionParser)93 File (java.io.File)40 OptionException (joptsimple.OptionException)22 IOException (java.io.IOException)20 List (java.util.List)16 Cluster (voldemort.cluster.Cluster)13 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)12 StoreDefinition (voldemort.store.StoreDefinition)12 ClusterMapper (voldemort.xml.ClusterMapper)10 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)9 FileNotFoundException (java.io.FileNotFoundException)6 VoldemortException (voldemort.VoldemortException)6 BufferedReader (java.io.BufferedReader)5 Properties (java.util.Properties)5 OptionSpec (joptsimple.OptionSpec)5 Node (voldemort.cluster.Node)5 ByteArray (voldemort.utils.ByteArray)5 Closer (com.google.common.io.Closer)4