changeset 858:5eb20e7371dc

CliHelper.createHttpCliet -> CliHelper.createHttpClient
author Devel 2
date Wed, 24 Jan 2018 10:28:04 +0100
parents 4c5afb3d4b25
children 6bb9d77670bd
files stress-tester/src/main/java/com/passus/st/CliHelper.java stress-tester/src/main/java/com/passus/st/Main.java stress-tester/src/main/java/com/passus/st/Main2.java
diffstat 3 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/CliHelper.java	Wed Jan 24 10:11:46 2018 +0100
+++ b/stress-tester/src/main/java/com/passus/st/CliHelper.java	Wed Jan 24 10:28:04 2018 +0100
@@ -2,6 +2,7 @@
 
 import com.passus.commons.Assert;
 import com.passus.config.Configuration;
+import com.passus.config.ConfigurationContext;
 import com.passus.config.ConfigurationContextImpl;
 import com.passus.config.YamlConfigurationReader;
 import com.passus.config.validation.Errors;
@@ -31,6 +32,8 @@
 import java.util.List;
 import java.util.Map;
 import org.apache.commons.cli.CommandLine;
+
+import static com.passus.st.utils.ConfigurationContextConsts.HTTP_FILTERS_FILTERS;
 import static org.apache.commons.io.FileUtils.openInputStream;
 import org.apache.commons.io.IOUtils;
 
@@ -138,7 +141,7 @@
         }
     }
 
-    public HttpClient createHttpCliet(Emitter emitter, CommandLine cl) {
+    public HttpClient createHttpClient(Emitter emitter, CommandLine cl) {
         HttpClient client = new HttpClient(emitter);
         client.setCollectMetrics(true);
         client.setConnectPartialSession(cl.hasOption("ps"));
@@ -156,13 +159,15 @@
         return client;
     }
 
+    @SuppressWarnings("unchecked")
     public List<HttpFilter> readHttpFilters(CommandLine cl) throws Exception {
         if (cl.hasOption("ff")) {
             File file = new File(cl.getOptionValue("ff"));
             Configuration cfg = YamlConfigurationReader.readFromFile(file);
             HttpFiltersConfigurator configurator = new HttpFiltersConfigurator();
             Errors errors = new Errors();
-            configurator.configure(cfg, errors, new ConfigurationContextImpl());
+            ConfigurationContext context = new ConfigurationContextImpl();
+            configurator.configure(cfg, errors, context);
             if (errors.getErrorCount() != 0) {
                 printError("Error in file '" + file.getAbsolutePath() + "'.", false);
                 for (ObjectError error : errors.getAllErrors()) {
@@ -171,7 +176,7 @@
                 System.exit(1);
             }
 
-            return configurator.getFilters();
+            return (List<HttpFilter>) context.get(HTTP_FILTERS_FILTERS);
         }
 
         return null;
--- a/stress-tester/src/main/java/com/passus/st/Main.java	Wed Jan 24 10:11:46 2018 +0100
+++ b/stress-tester/src/main/java/com/passus/st/Main.java	Wed Jan 24 10:28:04 2018 +0100
@@ -163,7 +163,7 @@
             emitter.setSessionMapper(mapper);
             emitter.setCollectMetrics(true);
 
-            HttpClient client = cliHelper.createHttpCliet(emitter, cl);
+            HttpClient client = cliHelper.createHttpClient(emitter, cl);
             client.addListener((request, response, context) -> {
                 if (startTime == 0) {
                     startTime = System.currentTimeMillis();
--- a/stress-tester/src/main/java/com/passus/st/Main2.java	Wed Jan 24 10:11:46 2018 +0100
+++ b/stress-tester/src/main/java/com/passus/st/Main2.java	Wed Jan 24 10:28:04 2018 +0100
@@ -169,7 +169,7 @@
             emitter.setSessionMapper(mapper);
             emitter.setCollectMetrics(true);
 
-            HttpClient client = cliHelper.createHttpCliet(emitter, cl);
+            HttpClient client = cliHelper.createHttpClient(emitter, cl);
             client.addListener((request, response, context) -> {
                 if (startTime == 0) {
                     startTime = System.currentTimeMillis();