@Test
public void testGetStringValueAsBoolean() throws ParseException
{

    ArgumentParser argParser = new ArgumentParser("");
    Option strOpt = argParser.addArgument("s", "str", true, "Some string input parameter to have a boolean value", false);
    final String shortStrOpt = String.format("-%s", strOpt.getOpt());
    final String longStrOpt = String.format("--%s", strOpt.getLongOpt());
    // Validate the default value - no option is specified.
    argParser.parseArguments(new String[] {});
    assertFalse(argParser.getStringValueAsBoolean(strOpt, false));
    assertTrue(argParser.getStringValueAsBoolean(strOpt, true));
    // Validate all "true" boolean values using both short an long options.
    for (String inputValue : Arrays
        .asList(CustomBooleanEditor.VALUE_TRUE, CustomBooleanEditor.VALUE_YES, CustomBooleanEditor.VALUE_ON, CustomBooleanEditor.VALUE_1))
    {
        argParser.parseArguments(new String[] {shortStrOpt, inputValue});
        assertTrue(argParser.getStringValueAsBoolean(strOpt, false));
        argParser.parseArguments(new String[] {longStrOpt, inputValue});
        assertTrue(argParser.getStringValueAsBoolean(strOpt, false));
    }
    // Validate all "false" boolean values.
    for (String inputValue : Arrays
        .asList(CustomBooleanEditor.VALUE_FALSE, CustomBooleanEditor.VALUE_NO, CustomBooleanEditor.VALUE_OFF, CustomBooleanEditor.VALUE_0))
    {
        argParser.parseArguments(new String[] {shortStrOpt, inputValue});
        assertFalse(argParser.getStringValueAsBoolean(strOpt, true));
    }
    // Try to parse an invalid boolean value.
    argParser.parseArguments(new String[] {shortStrOpt, INVALID_BOOLEAN_VALUE});
    try
    {
        argParser.getStringValueAsBoolean(strOpt, false);
        fail("Suppose to throw a ParseException when option has an invalid boolean value.");
    }
    catch (ParseException e)
    {
        assertEquals(String.format("Invalid boolean value [%s]", INVALID_BOOLEAN_VALUE), e.getMessage());
    }
}