You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/04/08 13:13:11 UTC

(commons-cli) 01/12: Add missing test for the deprecated handler

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

commit d4610ab06b464b9ac1d74b1d595dd80455c0c0ec
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 8 08:50:26 2024 -0400

    Add missing test for the deprecated handler
---
 src/test/java/org/apache/commons/cli/CommandLineTest.java | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/test/java/org/apache/commons/cli/CommandLineTest.java b/src/test/java/org/apache/commons/cli/CommandLineTest.java
index 861e736..49f146e 100644
--- a/src/test/java/org/apache/commons/cli/CommandLineTest.java
+++ b/src/test/java/org/apache/commons/cli/CommandLineTest.java
@@ -83,6 +83,20 @@ public class CommandLineTest {
         assertNull(handler.get());
     }
 
+    @Test
+    public void testDeprecatedDefaultOption() {
+        final CommandLine.Builder builder = new CommandLine.Builder();
+        builder.addArg("foo").addArg("bar");
+        final Option opt = Option.builder().option("T").deprecated().build();
+        builder.addOption(opt);
+        final AtomicReference<Option> handler = new AtomicReference<>();
+        final CommandLine cmd = builder.build();
+        cmd.getOptionValue(opt.getOpt());
+        handler.set(null);
+        cmd.getOptionValue("Nope");
+        assertNull(handler.get());
+    }
+
     @Test
     public void testGetOptionProperties() throws Exception {
         final String[] args = {"-Dparam1=value1", "-Dparam2=value2", "-Dparam3", "-Dparam4=value4", "-D", "--property", "foo=bar"};