/** * Set the selected option of this group to <code>name</code>. * * @param option the option that is selected * @throws AlreadySelectedException if an option from this group has * already been selected. */ public void setSelected(Option option) throws AlreadySelectedException { if (option == null) { // reset the option previously selected selected = null; return; } // if no option has already been selected or the // same option is being reselected then set the // selected member variable if (selected == null || selected.equals(option.getKey())) { selected = option.getKey(); } else { throw new AlreadySelectedException(this, option); } }
@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()); } }
public void foo(){ //here, at compile time we use the one in EvoSuite dependency, but not at runtime AlreadySelectedException e = new AlreadySelectedException(null); if(e.toString().equals("foo")){ System.out.println("Only executed if SUT version is used, and not the one in EvoSuite's dependencies"); } } }
System.exit(-2); } catch (AlreadySelectedException ex) { System.err.println("Argument already selected: " + ex.getMessage()); printHelp(); System.exit(-2);
/***************************************************************************** * {@link Runnable} Interface ****************************************************************************/ public void run(String[] args) throws IOException { if (needsHelp(args)) { printHelp(); System.exit(0); } try { CommandLine cli = _parser.parse(_options, args, true); runApplication(cli, args); } catch (MissingOptionException ex) { System.err.println("Missing argument: " + ex.getMessage()); printHelp(); } catch (MissingArgumentException ex) { System.err.println("Missing argument: " + ex.getMessage()); printHelp(); } catch (UnrecognizedOptionException ex) { System.err.println("Unknown argument: " + ex.getMessage()); printHelp(); } catch (AlreadySelectedException ex) { System.err.println("Argument already selected: " + ex.getMessage()); printHelp(); } catch (ParseException ex) { System.err.println(ex.getMessage()); printHelp(); } catch (Exception ex) { ex.printStackTrace(); } }
/** * set the selected option of this group to <code>name</code>. * @param opt the option that is selected * @throws AlreadySelectedException if an option from this group has * already been selected. */ public void setSelected(Option opt) throws AlreadySelectedException { // if no option has already been selected or the // same option is being reselected then set the // selected member variable if ((this.selected == null) || this.selected.equals(opt.getOpt())) { this.selected = opt.getOpt(); } else { throw new AlreadySelectedException("an option from this group has " + "already been selected: '" + selected + "'"); } }
@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()); } }
/** * set the selected option of this group to <code>name</code>. * @param opt the option that is selected * @throws AlreadySelectedException if an option from this group has * already been selected. */ public void setSelected(Option opt) throws AlreadySelectedException { // if no option has already been selected or the // same option is being reselected then set the // selected member variable if ((this.selected == null) || this.selected.equals(opt.getOpt())) { this.selected = opt.getOpt(); } else { throw new AlreadySelectedException("an option from this group has " + "already been selected: '" + selected + "'"); } }
/** * Set the selected option of this group to <code>name</code>. * * @param option the option that is selected * @throws AlreadySelectedException if an option from this group has * already been selected. */ public void setSelected(Option option) throws AlreadySelectedException { // if no option has already been selected or the // same option is being reselected then set the // selected member variable if (selected == null || selected.equals(option.getOpt())) { selected = option.getOpt(); } else { throw new AlreadySelectedException(this, option); } }
/** * Set the selected option of this group to <code>name</code>. * * @param option the option that is selected * @throws AlreadySelectedException if an option from this group has * already been selected. */ public void setSelected(Option option) throws AlreadySelectedException { // if no option has already been selected or the // same option is being reselected then set the // selected member variable if (selected == null || selected.equals(option.getOpt())) { selected = option.getOpt(); } else { throw new AlreadySelectedException(this, option); } }
/** * Set the selected option of this group to <code>name</code>. * * @param option the option that is selected * @throws AlreadySelectedException if an option from this group has * already been selected. */ public void setSelected(Option option) throws AlreadySelectedException { if (option == null) { // reset the option previously selected selected = null; return; } // if no option has already been selected or the // same option is being reselected then set the // selected member variable if (selected == null || selected.equals(option.getKey())) { selected = option.getKey(); } else { throw new AlreadySelectedException(this, option); } }