This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-cli.git
The following commit(s) were added to refs/heads/master by this push: new 8bfccb26 Use JUnit 5 convention for @Test method visibility 8bfccb26 is described below commit 8bfccb2644aab0cf35b54c515b3c994bb4ccd381 Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat Jun 7 09:29:00 2025 -0400 Use JUnit 5 convention for @Test method visibility --- .../apache/commons/cli/AbstractParserTestCase.java | 132 ++++++++++----------- .../commons/cli/AlreadySelectedExceptionTest.java | 2 +- .../org/apache/commons/cli/ApplicationTest.java | 10 +- .../apache/commons/cli/ArgumentIsOptionTest.java | 6 +- .../org/apache/commons/cli/CommandLineTest.java | 20 ++-- .../org/apache/commons/cli/ConverterTests.java | 10 +- .../org/apache/commons/cli/DefaultParserTest.java | 4 +- .../commons/cli/DeprecatedAttributesTest.java | 8 +- .../commons/cli/DisablePartialMatchingTest.java | 4 +- .../org/apache/commons/cli/HelpFormatterTest.java | 60 +++++----- .../org/apache/commons/cli/OptionBuilderTest.java | 18 +-- .../org/apache/commons/cli/OptionGroupTest.java | 26 ++-- .../java/org/apache/commons/cli/OptionTest.java | 42 +++---- .../apache/commons/cli/OptionValidatorTest.java | 2 +- .../java/org/apache/commons/cli/OptionsTest.java | 30 ++--- .../org/apache/commons/cli/ParseExceptionTest.java | 2 +- .../commons/cli/PatternOptionBuilderTest.java | 20 ++-- .../java/org/apache/commons/cli/SolrCliTest.java | 2 +- .../org/apache/commons/cli/SolrCreateToolTest.java | 4 +- .../org/apache/commons/cli/TypeHandlerTest.java | 20 ++-- .../cli/UnrecognizedOptionExceptionTest.java | 2 +- src/test/java/org/apache/commons/cli/UtilTest.java | 4 +- .../java/org/apache/commons/cli/ValueTest.java | 20 ++-- .../java/org/apache/commons/cli/ValuesTest.java | 14 +-- .../org/apache/commons/cli/bug/BugCLI133Test.java | 2 +- .../org/apache/commons/cli/bug/BugCLI13Test.java | 2 +- .../org/apache/commons/cli/bug/BugCLI148Test.java | 4 +- .../org/apache/commons/cli/bug/BugCLI162Test.java | 8 +- .../org/apache/commons/cli/bug/BugCLI18Test.java | 2 +- .../org/apache/commons/cli/bug/BugCLI252Test.java | 4 +- .../org/apache/commons/cli/bug/BugCLI265Test.java | 6 +- .../org/apache/commons/cli/bug/BugCLI266Test.java | 4 +- .../org/apache/commons/cli/bug/BugCLI312Test.java | 6 +- .../org/apache/commons/cli/bug/BugCLI325Test.java | 2 +- .../org/apache/commons/cli/bug/BugCLI71Test.java | 8 +- .../java/org/apache/commons/cli/bug/BugsTest.java | 26 ++-- .../commons/cli/example/AptHelpAppendableTest.java | 14 +-- .../cli/example/XhtmlHelpAppendableTest.java | 12 +- .../apache/commons/cli/help/HelpFormatterTest.java | 26 ++-- .../commons/cli/help/OptionFormatterTest.java | 24 ++-- .../commons/cli/help/TextHelpAppendableTest.java | 32 ++--- .../apache/commons/cli/help/TextStyleTests.java | 2 +- .../java/org/apache/commons/cli/help/UtilTest.java | 4 +- 43 files changed, 325 insertions(+), 325 deletions(-) diff --git a/src/test/java/org/apache/commons/cli/AbstractParserTestCase.java b/src/test/java/org/apache/commons/cli/AbstractParserTestCase.java index bdac48cd..35450fd2 100644 --- a/src/test/java/org/apache/commons/cli/AbstractParserTestCase.java +++ b/src/test/java/org/apache/commons/cli/AbstractParserTestCase.java @@ -71,7 +71,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testAmbiguousLongWithoutEqualSingleDash() throws Exception { + void testAmbiguousLongWithoutEqualSingleDash() throws Exception { final String[] args = { "-b", "-foobar" }; final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("foo").hasOptionalArg().create('f')); @@ -83,7 +83,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testAmbiguousLongWithoutEqualSingleDash2() throws Exception { + void testAmbiguousLongWithoutEqualSingleDash2() throws Exception { final String[] args = { "-b", "-foobar" }; final Options options = new Options(); options.addOption(Option.builder().longOpt("foo").option("f").optionalArg(true).build()); @@ -95,7 +95,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testAmbiguousPartialLongOption1() throws Exception { + void testAmbiguousPartialLongOption1() throws Exception { final String[] args = { "--ver" }; final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("version").create()); @@ -107,7 +107,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testAmbiguousPartialLongOption2() throws Exception { + void testAmbiguousPartialLongOption2() throws Exception { final String[] args = { "-ver" }; final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("version").create()); @@ -119,7 +119,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testAmbiguousPartialLongOption3() throws Exception { + void testAmbiguousPartialLongOption3() throws Exception { final String[] args = { "--ver=1" }; final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("version").create()); @@ -131,7 +131,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testAmbiguousPartialLongOption4() throws Exception { + void testAmbiguousPartialLongOption4() throws Exception { final String[] args = { "-ver=1" }; final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("version").create()); @@ -143,14 +143,14 @@ public abstract class AbstractParserTestCase { } @Test - public void testArgumentStartingWithHyphen() throws Exception { + void testArgumentStartingWithHyphen() throws Exception { final String[] args = { "-b", "-foo" }; final CommandLine cl = parser.parse(options, args); assertEquals("-foo", cl.getOptionValue("b")); } @Test - public void testBursting() throws Exception { + void testBursting() throws Exception { final String[] args = { "-acbtoast", "foo", "bar" }; final CommandLine cl = parser.parse(options, args); assertTrue(cl.hasOption("a"), "Confirm -a is set"); @@ -161,7 +161,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testDoubleDash1() throws Exception { + void testDoubleDash1() throws Exception { final String[] args = { "--copt", "--", "-b", "toast" }; final CommandLine cl = parser.parse(options, args); assertTrue(cl.hasOption("c"), "Confirm -c is set"); @@ -170,7 +170,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testDoubleDash2() throws Exception { + void testDoubleDash2() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.hasArg().create('n')); options.addOption(OptionBuilder.create('m')); @@ -180,21 +180,21 @@ public abstract class AbstractParserTestCase { } @Test - public void testLongOptionQuoteHandling() throws Exception { + void testLongOptionQuoteHandling() throws Exception { final String[] args = { "--bfile", "\"quoted string\"" }; final CommandLine cl = parser.parse(options, args); assertEquals("quoted string", cl.getOptionValue("b"), "Confirm --bfile \"arg\" strips quotes"); } @Test - public void testLongOptionWithEqualsQuoteHandling() throws Exception { + void testLongOptionWithEqualsQuoteHandling() throws Exception { final String[] args = { "--bfile=\"quoted string\"" }; final CommandLine cl = parser.parse(options, args); assertEquals("quoted string", cl.getOptionValue("b"), "Confirm --bfile=\"arg\" strips quotes"); } @Test - public void testLongWithEqualDoubleDash() throws Exception { + void testLongWithEqualDoubleDash() throws Exception { final String[] args = { "--foo=bar" }; final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("foo").hasArg().create('f')); @@ -203,7 +203,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testLongWithEqualSingleDash() throws Exception { + void testLongWithEqualSingleDash() throws Exception { final String[] args = { "-foo=bar" }; final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("foo").hasArg().create('f')); @@ -212,7 +212,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testLongWithoutEqualDoubleDash() throws Exception { + void testLongWithoutEqualDoubleDash() throws Exception { final String[] args = { "--foobar" }; final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("foo").hasArg().create('f')); @@ -221,7 +221,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testLongWithoutEqualSingleDash() throws Exception { + void testLongWithoutEqualSingleDash() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("foo").hasArg().create('f')); final CommandLine cl = parser.parse(options, new String[] { "-foobar" }); @@ -229,7 +229,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testLongWithUnexpectedArgument1() throws Exception { + void testLongWithUnexpectedArgument1() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("foo").create('f')); final UnrecognizedOptionException e = assertThrows(UnrecognizedOptionException.class, () -> parser.parse(options, new String[] { "--foo=bar" })); @@ -237,7 +237,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testLongWithUnexpectedArgument2() throws Exception { + void testLongWithUnexpectedArgument2() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("foo").create('f')); final UnrecognizedOptionException e = assertThrows(UnrecognizedOptionException.class, () -> parser.parse(options, new String[] { "-foobar" })); @@ -245,20 +245,20 @@ public abstract class AbstractParserTestCase { } @Test - public void testMissingArg() throws Exception { + void testMissingArg() throws Exception { final MissingArgumentException e = assertThrows(MissingArgumentException.class, () -> parser.parse(options, new String[] { "-b" })); assertEquals("b", e.getOption().getOpt(), "option missing an argument"); } @Test - public void testMissingArgWithBursting() throws Exception { + void testMissingArgWithBursting() throws Exception { final String[] args = { "-acb" }; final MissingArgumentException e = assertThrows(MissingArgumentException.class, () -> parser.parse(options, args)); assertEquals("b", e.getOption().getOpt(), "option missing an argument"); } @Test - public void testMissingRequiredGroup() throws Exception { + void testMissingRequiredGroup() throws Exception { final OptionGroup group = new OptionGroup(); group.addOption(OptionBuilder.create("a")); group.addOption(OptionBuilder.create("b")); @@ -272,7 +272,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testMissingRequiredOption() { + void testMissingRequiredOption() { final String[] args = { "-a" }; final Options options = new Options(); options.addOption("a", "enable-a", false, null); @@ -283,7 +283,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testMissingRequiredOptions() { + void testMissingRequiredOptions() { final String[] args = { "-a" }; final Options options = new Options(); options.addOption("a", "enable-a", false, null); @@ -296,7 +296,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testMultiple() throws Exception { + void testMultiple() throws Exception { final String[] args = { "-c", "foobar", "-b", "toast" }; CommandLine cl = parser.parse(options, args, true); assertTrue(cl.hasOption("c"), "Confirm -c is set"); @@ -310,7 +310,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testMultipleWithLong() throws Exception { + void testMultipleWithLong() throws Exception { final String[] args = { "--copt", "foobar", "--bfile", "toast" }; CommandLine cl = parser.parse(options, args, true); assertTrue(cl.hasOption("c"), "Confirm -c is set"); @@ -324,7 +324,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testMultipleWithNull() throws Exception { + void testMultipleWithNull() throws Exception { final String[] args = { null, "-c", null, "foobar", null, "-b", null, "toast", null }; CommandLine cl = parser.parse(options, args, true); assertTrue(cl.hasOption("c"), "Confirm -c is set"); @@ -338,14 +338,14 @@ public abstract class AbstractParserTestCase { } @Test - public void testNegativeArgument() throws Exception { + void testNegativeArgument() throws Exception { final String[] args = { "-b", "-1" }; final CommandLine cl = parser.parse(options, args); assertEquals("-1", cl.getOptionValue("b")); } @Test - public void testNegativeOption() throws Exception { + void testNegativeOption() throws Exception { final String[] args = { "-b", "-1" }; options.addOption("1", false, null); final CommandLine cl = parser.parse(options, args); @@ -353,7 +353,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testOptionalArgsOptionBuilder() throws Exception { + void testOptionalArgsOptionBuilder() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.hasOptionalArgs(2).create('i')); final Properties properties = new Properties(); @@ -377,7 +377,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testOptionalArgsOptionDotBuilder() throws Exception { + void testOptionalArgsOptionDotBuilder() throws Exception { final Options options = new Options(); options.addOption(Option.builder("i").numberOfArgs(2).optionalArg(true).build()); final Properties properties = new Properties(); @@ -404,7 +404,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testOptionAndRequiredOption() throws Exception { + void testOptionAndRequiredOption() throws Exception { final String[] args = { "-a", "-b", "file" }; final Options options = new Options(); @@ -420,7 +420,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testOptionGroup() throws Exception { + void testOptionGroup() throws Exception { final OptionGroup group = new OptionGroup(); assertFalse(group.isSelected()); group.addOption(OptionBuilder.create("a")); @@ -436,7 +436,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testOptionGroupLong() throws Exception { + void testOptionGroupLong() throws Exception { final OptionGroup group = new OptionGroup(); group.addOption(OptionBuilder.withLongOpt("foo").create()); group.addOption(OptionBuilder.withLongOpt("bar").create()); @@ -452,7 +452,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testPartialLongOptionSingleDash() throws Exception { + void testPartialLongOptionSingleDash() throws Exception { final String[] args = { "-ver" }; final Options options = new Options(); @@ -466,7 +466,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testPropertiesOption1() throws Exception { + void testPropertiesOption1() throws Exception { final String[] args = { "-Jsource=1.5", "-J", "target", "1.5", "foo" }; final Options options = new Options(); @@ -488,7 +488,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testPropertiesOption2() throws Exception { + void testPropertiesOption2() throws Exception { final String[] args = { "-Dparam1", "-Dparam2=value2", "-D" }; final Options options = new Options(); @@ -507,7 +507,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testPropertyOptionFlags() throws Exception { + void testPropertyOptionFlags() throws Exception { final Options options = new Options(); options.addOption("a", false, "toggle -a"); options.addOption("c", "c", false, "toggle -c"); @@ -562,7 +562,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testPropertyOptionGroup() throws Exception { + void testPropertyOptionGroup() throws Exception { final Options options = new Options(); final OptionGroup group1 = new OptionGroup(); @@ -590,7 +590,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testPropertyOptionMultipleValues() throws Exception { + void testPropertyOptionMultipleValues() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.hasArgs().withValueSeparator(',').create('k')); @@ -604,7 +604,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testPropertyOptionRequired() throws Exception { + void testPropertyOptionRequired() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.isRequired().create("f")); @@ -616,7 +616,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testPropertyOptionSingularValue() throws Exception { + void testPropertyOptionSingularValue() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.hasOptionalArgs(2).withLongOpt("hide").create()); @@ -630,7 +630,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testPropertyOptionUnexpected() throws Exception { + void testPropertyOptionUnexpected() throws Exception { final Options options = new Options(); final Properties properties = new Properties(); properties.setProperty("f", "true"); @@ -638,7 +638,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testPropertyOverrideValues() throws Exception { + void testPropertyOverrideValues() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.hasOptionalArgs(2).create('i')); options.addOption(OptionBuilder.hasOptionalArgs().create('j')); @@ -657,7 +657,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testReuseOptionsTwice() throws Exception { + void testReuseOptionsTwice() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.isRequired().create('v')); // first parsing @@ -667,19 +667,19 @@ public abstract class AbstractParserTestCase { } @Test - public void testShortOptionConcatenatedQuoteHandling() throws Exception { + void testShortOptionConcatenatedQuoteHandling() throws Exception { final CommandLine cl = parser.parse(options, new String[] { "-b\"quoted string\"" }); assertEquals("quoted string", cl.getOptionValue("b"), "Confirm -b\"arg\" strips quotes"); } @Test - public void testShortOptionQuoteHandling() throws Exception { + void testShortOptionQuoteHandling() throws Exception { final CommandLine cl = parser.parse(options, new String[] { "-b", "\"quoted string\"" }); assertEquals("quoted string", cl.getOptionValue("b"), "Confirm -b \"arg\" strips quotes"); } @Test - public void testShortWithEqual() throws Exception { + void testShortWithEqual() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("foo").hasArg().create('f')); final CommandLine cl = parser.parse(options, new String[] { "-f=bar" }); @@ -687,7 +687,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testShortWithoutEqual() throws Exception { + void testShortWithoutEqual() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("foo").hasArg().create('f')); final CommandLine cl = parser.parse(options, new String[] { "-fbar" }); @@ -695,7 +695,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testShortWithUnexpectedArgument() throws Exception { + void testShortWithUnexpectedArgument() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("foo").create('f')); final UnrecognizedOptionException e = assertThrows(UnrecognizedOptionException.class, () -> parser.parse(options, new String[] { "-f=bar" })); @@ -703,7 +703,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testSimpleLong() throws Exception { + void testSimpleLong() throws Exception { final CommandLine cl = parser.parse(options, new String[] { "--enable-a", "--bfile", "toast", "foo", "bar" }); assertTrue(cl.hasOption("a"), "Confirm -a is set"); assertTrue(cl.hasOption("b"), "Confirm -b is set"); @@ -713,7 +713,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testSimpleShort() throws Exception { + void testSimpleShort() throws Exception { final CommandLine cl = parser.parse(options, new String[] { "-a", "-b", "toast", "foo", "bar" }); assertTrue(cl.hasOption("a"), "Confirm -a is set"); assertTrue(cl.hasOption("b"), "Confirm -b is set"); @@ -722,7 +722,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testSingleDash() throws Exception { + void testSingleDash() throws Exception { final CommandLine cl = parser.parse(options, new String[] { "--copt", "-b", "-", "-a", "-" }); assertTrue(cl.hasOption("a"), "Confirm -a is set"); assertTrue(cl.hasOption("b"), "Confirm -b is set"); @@ -732,7 +732,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testStopAtExpectedArg() throws Exception { + void testStopAtExpectedArg() throws Exception { final String[] args = { "-b", "foo" }; final CommandLine cl = parser.parse(options, args, true); assertTrue(cl.hasOption('b'), "Confirm -b is set"); @@ -741,7 +741,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testStopAtNonOptionLong() throws Exception { + void testStopAtNonOptionLong() throws Exception { final String[] args = { "--zop==1", "-abtoast", "--b=bar" }; final CommandLine cl = parser.parse(options, args, true); assertFalse(cl.hasOption("a"), "Confirm -a is not set"); @@ -750,21 +750,21 @@ public abstract class AbstractParserTestCase { } @Test - public void testStopAtNonOptionShort() throws Exception { + void testStopAtNonOptionShort() throws Exception { final CommandLine cl = parser.parse(options, new String[] { "-z", "-a", "-btoast" }, true); assertFalse(cl.hasOption("a"), "Confirm -a is not set"); assertEquals(3, cl.getArgList().size(), "Confirm 3 extra args: " + cl.getArgList().size()); } @Test - public void testStopAtUnexpectedArg() throws Exception { + void testStopAtUnexpectedArg() throws Exception { final CommandLine cl = parser.parse(options, new String[] { "-c", "foober", "-b", "toast" }, true); assertTrue(cl.hasOption("c"), "Confirm -c is set"); assertEquals(3, cl.getArgList().size(), "Confirm 3 extra args: " + cl.getArgList().size()); } @Test - public void testStopBursting() throws Exception { + void testStopBursting() throws Exception { final CommandLine cl = parser.parse(options, new String[] { "-azc" }, true); assertTrue(cl.hasOption("a"), "Confirm -a is set"); assertFalse(cl.hasOption("c"), "Confirm -c is not set"); @@ -773,7 +773,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testStopBursting2() throws Exception { + void testStopBursting2() throws Exception { CommandLine cl = parser.parse(options, new String[] { "-c", "foobar", "-btoast" }, true); assertTrue(cl.hasOption("c"), "Confirm -c is set"); assertEquals(2, cl.getArgList().size(), "Confirm 2 extra args: " + cl.getArgList().size()); @@ -786,7 +786,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testUnambiguousPartialLongOption1() throws Exception { + void testUnambiguousPartialLongOption1() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("version").create()); options.addOption(OptionBuilder.withLongOpt("help").create()); @@ -795,7 +795,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testUnambiguousPartialLongOption2() throws Exception { + void testUnambiguousPartialLongOption2() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("version").create()); options.addOption(OptionBuilder.withLongOpt("help").create()); @@ -804,7 +804,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testUnambiguousPartialLongOption3() throws Exception { + void testUnambiguousPartialLongOption3() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("verbose").hasOptionalArg().create()); options.addOption(OptionBuilder.withLongOpt("help").create()); @@ -814,7 +814,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testUnambiguousPartialLongOption4() throws Exception { + void testUnambiguousPartialLongOption4() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("verbose").hasOptionalArg().create()); options.addOption(OptionBuilder.withLongOpt("help").create()); @@ -824,7 +824,7 @@ public abstract class AbstractParserTestCase { } @Test - public void testUnlimitedArgs() throws Exception { + void testUnlimitedArgs() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.hasArgs().create("e")); options.addOption(OptionBuilder.hasArgs().create("f")); @@ -836,21 +836,21 @@ public abstract class AbstractParserTestCase { } @Test - public void testUnrecognizedOption() throws Exception { + void testUnrecognizedOption() throws Exception { final UnrecognizedOptionException e = assertThrows(UnrecognizedOptionException.class, () -> parser.parse(options, new String[] { "-a", "-d", "-b", "toast", "foo", "bar" })); assertEquals("-d", e.getOption()); } @Test - public void testUnrecognizedOptionWithBursting() throws Exception { + void testUnrecognizedOptionWithBursting() throws Exception { final UnrecognizedOptionException e = assertThrows(UnrecognizedOptionException.class, () -> parser.parse(options, new String[] { "-adbtoast", "foo", "bar" })); assertEquals("-adbtoast", e.getOption()); } @Test - public void testWithRequiredOption() throws Exception { + void testWithRequiredOption() throws Exception { final String[] args = { "-b", "file" }; final Options options = new Options(); options.addOption("a", "enable-a", false, null); diff --git a/src/test/java/org/apache/commons/cli/AlreadySelectedExceptionTest.java b/src/test/java/org/apache/commons/cli/AlreadySelectedExceptionTest.java index 547d1a69..b4ffbb0c 100644 --- a/src/test/java/org/apache/commons/cli/AlreadySelectedExceptionTest.java +++ b/src/test/java/org/apache/commons/cli/AlreadySelectedExceptionTest.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test; public class AlreadySelectedExceptionTest { @Test - public void testConstructor() { + void testConstructor() { assertEquals("a", new AlreadySelectedException("a").getMessage()); assertNull(new AlreadySelectedException("a").getOption()); final Option option = new Option("a", "d"); diff --git a/src/test/java/org/apache/commons/cli/ApplicationTest.java b/src/test/java/org/apache/commons/cli/ApplicationTest.java index 6e3198e4..37d803cd 100644 --- a/src/test/java/org/apache/commons/cli/ApplicationTest.java +++ b/src/test/java/org/apache/commons/cli/ApplicationTest.java @@ -44,7 +44,7 @@ public class ApplicationTest { * Ant test */ @Test - public void testAnt() throws Exception { + void testAnt() throws Exception { // use the GNU parser final CommandLineParser parser = new GnuParser(); final Options options = new Options(); @@ -86,7 +86,7 @@ public class ApplicationTest { } @Test - public void testGroovy() throws Exception { + void testGroovy() throws Exception { final Options options = new Options(); //@formatter:off @@ -156,7 +156,7 @@ public class ApplicationTest { } @Test - public void testLs() throws Exception { + void testLs() throws Exception { // create the command line parser final CommandLineParser parser = new PosixParser(); final Options options = new Options(); @@ -186,7 +186,7 @@ public class ApplicationTest { * author Slawek Zachcial */ @Test - public void testMan() { + void testMan() { final String cmdLine = "man [-c|-f|-k|-w|-tZT device] [-adlhu7V] [-Mpath] [-Ppager] [-Slist] [-msystem] [-pstring] [-Llocale] [-eextension] [section]" + " page ..."; //@formatter:off @@ -279,7 +279,7 @@ public class ApplicationTest { * Real world test with long and short options. */ @Test - public void testNLT() throws Exception { + void testNLT() throws Exception { final Option help = new Option("h", "help", false, "print this message"); final Option version = new Option("v", "version", false, "print version information"); final Option newRun = new Option("n", "new", false, "Create NLT cache entries only for new items"); diff --git a/src/test/java/org/apache/commons/cli/ArgumentIsOptionTest.java b/src/test/java/org/apache/commons/cli/ArgumentIsOptionTest.java index a35b30d0..b16f9aa0 100644 --- a/src/test/java/org/apache/commons/cli/ArgumentIsOptionTest.java +++ b/src/test/java/org/apache/commons/cli/ArgumentIsOptionTest.java @@ -37,7 +37,7 @@ public class ArgumentIsOptionTest { } @Test - public void testOption() throws Exception { + void testOption() throws Exception { final String[] args = {"-p"}; final CommandLine cl = parser.parse(options, args); @@ -47,7 +47,7 @@ public class ArgumentIsOptionTest { } @Test - public void testOptionAndOptionWithArgument() throws Exception { + void testOptionAndOptionWithArgument() throws Exception { final String[] args = {"-p", "-attr", "p"}; final CommandLine cl = parser.parse(options, args); @@ -58,7 +58,7 @@ public class ArgumentIsOptionTest { } @Test - public void testOptionWithArgument() throws Exception { + void testOptionWithArgument() throws Exception { final String[] args = {"-attr", "p"}; final CommandLine cl = parser.parse(options, args); diff --git a/src/test/java/org/apache/commons/cli/CommandLineTest.java b/src/test/java/org/apache/commons/cli/CommandLineTest.java index 5fb53529..e7ad12ff 100644 --- a/src/test/java/org/apache/commons/cli/CommandLineTest.java +++ b/src/test/java/org/apache/commons/cli/CommandLineTest.java @@ -231,7 +231,7 @@ public class CommandLineTest { } @Test - public void testBadGetParsedOptionValue() throws Exception { + void testBadGetParsedOptionValue() throws Exception { final Options options = new Options(); options.addOption(Option.builder("i").hasArg().type(Number.class).build()); @@ -245,7 +245,7 @@ public class CommandLineTest { } @Test - public void testBuilderBuild() { + void testBuilderBuild() { // @formatter:off final CommandLine cmd = CommandLine.builder() .addArg("foo") @@ -259,7 +259,7 @@ public class CommandLineTest { } @Test - public void testBuilderGet() { + void testBuilderGet() { // @formatter:off final CommandLine cmd = CommandLine.builder() .addArg("foo") @@ -273,7 +273,7 @@ public class CommandLineTest { } @Test - public void testBuilderNullArgs() { + void testBuilderNullArgs() { final CommandLine.Builder builder = CommandLine.builder(); builder.addArg(null).addArg(null); builder.addOption(Option.builder("T").build()); @@ -284,7 +284,7 @@ public class CommandLineTest { } @Test - public void testBuilderNullOption() { + void testBuilderNullOption() { final CommandLine.Builder builder = CommandLine.builder(); builder.addArg("foo").addArg("bar"); builder.addOption(null); @@ -298,7 +298,7 @@ public class CommandLineTest { } @Test - public void testGetOptionProperties() throws Exception { + void testGetOptionProperties() throws Exception { final String[] args = {"-Dparam1=value1", "-Dparam2=value2", "-Dparam3", "-Dparam4=value4", "-D", "--property", "foo=bar"}; final Options options = new Options(); @@ -320,7 +320,7 @@ public class CommandLineTest { } @Test - public void testGetOptionPropertiesWithOption() throws Exception { + void testGetOptionPropertiesWithOption() throws Exception { final String[] args = {"-Dparam1=value1", "-Dparam2=value2", "-Dparam3", "-Dparam4=value4", "-D", "--property", "foo=bar"}; final Options options = new Options(); @@ -344,7 +344,7 @@ public class CommandLineTest { } @Test - public void testGetOptionsBuilder() { + void testGetOptionsBuilder() { final CommandLine cmd = CommandLine.builder().build(); assertNotNull(cmd.getOptions()); assertEquals(0, cmd.getOptions().length); @@ -358,7 +358,7 @@ public class CommandLineTest { } @Test - public void testGetOptionsCtor() { + void testGetOptionsCtor() { final CommandLine cmd = new CommandLine(); assertNotNull(cmd.getOptions()); assertEquals(0, cmd.getOptions().length); @@ -1006,7 +1006,7 @@ public class CommandLineTest { } @Test - public void testNullOption() throws Exception { + void testNullOption() throws Exception { final Options options = new Options(); final Option optI = Option.builder("i").hasArg().type(Number.class).build(); final Option optF = Option.builder("f").hasArg().build(); diff --git a/src/test/java/org/apache/commons/cli/ConverterTests.java b/src/test/java/org/apache/commons/cli/ConverterTests.java index 231f60f7..bf65447e 100644 --- a/src/test/java/org/apache/commons/cli/ConverterTests.java +++ b/src/test/java/org/apache/commons/cli/ConverterTests.java @@ -61,7 +61,7 @@ public class ConverterTests { } @Test - public void testClass() throws Exception { + void testClass() throws Exception { assertNotNull(Converter.CLASS.apply(this.getClass().getName()), this.getClass().getName()); assertNotNull(Converter.CLASS.apply(this.getClass().getCanonicalName()), this.getClass().getCanonicalName()); @@ -74,7 +74,7 @@ public class ConverterTests { } @Test - public void testDate() throws Exception { + void testDate() throws Exception { assertThrows(java.text.ParseException.class, () -> Converter.DATE.apply("whatever")); /* @@ -92,7 +92,7 @@ public class ConverterTests { } @Test - public void testFile() throws Exception { + void testFile() throws Exception { final URL url = this.getClass().getClassLoader().getResource("./org/apache/commons/cli/existing-readable.file"); final String fileName = url.toString().substring("file:".length()); assertNotNull(Converter.FILE.apply(fileName)); @@ -109,7 +109,7 @@ public class ConverterTests { } @Test - public void testObject() throws Exception { + void testObject() throws Exception { assertNotNull(Converter.OBJECT.apply(this.getClass().getName()), this.getClass().getName()); assertNotNull(Converter.OBJECT.apply(this.getClass().getCanonicalName()), this.getClass().getCanonicalName()); assertThrows(ClassNotFoundException.class, () -> Converter.OBJECT.apply(this.getClass().getSimpleName()), @@ -121,7 +121,7 @@ public class ConverterTests { } @Test - public void testUrl() throws Exception { + void testUrl() throws Exception { assertEquals(new URL("http://apache.org"), Converter.URL.apply("http://apache.org")); assertThrows(java.net.MalformedURLException.class, () -> Converter.URL.apply("foo.bar")); } diff --git a/src/test/java/org/apache/commons/cli/DefaultParserTest.java b/src/test/java/org/apache/commons/cli/DefaultParserTest.java index 61f616d7..322cd0ef 100644 --- a/src/test/java/org/apache/commons/cli/DefaultParserTest.java +++ b/src/test/java/org/apache/commons/cli/DefaultParserTest.java @@ -158,7 +158,7 @@ public class DefaultParserTest extends AbstractParserTestCase { } @Test - public void testBuilder() { + void testBuilder() { // @formatter:off final Builder builder = DefaultParser.builder() .setStripLeadingAndTrailingQuotes(false) @@ -172,7 +172,7 @@ public class DefaultParserTest extends AbstractParserTestCase { } @Test - public void testDeprecated() throws ParseException { + void testDeprecated() throws ParseException { final Set<Option> handler = new HashSet<>(); parser = DefaultParser.builder().setDeprecatedHandler(handler::add).build(); final Option opt1 = Option.builder().option("d1").deprecated().build(); diff --git a/src/test/java/org/apache/commons/cli/DeprecatedAttributesTest.java b/src/test/java/org/apache/commons/cli/DeprecatedAttributesTest.java index 4182e6d3..29e72352 100644 --- a/src/test/java/org/apache/commons/cli/DeprecatedAttributesTest.java +++ b/src/test/java/org/apache/commons/cli/DeprecatedAttributesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; public class DeprecatedAttributesTest { @Test - public void testBuilderNonDefaults() { + void testBuilderNonDefaults() { // @formatter:off final DeprecatedAttributes value = DeprecatedAttributes.builder() .setDescription("Use Bar instead!") @@ -38,7 +38,7 @@ public class DeprecatedAttributesTest { } @Test - public void testBuilderNonDefaultsToString() { + void testBuilderNonDefaultsToString() { // @formatter:off assertEquals("Deprecated for removal since 2.0: Use Bar instead!", DeprecatedAttributes.builder() .setDescription("Use Bar instead!") @@ -61,7 +61,7 @@ public class DeprecatedAttributesTest { } @Test - public void testDefaultBuilder() { + void testDefaultBuilder() { final DeprecatedAttributes defaultValue = DeprecatedAttributes.builder().get(); assertEquals(DeprecatedAttributes.DEFAULT.getDescription(), defaultValue.getDescription()); assertEquals(DeprecatedAttributes.DEFAULT.getSince(), defaultValue.getSince()); @@ -69,7 +69,7 @@ public class DeprecatedAttributesTest { } @Test - public void testDefaultToString() { + void testDefaultToString() { assertEquals("Deprecated", DeprecatedAttributes.DEFAULT.toString()); } } diff --git a/src/test/java/org/apache/commons/cli/DisablePartialMatchingTest.java b/src/test/java/org/apache/commons/cli/DisablePartialMatchingTest.java index 0c16bb44..e0c5f4a5 100644 --- a/src/test/java/org/apache/commons/cli/DisablePartialMatchingTest.java +++ b/src/test/java/org/apache/commons/cli/DisablePartialMatchingTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; public class DisablePartialMatchingTest { @Test - public void testDisablePartialMatching() throws Exception { + void testDisablePartialMatching() throws Exception { final CommandLineParser parser = new DefaultParser(false); final Options options = new Options(); @@ -41,7 +41,7 @@ public class DisablePartialMatchingTest { } @Test - public void testRegularPartialMatching() throws Exception { + void testRegularPartialMatching() throws Exception { final CommandLineParser parser = new DefaultParser(); final Options options = new Options(); diff --git a/src/test/java/org/apache/commons/cli/HelpFormatterTest.java b/src/test/java/org/apache/commons/cli/HelpFormatterTest.java index 2b6d3fe7..585aa6fb 100644 --- a/src/test/java/org/apache/commons/cli/HelpFormatterTest.java +++ b/src/test/java/org/apache/commons/cli/HelpFormatterTest.java @@ -86,7 +86,7 @@ public class HelpFormatterTest { } @Test - public void testAccessors() { + void testAccessors() { final HelpFormatter formatter = new HelpFormatter(); formatter.setArgName("argname"); @@ -115,7 +115,7 @@ public class HelpFormatterTest { } @Test - public void testAutomaticUsage() { + void testAutomaticUsage() { final HelpFormatter hf = new HelpFormatter(); Options options; String expected = "usage: app [-a]"; @@ -137,7 +137,7 @@ public class HelpFormatterTest { } @Test - public void testDefaultArgName() { + void testDefaultArgName() { final Option option = Option.builder("f").hasArg().required(true).build(); final Options options = new Options(); @@ -153,7 +153,7 @@ public class HelpFormatterTest { } @Test - public void testFindWrapPos() { + void testFindWrapPos() { final HelpFormatter hf = new HelpFormatter(); String text = "This is a test."; @@ -180,7 +180,7 @@ public class HelpFormatterTest { } @Test - public void testHeaderStartingWithLineSeparator0() { + void testHeaderStartingWithLineSeparator0() { // related to Bugzilla #21215 final Options options = new Options(); final HelpFormatter formatter = new HelpFormatter(); @@ -200,7 +200,7 @@ public class HelpFormatterTest { } @Test - public void testHeaderStartingWithLineSeparator1() { + void testHeaderStartingWithLineSeparator1() { // related to Bugzilla #21215 final Options options = new Options(); final String header = EOL + "Header"; @@ -272,7 +272,7 @@ public class HelpFormatterTest { } @Test - public void testHelpWithLongOptSeparator() { + void testHelpWithLongOptSeparator() { final Options options = new Options(); options.addOption("f", true, "the file"); options.addOption(Option.builder("s").longOpt("size").desc("the size").hasArg().argName("SIZE").build()); @@ -300,7 +300,7 @@ public class HelpFormatterTest { } @Test - public void testIndentedHeaderAndFooter() { + void testIndentedHeaderAndFooter() { // related to CLI-207 final Options options = new Options(); final HelpFormatter formatter = new HelpFormatter(); @@ -321,7 +321,7 @@ public class HelpFormatterTest { } @Test - public void testOptionWithoutShortFormat() { + void testOptionWithoutShortFormat() { // related to Bugzilla #19383 (CLI-67) final Options options = new Options(); options.addOption(new Option("a", "aaa", false, "aaaaaaa")); @@ -342,7 +342,7 @@ public class HelpFormatterTest { } @Test - public void testOptionWithoutShortFormat2() { + void testOptionWithoutShortFormat2() { // related to Bugzilla #27635 (CLI-26) final Option help = new Option("h", "help", false, "print this message"); final Option version = new Option("v", "version", false, "print version information"); @@ -432,7 +432,7 @@ public class HelpFormatterTest { } @Test - public void testPrintHelpNewlineFooter() { + void testPrintHelpNewlineFooter() { final HelpFormatter formatter = new HelpFormatter(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final PrintWriter pw = new PrintWriter(out); @@ -459,7 +459,7 @@ public class HelpFormatterTest { } @Test - public void testPrintHelpNewlineHeader() { + void testPrintHelpNewlineHeader() { final HelpFormatter formatter = new HelpFormatter(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final PrintWriter pw = new PrintWriter(out); @@ -486,7 +486,7 @@ public class HelpFormatterTest { } @Test - public void testPrintHelpWithEmptySyntax() { + void testPrintHelpWithEmptySyntax() { final HelpFormatter formatter = new HelpFormatter(); assertThrows(IllegalArgumentException.class, () -> formatter.printHelp(null, new Options()), "null command line syntax should be rejected"); assertThrows(IllegalArgumentException.class, () -> formatter.printHelp(null, new Options(), true), "null command line syntax should be rejected"); @@ -496,7 +496,7 @@ public class HelpFormatterTest { } @Test - public void testPrintHelpWithSince() { + void testPrintHelpWithSince() { final String [] expected = {"usage: Command syntax", "Header", "Options Since Description", " -n,--no-since - Description for n", " -W,--with-since 1.19.0 Descripton for W", "footer"}; final Options options = new Options() @@ -512,7 +512,7 @@ public class HelpFormatterTest { } @Test - public void testPrintOptionGroupUsage() { + void testPrintOptionGroupUsage() { final OptionGroup group = new OptionGroup(); group.addOption(Option.builder("a").build()); group.addOption(Option.builder("b").build()); @@ -530,7 +530,7 @@ public class HelpFormatterTest { } @Test - public void testPrintOptions() { + void testPrintOptions() { final StringBuffer sb = new StringBuffer(); final HelpFormatter hf = new HelpFormatter(); final int leftPad = 1; @@ -572,7 +572,7 @@ public class HelpFormatterTest { } @Test - public void testPrintOptionWithEmptyArgNameUsage() { + void testPrintOptionWithEmptyArgNameUsage() { final Option option = new Option("f", true, null); option.setArgName(""); option.setRequired(true); @@ -589,7 +589,7 @@ public class HelpFormatterTest { } @Test - public void testPrintRequiredOptionGroupUsage() { + void testPrintRequiredOptionGroupUsage() { final OptionGroup group = new OptionGroup(); group.addOption(Option.builder("a").build()); group.addOption(Option.builder("b").build()); @@ -609,7 +609,7 @@ public class HelpFormatterTest { // uses the test for CLI-131 to implement CLI-155 @Test - public void testPrintSortedUsage() { + void testPrintSortedUsage() { final Options opts = new Options(); opts.addOption(new Option("a", "first")); opts.addOption(new Option("b", "second")); @@ -625,7 +625,7 @@ public class HelpFormatterTest { } @Test - public void testPrintSortedUsageWithNullComparator() { + void testPrintSortedUsageWithNullComparator() { final Options opts = new Options(); opts.addOption(new Option("c", "first")); opts.addOption(new Option("b", "second")); @@ -643,7 +643,7 @@ public class HelpFormatterTest { // This test ensures the options are properly sorted // See https://issues.apache.org/jira/browse/CLI-131 @Test - public void testPrintUsage() { + void testPrintUsage() { final Option optionA = new Option("a", "first"); final Option optionB = new Option("b", "second"); final Option optionC = new Option("c", "third"); @@ -660,7 +660,7 @@ public class HelpFormatterTest { } @Test - public void testRenderSince() throws IOException { + void testRenderSince() throws IOException { final String[] expected = {"Options Since Description", " -n,--no-since - Description for n", " -W,--with-since 1.19.0 Descripton for W"}; final Options options = new Options() @@ -678,7 +678,7 @@ public class HelpFormatterTest { } @Test - public void testRenderWrappedTextMultiLine() { + void testRenderWrappedTextMultiLine() { // multi line text final int width = 16; final int padding = 0; @@ -694,7 +694,7 @@ public class HelpFormatterTest { } @Test - public void testRenderWrappedTextMultiLinePadded() { + void testRenderWrappedTextMultiLinePadded() { // multi-line padded text final int width = 16; final int padding = 4; @@ -713,7 +713,7 @@ public class HelpFormatterTest { } @Test - public void testRenderWrappedTextSingleLine() throws IOException { + void testRenderWrappedTextSingleLine() throws IOException { // single line text final int width = 12; final int padding = 0; @@ -731,7 +731,7 @@ public class HelpFormatterTest { } @Test - public void testRenderWrappedTextSingleLinePadded() { + void testRenderWrappedTextSingleLinePadded() { // single line padded text final int width = 12; final int padding = 4; @@ -744,7 +744,7 @@ public class HelpFormatterTest { } @Test - public void testRenderWrappedTextSingleLinePadded2() { + void testRenderWrappedTextSingleLinePadded2() { // single line padded text 2 final int width = 53; final int padding = 24; @@ -762,7 +762,7 @@ public class HelpFormatterTest { } @Test - public void testRenderWrappedTextWordCut() { + void testRenderWrappedTextWordCut() { final int width = 7; final int padding = 0; final String text = "Thisisatest."; @@ -774,7 +774,7 @@ public class HelpFormatterTest { } @Test - public void testRtrim() { + void testRtrim() { final HelpFormatter formatter = new HelpFormatter(); assertNull(formatter.rtrim(null)); @@ -783,7 +783,7 @@ public class HelpFormatterTest { } @Test - public void testUsageWithLongOptSeparator() { + void testUsageWithLongOptSeparator() { final Options options = new Options(); options.addOption("f", true, "the file"); options.addOption(Option.builder("s").longOpt("size").desc("the size").hasArg().argName("SIZE").build()); diff --git a/src/test/java/org/apache/commons/cli/OptionBuilderTest.java b/src/test/java/org/apache/commons/cli/OptionBuilderTest.java index 8e1071d0..31fab0d2 100644 --- a/src/test/java/org/apache/commons/cli/OptionBuilderTest.java +++ b/src/test/java/org/apache/commons/cli/OptionBuilderTest.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.function.Executable; @SuppressWarnings("deprecation") // OptionBuilder is marked deprecated public class OptionBuilderTest { @Test - public void testBaseOptionCharOpt() { + void testBaseOptionCharOpt() { final Option base = OptionBuilder.withDescription("option description").create('o'); assertEquals("o", base.getOpt()); @@ -38,7 +38,7 @@ public class OptionBuilderTest { } @Test - public void testBaseOptionStringOpt() { + void testBaseOptionStringOpt() { final Option base = OptionBuilder.withDescription("option description").create("o"); assertEquals("o", base.getOpt()); @@ -47,7 +47,7 @@ public class OptionBuilderTest { } @Test - public void testBuilderIsResettedAlways() { + void testBuilderIsResettedAlways() { assertThrows(IllegalArgumentException.class, () -> OptionBuilder.withDescription("JUnit").create('"')); assertNull(OptionBuilder.create('x').getDescription(), "we inherited a description"); assertThrows(IllegalArgumentException.class, (Executable) OptionBuilder::create); @@ -55,7 +55,7 @@ public class OptionBuilderTest { } @Test - public void testCompleteOption() { + void testCompleteOption() { //@formatter:off final Option simple = OptionBuilder.withLongOpt("simple option") .hasArg() @@ -76,14 +76,14 @@ public class OptionBuilderTest { } @Test - public void testCreateIncompleteOption() { + void testCreateIncompleteOption() { assertThrows(IllegalArgumentException.class, (Executable) OptionBuilder::create); // implicitly reset the builder OptionBuilder.create("opt"); } @Test - public void testIllegalOptions() { + void testIllegalOptions() { // bad single character option assertThrows(IllegalArgumentException.class, () -> OptionBuilder.withDescription("option description").create('"')); // bad character in option string @@ -93,7 +93,7 @@ public class OptionBuilderTest { } @Test - public void testOptionArgNumbers() { + void testOptionArgNumbers() { //@formatter:off final Option opt = OptionBuilder.withDescription("option description") .hasArgs(2) @@ -103,7 +103,7 @@ public class OptionBuilderTest { } @Test - public void testSpecialOptChars() throws Exception { + void testSpecialOptChars() throws Exception { // '?' final Option opt1 = OptionBuilder.withDescription("help options").create('?'); assertEquals("?", opt1.getOpt()); @@ -115,7 +115,7 @@ public class OptionBuilderTest { } @Test - public void testTwoCompleteOptions() { + void testTwoCompleteOptions() { //@formatter:off Option simple = OptionBuilder.withLongOpt("simple option") .hasArg() diff --git a/src/test/java/org/apache/commons/cli/OptionGroupTest.java b/src/test/java/org/apache/commons/cli/OptionGroupTest.java index 138ae81d..be99b9aa 100644 --- a/src/test/java/org/apache/commons/cli/OptionGroupTest.java +++ b/src/test/java/org/apache/commons/cli/OptionGroupTest.java @@ -62,7 +62,7 @@ public class OptionGroupTest { } @Test - public void testGetNames() { + void testGetNames() { final OptionGroup group = new OptionGroup(); assertFalse(group.isSelected()); group.addOption(OptionBuilder.create('a')); @@ -74,7 +74,7 @@ public class OptionGroupTest { } @Test - public void testNoOptionsExtraArgs() throws Exception { + void testNoOptionsExtraArgs() throws Exception { final String[] args = {"arg1", "arg2"}; final CommandLine cl = parser.parse(options, args); assertFalse(cl.hasOption("r"), "Confirm -r is NOT set"); @@ -86,7 +86,7 @@ public class OptionGroupTest { } @Test - public void testSingleLongOption() throws Exception { + void testSingleLongOption() throws Exception { final String[] args = {"--file"}; final CommandLine cl = parser.parse(options, args); assertFalse(cl.hasOption("r"), "Confirm -r is NOT set"); @@ -98,7 +98,7 @@ public class OptionGroupTest { } @Test - public void testSingleOption() throws Exception { + void testSingleOption() throws Exception { final String[] args = {"-r"}; final CommandLine cl = parser.parse(options, args); assertTrue(cl.hasOption("r"), "Confirm -r is set"); @@ -110,7 +110,7 @@ public class OptionGroupTest { } @Test - public void testSingleOptionFromGroup() throws Exception { + void testSingleOptionFromGroup() throws Exception { final String[] args = {"-f"}; final CommandLine cl = parser.parse(options, args); assertFalse(cl.hasOption("r"), "Confirm -r is NOT set"); @@ -122,7 +122,7 @@ public class OptionGroupTest { } @Test - public void testToString() { + void testToString() { final OptionGroup group1 = new OptionGroup(); group1.addOption(new Option(null, "foo", false, "Foo")); group1.addOption(new Option(null, "bar", false, "Bar")); @@ -138,7 +138,7 @@ public class OptionGroupTest { } @Test - public void testTwoLongOptionsFromGroup() throws Exception { + void testTwoLongOptionsFromGroup() throws Exception { final String[] args = { "--file", "--directory" }; final AlreadySelectedException e = assertThrows(AlreadySelectedException.class, () -> parser.parse(options, args)); assertNotNull(e.getOptionGroup(), "null option group"); @@ -148,7 +148,7 @@ public class OptionGroupTest { } @Test - public void testTwoOptionsFromDifferentGroup() throws Exception { + void testTwoOptionsFromDifferentGroup() throws Exception { final String[] args = {"-f", "-s"}; final CommandLine cl = parser.parse(options, args); assertFalse(cl.hasOption("r"), "Confirm -r is NOT set"); @@ -160,7 +160,7 @@ public class OptionGroupTest { } @Test - public void testTwoOptionsFromGroup() throws Exception { + void testTwoOptionsFromGroup() throws Exception { final String[] args = { "-f", "-d" }; final AlreadySelectedException e = assertThrows(AlreadySelectedException.class, () -> parser.parse(options, args)); assertNotNull(e.getOptionGroup(), "null option group"); @@ -170,7 +170,7 @@ public class OptionGroupTest { } @Test - public void testTwoOptionsFromGroupWithProperties() throws Exception { + void testTwoOptionsFromGroupWithProperties() throws Exception { final String[] args = {"-f"}; final Properties properties = new Properties(); properties.put("d", "true"); @@ -180,7 +180,7 @@ public class OptionGroupTest { } @Test - public void testTwoValidLongOptions() throws Exception { + void testTwoValidLongOptions() throws Exception { final String[] args = {"--revision", "--file"}; final CommandLine cl = parser.parse(options, args); assertTrue(cl.hasOption("r"), "Confirm -r is set"); @@ -192,7 +192,7 @@ public class OptionGroupTest { } @Test - public void testTwoValidOptions() throws Exception { + void testTwoValidOptions() throws Exception { final String[] args = {"-r", "-f"}; final CommandLine cl = parser.parse(options, args); assertTrue(cl.hasOption("r"), "Confirm -r is set"); @@ -204,7 +204,7 @@ public class OptionGroupTest { } @Test - public void testValidLongOnlyOptions() throws Exception { + void testValidLongOnlyOptions() throws Exception { final CommandLine cl1 = parser.parse(options, new String[] {"--export"}); assertTrue(cl1.hasOption("export"), "Confirm --export is set"); final CommandLine cl2 = parser.parse(options, new String[] {"--import"}); diff --git a/src/test/java/org/apache/commons/cli/OptionTest.java b/src/test/java/org/apache/commons/cli/OptionTest.java index ad8a717f..4b134c3d 100644 --- a/src/test/java/org/apache/commons/cli/OptionTest.java +++ b/src/test/java/org/apache/commons/cli/OptionTest.java @@ -101,56 +101,56 @@ public class OptionTest { } @Test - public void testAddValue() { + void testAddValue() { final Option option = new Option("f", null); assertThrows(UnsupportedOperationException.class, () -> option.addValue("")); assertThrows(IllegalArgumentException.class, () -> option.processValue("")); } @Test - public void testBuilderEmpty() { + void testBuilderEmpty() { assertThrows(IllegalArgumentException.class, () -> Option.builder().build()); } @Test - public void testBuilderInsufficientParams1() { + void testBuilderInsufficientParams1() { assertThrows(IllegalArgumentException.class, () -> Option.builder().desc("desc").build()); } @Test - public void testBuilderInsufficientParams2() { + void testBuilderInsufficientParams2() { assertThrows(IllegalArgumentException.class, () -> Option.builder(null).desc("desc").build()); } @Test - public void testBuilderInvalidOptionName0() { + void testBuilderInvalidOptionName0() { assertThrows(IllegalArgumentException.class, () -> Option.builder().option(null).build()); assertThrows(IllegalArgumentException.class, () -> Option.builder().option("")); assertThrows(IllegalArgumentException.class, () -> Option.builder().option(" ")); } @Test - public void testBuilderInvalidOptionName1() { + void testBuilderInvalidOptionName1() { assertThrows(IllegalArgumentException.class, () -> Option.builder().option("invalid?")); } @Test - public void testBuilderInvalidOptionName2() { + void testBuilderInvalidOptionName2() { assertThrows(IllegalArgumentException.class, () -> Option.builder().option("invalid@")); } @Test - public void testBuilderInvalidOptionName3() { + void testBuilderInvalidOptionName3() { assertThrows(IllegalArgumentException.class, () -> Option.builder("invalid?")); } @Test - public void testBuilderInvalidOptionName4() { + void testBuilderInvalidOptionName4() { assertThrows(IllegalArgumentException.class, () -> Option.builder("invalid@")); } @Test - public void testBuilderMethods() { + void testBuilderMethods() { final char defaultSeparator = (char) 0; checkOption(Option.builder("a").desc("desc").build(), "a", "desc", null, Option.UNINITIALIZED, null, false, false, defaultSeparator, String.class, null, @@ -204,7 +204,7 @@ public class OptionTest { } @Test - public void testClear() { + void testClear() { final TestOption option = new TestOption("x", true, ""); assertEquals(0, option.getValuesList().size()); option.addValue("a"); @@ -215,7 +215,7 @@ public class OptionTest { // See https://issues.apache.org/jira/browse/CLI-21 @Test - public void testClone() { + void testClone() { final TestOption a = new TestOption("a", true, ""); final TestOption b = (TestOption) a.clone(); assertEquals(a, b); @@ -231,7 +231,7 @@ public class OptionTest { } @Test - public void testEquals() { + void testEquals() { final Option option1a = new Option("1", null); final Option option1b = new Option("1", null); final Option option2 = new Option("2", null); @@ -245,7 +245,7 @@ public class OptionTest { } @Test - public void testGetValue() { + void testGetValue() { final Option option = new Option("f", null); option.setArgs(Option.UNLIMITED_VALUES); @@ -260,7 +260,7 @@ public class OptionTest { } @Test - public void testHasArgName() { + void testHasArgName() { final Option option = new Option("f", null); option.setArgName(null); @@ -274,7 +274,7 @@ public class OptionTest { } @Test - public void testHasArgs() { + void testHasArgs() { final Option option = new Option("f", null); option.setArgs(0); @@ -294,14 +294,14 @@ public class OptionTest { } @Test - public void testHashCode() { + void testHashCode() { assertNotEquals(Option.builder("test").build().hashCode(), Option.builder("test2").build().hashCode()); assertNotEquals(Option.builder("test").build().hashCode(), Option.builder().longOpt("test").build().hashCode()); assertNotEquals(Option.builder("test").build().hashCode(), Option.builder("test").longOpt("long test").build().hashCode()); } @Test - public void testSerialization() throws IOException, ClassNotFoundException { + void testSerialization() throws IOException, ClassNotFoundException { final Option option = Option.builder("o").type(TypeHandlerTest.Instantiable.class).build(); assertEquals(Converter.DEFAULT, option.getConverter()); Option roundtrip = roundTrip(option); @@ -320,7 +320,7 @@ public class OptionTest { } @Test - public void testSubclass() { + void testSubclass() { final Option option = new DefaultOption("f", "file", "myfile.txt"); final Option clone = (Option) option.clone(); assertEquals("myfile.txt", clone.getValue()); @@ -328,7 +328,7 @@ public class OptionTest { } @Test - public void testTypeClass() { + void testTypeClass() { final Option option = new Option("f", null); assertEquals(String.class, option.getType()); option.setType(CharSequence.class); @@ -336,7 +336,7 @@ public class OptionTest { } @Test - public void testTypeObject() { + void testTypeObject() { final Option option = new Option("f", null); assertEquals(String.class, option.getType()); @SuppressWarnings("cast") diff --git a/src/test/java/org/apache/commons/cli/OptionValidatorTest.java b/src/test/java/org/apache/commons/cli/OptionValidatorTest.java index b9711c5a..65feefcb 100644 --- a/src/test/java/org/apache/commons/cli/OptionValidatorTest.java +++ b/src/test/java/org/apache/commons/cli/OptionValidatorTest.java @@ -160,7 +160,7 @@ public class OptionValidatorTest { } @Test - public void testExclusivity() { + void testExclusivity() { /* since we modify acceptable chars by add and removing ADDITIONAL* chars we must verify that they do not exist in the * base javaIdentiferPart that is used in OptionValidator to validate basic characters */ for (final char c : OptionValidator.ADDITIONAL_LONG_CHARS) { diff --git a/src/test/java/org/apache/commons/cli/OptionsTest.java b/src/test/java/org/apache/commons/cli/OptionsTest.java index d6d67181..9c570100 100644 --- a/src/test/java/org/apache/commons/cli/OptionsTest.java +++ b/src/test/java/org/apache/commons/cli/OptionsTest.java @@ -44,7 +44,7 @@ public class OptionsTest { } @Test - public void testAddConflictingOptions() { + void testAddConflictingOptions() { final Options options1 = new Options(); final OptionGroup group1 = new OptionGroup(); group1.addOption(Option.builder("a").build()); @@ -62,7 +62,7 @@ public class OptionsTest { } @Test - public void testAddNonConflictingOptions() { + void testAddNonConflictingOptions() { final Options options1 = new Options(); final OptionGroup group1 = new OptionGroup(); group1.addOption(Option.builder("a").build()); @@ -92,7 +92,7 @@ public class OptionsTest { } @Test - public void testAddOptions() { + void testAddOptions() { final Options options = new Options(); final OptionGroup group1 = new OptionGroup(); @@ -112,7 +112,7 @@ public class OptionsTest { } @Test - public void testAddOptions2X() { + void testAddOptions2X() { final Options options = new Options(); final OptionGroup group1 = new OptionGroup(); @@ -128,7 +128,7 @@ public class OptionsTest { } @Test - public void testDeprecated() { + void testDeprecated() { final Options options = new Options(); options.addOption(Option.builder().option("a").build()); options.addOption(Option.builder().option("b").deprecated().build()); @@ -150,7 +150,7 @@ public class OptionsTest { } @Test - public void testDuplicateLong() { + void testDuplicateLong() { final Options options = new Options(); options.addOption("a", "--a", false, "toggle -a"); options.addOption("a", "--a", false, "toggle -a*"); @@ -159,7 +159,7 @@ public class OptionsTest { } @Test - public void testDuplicateSimple() { + void testDuplicateSimple() { final Options options = new Options(); options.addOption("a", false, "toggle -a"); assertToStrings(options.getOption("a")); @@ -169,7 +169,7 @@ public class OptionsTest { } @Test - public void testGetMatchingOpts() { + void testGetMatchingOpts() { final Options options = new Options(); OptionBuilder.withLongOpt("version"); options.addOption(OptionBuilder.create()); @@ -183,7 +183,7 @@ public class OptionsTest { } @Test - public void testGetOptionsGroups() { + void testGetOptionsGroups() { final Options options = new Options(); final OptionGroup group1 = new OptionGroup(); @@ -202,7 +202,7 @@ public class OptionsTest { } @Test - public void testHelpOptions() { + void testHelpOptions() { OptionBuilder.withLongOpt("long-only1"); final Option longOnly1 = OptionBuilder.create(); OptionBuilder.withLongOpt("long-only2"); @@ -237,7 +237,7 @@ public class OptionsTest { } @Test - public void testLong() { + void testLong() { final Options options = new Options(); options.addOption("a", "--a", false, "toggle -a"); options.addOption("b", "--b", true, "set -b"); @@ -246,7 +246,7 @@ public class OptionsTest { } @Test - public void testMissingOptionException() throws ParseException { + void testMissingOptionException() throws ParseException { final Options options = new Options(); OptionBuilder.isRequired(); options.addOption(OptionBuilder.create("f")); @@ -255,7 +255,7 @@ public class OptionsTest { } @Test - public void testMissingOptionsException() throws ParseException { + void testMissingOptionsException() throws ParseException { final Options options = new Options(); OptionBuilder.isRequired(); options.addOption(OptionBuilder.create("f")); @@ -266,7 +266,7 @@ public class OptionsTest { } @Test - public void testSimple() { + void testSimple() { final Options options = new Options(); options.addOption("a", false, "toggle -a"); options.addOption("b", true, "toggle -b"); @@ -275,7 +275,7 @@ public class OptionsTest { } @Test - public void testToString() { + void testToString() { final Options options = new Options(); options.addOption("f", "foo", true, "Foo"); options.addOption("b", "bar", false, "Bar"); diff --git a/src/test/java/org/apache/commons/cli/ParseExceptionTest.java b/src/test/java/org/apache/commons/cli/ParseExceptionTest.java index eb9aa6d8..da89a268 100644 --- a/src/test/java/org/apache/commons/cli/ParseExceptionTest.java +++ b/src/test/java/org/apache/commons/cli/ParseExceptionTest.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test; public class ParseExceptionTest { @Test - public void testConstructor() { + void testConstructor() { assertEquals("a", new ParseException("a").getMessage()); final Throwable t = new IOException(); assertEquals(t, new ParseException(t).getCause()); diff --git a/src/test/java/org/apache/commons/cli/PatternOptionBuilderTest.java b/src/test/java/org/apache/commons/cli/PatternOptionBuilderTest.java index 99a24462..de9139c0 100644 --- a/src/test/java/org/apache/commons/cli/PatternOptionBuilderTest.java +++ b/src/test/java/org/apache/commons/cli/PatternOptionBuilderTest.java @@ -43,7 +43,7 @@ import org.junit.jupiter.api.Test; public class PatternOptionBuilderTest { @Test - public void testClassPattern() throws Exception { + void testClassPattern() throws Exception { final Options options = PatternOptionBuilder.parsePattern("c+d+"); final CommandLineParser parser = new PosixParser(); final CommandLine line = parser.parse(options, new String[] {"-c", "java.util.Calendar", "-d", "System.DateTime"}); @@ -52,13 +52,13 @@ public class PatternOptionBuilderTest { } @Test - public void testEmptyPattern() { + void testEmptyPattern() { final Options options = PatternOptionBuilder.parsePattern(""); assertTrue(options.getOptions().isEmpty()); } @Test - public void testExistingFilePattern() throws Exception { + void testExistingFilePattern() throws Exception { final Options options = PatternOptionBuilder.parsePattern("g<"); final CommandLineParser parser = new PosixParser(); final CommandLine line = parser.parse(options, new String[] {"-g", "src/test/resources/org/apache/commons/cli/existing-readable.file"}); @@ -68,7 +68,7 @@ public class PatternOptionBuilderTest { } @Test - public void testExistingFilePatternFileNotExist() throws Exception { + void testExistingFilePatternFileNotExist() throws Exception { final Options options = PatternOptionBuilder.parsePattern("f<"); final CommandLineParser parser = new PosixParser(); final CommandLine line = parser.parse(options, new String[] {"-f", "non-existing.file"}); @@ -76,7 +76,7 @@ public class PatternOptionBuilderTest { } @Test - public void testNumberPattern() throws Exception { + void testNumberPattern() throws Exception { final Options options = PatternOptionBuilder.parsePattern("n%d%x%"); final CommandLineParser parser = new PosixParser(); // 3,5 fails validation. @@ -90,7 +90,7 @@ public class PatternOptionBuilderTest { } @Test - public void testObjectPattern() throws Exception { + void testObjectPattern() throws Exception { final Options options = PatternOptionBuilder.parsePattern("o@i@n@"); final CommandLineParser parser = new PosixParser(); final CommandLine line = parser.parse(options, new String[] {"-o", "java.lang.String", "-i", "java.util.Calendar", "-n", "System.DateTime"}); @@ -100,7 +100,7 @@ public class PatternOptionBuilderTest { } @Test - public void testRequiredOption() throws Exception { + void testRequiredOption() throws Exception { final Options options = PatternOptionBuilder.parsePattern("!n%m%"); final CommandLineParser parser = new PosixParser(); final MissingOptionException e = assertThrows(MissingOptionException.class, () -> parser.parse(options, new String[] { "" })); @@ -109,7 +109,7 @@ public class PatternOptionBuilderTest { } @Test - public void testSimplePattern() throws Exception { + void testSimplePattern() throws Exception { /* * Dates calculated from strings are dependent upon configuration and environment settings for the * machine on which the test is running. To avoid this problem, convert the time into a string @@ -149,7 +149,7 @@ public class PatternOptionBuilderTest { } @Test - public void testUntypedPattern() throws Exception { + void testUntypedPattern() throws Exception { final Options options = PatternOptionBuilder.parsePattern("abc"); final CommandLineParser parser = new PosixParser(); final CommandLine line = parser.parse(options, new String[] {"-abc"}); @@ -162,7 +162,7 @@ public class PatternOptionBuilderTest { } @Test - public void testURLPattern() throws Exception { + void testURLPattern() throws Exception { final Options options = PatternOptionBuilder.parsePattern("u/v/"); final CommandLineParser parser = new PosixParser(); final CommandLine line = parser.parse(options, new String[] {"-u", "https://commons.apache.org", "-v", "foo://commons.apache.org"}); diff --git a/src/test/java/org/apache/commons/cli/SolrCliTest.java b/src/test/java/org/apache/commons/cli/SolrCliTest.java index 2afc3a92..a5f889c3 100644 --- a/src/test/java/org/apache/commons/cli/SolrCliTest.java +++ b/src/test/java/org/apache/commons/cli/SolrCliTest.java @@ -145,7 +145,7 @@ class SolrCliTest { } @Test - public void testOptions() { + void testOptions() { // sanity checks assertNotNull(DEFAULT_CONFIG_SET); assertNotNull(OPTION_CREDENTIALS); diff --git a/src/test/java/org/apache/commons/cli/SolrCreateToolTest.java b/src/test/java/org/apache/commons/cli/SolrCreateToolTest.java index 9cd3de93..cde29101 100644 --- a/src/test/java/org/apache/commons/cli/SolrCreateToolTest.java +++ b/src/test/java/org/apache/commons/cli/SolrCreateToolTest.java @@ -91,14 +91,14 @@ public class SolrCreateToolTest { } @Test - public void testHelpFormatter() { + void testHelpFormatter() { final HelpFormatter formatter = new HelpFormatter(); final String actual = printHelp(formatter); assertFalse(actual.contains("Deprecated")); } @Test - public void testHelpFormatterDeprecated() { + void testHelpFormatterDeprecated() { final HelpFormatter formatter = HelpFormatter.builder().setShowDeprecated(true).get(); final String actual = printHelp(formatter); assertTrue(actual.contains("-zkHost,--zkHost <HOST> [Deprecated] Zookeeper connection")); diff --git a/src/test/java/org/apache/commons/cli/TypeHandlerTest.java b/src/test/java/org/apache/commons/cli/TypeHandlerTest.java index 4058da6e..cdba1715 100644 --- a/src/test/java/org/apache/commons/cli/TypeHandlerTest.java +++ b/src/test/java/org/apache/commons/cli/TypeHandlerTest.java @@ -169,7 +169,7 @@ public class TypeHandlerTest { } @Test - public void testCreateClass() throws ParseException { + void testCreateClass() throws ParseException { final Class<?> cls = getClass(); assertEquals(cls, TypeHandler.createClass(cls.getName())); } @@ -181,29 +181,29 @@ public class TypeHandlerTest { } @Test - public void testCreateFile() { + void testCreateFile() { final File file = new File("").getAbsoluteFile(); assertEquals(file, TypeHandler.createFile(file.toString())); } @Test - public void testCreateFiles() { + void testCreateFiles() { assertThrows(UnsupportedOperationException.class, () -> TypeHandler.createFiles(null)); } @Test - public void testCreateNumber() throws ParseException { + void testCreateNumber() throws ParseException { assertEquals(0L, TypeHandler.createNumber("0")); assertEquals(0d, TypeHandler.createNumber("0.0")); } @Test - public void testCreateObject() throws ParseException { + void testCreateObject() throws ParseException { assertTrue(TypeHandler.createObject(Date.class.getName()) instanceof Date); } @Test - public void testCreateURL() throws ParseException, MalformedURLException { + void testCreateURL() throws ParseException, MalformedURLException { final URL file = Paths.get("").toAbsolutePath().toUri().toURL(); assertEquals(file, TypeHandler.createURL(file.toString())); } @@ -224,7 +224,7 @@ public class TypeHandlerTest { } @Test - public void testCreateValueExistingFile() throws Exception { + void testCreateValueExistingFile() throws Exception { try (FileInputStream result = TypeHandler.createValue("src/test/resources/org/apache/commons/cli/existing-readable.file", PatternOptionBuilder.EXISTING_FILE_VALUE)) { assertNotNull(result); @@ -233,19 +233,19 @@ public class TypeHandlerTest { /* proof of equality for later tests */ @Test - public void testnstantiableEquals() { + void testnstantiableEquals() { assertEquals(new Instantiable(), new Instantiable()); } @Test - public void testOpenFile() throws ParseException, IOException { + void testOpenFile() throws ParseException, IOException { try (FileInputStream fis = TypeHandler.openFile("src/test/resources/org/apache/commons/cli/existing-readable.file")) { IOUtils.consume(fis); } } @Test - public void testRegister() { + void testRegister() { final Map<Class<?>, Converter<?, ? extends Throwable>> map = TypeHandler.createDefaultMap(); final TypeHandler typeHandler = new TypeHandler(map); assertEquals(Converter.PATH, typeHandler.getConverter(Path.class)); diff --git a/src/test/java/org/apache/commons/cli/UnrecognizedOptionExceptionTest.java b/src/test/java/org/apache/commons/cli/UnrecognizedOptionExceptionTest.java index e9352ab5..56149e6f 100644 --- a/src/test/java/org/apache/commons/cli/UnrecognizedOptionExceptionTest.java +++ b/src/test/java/org/apache/commons/cli/UnrecognizedOptionExceptionTest.java @@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test; public class UnrecognizedOptionExceptionTest { @Test - public void testConstructor() { + void testConstructor() { assertEquals("a", new UnrecognizedOptionException("a").getMessage()); assertEquals("a", new UnrecognizedOptionException("a", "b").getMessage()); assertEquals("b", new UnrecognizedOptionException("a", "b").getOption()); diff --git a/src/test/java/org/apache/commons/cli/UtilTest.java b/src/test/java/org/apache/commons/cli/UtilTest.java index 0696c0f9..f2a8ff66 100644 --- a/src/test/java/org/apache/commons/cli/UtilTest.java +++ b/src/test/java/org/apache/commons/cli/UtilTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; public class UtilTest { @Test - public void testStripLeadingAndTrailingQuotes() { + void testStripLeadingAndTrailingQuotes() { assertNull(Util.stripLeadingAndTrailingQuotes(null)); assertEquals("", Util.stripLeadingAndTrailingQuotes("")); assertEquals("foo", Util.stripLeadingAndTrailingQuotes("\"foo\"")); @@ -36,7 +36,7 @@ public class UtilTest { } @Test - public void testStripLeadingHyphens() { + void testStripLeadingHyphens() { assertEquals("f", Util.stripLeadingHyphens("-f")); assertEquals("foo", Util.stripLeadingHyphens("--foo")); assertEquals("-foo", Util.stripLeadingHyphens("---foo")); diff --git a/src/test/java/org/apache/commons/cli/ValueTest.java b/src/test/java/org/apache/commons/cli/ValueTest.java index 4b2eb53d..574a8815 100644 --- a/src/test/java/org/apache/commons/cli/ValueTest.java +++ b/src/test/java/org/apache/commons/cli/ValueTest.java @@ -64,13 +64,13 @@ public class ValueTest { } @Test - public void testLongNoArg() { + void testLongNoArg() { assertTrue(cl.hasOption("c")); assertNull(cl.getOptionValue("c")); } @Test - public void testLongNoArgWithOption() { + void testLongNoArgWithOption() { assertTrue(cl.hasOption(opts.getOption("c"))); assertNull(cl.getOptionValue(opts.getOption("c"))); } @@ -167,27 +167,27 @@ public class ValueTest { } @Test - public void testLongWithArg() { + void testLongWithArg() { assertTrue(cl.hasOption("d")); assertNotNull(cl.getOptionValue("d")); assertEquals(cl.getOptionValue("d"), "bar"); } @Test - public void testLongWithArgWithOption() { + void testLongWithArgWithOption() { assertTrue(cl.hasOption(opts.getOption("d"))); assertNotNull(cl.getOptionValue(opts.getOption("d"))); assertEquals(cl.getOptionValue(opts.getOption("d")), "bar"); } @Test - public void testShortNoArg() { + void testShortNoArg() { assertTrue(cl.hasOption("a")); assertNull(cl.getOptionValue("a")); } @Test - public void testShortNoArgWithOption() { + void testShortNoArgWithOption() { assertTrue(cl.hasOption(opts.getOption("a"))); assertNull(cl.getOptionValue(opts.getOption("a"))); } @@ -273,7 +273,7 @@ public class ValueTest { } @Test - public void testShortOptionalNArgValuesSeparated() throws Exception { + void testShortOptionalNArgValuesSeparated() throws Exception { final String[] args = { "-v=ink", "-v=idea", "-v=isotope", "-v=ice" }; final CommandLineParser parser = new DefaultParser(); final CommandLine cmd = parser.parse(opts, args); @@ -288,7 +288,7 @@ public class ValueTest { } @Test - public void testShortOptionalNArgValuesWithOption() throws Exception { + void testShortOptionalNArgValuesWithOption() throws Exception { final String[] args = { "-i", "ink", "idea", "isotope", "ice" }; final CommandLineParser parser = new PosixParser(); final CommandLine cmd = parser.parse(opts, args); @@ -304,14 +304,14 @@ public class ValueTest { } @Test - public void testShortWithArg() { + void testShortWithArg() { assertTrue(cl.hasOption("b")); assertNotNull(cl.getOptionValue("b")); assertEquals(cl.getOptionValue("b"), "foo"); } @Test - public void testShortWithArgWithOption() { + void testShortWithArgWithOption() { assertTrue(cl.hasOption(opts.getOption("b"))); assertNotNull(cl.getOptionValue(opts.getOption("b"))); assertEquals(cl.getOptionValue(opts.getOption("b")), "foo"); diff --git a/src/test/java/org/apache/commons/cli/ValuesTest.java b/src/test/java/org/apache/commons/cli/ValuesTest.java index 32477533..7cda4baa 100644 --- a/src/test/java/org/apache/commons/cli/ValuesTest.java +++ b/src/test/java/org/apache/commons/cli/ValuesTest.java @@ -73,7 +73,7 @@ public class ValuesTest { } @Test - public void testCharSeparator() { + void testCharSeparator() { // tests the char methods of CommandLine that delegate to the String methods assertTrue(cmd.hasOption("j"), "Option j is not set"); assertTrue(cmd.hasOption('j'), "Option j is not set"); @@ -92,25 +92,25 @@ public class ValuesTest { } @Test - public void testComplexValues() { + void testComplexValues() { assertTrue(cmd.hasOption("i"), "Option i is not set"); assertTrue(cmd.hasOption("h"), "Option h is not set"); assertArrayEquals(new String[] {"val1", "val2"}, cmd.getOptionValues("h")); } @Test - public void testExtraArgs() { + void testExtraArgs() { assertArrayEquals(new String[] {"arg1", "arg2", "arg3"}, cmd.getArgs(), "Extra args"); } @Test - public void testMultipleArgValues() { + void testMultipleArgValues() { assertTrue(cmd.hasOption("e"), "Option e is not set"); assertArrayEquals(new String[] {"one", "two"}, cmd.getOptionValues("e")); } @Test - public void testShortArgs() { + void testShortArgs() { assertTrue(cmd.hasOption("a"), "Option a is not set"); assertTrue(cmd.hasOption("c"), "Option c is not set"); @@ -119,7 +119,7 @@ public class ValuesTest { } @Test - public void testShortArgsWithValue() { + void testShortArgsWithValue() { assertTrue(cmd.hasOption("b"), "Option b is not set"); assertEquals("foo", cmd.getOptionValue("b")); assertEquals(1, cmd.getOptionValues("b").length); @@ -130,7 +130,7 @@ public class ValuesTest { } @Test - public void testTwoArgValues() { + void testTwoArgValues() { assertTrue(cmd.hasOption("g"), "Option g is not set"); assertArrayEquals(new String[] {"val1", "val2"}, cmd.getOptionValues("g")); } diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI133Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI133Test.java index ba65b69e..c6bed11a 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugCLI133Test.java +++ b/src/test/java/org/apache/commons/cli/bug/BugCLI133Test.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test; @SuppressWarnings("deprecation") // tests some deprecated classes public class BugCLI133Test { @Test - public void testOrder() throws ParseException { + void testOrder() throws ParseException { final Option optionA = new Option("a", "first"); final Options opts = new Options(); opts.addOption(optionA); diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI13Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI13Test.java index 2e8aa717..efa3f290 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugCLI13Test.java +++ b/src/test/java/org/apache/commons/cli/bug/BugCLI13Test.java @@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test; public class BugCLI13Test { @Test - public void testCLI13() throws ParseException { + void testCLI13() throws ParseException { final String debugOpt = "debug"; @SuppressWarnings("static-access") //@formatter:off diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI148Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI148Test.java index 7724adf0..38d10199 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugCLI148Test.java +++ b/src/test/java/org/apache/commons/cli/bug/BugCLI148Test.java @@ -42,7 +42,7 @@ public class BugCLI148Test { } @Test - public void testWorkaround1() throws Exception { + void testWorkaround1() throws Exception { final CommandLineParser parser = new PosixParser(); final String[] args = {"-t-something"}; @@ -51,7 +51,7 @@ public class BugCLI148Test { } @Test - public void testWorkaround2() throws Exception { + void testWorkaround2() throws Exception { final CommandLineParser parser = new PosixParser(); final String[] args = {"-t", "\"-something\""}; diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI162Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI162Test.java index af2b8cac..ccba7b7d 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugCLI162Test.java +++ b/src/test/java/org/apache/commons/cli/bug/BugCLI162Test.java @@ -175,7 +175,7 @@ public class BugCLI162Test { } @Test - public void testInfiniteLoop() { + void testInfiniteLoop() { final Options options = new Options(); options.addOption("h", "help", false, "This is a looooong description"); // used to hang & crash @@ -194,7 +194,7 @@ public class BugCLI162Test { } @Test - public void testLongLineChunking() { + void testLongLineChunking() { final Options options = new Options(); //@formatter:off options.addOption("x", "extralongarg", false, @@ -229,7 +229,7 @@ public class BugCLI162Test { } @Test - public void testLongLineChunkingIndentIgnored() { + void testLongLineChunkingIndentIgnored() { final Options options = new Options(); options.addOption("x", "extralongarg", false, "This description is Long."); formatter.printHelp(new PrintWriter(sw), 22, this.getClass().getName(), "Header", options, 0, 5, "Footer"); @@ -248,7 +248,7 @@ public class BugCLI162Test { } @Test - public void testPrintHelpLongLines() { + void testPrintHelpLongLines() { // Options build final Options commandLineOptions; commandLineOptions = new Options(); diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI18Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI18Test.java index 820859ab..b1d6015e 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugCLI18Test.java +++ b/src/test/java/org/apache/commons/cli/bug/BugCLI18Test.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; */ public class BugCLI18Test { @Test - public void testCLI18() { + void testCLI18() { final Options options = new Options(); options.addOption(new Option("a", "aaa", false, "aaaaaaa")); options.addOption(new Option(null, "bbb", false, "bbbbbbb dksh fkshd fkhs dkfhsdk fhskd hksdks dhfowehfsdhfkjshf skfhkshf sf jkshfk sfh skfh skf f")); diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI252Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI252Test.java index 6b9afe01..8d01338d 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugCLI252Test.java +++ b/src/test/java/org/apache/commons/cli/bug/BugCLI252Test.java @@ -36,14 +36,14 @@ public class BugCLI252Test { } @Test - public void testAmbiquousOptionName() { + void testAmbiquousOptionName() { assertThrows(AmbiguousOptionException.class, () -> new DefaultParser().parse(getOptions(), new String[]{"--pref"}) ); } @Test - public void testExactOptionNameMatch() throws ParseException { + void testExactOptionNameMatch() throws ParseException { new DefaultParser().parse(getOptions(), new String[] {"--prefix"}); } diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI265Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI265Test.java index 52e550d7..9709232d 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugCLI265Test.java +++ b/src/test/java/org/apache/commons/cli/bug/BugCLI265Test.java @@ -53,7 +53,7 @@ public class BugCLI265Test { } @Test - public void testShouldParseConcatenatedShortOptions() throws Exception { + void testShouldParseConcatenatedShortOptions() throws Exception { final String[] concatenatedShortOptions = {"-t1", "-ab"}; final CommandLine commandLine = parser.parse(options, concatenatedShortOptions); @@ -66,7 +66,7 @@ public class BugCLI265Test { } @Test - public void testShouldParseShortOptionWithoutValue() throws Exception { + void testShouldParseShortOptionWithoutValue() throws Exception { final String[] twoShortOptions = {"-t1", "-last"}; final CommandLine commandLine = parser.parse(options, twoShortOptions); @@ -77,7 +77,7 @@ public class BugCLI265Test { } @Test - public void testShouldParseShortOptionWithValue() throws Exception { + void testShouldParseShortOptionWithValue() throws Exception { final String[] shortOptionWithValue = {"-t1", "path/to/my/db"}; final CommandLine commandLine = parser.parse(options, shortOptionWithValue); diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI266Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI266Test.java index b1acc2dd..7b2b55d5 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugCLI266Test.java +++ b/src/test/java/org/apache/commons/cli/bug/BugCLI266Test.java @@ -105,7 +105,7 @@ public class BugCLI266Test { } @Test - public void testOptionComparatorDefaultOrder() { + void testOptionComparatorDefaultOrder() { final HelpFormatter formatter = new HelpFormatter(); final List<Option> options = new ArrayList<>(getOptions().getOptions()); Collections.sort(options, formatter.getOptionComparator()); @@ -117,7 +117,7 @@ public class BugCLI266Test { } @Test - public void testOptionComparatorInsertedOrder() { + void testOptionComparatorInsertedOrder() { final Collection<Option> options = getOptions().getOptions(); int i = 0; for (final Option o : options) { diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI312Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI312Test.java index a6a3a0de..aa1a0d0d 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugCLI312Test.java +++ b/src/test/java/org/apache/commons/cli/bug/BugCLI312Test.java @@ -37,7 +37,7 @@ import org.junit.jupiter.api.Test; */ public class BugCLI312Test { @Test - public void testNoOptionValues() { + void testNoOptionValues() { final Option o1 = Option.builder("A").build(); final Option o2 = Option.builder().option("D").longOpt("define").numberOfArgs(2).valueSeparator('=').build(); final Options options = new Options().addOption(o1).addOption(o2); @@ -48,7 +48,7 @@ public class BugCLI312Test { } @Test - public void testPropertyStyleOption_withGetOptionProperties() throws ParseException { + void testPropertyStyleOption_withGetOptionProperties() throws ParseException { final Option o1 = Option.builder().option("D").longOpt("define").numberOfArgs(2).valueSeparator('=').build(); final Options options = new Options(); @@ -70,7 +70,7 @@ public class BugCLI312Test { } @Test - public void testPropertyStyleOption_withGetOptions() throws ParseException { + void testPropertyStyleOption_withGetOptions() throws ParseException { final Option o1 = Option.builder().option("D").longOpt("define").numberOfArgs(2).valueSeparator('=').build(); final Options options = new Options(); diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI325Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI325Test.java index 1f2c1276..39131a30 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugCLI325Test.java +++ b/src/test/java/org/apache/commons/cli/bug/BugCLI325Test.java @@ -31,7 +31,7 @@ import org.junit.jupiter.api.Test; public class BugCLI325Test { @Test - public void testCli325() throws ParseException { + void testCli325() throws ParseException { // @formatter:off final Option option = Option.builder("x") .hasArgs() diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI71Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI71Test.java index cdaf2cf3..1b9300fc 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugCLI71Test.java +++ b/src/test/java/org/apache/commons/cli/bug/BugCLI71Test.java @@ -50,7 +50,7 @@ public class BugCLI71Test { } @Test - public void testBasic() throws Exception { + void testBasic() throws Exception { final String[] args = {"-a", "Caesar", "-k", "A"}; final CommandLine line = parser.parse(options, args); assertEquals("Caesar", line.getOptionValue("a")); @@ -58,7 +58,7 @@ public class BugCLI71Test { } @Test - public void testGetsDefaultIfOptional() throws Exception { + void testGetsDefaultIfOptional() throws Exception { final String[] args = {"-k", "-a", "Caesar"}; options.getOption("k").setOptionalArg(true); final CommandLine line = parser.parse(options, args); @@ -68,14 +68,14 @@ public class BugCLI71Test { } @Test - public void testLackOfError() throws Exception { + void testLackOfError() throws Exception { final String[] args = { "-k", "-a", "Caesar" }; final MissingArgumentException e = assertThrows(MissingArgumentException.class, () -> parser.parse(options, args)); assertEquals("k", e.getOption().getOpt(), "option missing an argument"); } @Test - public void testMistakenArgument() throws Exception { + void testMistakenArgument() throws Exception { String[] args = {"-a", "Caesar", "-k", "A"}; CommandLine line = parser.parse(options, args); args = new String[] {"-a", "Caesar", "-k", "a"}; diff --git a/src/test/java/org/apache/commons/cli/bug/BugsTest.java b/src/test/java/org/apache/commons/cli/bug/BugsTest.java index ec65fbf4..dc0e90bd 100644 --- a/src/test/java/org/apache/commons/cli/bug/BugsTest.java +++ b/src/test/java/org/apache/commons/cli/bug/BugsTest.java @@ -49,7 +49,7 @@ import org.junit.jupiter.api.Test; @SuppressWarnings("deprecation") // tests some deprecated classes public class BugsTest { @Test - public void test11456() throws Exception { + void test11456() throws Exception { // POSIX Options options = new Options(); options.addOption(OptionBuilder.hasOptionalArg().create('a')); @@ -74,7 +74,7 @@ public class BugsTest { } @Test - public void test11457() throws Exception { + void test11457() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("verbose").create()); final String[] args = {"--verbose"}; @@ -86,7 +86,7 @@ public class BugsTest { } @Test - public void test11458() throws Exception { + void test11458() throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withValueSeparator('=').hasArgs().create('D')); options.addOption(OptionBuilder.withValueSeparator(':').hasArgs().create('p')); @@ -127,7 +127,7 @@ public class BugsTest { } @Test - public void test11680() throws Exception { + void test11680() throws Exception { final Options options = new Options(); final Option optionF = options.addOption("f", true, "foobar").getOption("f"); final Option optionM = options.addOption("m", true, "missing").getOption("m"); @@ -152,7 +152,7 @@ public class BugsTest { } @Test - public void test12210() throws Exception { + void test12210() throws Exception { // create the main options object which will handle the first parameter final Options mainOptions = new Options(); // There can be 2 main exclusive options: -exec|-rep @@ -204,7 +204,7 @@ public class BugsTest { } @Test - public void test13425() throws Exception { + void test13425() throws Exception { final Options options = new Options(); //@formatter:off final Option oldpass = OptionBuilder.withLongOpt("old-password") @@ -223,7 +223,7 @@ public class BugsTest { } @Test - public void test13666() throws Exception { + void test13666() throws Exception { final Options options = new Options(); final Option dirOption = OptionBuilder.withDescription("dir").hasArg().create('d'); options.addOption(dirOption); @@ -241,7 +241,7 @@ public class BugsTest { } @Test - public void test13666_Builder() throws Exception { + void test13666_Builder() throws Exception { final Options options = new Options(); final Option dirOption = OptionBuilder.withDescription("dir").hasArg().create('d'); options.addOption(dirOption); @@ -253,7 +253,7 @@ public class BugsTest { } @Test - public void test13935() throws Exception { + void test13935() throws Exception { final OptionGroup directions = new OptionGroup(); final Option left = new Option("l", "left", false, "go left"); @@ -286,7 +286,7 @@ public class BugsTest { } @Test - public void test14786() throws Exception { + void test14786() throws Exception { final Option o = OptionBuilder.isRequired().withDescription("test").create("test"); final Options opts = new Options(); opts.addOption(o); @@ -301,7 +301,7 @@ public class BugsTest { } @Test - public void test15046() throws Exception { + void test15046() throws Exception { final CommandLineParser parser = new PosixParser(); final String[] cliArgs = {"-z", "c"}; @@ -318,7 +318,7 @@ public class BugsTest { } @Test - public void test15648() throws Exception { + void test15648() throws Exception { final CommandLineParser parser = new PosixParser(); final String[] args = {"-m", "\"Two Words\""}; final Option m = OptionBuilder.hasArgs().create("m"); @@ -329,7 +329,7 @@ public class BugsTest { } @Test - public void test31148() throws ParseException { + void test31148() throws ParseException { final Option multiArgOption = new Option("o", "option with multiple args"); multiArgOption.setArgs(1); diff --git a/src/test/java/org/apache/commons/cli/example/AptHelpAppendableTest.java b/src/test/java/org/apache/commons/cli/example/AptHelpAppendableTest.java index f213554c..3efddfb1 100644 --- a/src/test/java/org/apache/commons/cli/example/AptHelpAppendableTest.java +++ b/src/test/java/org/apache/commons/cli/example/AptHelpAppendableTest.java @@ -47,13 +47,13 @@ public class AptHelpAppendableTest { } @Test - public void testAppendFormatTest() throws IOException { + void testAppendFormatTest() throws IOException { underTest.appendFormat("Big %s and Phantom %,d", "Joe", 309); assertEquals(String.format("Big Joe and Phantom 309"), sb.toString()); } @Test - public void testAppendHeaderTest() throws IOException { + void testAppendHeaderTest() throws IOException { underTest.appendHeader(1, "Hello World"); assertEquals(String.format("* Hello World%n%n"), sb.toString()); sb.setLength(0); @@ -64,7 +64,7 @@ public class AptHelpAppendableTest { } @Test - public void testAppendListTest() throws IOException { + void testAppendListTest() throws IOException { final String[] entries = { "one", "two", "three" }; underTest.appendList(true, Arrays.asList(entries)); assertEquals(String.format(" [[1]] one%n [[2]] two%n [[3]] three%n%n"), sb.toString()); @@ -74,19 +74,19 @@ public class AptHelpAppendableTest { } @Test - public void testAppendParagraphFormatTest() throws IOException { + void testAppendParagraphFormatTest() throws IOException { underTest.appendParagraphFormat("Hello %s World %,d", "Big Joe", 309); assertEquals(String.format(" Hello Big Joe World 309%n%n"), sb.toString()); } @Test - public void testAppendParagraphTest() throws IOException { + void testAppendParagraphTest() throws IOException { underTest.appendParagraph("Hello World"); assertEquals(String.format(" Hello World%n%n"), sb.toString()); } @Test - public void testAppendTableTest() throws IOException { + void testAppendTableTest() throws IOException { final List<TextStyle> styles = Arrays.asList(TextStyle.DEFAULT, TextStyle.DEFAULT, TextStyle.DEFAULT); final String[] headers = { "one", "two", "three" }; // @formatter:off @@ -132,7 +132,7 @@ public class AptHelpAppendableTest { } @Test - public void testAppendTitleTest() throws IOException { + void testAppendTitleTest() throws IOException { sb.setLength(0); underTest.appendTitle("Hello World"); assertEquals(String.format(" -----%n Hello World%n -----%n%nHello World%n%n"), sb.toString()); diff --git a/src/test/java/org/apache/commons/cli/example/XhtmlHelpAppendableTest.java b/src/test/java/org/apache/commons/cli/example/XhtmlHelpAppendableTest.java index e5a298b5..643bead7 100644 --- a/src/test/java/org/apache/commons/cli/example/XhtmlHelpAppendableTest.java +++ b/src/test/java/org/apache/commons/cli/example/XhtmlHelpAppendableTest.java @@ -47,7 +47,7 @@ public class XhtmlHelpAppendableTest { } @Test - public void testAppendHeaderTest() throws IOException { + void testAppendHeaderTest() throws IOException { underTest.appendHeader(1, "Hello World"); assertEquals(String.format("<h1>Hello World</h1>%n"), sb.toString()); sb.setLength(0); @@ -58,7 +58,7 @@ public class XhtmlHelpAppendableTest { } @Test - public void testAppendListTest() throws IOException { + void testAppendListTest() throws IOException { final String[] entries = { "one", "two", "three" }; underTest.appendList(true, Arrays.asList(entries)); assertEquals(String.format("<ol>%n <li>one</li>%n <li>two</li>%n <li>three</li>%n</ol>%n"), sb.toString()); @@ -68,19 +68,19 @@ public class XhtmlHelpAppendableTest { } @Test - public void testAppendParagraphFormatTest() throws IOException { + void testAppendParagraphFormatTest() throws IOException { underTest.appendParagraphFormat("Hello %s World %,d", "Joe", 309); assertEquals(String.format("<p>Hello Joe World 309</p>%n"), sb.toString()); } @Test - public void testAppendParagraphTest() throws IOException { + void testAppendParagraphTest() throws IOException { underTest.appendParagraph("Hello World"); assertEquals(String.format("<p>Hello World</p>%n"), sb.toString()); } @Test - public void testAppendTableTest() throws IOException { + void testAppendTableTest() throws IOException { final List<TextStyle> styles = Arrays.asList(TextStyle.DEFAULT, TextStyle.DEFAULT, TextStyle.DEFAULT); final String[] headers = { "one", "two", "three" }; // @formatter:off @@ -140,7 +140,7 @@ public class XhtmlHelpAppendableTest { } @Test - public void testAppendTitleTest() throws IOException { + void testAppendTitleTest() throws IOException { underTest.appendTitle("Hello World"); assertEquals(String.format("<span class='commons_cli_title'>Hello World</span>%n"), sb.toString()); } diff --git a/src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java b/src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java index a67968e2..accd99fe 100644 --- a/src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java +++ b/src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java @@ -60,7 +60,7 @@ public class HelpFormatterTest { } @Test - public void testDefault() { + void testDefault() { final StringBuilder sb = new StringBuilder(); final TextHelpAppendable serializer = new TextHelpAppendable(sb); final HelpFormatter formatter = HelpFormatter.builder().setHelpAppendable(serializer).get(); @@ -70,7 +70,7 @@ public class HelpFormatterTest { } @Test - public void testPrintHelp() throws IOException { + void testPrintHelp() throws IOException { final StringBuilder sb = new StringBuilder(); final TextHelpAppendable serializer = new TextHelpAppendable(sb); HelpFormatter formatter = HelpFormatter.builder().setHelpAppendable(serializer).get(); @@ -148,7 +148,7 @@ public class HelpFormatterTest { } @Test - public void testPrintHelpXML() throws IOException { + void testPrintHelpXML() throws IOException { final StringBuilder sb = new StringBuilder(); final XhtmlHelpAppendable serializer = new XhtmlHelpAppendable(sb); final HelpFormatter formatter = HelpFormatter.builder().setHelpAppendable(serializer).get(); @@ -179,7 +179,7 @@ public class HelpFormatterTest { } @Test - public void testPrintOptions() throws IOException { + void testPrintOptions() throws IOException { final StringBuilder sb = new StringBuilder(); final TextHelpAppendable serializer = new TextHelpAppendable(sb); final HelpFormatter formatter = HelpFormatter.builder().setHelpAppendable(serializer).setShowSince(false).get(); @@ -229,7 +229,7 @@ public class HelpFormatterTest { } @Test - public void testSetOptionFormatBuilderTest() { + void testSetOptionFormatBuilderTest() { final HelpFormatter.Builder underTest = HelpFormatter.builder(); final OptionFormatter.Builder ofBuilder = OptionFormatter.builder().setOptPrefix("Just Another "); underTest.setOptionFormatBuilder(ofBuilder); @@ -240,7 +240,7 @@ public class HelpFormatterTest { } @Test - public void testSetOptionGroupSeparatorTest() { + void testSetOptionGroupSeparatorTest() { final HelpFormatter.Builder underTest = HelpFormatter.builder().setOptionGroupSeparator(" and "); final HelpFormatter formatter = underTest.get(); final String result = formatter.toSyntaxOptions(new OptionGroup().addOption(Option.builder("this").build()).addOption(Option.builder("that").build())); @@ -248,7 +248,7 @@ public class HelpFormatterTest { } @Test - public void testSortOptionGroupsTest() { + void testSortOptionGroupsTest() { final Options options = getTestGroups(); final List<Option> optList = new ArrayList<>(options.getOptions()); final HelpFormatter underTest = HelpFormatter.builder().get(); @@ -266,7 +266,7 @@ public class HelpFormatterTest { } @Test - public void testSortOptionsTest() { + void testSortOptionsTest() { // @formatter:off final Options options = new Options() .addOption(Option.builder("a").longOpt("optA").hasArg().desc("The description of A").build()) @@ -293,7 +293,7 @@ public class HelpFormatterTest { } @Test - public void testSyntaxPrefix() { + void testSyntaxPrefix() { final StringBuilder sb = new StringBuilder(); final TextHelpAppendable serializer = new TextHelpAppendable(sb); final HelpFormatter formatter = HelpFormatter.builder().setHelpAppendable(serializer).get(); @@ -303,7 +303,7 @@ public class HelpFormatterTest { } @Test - public void testToArgNameTest() { + void testToArgNameTest() { final StringBuilder sb = new StringBuilder(); final TextHelpAppendable serializer = new TextHelpAppendable(sb); final HelpFormatter formatter = HelpFormatter.builder().setHelpAppendable(serializer).get(); @@ -314,7 +314,7 @@ public class HelpFormatterTest { } @Test - public void testToSyntaxOptionGroupTest() { + void testToSyntaxOptionGroupTest() { final HelpFormatter underTest = HelpFormatter.builder().get(); // @formatter:off final OptionGroup group = new OptionGroup() @@ -335,7 +335,7 @@ public class HelpFormatterTest { } @Test - public void testToSyntaxOptionIterableTest() { + void testToSyntaxOptionIterableTest() { final HelpFormatter underTest = HelpFormatter.builder().get(); final List<Option> options = new ArrayList<>(); @@ -351,7 +351,7 @@ public class HelpFormatterTest { } @Test - public void testToSyntaxOptionOptionsTest() { + void testToSyntaxOptionOptionsTest() { final HelpFormatter underTest = HelpFormatter.builder().get(); Options options = getTestGroups(); assertEquals("[-1 <arg> | --aon <arg> | --uno <arg>] [--dos <arg> | --dó <arg> | --two <arg>] " + "[--three <arg> | --tres <arg> | --trí <arg>]", diff --git a/src/test/java/org/apache/commons/cli/help/OptionFormatterTest.java b/src/test/java/org/apache/commons/cli/help/OptionFormatterTest.java index aca77153..0dae2642 100644 --- a/src/test/java/org/apache/commons/cli/help/OptionFormatterTest.java +++ b/src/test/java/org/apache/commons/cli/help/OptionFormatterTest.java @@ -81,7 +81,7 @@ public class OptionFormatterTest { } @Test - public void testAsOptional() { + void testAsOptional() { OptionFormatter underTest; final Option option = Option.builder().option("o").longOpt("opt").hasArg().build(); @@ -96,7 +96,7 @@ public class OptionFormatterTest { } @Test - public void testAsSyntaxOption() { + void testAsSyntaxOption() { OptionFormatter underTest; Option option = Option.builder().option("o").longOpt("opt").hasArg().build(); @@ -143,7 +143,7 @@ public class OptionFormatterTest { } @Test - public void testCopyConstructor() { + void testCopyConstructor() { final Function<Option, String> depFunc = o -> "Ooo Deprecated"; final BiFunction<OptionFormatter, Boolean, String> fmtFunc = (o, b) -> "Yep, it worked"; // @formatter:off @@ -171,7 +171,7 @@ public class OptionFormatterTest { } @Test - public void testDefaultSyntaxFormat() { + void testDefaultSyntaxFormat() { Option option = Option.builder().option("o").longOpt("opt").hasArg().build(); OptionFormatter formatter = OptionFormatter.from(option); @@ -185,7 +185,7 @@ public class OptionFormatterTest { } @Test - public void testGetBothOpt() { + void testGetBothOpt() { OptionFormatter underTest; Option option = Option.builder().option("o").longOpt("opt").hasArg().build(); @@ -202,7 +202,7 @@ public class OptionFormatterTest { } @Test - public void testGetDescription() { + void testGetDescription() { final Option normalOption = Option.builder().option("o").longOpt("one").hasArg().desc("The description").build(); final Option deprecatedOption = Option.builder().option("o").longOpt("one").hasArg().desc("The description").deprecated().build(); @@ -229,7 +229,7 @@ public class OptionFormatterTest { } @Test - public void testSetArgumentNameDelimiters() { + void testSetArgumentNameDelimiters() { final Option option = Option.builder().option("o").longOpt("opt").hasArg().build(); OptionFormatter.Builder builder = OptionFormatter.builder().setArgumentNameDelimiters("with argument named ", "."); assertEquals("with argument named arg.", builder.build(option).getArgName()); @@ -243,7 +243,7 @@ public class OptionFormatterTest { } @Test - public void testSetDefaultArgName() { + void testSetDefaultArgName() { final Option option = Option.builder().option("o").longOpt("opt").hasArg().build(); OptionFormatter.Builder builder = OptionFormatter.builder().setDefaultArgName("foo"); assertEquals("<foo>", builder.build(option).getArgName()); @@ -256,7 +256,7 @@ public class OptionFormatterTest { } @Test - public void testSetLongOptPrefix() { + void testSetLongOptPrefix() { final Option option = Option.builder().option("o").longOpt("opt").hasArg().build(); OptionFormatter.Builder builder = OptionFormatter.builder().setLongOptPrefix("fo"); assertEquals("foopt", builder.build(option).getLongOpt()); @@ -269,7 +269,7 @@ public class OptionFormatterTest { } @Test - public void testSetOptArgumentSeparator() { + void testSetOptArgumentSeparator() { final Option option = Option.builder().option("o").longOpt("opt").hasArg().build(); OptionFormatter.Builder builder = OptionFormatter.builder().setOptArgSeparator(" with argument named "); assertEquals("[-o with argument named <arg>]", builder.build(option).toSyntaxOption()); @@ -282,7 +282,7 @@ public class OptionFormatterTest { } @Test - public void testSetOptSeparator() { + void testSetOptSeparator() { final Option option = Option.builder().option("o").longOpt("opt").hasArg().build(); OptionFormatter.Builder builder = OptionFormatter.builder().setOptSeparator(" and "); assertEquals("-o and --opt", builder.build(option).getBothOpt()); @@ -295,7 +295,7 @@ public class OptionFormatterTest { } @Test - public void testSetSyntaxFormatFunction() { + void testSetSyntaxFormatFunction() { final BiFunction<OptionFormatter, Boolean, String> func = (o, b) -> "Yep, it worked"; final Option option = Option.builder().option("o").longOpt("opt").hasArg().build(); diff --git a/src/test/java/org/apache/commons/cli/help/TextHelpAppendableTest.java b/src/test/java/org/apache/commons/cli/help/TextHelpAppendableTest.java index 8f41daa8..e60fa074 100644 --- a/src/test/java/org/apache/commons/cli/help/TextHelpAppendableTest.java +++ b/src/test/java/org/apache/commons/cli/help/TextHelpAppendableTest.java @@ -49,7 +49,7 @@ public final class TextHelpAppendableTest { } @Test - public void tesstMakeColumnQueue() { + void tesstMakeColumnQueue() { final String text = "The quick brown fox jumps over the lazy dog"; final TextStyle.Builder styleBuilder = TextStyle.builder().setMaxWidth(10).setIndent(0).setLeftPad(0); @@ -99,7 +99,7 @@ public final class TextHelpAppendableTest { } @Test - public void testAdjustTableFormat() { + void testAdjustTableFormat() { // test width smaller than header // @formatter:off final TableDefinition tableDefinition = TableDefinition.from("Testing", @@ -115,7 +115,7 @@ public final class TextHelpAppendableTest { } @Test - public void testAppend() throws IOException { + void testAppend() throws IOException { final char c = (char) 0x1F44D; underTest.append(c); assertEquals(1, sb.length()); @@ -127,7 +127,7 @@ public final class TextHelpAppendableTest { } @Test - public void testAppendHeader() throws IOException { + void testAppendHeader() throws IOException { final String[] expected = { " Hello World", " ===========", "" }; sb.setLength(0); @@ -171,7 +171,7 @@ public final class TextHelpAppendableTest { } @Test - public void testAppendList() throws IOException { + void testAppendList() throws IOException { final List<String> expected = new ArrayList<>(); final String[] entries = { "one", "two", "three" }; for (int i = 0; i < entries.length; i++) { @@ -208,7 +208,7 @@ public final class TextHelpAppendableTest { } @Test - public void testAppendParagraph() throws IOException { + void testAppendParagraph() throws IOException { final String[] expected = { " Hello World", "" }; sb.setLength(0); @@ -226,7 +226,7 @@ public final class TextHelpAppendableTest { } @Test - public void testAppendParagraphFormat() throws IOException { + void testAppendParagraphFormat() throws IOException { final String[] expected = { " Hello Joe World 309", "" }; sb.setLength(0); @@ -240,7 +240,7 @@ public final class TextHelpAppendableTest { } @Test - public void testAppendTable() throws IOException { + void testAppendTable() throws IOException { final TextStyle.Builder styleBuilder = TextStyle.builder(); final List<TextStyle> styles = new ArrayList<>(); styles.add(styleBuilder.setIndent(2).get()); @@ -291,7 +291,7 @@ public final class TextHelpAppendableTest { } @Test - public void testAppendTitle() throws IOException { + void testAppendTitle() throws IOException { final String[] expected = { " Hello World", " ###########", "" }; sb.setLength(0); @@ -310,7 +310,7 @@ public final class TextHelpAppendableTest { } @Test - public void testGetStyleBuilder() { + void testGetStyleBuilder() { final TextStyle.Builder builder = underTest.getTextStyleBuilder(); assertEquals(TextHelpAppendable.DEFAULT_INDENT, builder.getIndent(), "Default indent value was changed, some tests may fail"); assertEquals(TextHelpAppendable.DEFAULT_LEFT_PAD, builder.getLeftPad(), "Default left pad value was changed, some tests may fail"); @@ -318,7 +318,7 @@ public final class TextHelpAppendableTest { } @Test - public void testindexOfWrapPos() { + void testindexOfWrapPos() { final String testString = "The quick brown fox jumps over\tthe lazy dog"; assertEquals(9, TextHelpAppendable.indexOfWrap(testString, 10, 0), "did not find end of word"); @@ -340,7 +340,7 @@ public final class TextHelpAppendableTest { } @Test - public void testPrintWrapped() throws IOException { + void testPrintWrapped() throws IOException { String text = "The quick brown fox jumps over the lazy dog"; final TextStyle.Builder styleBuilder = TextStyle.builder().setMaxWidth(10).setIndent(0).setLeftPad(0); @@ -403,7 +403,7 @@ public final class TextHelpAppendableTest { } @Test - public void testResize() { + void testResize() { TextStyle.Builder tsBuilder = TextStyle.builder().setIndent(2).setMaxWidth(3); underTest.resize(tsBuilder, 0.5); assertEquals(0, tsBuilder.getIndent()); @@ -414,7 +414,7 @@ public final class TextHelpAppendableTest { } @Test - public void testResizeTableFormat() { + void testResizeTableFormat() { underTest.setMaxWidth(150); final TableDefinition tableDefinition = TableDefinition.from("Caption", Collections.singletonList(TextStyle.builder().setMinWidth(20).setMaxWidth(100).get()), Collections.singletonList("header"), @@ -425,14 +425,14 @@ public final class TextHelpAppendableTest { } @Test - public void testSetIndent() { + void testSetIndent() { assertEquals(TextHelpAppendable.DEFAULT_INDENT, underTest.getIndent(), "Default indent value was changed, some tests may fail"); underTest.setIndent(TextHelpAppendable.DEFAULT_INDENT + 2); assertEquals(underTest.getIndent(), TextHelpAppendable.DEFAULT_INDENT + 2); } @Test - public void testWriteColumnQueues() throws IOException { + void testWriteColumnQueues() throws IOException { final List<Queue<String>> queues = new ArrayList<>(); Queue<String> queue = new LinkedList<>(); diff --git a/src/test/java/org/apache/commons/cli/help/TextStyleTests.java b/src/test/java/org/apache/commons/cli/help/TextStyleTests.java index dcdd0412..29ae9d41 100644 --- a/src/test/java/org/apache/commons/cli/help/TextStyleTests.java +++ b/src/test/java/org/apache/commons/cli/help/TextStyleTests.java @@ -86,7 +86,7 @@ public class TextStyleTests { } @Test - public void testDefaultStyle() { + void testDefaultStyle() { final TextStyle underTest = TextStyle.DEFAULT; assertEquals(TextStyle.Alignment.LEFT, underTest.getAlignment()); assertTrue(underTest.isScalable()); diff --git a/src/test/java/org/apache/commons/cli/help/UtilTest.java b/src/test/java/org/apache/commons/cli/help/UtilTest.java index 87d95caf..0a031590 100644 --- a/src/test/java/org/apache/commons/cli/help/UtilTest.java +++ b/src/test/java/org/apache/commons/cli/help/UtilTest.java @@ -58,7 +58,7 @@ public class UtilTest { } @Test - public void testFindNonWhitespacePos() { + void testFindNonWhitespacePos() { assertEquals(-1, Util.indexOfNonWhitespace(null, 0)); assertEquals(-1, Util.indexOfNonWhitespace("", 0)); } @@ -73,7 +73,7 @@ public class UtilTest { } @Test - public void testIsEmpty() { + void testIsEmpty() { String str = null; assertTrue(Util.isEmpty(str), "null string should be empty"); str = "";