### Question:
CommandLine implements Serializable { public Properties getOptionProperties(String opt) { Properties props = new Properties(); for (Option option : options) { if (opt.equals(option.getOpt()) || opt.equals(option.getLongOpt())) { List<String> values = option.getValuesList(); if (values.size() >= 2) { props.put(values.get(0), values.get(1)); } else if (values.size() == 1) { props.put(values.get(0), "true"); } } } return props; } protected  CommandLine(); boolean hasOption(String opt); boolean hasOption(char opt); @Deprecated Object getOptionObject(String opt); Object getParsedOptionValue(String opt); Object getOptionObject(char opt); String getOptionValue(String opt); String getOptionValue(char opt); String[] getOptionValues(String opt); String[] getOptionValues(char opt); String getOptionValue(String opt, String defaultValue); String getOptionValue(char opt, String defaultValue); Properties getOptionProperties(String opt); String[] getArgs(); List<String> getArgList(); Iterator<Option> iterator(); Option[] getOptions();  }### Answer:
@Test public void testGetOptionProperties() throws Exception { String[] args = new String[] { "-Dparam1=value1", "-Dparam2=value2", "-Dparam3", "-Dparam4=value4", "-D", "--property", "foo=bar" }; Options options = new Options(); options.addOption(OptionBuilder.withValueSeparator().hasOptionalArgs(2).create('D')); options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withLongOpt("property").create()); Parser parser = new GnuParser(); CommandLine cl = parser.parse(options, args); Properties props = cl.getOptionProperties("D"); assertNotNull("null properties", props); assertEquals("number of properties in " + props, 4, props.size()); assertEquals("property 1", "value1", props.getProperty("param1")); assertEquals("property 2", "value2", props.getProperty("param2")); assertEquals("property 3", "true", props.getProperty("param3")); assertEquals("property 4", "value4", props.getProperty("param4")); assertEquals("property with long format", "bar", cl.getOptionProperties("property").getProperty("foo")); }