Skip to content

Commit d4610ab

Browse files
committed
Add missing test for the deprecated handler
1 parent b87725f commit d4610ab

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/test/java/org/apache/commons/cli/CommandLineTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,20 @@ public void testDeprecatedOption() {
8383
assertNull(handler.get());
8484
}
8585

86+
@Test
87+
public void testDeprecatedDefaultOption() {
88+
final CommandLine.Builder builder = new CommandLine.Builder();
89+
builder.addArg("foo").addArg("bar");
90+
final Option opt = Option.builder().option("T").deprecated().build();
91+
builder.addOption(opt);
92+
final AtomicReference<Option> handler = new AtomicReference<>();
93+
final CommandLine cmd = builder.build();
94+
cmd.getOptionValue(opt.getOpt());
95+
handler.set(null);
96+
cmd.getOptionValue("Nope");
97+
assertNull(handler.get());
98+
}
99+
86100
@Test
87101
public void testGetOptionProperties() throws Exception {
88102
final String[] args = {"-Dparam1=value1", "-Dparam2=value2", "-Dparam3", "-Dparam4=value4", "-D", "--property", "foo=bar"};

0 commit comments

Comments
 (0)