Mercurial > stress-tester
changeset 1171:0fc158f0ca19
Validators refactorization
author | Devel 2 |
---|---|
date | Tue, 16 Jun 2020 15:57:01 +0200 |
parents | 93826d05cd95 |
children | 0e280ef89e8e |
files | stress-tester/src/main/java/com/passus/st/validation/HttpValidators.java stress-tester/src/main/java/com/passus/st/validation/PortValidator.java stress-tester/src/main/java/com/passus/st/validation/RuleBasedSessionMapperRuleValidator.java stress-tester/src/test/java/com/passus/st/project/ProjectConfiguratorTest.java stress-tester/src/test/java/com/passus/st/validation/PortValidatorTest.java |
diffstat | 5 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/validation/HttpValidators.java Tue Jun 16 14:44:22 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/validation/HttpValidators.java Tue Jun 16 15:57:01 2020 +0200 @@ -1,5 +1,6 @@ package com.passus.st.validation; +import com.passus.config.ConfigurationContext; import com.passus.config.validation.Errors; import com.passus.config.validation.Validator; import com.passus.net.http.HttpMethod; @@ -25,7 +26,7 @@ } @Override - public void validate(Object target, Errors errors) { + public void validate(Object target, Errors errors, ConfigurationContext context) { CharSequence value = ((CharSequence) target); if (!HttpUtils.isValidRequestMethod(value)) { errors.reject("Invalid HTTP method \"%s\"", value); @@ -44,7 +45,7 @@ } @Override - public void validate(Object target, Errors errors) { + public void validate(Object target, Errors errors, ConfigurationContext context) { CharSequence value = ((CharSequence) target); if (!HttpUtils.isValidVersionString(value)) { errors.reject("Invalid HTTP method \"%s\"", value); @@ -60,7 +61,7 @@ } @Override - public void validate(Object target, Errors errors) { + public void validate(Object target, Errors errors, ConfigurationContext context) { CharSequence value = ((CharSequence) target); if (!HttpUtils.isValidHeaderName(value)) { errors.reject("Invalid header name \"%s\"", value);
--- a/stress-tester/src/main/java/com/passus/st/validation/PortValidator.java Tue Jun 16 14:44:22 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/validation/PortValidator.java Tue Jun 16 15:57:01 2020 +0200 @@ -1,5 +1,6 @@ package com.passus.st.validation; +import com.passus.config.ConfigurationContext; import com.passus.config.validation.Errors; import com.passus.config.validation.Validator; import com.passus.data.type.Type; @@ -17,7 +18,7 @@ } @Override - public void validate(Object target, Errors errors) { + public void validate(Object target, Errors errors, ConfigurationContext context) { try { if (target == null) { return;
--- a/stress-tester/src/main/java/com/passus/st/validation/RuleBasedSessionMapperRuleValidator.java Tue Jun 16 14:44:22 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/validation/RuleBasedSessionMapperRuleValidator.java Tue Jun 16 15:57:01 2020 +0200 @@ -1,5 +1,6 @@ package com.passus.st.validation; +import com.passus.config.ConfigurationContext; import com.passus.config.validation.Errors; import com.passus.config.validation.Validator; import com.passus.st.emitter.RuleBasedSessionMapper; @@ -18,7 +19,7 @@ } @Override - public void validate(Object target, Errors errors) { + public void validate(Object target, Errors errors, ConfigurationContext context) { CharSequence value = ((CharSequence) target); if (!RuleBasedSessionMapper.validateRule(value.toString())) { errors.reject("Invalid session mapper rule \"%s\"", value);
--- a/stress-tester/src/test/java/com/passus/st/project/ProjectConfiguratorTest.java Tue Jun 16 14:44:22 2020 +0200 +++ b/stress-tester/src/test/java/com/passus/st/project/ProjectConfiguratorTest.java Tue Jun 16 15:57:01 2020 +0200 @@ -30,6 +30,7 @@ ProjectConfigurator configurator = new ProjectConfigurator(); ConfigurationContext context = new ConfigurationContextImpl(); configurator.configure(config, errors, context); + assertFalse(errors.hasError()); Project project = context.get(ConfigurationContextConsts.PROJECT);
--- a/stress-tester/src/test/java/com/passus/st/validation/PortValidatorTest.java Tue Jun 16 14:44:22 2020 +0200 +++ b/stress-tester/src/test/java/com/passus/st/validation/PortValidatorTest.java Tue Jun 16 15:57:01 2020 +0200 @@ -37,7 +37,7 @@ @Test(dataProvider = "portsDefs") public void testValidate(Object value, String errorMsg) throws Exception { - validator.validate(value, errors); + validator.validate(value, errors, null); if (errorMsg != null) { if (!errors.hasError()) { fail("Error message required for '" + value + "'.");