changeset 857:4c5afb3d4b25

Configuration "filters" changed to "httpFilters", CliHelper.
author Devel 2
date Wed, 24 Jan 2018 10:11:46 +0100
parents 8e9d0f8be7e3
children 5eb20e7371dc
files stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersConfigurator.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreator.java stress-tester/src/main/java/com/passus/st/utils/ConfigurationContextConsts.java stress-tester/src/test/java/com/passus/st/config/ClientConfiguratorTest.java stress-tester/src/test/resources/com/passus/st/client/http/filter/http_message_modify_filter.yml stress-tester/src/test/resources/com/passus/st/config/test_job_config.yml
diffstat 6 files changed, 26 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersConfigurator.java	Wed Jan 24 09:05:17 2018 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersConfigurator.java	Wed Jan 24 10:11:46 2018 +0100
@@ -1,35 +1,34 @@
 package com.passus.st.client.http.filter;
 
-import com.passus.config.CListNode;
-import com.passus.config.CMapNode;
-import com.passus.config.CNode;
-import com.passus.config.Configuration;
-import com.passus.config.ConfigurationContext;
-import com.passus.config.ConfigurationImpl;
-import static com.passus.config.ConfigurationUtils.tupleNodeStringValue;
-import com.passus.config.Configurator;
-import com.passus.config.NodeException;
-import com.passus.config.YamlConfigurationReader;
+import com.passus.commons.annotations.Plugin;
+import com.passus.config.*;
 import com.passus.config.schema.ConfigurationSchema;
 import com.passus.config.schema.ConfigurationSchemaImpl;
 import com.passus.config.validation.Errors;
+import com.passus.st.config.ClientConfigurator;
+import com.passus.st.plugin.PluginConstants;
+import com.passus.st.utils.ConfigurationContextConsts;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
+import static com.passus.config.ConfigurationUtils.tupleNodeStringValue;
+
 /**
- *
  * @author Mirosław Hawrot
  */
-public class HttpFiltersConfigurator implements Configurator {
+@Plugin(name = HttpFiltersConfigurator.DOMAIN, category = PluginConstants.CATEGORY_DOMAIN_CONFIGURATOR)
+public class HttpFiltersConfigurator implements DomainConfigurator {
+
+    public static final String DOMAIN = "httpFilters";
 
     private static final ConfigurationSchema SCHEMA = new ConfigurationSchemaImpl(new HttpFiltersNodeDefinitionCreator().create());
 
-    private List<HttpFilter> filters;
-
-    public List<HttpFilter> getFilters() {
-        return filters;
+    @Override
+    public String getDomain() {
+        return DOMAIN;
     }
 
     public static List<HttpFilter> getFilters(File configFile, Errors errors, ConfigurationContext context) throws IOException, NodeException {
@@ -49,7 +48,7 @@
         if (errors.getErrorCount() == 0) {
             List<HttpFilter> filters = new ArrayList<>();
             CMapNode node = (CMapNode) tConfig.getRootNode();
-            CListNode filtersNodes = (CListNode) node.get("filters").getNode();
+            CListNode filtersNodes = (CListNode) node.get("httpFilters").getNode();
             HttpFilterFactory factory = new HttpFilterFactory();
 
             for (CNode child : filtersNodes.getChildren()) {
@@ -79,7 +78,8 @@
     public void configure(Configuration config, Errors errors, ConfigurationContext context) {
         List<HttpFilter> cfgFilters = getFilters(config, errors, context);
         if (errors.getErrorCount() == 0) {
-            filters = new ArrayList<>(cfgFilters);
+            List<HttpFilter> filters = new ArrayList<>(cfgFilters);
+            context.add(ConfigurationContextConsts.HTTP_FILTERS_FILTERS, filters);
         }
     }
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreator.java	Wed Jan 24 09:05:17 2018 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreator.java	Wed Jan 24 10:11:46 2018 +0100
@@ -23,7 +23,7 @@
 
     @Override
     public NodeDefinition create() {
-        return mapDef(tupleDef("filters", createFiltersList()));
+        return mapDef(tupleDef("httpFilters", createFiltersList()));
     }
 
 
--- a/stress-tester/src/main/java/com/passus/st/utils/ConfigurationContextConsts.java	Wed Jan 24 09:05:17 2018 +0100
+++ b/stress-tester/src/main/java/com/passus/st/utils/ConfigurationContextConsts.java	Wed Jan 24 10:11:46 2018 +0100
@@ -39,6 +39,8 @@
 
     public static final String PROJECT = "project";
 
+    public static final String HTTP_FILTERS_FILTERS = "httpFilters.filters";
+
     private ConfigurationContextConsts() {
     }
 
--- a/stress-tester/src/test/java/com/passus/st/config/ClientConfiguratorTest.java	Wed Jan 24 09:05:17 2018 +0100
+++ b/stress-tester/src/test/java/com/passus/st/config/ClientConfiguratorTest.java	Wed Jan 24 10:11:46 2018 +0100
@@ -54,7 +54,7 @@
                 + "          userField: username\n"
                 + "          passwordField: password\n"
                 + "          applyIf:\n"
-                + "              \"req.url\": {$contains: \"/login\"}\n"
+                + "              \"@req.url\": {$contains: \"/login\"}\n"
                 + "          provider:\n"
                 + "            UsernamePassword:\n"
                 + "                username: user2\n"
--- a/stress-tester/src/test/resources/com/passus/st/client/http/filter/http_message_modify_filter.yml	Wed Jan 24 09:05:17 2018 +0100
+++ b/stress-tester/src/test/resources/com/passus/st/client/http/filter/http_message_modify_filter.yml	Wed Jan 24 10:11:46 2018 +0100
@@ -1,4 +1,4 @@
-filters:
+httpFilters:
     - type: modifyMessage
       operations:
         removeHeader: Test
--- a/stress-tester/src/test/resources/com/passus/st/config/test_job_config.yml	Wed Jan 24 09:05:17 2018 +0100
+++ b/stress-tester/src/test/resources/com/passus/st/config/test_job_config.yml	Wed Jan 24 10:11:46 2018 +0100
@@ -36,3 +36,6 @@
           connectPartialSession: false
           collectMetrics: true
           workers: 4
+
+httpFilters:
+    - type: requestCacheHeadersCleaner