Mercurial > stress-tester
changeset 843:393e5b6f9f7b
ReporterConfigurator
author | Devel 1 |
---|---|
date | Tue, 23 Jan 2018 11:39:31 +0100 |
parents | 48681d1fd832 |
children | 421e04bfc24b |
files | stress-tester/src/main/java/com/passus/st/client/http/ReporterNodeDefinitionCreator.java stress-tester/src/test/java/com/passus/st/client/http/ReporterConfiguratorTest.java |
diffstat | 2 files changed, 33 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/ReporterNodeDefinitionCreator.java Tue Jan 23 11:08:35 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/ReporterNodeDefinitionCreator.java Tue Jan 23 11:39:31 2018 +0100 @@ -17,9 +17,9 @@ public static NodeDefinition createDef() { return mapDef( tupleDef("active", valueDefBool()).setRequired(false), - tupleDef("address", valueDef()).setRequired(false), + tupleDef("host", valueDef()).setRequired(false), tupleDef("port", valueDefInteger().addValidator(PortValidator.INSTANCE)).setRequired(false), - tupleDef("threads", valueDefInteger()), + tupleDef("threads", valueDefInteger()).setRequired(false), tupleDef("destinations", createDestinationsListDef()).setRequired(false) ); }
--- a/stress-tester/src/test/java/com/passus/st/client/http/ReporterConfiguratorTest.java Tue Jan 23 11:08:35 2018 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/ReporterConfiguratorTest.java Tue Jan 23 11:39:31 2018 +0100 @@ -18,8 +18,15 @@ */ public class ReporterConfiguratorTest { - @Test - public void testValidate() { + private static void validate(String cfgString) throws Exception { + Configuration config = YamlConfigurationReader.readFromString(cfgString); + ReporterConfigurator configurator = new ReporterConfigurator(); + Errors errors = new Errors(); + ConfigurationContext context = new ConfigurationContextImpl(); + + configurator.validate(config, errors, context); + errors.getAllErrors().forEach(System.out::println); + assertEquals(0, errors.getErrorCount()); } private static void configure(String cfgString, ConfigurationContext context) throws Exception { @@ -30,7 +37,6 @@ configurator.configure(config, errors, context); errors.getAllErrors().forEach(System.out::println); assertEquals(0, errors.getErrorCount()); - } private static void checkRemote(ReporterRemoteDestination remote, String host, int port, int threads) { @@ -41,9 +47,28 @@ } @Test - public void testConfigure_default_noParams() throws Exception { - String cfgString - = " active: true\n"; + public void testValidate_noParams() throws Exception { + String cfgString = " active: true\n"; + validate(cfgString); + } + + @Test + public void testValidate() throws Exception { + String cfgString = " active: true\n" + + " host: 1.1.1.1\n" + + " port: 11111 \n" + + " destinations:\n" + + " - type: remote\n" + + " host: 1.1.1.1\n" + + " port: 11111\n" + + " - type: file\n" + + " directory: 'c:\\reporter'"; + validate(cfgString); + } + + @Test + public void testConfigure_noParams() throws Exception { + String cfgString = " active: true\n"; ConfigurationContext context = new ConfigurationContextImpl(); configure(cfgString, context);