From 6158aae5b53d8b874dfe48a752955645b91cf45a Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Wed, 18 Dec 2013 14:04:04 -0600 Subject: [PATCH] Let's test the JCommander on a self instance. --- .../com/graywolf336/jail/TestJCommander.java | 27 ++++++++++++++----- .../jail/util/JCommanderExample.java | 20 -------------- 2 files changed, 20 insertions(+), 27 deletions(-) delete mode 100644 src/test/java/test/java/com/graywolf336/jail/util/JCommanderExample.java diff --git a/src/test/java/test/java/com/graywolf336/jail/TestJCommander.java b/src/test/java/test/java/com/graywolf336/jail/TestJCommander.java index 6f3c6a2..e36614f 100644 --- a/src/test/java/test/java/com/graywolf336/jail/TestJCommander.java +++ b/src/test/java/test/java/com/graywolf336/jail/TestJCommander.java @@ -1,21 +1,34 @@ package test.java.com.graywolf336.jail; +import java.util.ArrayList; +import java.util.List; + import junit.framework.Assert; import org.junit.Test; import com.beust.jcommander.JCommander; - -import test.java.com.graywolf336.jail.util.JCommanderExample; +import com.beust.jcommander.Parameter; public class TestJCommander { + @Parameter + public List parameters = new ArrayList(); + + @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 - public void testIt() { - JCommanderExample jce = new JCommanderExample(); + public void testJCommander() { String[] args = { "-log", "2", "-groups", "unit" }; - new JCommander(jce, args); + new JCommander(this, args); - Assert.assertEquals(jce.verbose.intValue(), 2); - Assert.assertEquals(jce.groups.toLowerCase(), "unit"); + Assert.assertEquals(this.verbose.intValue(), 2); + Assert.assertEquals(this.groups.toLowerCase(), "unit"); } } diff --git a/src/test/java/test/java/com/graywolf336/jail/util/JCommanderExample.java b/src/test/java/test/java/com/graywolf336/jail/util/JCommanderExample.java deleted file mode 100644 index 01d065b..0000000 --- a/src/test/java/test/java/com/graywolf336/jail/util/JCommanderExample.java +++ /dev/null @@ -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 parameters = new ArrayList(); - - @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; -}