Package com.beust.jcommander

Examples of com.beust.jcommander.ParameterException


        public void validate(String name, String value) throws ParameterException {
            Pattern routerIdPattern = GraphServiceImpl.routerIdPattern;
            Matcher m = routerIdPattern.matcher(value);
            if ( ! m.matches()) {
                String msg = String.format("%s: '%s' is not a valid router ID.", name, value);
                throw new ParameterException(msg);
            }
        }
View Full Code Here


    List<String> methods = args.commandLineMethods;

    if (testClasses == null && slave == null && testJar == null
        && (testNgXml == null || testNgXml.isEmpty())
        && (methods == null || methods.isEmpty())) {
      throw new ParameterException("You need to specify at least one testng.xml, one class"
          + " or one method");
    }

    String groups = args.groups;
    String excludedGroups = args.excludedGroups;

    if (testJar == null &&
        (null != groups || null != excludedGroups) && testClasses == null
        && (testNgXml == null || testNgXml.isEmpty())) {
      throw new ParameterException("Groups option should be used with testclass option");
    }

    if (args.slave != null && args.master != null) {
     throw new ParameterException(CommandLineArgs.SLAVE + " can't be combined with "
         + CommandLineArgs.MASTER);
    }

    Boolean junit = args.junit;
    Boolean mixed = args.mixed;
    if (junit && mixed) {
     throw new ParameterException(CommandLineArgs.MIXED + " can't be combined with "
         + CommandLineArgs.JUNIT);
    }
  }
View Full Code Here

                    args.remove(configFileParamKey);
                    args.remove(configFileParamValue);
                    args.addAll(configFileParams);
                } catch (IOException e) {
                    exit1(jc,
                            new ParameterException("Could not read file '" + configFileParamValue + "'."));
                    return;
                }
            }
        }
View Full Code Here

  @Override
  public Integer convert(String value) {
    try {
      return Integer.parseInt(value);
    } catch(NumberFormatException ex) {
      throw new ParameterException(getErrorString(value, "an integer"));
    }
  }
View Full Code Here

  @Override
  public Long convert(String value) {
    try {
      return Long.parseLong(value);
    } catch(NumberFormatException ex) {
      throw new ParameterException(getErrorString(value, "a long"));
    }
  }
View Full Code Here

  @Override
  public Boolean convert(String value) {
    if ("false".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value)) {
      return Boolean.parseBoolean(value);
    } else {
      throw new ParameterException(getErrorString(value, "a boolean"));
    }
  }
View Full Code Here

      m_properties = new Properties();
      URL url = ClassLoader.getSystemResource(fileName);
      if (url != null) {
        m_properties.load(url.openStream());
      } else {
        throw new ParameterException("Could not find property file: " + fileName
            + " on the class path");
      }
    }
    catch (IOException e) {
      throw new ParameterException("Could not open property file: " + fileName);
    }
  }
View Full Code Here

public class FileExistsValidator implements IParameterValidator {

    @Override
    public void validate(String name, String value) throws ParameterException {
        if (!new File(value).exists()) {
            throw new ParameterException("File with path [" + value + "] specified in [" + name + "] does not exist");
        }

    }
View Full Code Here

    List<String> methods = args.commandLineMethods;

    if (testClasses == null && slave == null && testJar == null
        && (testNgXml == null || testNgXml.isEmpty())
        && (methods == null || methods.isEmpty())) {
      throw new ParameterException("You need to specify at least one testng.xml, one class"
          + " or one method");
    }

    String groups = args.groups;
    String excludedGroups = args.excludedGroups;

    if (testJar == null &&
        (null != groups || null != excludedGroups) && testClasses == null
        && (testNgXml == null || testNgXml.isEmpty())) {
      throw new ParameterException("Groups option should be used with testclass option");
    }

    if (args.slave != null && args.master != null) {
     throw new ParameterException(CommandLineArgs.SLAVE + " can't be combined with "
         + CommandLineArgs.MASTER);
    }
  }
View Full Code Here

    public Charset convert(String value) {
        try {
            return Charset.forName(value);
        } catch (IllegalCharsetNameException e) {
            throw new ParameterException("unknown encoding '" + value + "'");
        } catch (UnsupportedCharsetException e) {
            throw new ParameterException("unknown encoding '" + value + "'");
        }
    }
View Full Code Here

TOP

Related Classes of com.beust.jcommander.ParameterException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.