/** * Returns a validation * * @param value the integer to validate * @throws ValidationException if value does not fall in valid port number range */ public void validate(Integer value) throws ValidationException { if (value < MIN_PORT) { throw new ValidationException("hz-port number must be greater 0"); } if (value > MAX_PORT) { throw new ValidationException("hz-port number must be less or equal to 65535"); } }
public void validate(Integer value) throws ValidationException { if (value < MIN_PORT) { throw new ValidationException("hz-port number must be greater 0"); } if (value > MAX_PORT) { throw new ValidationException("hz-port number must be less or equal to 65535"); } }
@Test public void portValueValidator_should_not_throw_ValidationException_when_configured_in_range_values() { try { JCloudsProperties.PortValueValidator valueValidator = new JCloudsProperties.PortValueValidator(); valueValidator.validate(5701); } catch (ValidationException e) { fail("PortValueValidator should not throw ValidationException when configured in range values"); } }
@Test(expected = ValidationException.class) public void testPortValueValidator_validate_negative_val() throws Exception { final AwsProperties.PortValueValidator validator = new AwsProperties.PortValueValidator(); validator.validate(-1); }
@Test(expected = ValidationException.class) public void testPortValueValidatorValidateTooBig() throws Exception { final AwsProperties.PortValueValidator validator = new AwsProperties.PortValueValidator(); validator.validate(65536); }