@ConfigValidator public void validate() { if (host == null) throw new ConfigValidatorException("host property must be set"); if (port < 0) throw new ConfigValidatorException("port must be set and > 0"); if (connectionAttempts < 0) throw new ConfigValidatorException("connectionAttempts must be set and > 0"); if (connectionAttemptMillis < 0) throw new ConfigValidatorException("connectionAttemptMillis must be set and > 0"); }
public static void checkNotNullAndNotEmpty(String value, String propertyName) { if (value == null || "".equals(value.trim())) { throw new ConfigValidatorException(propertyName + " cannot be null or empty String"); } } }
@ConfigValidator public void checkValid() { if ( getPort() == 0) { throw new ConfigValidatorException("port cannot be 0"); } else if ( getStepTimeoutSeconds() < 1) { throw new ConfigValidatorException("stepTimeoutSeconds was less than 1"); } else if ( getScope() == null) { throw new ConfigValidatorException("scope was not set"); } else if ( getClientConnectTimeoutSeconds() < 1) { throw new ConfigValidatorException("client connect timeout seconds cannot be < 1"); } }
private void checkPropertiesForJavaProcess() { String jre = getJre(); if ( jre == null || ! new File(jre).isDirectory() ) { throw new ConfigValidatorException("jre property is null or jre path does not exist"); } else if ( ! isSet(getClasspath()) ) { throw new ConfigValidatorException("classpath was null"); } else if ( ! isSet(getMainclass()) ) { throw new ConfigValidatorException("main class was null or empty"); } }
private boolean checkPropertiesForNativeProcess() { boolean valid = true; if (isSet(getMainclass())) { throw new ConfigValidatorException("Cannot set the mainclass property for non-java process configured with pathToExecutable"); } else if (isSet(getJvmargs()) ) { throw new ConfigValidatorException("Cannot set jvmargs property for non-java process configured with pathToExecutable"); } return valid; }
@ConfigProperty( name="connection", description="A shorthand way of setting protocol host and port properties delimited by colon, e.g. jmx:myHost:myPort", validationPattern = "jmx:\\S+:\\d+", mandatory = false ) public void setConnection(String connection) { String[] vals = String.valueOf(connection).split(":"); if (vals.length != 3) { throw new ConfigValidatorException( "Could not parse remoting property 'connection', " + "expecting a value in the form protocol:host:port" ); } setProtocol(vals[0]); setHost(vals[1]); setPort(Integer.parseInt(vals[2])); }
@ConfigValidator public void checkValid() { switch (seleniumDriverType) { case CHROME: checkChromeProperties(); break; case REMOTE_WEB_DRIVER: checkRemoteWebDriverProperites(); break; default: throw new ConfigValidatorException("Selenium Driver Type " + seleniumDriverType + " config cannot be validated"); } }