-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package picocli; | ||
|
||
import org.junit.Test; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.Option; | ||
import picocli.CommandLine.ParseResult; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class Issue2228 { | ||
|
||
@Command | ||
static class TestCommand implements Runnable { | ||
|
||
@Option(names = "-x") | ||
public boolean x; | ||
|
||
public void run() { | ||
throw new IllegalStateException("failing, just for fun"); | ||
} | ||
} | ||
|
||
@Test | ||
public void testParseResult() { | ||
final CommandLine commandLine = new CommandLine(new Issue2228.TestCommand()); | ||
final ParseResult[] caughtParseResult = new ParseResult[1]; | ||
commandLine.setExecutionExceptionHandler(new CommandLine.IExecutionExceptionHandler() { | ||
public int handleExecutionException(Exception ex, CommandLine exCmdLine, ParseResult parseResult) throws Exception { | ||
assertSame(commandLine, exCmdLine); | ||
assertNotNull(parseResult); | ||
caughtParseResult[0] = parseResult; | ||
return 0; | ||
} | ||
}); | ||
assertSame(commandLine.getParseResult(), caughtParseResult[0]); | ||
} | ||
} |