### Question:
OptionGroup implements Serializable { public String getSelected() { return selected; }  OptionGroup addOption(Option option); Collection<String> getNames(); Collection<Option> getOptions(); void setSelected(Option option); String getSelected(); void setRequired(boolean required); boolean isRequired(); @Override String toString();  }### Answer:
@Test public void testTwoOptionsFromGroup() throws Exception { String[] args = new String[] { "-f", "-d" }; try { parser.parse( _options, args); fail( "two arguments from group not allowed" ); } catch (AlreadySelectedException e) { assertNotNull("null option group", e.getOptionGroup()); assertEquals("selected option", "f", e.getOptionGroup().getSelected()); assertEquals("option", "d", e.getOption().getOpt()); } }
@Test public void testTwoLongOptionsFromGroup() throws Exception { String[] args = new String[] { "--file", "--directory" }; try { parser.parse(_options, args); fail( "two arguments from group not allowed" ); } catch (AlreadySelectedException e) { assertNotNull("null option group", e.getOptionGroup()); assertEquals("selected option", "f", e.getOptionGroup().getSelected()); assertEquals("option", "d", e.getOption().getOpt()); } }