Let's test the JCommander on a self instance.
This commit is contained in:
parent
84dbfc3063
commit
6158aae5b5
@ -1,21 +1,34 @@
|
|||||||
package test.java.com.graywolf336.jail;
|
package test.java.com.graywolf336.jail;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.beust.jcommander.JCommander;
|
import com.beust.jcommander.JCommander;
|
||||||
|
import com.beust.jcommander.Parameter;
|
||||||
import test.java.com.graywolf336.jail.util.JCommanderExample;
|
|
||||||
|
|
||||||
public class TestJCommander {
|
public class TestJCommander {
|
||||||
|
@Parameter
|
||||||
|
public List<String> parameters = new ArrayList<String>();
|
||||||
|
|
||||||
|
@Parameter(names = { "-log", "-verbose" }, description = "Level of verbosity")
|
||||||
|
public Integer verbose = 1;
|
||||||
|
|
||||||
|
@Parameter(names = "-groups", description = "Comma-separated list of group names to be run")
|
||||||
|
public String groups;
|
||||||
|
|
||||||
|
@Parameter(names = "-debug", description = "Debug mode")
|
||||||
|
public boolean debug = false;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIt() {
|
public void testJCommander() {
|
||||||
JCommanderExample jce = new JCommanderExample();
|
|
||||||
String[] args = { "-log", "2", "-groups", "unit" };
|
String[] args = { "-log", "2", "-groups", "unit" };
|
||||||
new JCommander(jce, args);
|
new JCommander(this, args);
|
||||||
|
|
||||||
Assert.assertEquals(jce.verbose.intValue(), 2);
|
Assert.assertEquals(this.verbose.intValue(), 2);
|
||||||
Assert.assertEquals(jce.groups.toLowerCase(), "unit");
|
Assert.assertEquals(this.groups.toLowerCase(), "unit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package test.java.com.graywolf336.jail.util;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.beust.jcommander.Parameter;
|
|
||||||
|
|
||||||
public class JCommanderExample {
|
|
||||||
@Parameter
|
|
||||||
public List<String> parameters = new ArrayList<String>();
|
|
||||||
|
|
||||||
@Parameter(names = { "-log", "-verbose" }, description = "Level of verbosity")
|
|
||||||
public Integer verbose = 1;
|
|
||||||
|
|
||||||
@Parameter(names = "-groups", description = "Comma-separated list of group names to be run")
|
|
||||||
public String groups;
|
|
||||||
|
|
||||||
@Parameter(names = "-debug", description = "Debug mode")
|
|
||||||
public boolean debug = false;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user