Mercurial > stress-tester
changeset 960:b1a58efd0bf7
Refactorization in progress
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/CliHelper.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/CliHelper.java Thu May 30 14:55:34 2019 +0200 @@ -9,9 +9,9 @@ import com.passus.filter.ValueExtractor; import com.passus.net.PortRangeSet; import com.passus.net.http.session.HttpSessionAnalyzer; -import com.passus.st.client.http.HttpClient; -import com.passus.st.client.http.filter.HttpFilter; -import com.passus.st.client.http.filter.HttpFiltersConfigurator; +import com.passus.st.client.FlowExecutor; +import com.passus.st.client.FlowFilter; +import com.passus.st.client.FlowFiltersConfigurator; import com.passus.st.client.http.filter.HttpVarsFilter; import com.passus.st.emitter.Emitter; import com.passus.st.emitter.PassThroughSessionMapper; @@ -148,22 +148,24 @@ } } - public HttpClient createHttpClient(Emitter emitter, CommandLine cl) { - HttpClient client = new HttpClient(emitter); - client.setCollectMetrics(true); - client.setConnectPartialSession(cl.hasOption("ps")); - client.setWokerType(cl.getOptionValue("wt", "synch")); + public FlowExecutor createFlowExecutor(Emitter emitter, CommandLine cl) { + FlowExecutor executor = new FlowExecutor(); + executor.setEmitter(emitter); + executor.setCollectMetrics(true); + executor.setConnectPartialSession(cl.hasOption("ps")); + executor.setWokerType(cl.getOptionValue("wt", "synch")); - if (cl.hasOption("rs")) { + //TODO Wyprowadzic parametr + /*if (cl.hasOption("rs")) { float speed = Float.parseFloat(cl.getOptionValue("rs")); if (speed > .1f && speed < 100f) { - client.setSleepFactor(1f / speed); + executor.setSleepFactor(1f / speed); } else if (speed != 0f) { throw new IllegalArgumentException(); } - } + }*/ - return client; + return executor; } public void beforeExit(ConfigurationContext context) { @@ -184,11 +186,11 @@ } @SuppressWarnings("unchecked") - public List<HttpFilter> readHttpFilters(CommandLine cl, ConfigurationContext context) throws Exception { + public List<FlowFilter> readFilters(CommandLine cl, ConfigurationContext context) throws Exception { if (cl.hasOption("ff")) { File file = new File(cl.getOptionValue("ff")); Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(file, errors, context); + List<FlowFilter> filters = FlowFiltersConfigurator.getFilters(file, errors, context); handleErrors(errors, file); return filters; } @@ -204,8 +206,8 @@ * @return * @throws Exception */ - public List<HttpFilter> readHttpClientFilters(CommandLine cl, ConfigurationContext context) throws Exception { - List<HttpFilter> filters = readHttpFilters(cl, context); + public List<FlowFilter> readHttpClientFilters(CommandLine cl, ConfigurationContext context) throws Exception { + List<FlowFilter> filters = readFilters(cl, context); if (filters == null) { filters = new ArrayList<>(); }
--- a/stress-tester/src/main/java/com/passus/st/ConverterMain.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/ConverterMain.java Thu May 30 14:55:34 2019 +0200 @@ -135,7 +135,7 @@ cliHelper.readLookupsToContext(cl, context); - List<HttpFilter> httpFilters = cliHelper.readHttpFilters(cl, context); + List<HttpFilter> httpFilters = cliHelper.readFilters(cl, context); if (httpFilters != null) { httpFilters.forEach(client::addFilter); }
--- a/stress-tester/src/main/java/com/passus/st/Main.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/Main.java Thu May 30 14:55:34 2019 +0200 @@ -4,7 +4,7 @@ import com.passus.commons.metric.Metric; import com.passus.commons.service.Registry; import com.passus.config.ConfigurationContext; -import com.passus.st.client.MemoryEventsCache; +import com.passus.st.client.*; import com.passus.st.client.http.*; import com.passus.st.client.http.filter.HttpFilter; import com.passus.st.emitter.SessionMapper; @@ -165,12 +165,14 @@ emitter.setSessionMapper(mapper); emitter.setCollectMetrics(true); - HttpClient client = cliHelper.createHttpClient(emitter, cl); - client.addListener((request, response, context) -> { + List<ClientListener> executorListeners = new ArrayList<>(); + FlowExecutor executor = cliHelper.createFlowExecutor(emitter, cl); + executorListeners.add((request, response, context) -> { if (startTime == 0) { startTime = System.currentTimeMillis(); } }); + if (cl.hasOption("pr")) { if (clArgs.length != 1) { throw new IllegalArgumentException("Parameter \"parallelReplays\" works only for one pcap file."); @@ -179,13 +181,13 @@ int parallelReplays = Integer.parseInt(cl.getOptionValue("pr")); if (parallelReplays > 0 && parallelReplays <= 100) { emitter.setMaxThreads(parallelReplays); - client.setWorkersNum(parallelReplays); + executor.setWorkersNum(parallelReplays); } else { throw new IllegalArgumentException("Parameter \"parallelReplays\" should be in range 1-100."); } } else { - client.setWorkersNum(clArgs.length); - client.setDispatcher(new HttpSourceNameAwareClientWorkerDispatcher()); + executor.setWorkersNum(clArgs.length); + executor.setDispatcher(new SourceNameAwareFlowWorkerDispatcher()); } emitter.start(); @@ -200,7 +202,7 @@ } writerListener.write(Arrays.asList(args).toString()); writerListener.write("\n"); - client.addListener(writerListener); + executorListeners.add(writerListener); } SummaryHttpClientListener summaryListener = null; @@ -211,14 +213,14 @@ dumper.setDecodeContent(true); File directory = dumper.getDirectory(); if (directory.isDirectory() || directory.mkdirs()) { - client.addListener(dumper); + executorListeners.add(dumper); summaryListener = new SummaryHttpClientListener(new File(directory, "summary.txt")); File file = new File(directory, "cmd." + new File(clArgs[0]).getName() + ".txt"); String cmd = String.join(" ", args); try (FileOutputStream fos = new FileOutputStream(file)) { IOUtils.write(cmd, fos); } - client.addListener(summaryListener); + executorListeners.add(summaryListener); } else { throw new Exception("Cannot create directory: " + directory.getAbsolutePath()); } @@ -239,7 +241,7 @@ if (reporterDestination != null) { reporterDestination.start(); Registry.getInstance().add(ReporterDestination.SERVICE_NAME, reporterDestination); - client.addListener(reporterDestination); + executorListeners.add(reporterDestination); collector.addHandler(reporterDestination); } @@ -249,10 +251,11 @@ List<HttpFilter> httpFilters = cliHelper.readHttpClientFilters(cl, context); if (httpFilters != null) { - httpFilters.forEach(client::addFilter); + httpFilters.forEach(executor::addFilter); } - client.start(); + executor.setListener(new MultipleClientListener(executorListeners)); + executor.start(); EventSource[] eventSrcs = new EventSource[clArgs.length]; for (int i = 0; i < clArgs.length; i++) { @@ -286,7 +289,7 @@ } collector.register(emitter); - collector.register(client); + collector.register(executor); collector.start(); if (cl.hasOption("ca")) { @@ -296,7 +299,7 @@ sourcesName.add(eventSrc.getName()); } - MemoryEventsCache cache = new MemoryEventsCache(client, sourcesName); + MemoryEventsCache cache = new MemoryEventsCache(executor, sourcesName); for (int i = 0; i < clArgs.length; i++) { EventSource eventSrc = eventSrcs[i]; eventSrc.setHandler(cache); @@ -308,28 +311,28 @@ } else { for (int i = 0; i < clArgs.length; i++) { EventSource eventSrc = eventSrcs[i]; - eventSrc.setHandler(client); + eventSrc.setHandler(executor); eventSrc.setLoops(loops); eventSrc.start(); } } - ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); - executor.scheduleAtFixedRate(this::printMetrics, 5, 5, TimeUnit.SECONDS); + ScheduledExecutorService scheduleExecutor = Executors.newSingleThreadScheduledExecutor(); + scheduleExecutor.scheduleAtFixedRate(this::printMetrics, 5, 5, TimeUnit.SECONDS); - client.join(); + executor.join(); long endTime = System.currentTimeMillis(); System.out.println("Broadcast finished. Duration " + PeriodFormatter.INSTANCE.reverseTransform(endTime - startTime) + "."); collector.collect(); - executor.shutdownNow(); + scheduleExecutor.shutdownNow(); for (int i = 0; i < clArgs.length; i++) { eventSrcs[i].stop(); } - client.stop(); + executor.stop(); emitter.stop(); if (reporterDestination != null) { if (reporterDestination instanceof ReporterRemoteDestination) {
--- a/stress-tester/src/main/java/com/passus/st/Main2.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/Main2.java Thu May 30 14:55:34 2019 +0200 @@ -4,7 +4,6 @@ import com.passus.commons.metric.Metric; import com.passus.commons.service.Registry; import com.passus.config.ConfigurationContext; -import com.passus.net.PortRangeSet; import com.passus.st.client.MemoryEventsCache; import com.passus.st.client.http.DumperHttpClientListener; import com.passus.st.client.http.HttpClient; @@ -171,7 +170,7 @@ emitter.setSessionMapper(mapper); emitter.setCollectMetrics(true); - HttpClient client = cliHelper.createHttpClient(emitter, cl); + HttpClient client = cliHelper.createFlowExecutor(emitter, cl); client.addListener((request, response, context) -> { if (startTime == 0) { startTime = System.currentTimeMillis();
--- a/stress-tester/src/main/java/com/passus/st/client/AbstractClient.java Thu May 30 13:09:03 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -package com.passus.st.client; - -import com.passus.commons.Assert; -import com.passus.st.emitter.Emitter; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -public abstract class AbstractClient implements Client { - - private static final boolean DEFAULT_COLLECT_METRICS = false; - - private Emitter emitter; - - private final List<ClientListener> listeners = new ArrayList<>(); - - private FlowFilterChain filterChain = new FlowFilterChain(); - - private boolean collectMetrics = DEFAULT_COLLECT_METRICS; - - @Override - public Emitter getEmitter() { - return emitter; - } - - @Override - public void setEmitter(Emitter emitter) { - this.emitter = emitter; - } - - @Override - public void setListeners(Collection<ClientListener> listeners) { - Assert.notContainsNull(listeners, "listeners"); - this.listeners.addAll(listeners); - } - - @Override - public void addListener(ClientListener listener) { - Assert.notNull(listener, "listener"); - listeners.add(listener); - } - - @Override - public void removeListener(ClientListener listener) { - Assert.notNull(listener, "listener"); - listeners.remove(listener); - } - - @Override - public List<ClientListener> getListeners() { - return Collections.unmodifiableList(listeners); - } - - @Override - public List<FlowFilter> getFilters() { - return filterChain.getFilters(); - } - - @Override - public void addFilter(FlowFilter filter) { - Assert.notNull(filter, "filter"); - filterChain.addFilter(filter); - } - - @Override - public void setFilters(Collection<FlowFilter> filters) { - Assert.notContainsNull(filters, "filters"); - filterChain.clear(); - filters.forEach((filter) -> filterChain.addFilter(filter)); - } - - @Override - public boolean isCollectMetrics() { - return collectMetrics; - } - - @Override - public void setCollectMetrics(boolean collectMetrics) { - this.collectMetrics = collectMetrics; - } - -}
--- a/stress-tester/src/main/java/com/passus/st/client/Client.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/Client.java Thu May 30 14:55:34 2019 +0200 @@ -9,8 +9,11 @@ import java.util.List; /** + * + * * @author Mirosław Hawrot */ +@Deprecated public interface Client extends EventHandler, MetricSource, Service, Configurable { Emitter getEmitter();
--- a/stress-tester/src/main/java/com/passus/st/client/ClientException.java Thu May 30 13:09:03 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -package com.passus.st.client; - -/** - * - * @author Mirosław Hawrot - */ -public class ClientException extends RuntimeException { - - public ClientException() { - super(); - } - - public ClientException(String message) { - super(message); - } - - public ClientException(String message, Throwable cause) { - super(message, cause); - } - - public ClientException(Throwable cause) { - super(cause); - } - -}
--- a/stress-tester/src/main/java/com/passus/st/client/ClientFactory.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/ClientFactory.java Thu May 30 14:55:34 2019 +0200 @@ -7,6 +7,7 @@ * * @author Mirosław Hawrot */ +@Deprecated public class ClientFactory extends PluginFactory<Client> { private static ClientFactory instance;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/ClientListenerFactory.java Thu May 30 14:55:34 2019 +0200 @@ -0,0 +1,22 @@ +package com.passus.st.client; + +import com.passus.commons.plugin.PluginFactory; +import com.passus.st.plugin.PluginConstants; + +public class ClientListenerFactory extends PluginFactory<ClientListener> { + + private static ClientListenerFactory instance; + + public ClientListenerFactory() { + super(PluginConstants.CATEGORY_CLIENT_LISTENER, ClientListener.class); + } + + public static synchronized ClientListenerFactory getInstance() { + if (instance == null) { + instance = new ClientListenerFactory(); + } + + return instance; + } + +}
--- a/stress-tester/src/main/java/com/passus/st/client/FlowExecutor.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/FlowExecutor.java Thu May 30 14:55:34 2019 +0200 @@ -13,9 +13,6 @@ import com.passus.config.validation.EnumValidator; import com.passus.config.validation.Errors; import com.passus.config.validation.LongValidator; -import com.passus.st.client.http.HttpClient; -import com.passus.st.client.http.HttpClientListenerFactory; -import com.passus.st.client.http.filter.HttpFiltersNodeDefinitionCreator; import com.passus.st.emitter.Emitter; import com.passus.st.metric.MetricSource; import com.passus.st.metric.MetricsContainer; @@ -34,7 +31,7 @@ private static final boolean DEFAULT_COLLECT_METRICS = false; - private static final Logger LOGGER = LogManager.getLogger(HttpClient.class); + private static final Logger LOGGER = LogManager.getLogger(FlowExecutor.class); private Emitter emitter; @@ -351,10 +348,10 @@ .setTransformer(FlowExecutor.DispatcherTransformer.INSTANCE) ).setRequired(false), tupleDef("filters", - HttpFiltersNodeDefinitionCreator.createFiltersList(true) + FlowFilterNodeDefinitionCreator.createFiltersList(true) ).setRequired(false), tupleDef("listeners", - new DynaKeyValueVaryListNodeDefinition("type", HttpClientListenerFactory.getInstance()) + new DynaKeyValueVaryListNodeDefinition("type", ClientListenerFactory.getInstance()) .setTransformToPluginObject(true) ).setRequired(false) );
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/FlowFilterFactory.java Thu May 30 14:55:34 2019 +0200 @@ -0,0 +1,24 @@ +package com.passus.st.client; + +import com.passus.commons.plugin.PluginFactory; +import com.passus.st.plugin.PluginConstants; + +/** + * @author Mirosław Hawrot + */ +public final class FlowFilterFactory extends PluginFactory<FlowFilter> { + + private static FlowFilterFactory instance; + + public FlowFilterFactory() { + super(PluginConstants.CATEGORY_FLOW_FILTER, FlowFilter.class); + } + + public static synchronized FlowFilterFactory getInstance() { + if (instance == null) { + instance = new FlowFilterFactory(); + } + + return instance; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/FlowFilterNodeDefinitionCreator.java Thu May 30 14:55:34 2019 +0200 @@ -0,0 +1,22 @@ +package com.passus.st.client; + +import com.passus.config.schema.DynaKeyValueVaryListNodeDefinition; +import com.passus.config.schema.NodeDefinition; +import com.passus.config.schema.NodeDefinitionCreator; + +/** + * @author Mirosław Hawrot + */ +public class FlowFilterNodeDefinitionCreator implements NodeDefinitionCreator { + + public static NodeDefinition createFiltersList(boolean transformToObject) { + return new DynaKeyValueVaryListNodeDefinition("type", FlowFilterFactory.getInstance()) + .setTransformToPluginObject(transformToObject); + } + + @Override + public NodeDefinition create() { + return createFiltersList(true); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/FlowFiltersConfigurator.java Thu May 30 14:55:34 2019 +0200 @@ -0,0 +1,68 @@ +package com.passus.st.client; + +import com.passus.commons.annotations.Plugin; +import com.passus.config.*; +import com.passus.config.schema.NodeDefinition; +import com.passus.config.validation.Errors; +import com.passus.st.client.http.filter.HttpFilter; +import com.passus.st.plugin.PluginConstants; +import com.passus.st.utils.ConfigurationContextConsts; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +/** + * @author Mirosław Hawrot + */ +@Plugin(name = FlowFiltersConfigurator.DOMAIN, category = PluginConstants.CATEGORY_DOMAIN_CONFIGURATOR) +public class FlowFiltersConfigurator implements DomainConfigurator { + + public static final String DOMAIN = "filters"; + + private static final FlowFilterNodeDefinitionCreator CREATOR = new FlowFilterNodeDefinitionCreator(); + + private final NodeDefinition nodeDef = CREATOR.create(); + + @Override + public String getDomain() { + return DOMAIN; + } + + public static List<FlowFilter> getFilters(File configFile, Errors errors, ConfigurationContext context) throws IOException, NodeException { + Configuration config = YamlConfigurationReader.readFromFile(configFile); + return getFilters(config, errors, context); + } + + public static List<FlowFilter> getFilters(String configStr, Errors errors, ConfigurationContext context) throws IOException, NodeException { + Configuration config = YamlConfigurationReader.readFromString(configStr); + return getFilters(config, errors, context); + } + + public static List<FlowFilter> getFilters(Configuration config, Errors errors, ConfigurationContext context) { + NodeDefinition nodeDef = CREATOR.create(); + return ConfigurationUtils.getDomainObjects(config, errors, context, DOMAIN, nodeDef); + } + + @Override + public void validate(Configuration config, Errors errors, ConfigurationContext context) { + CCompositeNode rootNode = config.getRootNode(); + nodeDef.validate(rootNode, errors, context); + } + + @Override + public void configure(Configuration config, Errors errors, ConfigurationContext context) { + CCompositeNode rootNode = config.getRootNode(); + nodeDef.transform(rootNode, errors, context); + if (!errors.hasError()) { + try { + List<HttpFilter> filters = ConfigurationUtils.convertToList(rootNode, HttpFilter.class); + context.add(ConfigurationContextConsts.HTTP_FILTERS, filters); + } catch (Exception e) { + throw new RuntimeException(e.getMessage(), e); + } + + } + } + +}
--- a/stress-tester/src/main/java/com/passus/st/client/FlowUtils.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/FlowUtils.java Thu May 30 14:55:34 2019 +0200 @@ -29,7 +29,6 @@ private FlowUtils() { } - public static void trace(Logger log, FlowContext flowContext, String message, Object... args) { log(log, flowContext, Level.TRACE, message, args); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/MultipleClientListener.java Thu May 30 14:55:34 2019 +0200 @@ -0,0 +1,27 @@ +package com.passus.st.client; + +import com.passus.commons.Assert; + +import java.util.Collection; + +public class MultipleClientListener implements ClientListener { + + private final ClientListener[] listeners; + + public MultipleClientListener(Collection<ClientListener> listeners) { + this(listeners.toArray(new ClientListener[]{})); + } + + + public MultipleClientListener(ClientListener... listeners) { + Assert.notContainsNull(listeners, "listeners"); + this.listeners = listeners; + } + + @Override + public void responseReceived(Object request, Object response, FlowContext context) { + for (int i = 0; i < listeners.length; i++) { + listeners[i].responseReceived(request, response, context); + } + } +}
--- a/stress-tester/src/main/java/com/passus/st/client/http/Events.java Thu May 30 13:09:03 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -package com.passus.st.client.http; - -/** - * - * @author mikolaj.podbielski - */ -public class Events { - - public static final int HTTP_SESSION_PAYLOAD = 2; -}
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpClient.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpClient.java Thu May 30 14:55:34 2019 +0200 @@ -14,7 +14,7 @@ import com.passus.config.validation.Errors; import com.passus.config.validation.LongValidator; import com.passus.st.client.*; -import com.passus.st.client.http.filter.HttpFiltersNodeDefinitionCreator; +import com.passus.st.client.FlowFilterNodeDefinitionCreator; import com.passus.st.emitter.Emitter; import com.passus.st.metric.MetricsContainer; import com.passus.st.plugin.PluginConstants; @@ -30,6 +30,7 @@ * @author Mirosław Hawrot */ @SuppressWarnings("ALL") +@Deprecated @NodeDefinitionCreate(HttpClient.HttpClientNodeDefCreator.class) @Plugin(name = HttpClient.TYPE, category = PluginConstants.CATEGORY_CLIENT) public class HttpClient implements Client, FilterAware { @@ -391,10 +392,10 @@ .setTransformer(DispatcherTransformer.INSTANCE) ).setRequired(false), tupleDef("filters", - HttpFiltersNodeDefinitionCreator.createFiltersList(true) + FlowFilterNodeDefinitionCreator.createFiltersList(true) ).setRequired(false), tupleDef("listeners", - new DynaKeyValueVaryListNodeDefinition("type", HttpClientListenerFactory.getInstance()) + new DynaKeyValueVaryListNodeDefinition("type", ClientListenerFactory.getInstance()) .setTransformToPluginObject(true) ).setRequired(false) );
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpClientListener.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpClientListener.java Thu May 30 14:55:34 2019 +0200 @@ -8,6 +8,7 @@ /** * @author Mirosław Hawrot */ +@Deprecated public interface HttpClientListener extends ClientListener {
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpClientListenerFactory.java Thu May 30 13:09:03 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -package com.passus.st.client.http; - -import com.passus.commons.plugin.PluginFactory; -import com.passus.st.plugin.PluginConstants; - -public class HttpClientListenerFactory extends PluginFactory<HttpClientListener> { - - private static HttpClientListenerFactory instance; - - public HttpClientListenerFactory() { - super(PluginConstants.CATEGORY_HTTP_CLIENT_LISTENER, HttpClientListener.class); - } - - public static synchronized HttpClientListenerFactory getInstance() { - if (instance == null) { - instance = new HttpClientListenerFactory(); - } - - return instance; - } - -}
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilter.java Thu May 30 14:55:34 2019 +0200 @@ -28,7 +28,7 @@ * @author mikolaj.podbielski */ @NodeDefinitionCreate(HttpAbstractLoginFilter.GenericNodeDefinitionCreator.class) -@Plugin(name = HttpBasicAuthLoginFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpBasicAuthLoginFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpBasicAuthLoginFilter extends HttpAbstractLoginFilter { private static final Logger LOGGER = LogManager.getLogger(HttpBasicAuthLoginFilter.class);
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCounterFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCounterFilter.java Thu May 30 14:55:34 2019 +0200 @@ -20,7 +20,7 @@ * @author mikolaj.podbielski */ @NodeDefinitionCreate(HttpCounterFilter.NodeDefCreator.class) -@Plugin(name = HttpCounterFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpCounterFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpCounterFilter extends HttpFilter { public static final String TYPE = "counter";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFilter.java Thu May 30 14:55:34 2019 +0200 @@ -44,7 +44,7 @@ * @author Mirosław Hawrot */ @NodeDefinitionCreate(HttpCsrfFilter.HttpCsrfFilterNodeDefCreator.class) -@Plugin(name = HttpCsrfFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpCsrfFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public final class HttpCsrfFilter extends HttpFilter { private static final Logger LOGGER = LogManager.getLogger(HttpCsrfFilter.class);
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFormFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFormFilter.java Thu May 30 14:55:34 2019 +0200 @@ -28,7 +28,7 @@ * @author mikolaj.podbielski */ @NodeDefinitionCreate(HttpCsrfFormFilter.NodeDefCreator.class) -@Plugin(name = HttpCsrfFormFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpCsrfFormFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpCsrfFormFilter extends HttpFilter { private static final Set<String> CONTENT_TYPES_TO_SCAN = new HashSet<>(Arrays.asList(
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpDateFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpDateFilter.java Thu May 30 14:55:34 2019 +0200 @@ -12,7 +12,7 @@ import java.util.Date; -@Plugin(name = HttpDateFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpDateFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpDateFilter extends HttpFilter { public static final String TYPE = "date";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpDebugFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpDebugFilter.java Thu May 30 14:55:34 2019 +0200 @@ -17,7 +17,7 @@ * * @author mikolaj.podbielski */ -@Plugin(name = HttpDebugFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpDebugFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) @NodeDefinitionCreate(HttpDebugFilter.EmptyDefCreator.class) public class HttpDebugFilter extends HttpFilter {
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpDigestAuthLoginFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpDigestAuthLoginFilter.java Thu May 30 14:55:34 2019 +0200 @@ -32,7 +32,7 @@ * @author mikolaj.podbielski */ @NodeDefinitionCreate(HttpDigestAuthLoginFilter.HttpDigestAuthLoginFilterNodeDefinitionCreator.class) -@Plugin(name = HttpDigestAuthLoginFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpDigestAuthLoginFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpDigestAuthLoginFilter extends HttpAbstractLoginFilter { private static final Logger LOGGER = LogManager.getLogger(HttpDigestAuthLoginFilter.class);
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpDumper.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpDumper.java Thu May 30 14:55:34 2019 +0200 @@ -18,7 +18,7 @@ * * @author mikolaj.podbielski */ -@Plugin(name = HttpDumper.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpDumper.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpDumper extends HttpFilter { public static final String TYPE = "dumper";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilter.java Thu May 30 14:55:34 2019 +0200 @@ -34,7 +34,6 @@ return DUNNO; } - public int filterOutbound(HttpRequest req, HttpResponse resp, FlowContext context) { return DUNNO; }
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterFactory.java Thu May 30 13:09:03 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -package com.passus.st.client.http.filter; - -import com.passus.commons.plugin.PluginFactory; -import com.passus.st.plugin.PluginConstants; - -/** - * - * @author Mirosław Hawrot - */ -public final class HttpFilterFactory extends PluginFactory<HttpFilter> { - - private static HttpFilterFactory instance; - - public HttpFilterFactory() { - super(PluginConstants.CATEGORY_HTTP_FILTER, HttpFilter.class); - } - - public static synchronized HttpFilterFactory getInstance() { - if (instance == null) { - instance = new HttpFilterFactory(); - } - - return instance; - } -}
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersConfigurator.java Thu May 30 13:09:03 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -package com.passus.st.client.http.filter; - -import com.passus.commons.annotations.Plugin; -import com.passus.config.*; -import com.passus.config.schema.NodeDefinition; -import com.passus.config.validation.Errors; -import com.passus.st.plugin.PluginConstants; -import com.passus.st.utils.ConfigurationContextConsts; - -import java.io.File; -import java.io.IOException; -import java.util.List; - -/** - * @author Mirosław Hawrot - */ -@Plugin(name = HttpFiltersConfigurator.DOMAIN, category = PluginConstants.CATEGORY_DOMAIN_CONFIGURATOR) -public class HttpFiltersConfigurator implements DomainConfigurator { - - public static final String DOMAIN = "httpFilters"; - - private static final HttpFiltersNodeDefinitionCreator CREATOR = new HttpFiltersNodeDefinitionCreator(); - - private final NodeDefinition nodeDef = CREATOR.create(); - - @Override - public String getDomain() { - return DOMAIN; - } - - public static List<HttpFilter> getFilters(File configFile, Errors errors, ConfigurationContext context) throws IOException, NodeException { - Configuration config = YamlConfigurationReader.readFromFile(configFile); - return getFilters(config, errors, context); - } - - public static List<HttpFilter> getFilters(String configStr, Errors errors, ConfigurationContext context) throws IOException, NodeException { - Configuration config = YamlConfigurationReader.readFromString(configStr); - return getFilters(config, errors, context); - } - - public static List<HttpFilter> getFilters(Configuration config, Errors errors, ConfigurationContext context) { - NodeDefinition nodeDef = CREATOR.create(); - return ConfigurationUtils.getDomainObjects(config, errors, context, DOMAIN, nodeDef); - } - - @Override - public void validate(Configuration config, Errors errors, ConfigurationContext context) { - CCompositeNode rootNode = config.getRootNode(); - nodeDef.validate(rootNode, errors, context); - } - - @Override - public void configure(Configuration config, Errors errors, ConfigurationContext context) { - CCompositeNode rootNode = config.getRootNode(); - nodeDef.transform(rootNode, errors, context); - if (!errors.hasError()) { - try { - List<HttpFilter> filters = ConfigurationUtils.convertToList(rootNode, HttpFilter.class); - context.add(ConfigurationContextConsts.HTTP_FILTERS, filters); - } catch (Exception e) { - throw new RuntimeException(e.getMessage(), e); - } - - } - } - -}
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreator.java Thu May 30 13:09:03 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -package com.passus.st.client.http.filter; - -import com.passus.config.schema.DynaKeyValueVaryListNodeDefinition; -import com.passus.config.schema.NodeDefinition; -import com.passus.config.schema.NodeDefinitionCreator; - -/** - * - * @author Mirosław Hawrot - */ -public class HttpFiltersNodeDefinitionCreator implements NodeDefinitionCreator { - - public static NodeDefinition createFiltersList(boolean transformToObject) { - return new DynaKeyValueVaryListNodeDefinition("type", HttpFilterFactory.getInstance()) - .setTransformToPluginObject(transformToObject); - } - - @Override - public NodeDefinition create() { - return createFiltersList(true); - } - -}
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFormLoginFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFormLoginFilter.java Thu May 30 14:55:34 2019 +0200 @@ -26,7 +26,7 @@ * @author mikolaj.podbielski */ @NodeDefinitionCreate(HttpFormLoginFilter.HttpFormLoginFilterNodeDefinitionCreator.class) -@Plugin(name = HttpFormLoginFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpFormLoginFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpFormLoginFilter extends HttpAbstractLoginFilter { private static final Logger LOGGER = LogManager.getLogger(HttpFormLoginFilter.class);
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpHostRewriterFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpHostRewriterFilter.java Thu May 30 14:55:34 2019 +0200 @@ -26,7 +26,7 @@ import static com.passus.config.schema.ConfigurationSchemaBuilder.tupleDef; @NodeDefinitionCreate(HttpHostRewriterFilter.NodeDefCreator.class) -@Plugin(name = HttpHostRewriterFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpHostRewriterFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpHostRewriterFilter extends HttpFilter { public static final String TYPE = "host";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpLogoutFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpLogoutFilter.java Thu May 30 14:55:34 2019 +0200 @@ -22,7 +22,7 @@ * @author Mirosław Hawrot */ @NodeDefinitionCreate(HttpLogoutFilter.HttpLogoutFilterNodeDefinitionCreator.class) -@Plugin(name = HttpLogoutFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpLogoutFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpLogoutFilter extends HttpFilter { public static final String TYPE = "logout";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMarkFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMarkFilter.java Thu May 30 14:55:34 2019 +0200 @@ -25,7 +25,6 @@ import static com.passus.st.client.http.HttpConsts.TAG_MARKER; import com.passus.st.client.FlowContext; -import com.passus.st.client.http.HttpFlowContext; import com.passus.st.filter.Transformers; import com.passus.st.plugin.PluginConstants; import java.util.ArrayList; @@ -39,7 +38,7 @@ * @author Mirosław Hawrot */ @NodeDefinitionCreate(HttpMarkFilter.HttpMarkFilterNodeDefCreator.class) -@Plugin(name = HttpMarkFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpMarkFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpMarkFilter extends HttpFilter { public static final String TYPE = "marker";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMatchFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMatchFilter.java Thu May 30 14:55:34 2019 +0200 @@ -4,22 +4,21 @@ import com.passus.config.Configuration; import com.passus.config.ConfigurationContext; import com.passus.config.annotations.NodeDefinitionCreate; -import static com.passus.config.schema.ConfigurationSchemaBuilder.tupleDef; import com.passus.config.schema.NodeDefinition; import com.passus.config.schema.NodeDefinitionCreator; import com.passus.net.http.HttpRequest; import com.passus.net.http.HttpResponse; import com.passus.st.client.FlowContext; -import com.passus.st.client.http.HttpFlowContext; import com.passus.st.plugin.PluginConstants; + import static com.passus.config.schema.ConfigurationSchemaBuilder.mapDef; +import static com.passus.config.schema.ConfigurationSchemaBuilder.tupleDef; /** - * * @author Mirosław Hawrot */ @NodeDefinitionCreate(HttpMatchFilter.HttpMatchFilterNodeDefCreator.class) -@Plugin(name = HttpMatchFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpMatchFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpMatchFilter extends HttpFilter { public static final String TYPE = "matcher";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilter.java Thu May 30 14:55:34 2019 +0200 @@ -11,7 +11,6 @@ import com.passus.net.http.HttpRequest; import com.passus.net.http.HttpResponse; import com.passus.st.client.FlowContext; -import com.passus.st.client.http.HttpFlowContext; import com.passus.st.client.http.filter.HttpMessageModificationOperations.Operation; import com.passus.st.config.FieldValueExtractorTransformerNodeDefCreator; import com.passus.st.config.HeaderOperationNodeDefinition; @@ -30,7 +29,7 @@ * @author Mirosław Hawrot */ @NodeDefinitionCreate(HttpMessageModificationFilter.HttpMessageModificationFilterNodeDefCreator.class) -@Plugin(name = HttpMessageModificationFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpMessageModificationFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpMessageModificationFilter extends HttpFilter { private static final Logger LOGGER = LogManager.getLogger(HttpMessageModificationFilter.class);
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMvelFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMvelFilter.java Thu May 30 14:55:34 2019 +0200 @@ -30,7 +30,7 @@ * @author Mirosław Hawrot */ @NodeDefinitionCreate(HttpMvelFilter.HttpMvelFilterNodeDefCreator.class) -@Plugin(name = HttpMvelFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpMvelFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpMvelFilter extends HttpFilter { public static final String TYPE = "mvel";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestCacheHeadersCleanerFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestCacheHeadersCleanerFilter.java Thu May 30 14:55:34 2019 +0200 @@ -9,7 +9,7 @@ * * @author mikolaj.podbielski */ -@Plugin(name = HttpRequestCacheHeadersCleanerFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpRequestCacheHeadersCleanerFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpRequestCacheHeadersCleanerFilter extends HttpAbstractCleanerFilter { public static final String TYPE = "requestCacheHeadersCleaner";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersCleanerFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersCleanerFilter.java Thu May 30 14:55:34 2019 +0200 @@ -9,7 +9,7 @@ * * @author Mirosław Hawrot */ -@Plugin(name = HttpRequestProxyHeadersCleanerFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpRequestProxyHeadersCleanerFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpRequestProxyHeadersCleanerFilter extends HttpAbstractCleanerFilter { public static final String TYPE = "requestProxyHeadersCleaner";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpScopeModificationFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpScopeModificationFilter.java Thu May 30 14:55:34 2019 +0200 @@ -28,7 +28,7 @@ * @author Mirosław Hawrot */ @NodeDefinitionCreate(HttpScopeModificationFilter.HttpScopeModificationFilterNodeDefCreator.class) -@Plugin(name = HttpScopeModificationFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpScopeModificationFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpScopeModificationFilter extends HttpFilter { public static final String TYPE = "modifyScope";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSequenceFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSequenceFilter.java Thu May 30 14:55:34 2019 +0200 @@ -26,7 +26,6 @@ import com.passus.net.http.HttpRequest; import com.passus.net.http.HttpResponse; import com.passus.st.client.FlowContext; -import com.passus.st.client.http.HttpFlowContext; import com.passus.st.client.http.ReporterDestination; import com.passus.st.filter.Transformers; import com.passus.st.plugin.PluginConstants; @@ -45,7 +44,7 @@ * @author mikolaj.podbielski */ @NodeDefinitionCreate(HttpSequenceFilter.NodeDefCreator.class) -@Plugin(name = HttpSequenceFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpSequenceFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpSequenceFilter extends HttpFilter { public static class SequenceItem {
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSequenceListener.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSequenceListener.java Thu May 30 14:55:34 2019 +0200 @@ -8,5 +8,5 @@ */ public interface HttpSequenceListener { - public void sequenceDetected(MapMetric sequence); + void sequenceDetected(MapMetric sequence); }
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSessionBlockerFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSessionBlockerFilter.java Thu May 30 14:55:34 2019 +0200 @@ -18,7 +18,7 @@ import static com.passus.st.client.http.filter.HttpFlowUtils.extractHttpContext; @NodeDefinitionCreate(HttpSessionBlockerFilter.HttpSessionBlockerFilterNodeDefinitionCreator.class) -@Plugin(name = HttpSessionBlockerFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpSessionBlockerFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpSessionBlockerFilter extends HttpFilter { public static final String TYPE = "sessionBlocker";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSessionCookieFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSessionCookieFilter.java Thu May 30 14:55:34 2019 +0200 @@ -27,7 +27,7 @@ * @author mikolaj.podbielski */ @NodeDefinitionCreate(HttpSessionCookieFilter.HttpSessionCookieFilterNodeDefCreator.class) -@Plugin(name = HttpSessionCookieFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpSessionCookieFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public final class HttpSessionCookieFilter extends HttpFilter { public static final String TYPE = "session";
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSimpleHeaderModificationFilter.java Thu May 30 13:09:03 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -package com.passus.st.client.http.filter; - -import com.passus.commons.Assert; -import com.passus.data.ByteString; -import com.passus.net.http.HttpHeaders; -import com.passus.net.http.HttpMessage; -import com.passus.net.http.HttpRequest; -import com.passus.net.http.HttpResponse; -import com.passus.st.client.FlowContext; -import com.passus.st.client.http.HttpFlowContext; -import com.passus.st.emitter.SessionInfo; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -/** - * Zastapiony przez HttpMessageModificationFilter - * - * @author Mirosław Hawrot - * - */ -@Deprecated -public class HttpSimpleHeaderModificationFilter extends HttpFilter { - - private final List<Rule> rules = new ArrayList<>(); - - public void addRule(String rule) throws ParseException { - Assert.notEmpty(rule, "rule"); - - boolean applyToRequest = true; - StringTokenizer tokenizer = new StringTokenizer(rule, " "); - if (tokenizer.countTokens() != 3) { - throw new ParseException("Invalid rule.", 0); - } - - String token = tokenizer.nextToken(); - ByteString headerName = ByteString.create(token.trim()); - - token = tokenizer.nextToken(); - ByteString valuePattern = ByteString.create(token.trim()); - - token = tokenizer.nextToken(); - ByteString newValue = ByteString.create(token.trim()); - - rules.add(new Rule(applyToRequest, headerName, valuePattern, newValue)); - } - - @Override - public int filterOutbound(HttpRequest request, HttpResponse resp, FlowContext context) { - if (!rules.isEmpty()) { - for (Rule rule : rules) { - HttpMessage msg = (rule.applyToRequest ? request : resp); - if (msg != null) { - HttpHeaders headers = msg.getHeaders(); - ByteString value = headers.get(rule.headerName); - if (value != null && rule.valuePattern.equals(value)) { - headers.set(rule.headerName, rule.newValue); - } - } - } - } - - return DUNNO; - } - - @Override - public HttpSimpleHeaderModificationFilter instanceForWorker(int index) { - HttpSimpleHeaderModificationFilter filter = new HttpSimpleHeaderModificationFilter(); - filter.rules.addAll(rules); - return filter; - } - - private class Rule { - - private final boolean applyToRequest; - - private final ByteString headerName; - - private final ByteString valuePattern; - - private final ByteString newValue; - - private Rule(boolean applyToRequest, ByteString headerName, ByteString valuePattern, ByteString newValue) { - this.applyToRequest = applyToRequest; - this.headerName = headerName; - this.valuePattern = valuePattern; - this.newValue = newValue; - } - - } -}
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpZoneFilter.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpZoneFilter.java Thu May 30 14:55:34 2019 +0200 @@ -30,7 +30,7 @@ * @author Mirosław Hawrot */ @NodeDefinitionCreate(HttpZoneFilter.HttpZoneFilterNodeDefCreator.class) -@Plugin(name = HttpZoneFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +@Plugin(name = HttpZoneFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) public class HttpZoneFilter extends HttpFilter { public static final String TYPE = "zone";
--- a/stress-tester/src/main/java/com/passus/st/plugin/PluginConstants.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/main/java/com/passus/st/plugin/PluginConstants.java Thu May 30 14:55:34 2019 +0200 @@ -7,9 +7,9 @@ public static final String CATEGORY_DOMAIN_CONFIGURATOR = "DomainConfigurator"; - public static final String CATEGORY_HTTP_FILTER = "HttpFilter"; + public static final String CATEGORY_FLOW_FILTER = "FlowFilter"; - public static final String CATEGORY_HTTP_CLIENT_LISTENER = "HttpClientListener"; + public static final String CATEGORY_CLIENT_LISTENER = "ClientListener"; public static final String CATEGORY_CREDENTIALS_PROVIDER = "CredentialsProvider";
--- a/stress-tester/src/test/java/com/passus/st/FilterScanner.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/FilterScanner.java Thu May 30 14:55:34 2019 +0200 @@ -1,6 +1,6 @@ package com.passus.st; -import com.passus.st.client.http.filter.HttpFilterFactory; +import com.passus.st.client.FlowFilterFactory; /** * @@ -9,7 +9,7 @@ public class FilterScanner { public static void main(String[] args) { - HttpFilterFactory.getInstance().getAll().stream() + FlowFilterFactory.getInstance().getAll().stream() .sorted((pi1, pi2) -> pi1.getPluginClass().getSimpleName().compareTo(pi2.getPluginClass().getSimpleName())) .forEach((pi) -> System.out.format("%-28s %s\n", pi.getElementName(), pi.getPluginClass().getSimpleName())); }
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -11,6 +11,7 @@ import com.passus.net.http.HttpResponseBuilder; import com.passus.st.AppUtils; import com.passus.st.client.FlowContext; +import com.passus.st.client.FlowFiltersConfigurator; import com.passus.st.client.credentials.Credentials; import com.passus.st.client.credentials.CredentialsProvider; import com.passus.st.client.credentials.CsvUsernamePasswordCredentialsProvider; @@ -19,7 +20,6 @@ import com.passus.st.client.credentials.UsernamePasswordCredentialsProvider; import static com.passus.st.client.http.HttpConsts.PARAM_USERNAME; import static com.passus.st.client.http.HttpConsts.TAG_SESSION_ID; -import com.passus.st.client.http.HttpFlowContext; import static com.passus.st.client.http.filter.HttpBasicAuthLoginFilter.decodeUsername; import static com.passus.st.client.http.filter.HttpBasicAuthLoginFilter.encode; import com.passus.st.utils.TestHttpUtils; @@ -138,7 +138,7 @@ filterConfig = String.format(filterConfig, file.getAbsolutePath()); Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, ConfigurationContext.create()); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, ConfigurationContext.create()); HttpFilterTestUtils.printErrors(errors); assertEquals(errors.getErrorCount(), 0);
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCounterFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCounterFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -12,6 +12,8 @@ import java.util.ArrayList; import java.util.List; import static org.testng.AssertJUnit.*; + +import com.passus.st.client.FlowFiltersConfigurator; import org.testng.annotations.Test; /** @@ -49,7 +51,7 @@ + " applyIf: {'@resp.status.code': 404}\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, null); HttpFilterTestUtils.printErrors(errors); assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -8,6 +8,7 @@ import com.passus.net.http.HttpResponseBuilder; import com.passus.st.ParametersBag; import com.passus.st.client.FlowContext; +import com.passus.st.client.FlowFiltersConfigurator; import com.passus.st.client.http.HttpScopes; import com.passus.st.client.http.filter.HttpCsrfFilter.*; import com.passus.st.emitter.SessionInfo; @@ -146,7 +147,7 @@ + " store: single\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFormFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFormFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -9,8 +9,7 @@ import com.passus.net.http.HttpResponse; import com.passus.net.http.HttpResponseBuilder; import com.passus.st.client.FlowContext; -import com.passus.st.client.http.HttpFlowContext; -import com.passus.st.client.http.HttpScopes; + import java.io.IOException; import java.util.List; @@ -19,6 +18,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.AssertJUnit.*; + +import com.passus.st.client.FlowFiltersConfigurator; import org.testng.annotations.Test; /** @@ -73,7 +74,7 @@ + " contentTypesToScan: ['text/html', 'application/xhtml+xml', 'application/xml']\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersConfiguratorTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersConfiguratorTest.java Thu May 30 14:55:34 2019 +0200 @@ -3,6 +3,7 @@ import com.passus.commons.utils.ResourceUtils; import com.passus.config.ConfigurationContext; import com.passus.config.validation.Errors; +import com.passus.st.client.FlowFiltersConfigurator; import com.passus.st.client.credentials.MultiCredentialsProvider; import com.passus.st.client.credentials.UsernamePasswordCredentialsProvider; import java.io.File; @@ -21,7 +22,7 @@ File file = ResourceUtils.getFile("com/passus/st/client/http/filter/http_message_modify_filter.yml"); Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(file, errors, ConfigurationContext.create()); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(file, errors, ConfigurationContext.create()); assertEquals(0, errors.getErrorCount()); assertTrue(filters.get(0) instanceof HttpMessageModificationFilter);
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreatorTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreatorTest.java Thu May 30 14:55:34 2019 +0200 @@ -10,6 +10,7 @@ import com.passus.config.YamlConfigurationReader; import com.passus.config.schema.NodeDefinition; import com.passus.config.validation.Errors; +import com.passus.st.client.FlowFilterNodeDefinitionCreator; import com.passus.st.client.http.filter.HttpMessageModificationOperations.*; import java.io.File; import java.util.List; @@ -27,7 +28,7 @@ File file = ResourceUtils.getFile("com/passus/st/client/http/filter/http_message_modify_filter.yml"); Configuration config = YamlConfigurationReader.readFromFile(file); - HttpFiltersNodeDefinitionCreator creator = new HttpFiltersNodeDefinitionCreator(); + FlowFilterNodeDefinitionCreator creator = new FlowFilterNodeDefinitionCreator(); NodeDefinition def = creator.create(); Errors errors = new Errors(); @@ -41,7 +42,7 @@ File file = ResourceUtils.getFile("com/passus/st/client/http/filter/http_message_modify_filter.yml"); Configuration config = YamlConfigurationReader.readFromFile(file); - NodeDefinition def = HttpFiltersNodeDefinitionCreator.createFiltersList(false); + NodeDefinition def = FlowFilterNodeDefinitionCreator.createFiltersList(false); Errors errors = new Errors(); CNode filtersNode = ((CTupleNode) config.getRootNode().getFirstChild()).getNode();
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpHostRewriterFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpHostRewriterFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -8,6 +8,7 @@ import static com.passus.net.http.HttpHeaders.*; import com.passus.net.http.HttpRequest; import com.passus.net.http.HttpRequestBuilder; +import com.passus.st.client.FlowFiltersConfigurator; import com.passus.st.client.http.filter.HttpHostRewriterFilter.HostPort; import java.util.List; import java.util.Map; @@ -89,7 +90,7 @@ + " \"example.com:8080\": \"example.org\"\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpLogoutFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpLogoutFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -7,6 +7,7 @@ import com.passus.net.http.HttpResponseBuilder; import com.passus.st.AppUtils; import com.passus.st.client.FlowContext; +import com.passus.st.client.FlowFiltersConfigurator; import com.passus.st.client.http.HttpScopes; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -85,7 +86,7 @@ + " applyIf: {\"@req.uri\": \"/logout\"}\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMarkFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMarkFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -5,6 +5,8 @@ import com.passus.net.http.HttpRequestBuilder; import com.passus.st.AppUtils; import static com.passus.st.client.http.HttpConsts.TAG_MARKER; + +import com.passus.st.client.FlowFiltersConfigurator; import com.passus.st.client.http.filter.HttpMarkFilter.Marker; import com.passus.st.client.http.filter.HttpMarkFilter.MarkerRule; import java.util.List; @@ -56,7 +58,7 @@ + " applyIf: {req.url: {$contains: test}}\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMatchFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMatchFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -13,6 +13,8 @@ import java.util.List; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; + +import com.passus.st.client.FlowFiltersConfigurator; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -100,7 +102,7 @@ + " '@resp.status.code': 200\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -7,6 +7,7 @@ import com.passus.net.http.*; import com.passus.st.AppUtils; import com.passus.st.client.FlowContext; +import com.passus.st.client.FlowFiltersConfigurator; import com.passus.st.extractor.ContentExtractorUtils; import com.passus.st.client.http.filter.HttpMessageModificationOperations.*; import com.passus.st.utils.ConfigurationContextConsts; @@ -191,7 +192,7 @@ Errors errors = new Errors(); ConfigurationContextImpl emptyContext = new ConfigurationContextImpl(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, emptyContext); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, emptyContext); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size()); assertTrue(filters.get(0) instanceof HttpMessageModificationFilter); @@ -241,7 +242,7 @@ Errors errors = new Errors(); ConfigurationContextImpl emptyContext = new ConfigurationContextImpl(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, emptyContext); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, emptyContext); HttpFilterTestUtils.printErrors(errors); assertEquals(0, errors.getErrorCount()); assertEquals(2, filters.size()); @@ -282,7 +283,7 @@ Errors errors = new Errors(); ConfigurationContextImpl context = new ConfigurationContextImpl(); context.add(ConfigurationContextConsts.APP_VARS, appVars); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, context); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, context); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size()); assertTrue(filters.get(0) instanceof HttpMessageModificationFilter); @@ -314,7 +315,7 @@ Errors errors = new Errors(); ConfigurationContextImpl emptyContext = new ConfigurationContextImpl(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, emptyContext); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, emptyContext); HttpFilterTestUtils.printErrors(errors); HttpMessageModificationFilter filter = (HttpMessageModificationFilter) filters.get(0); @@ -341,7 +342,7 @@ Errors errors = new Errors(); ConfigurationContextImpl emptyContext = new ConfigurationContextImpl(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, emptyContext); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, emptyContext); HttpFilterTestUtils.printErrors(errors); assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMvelFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMvelFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -7,6 +7,8 @@ import com.passus.net.http.HttpRequestBuilder; import java.io.File; import java.util.List; + +import com.passus.st.client.FlowFiltersConfigurator; import org.mvel2.MVEL; import org.mvel2.compiler.ExecutableStatement; import static org.testng.AssertJUnit.*; @@ -44,7 +46,7 @@ + " script: return -1\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, null); HttpFilterTestUtils.printErrors(errors); assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpScopeModificationFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpScopeModificationFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -8,6 +8,7 @@ import com.passus.net.http.HttpRequestBuilder; import com.passus.st.AppUtils; import com.passus.st.client.FlowContext; +import com.passus.st.client.FlowFiltersConfigurator; import com.passus.st.client.http.HttpConsts; import com.passus.st.client.http.HttpScopes; import com.passus.st.client.http.filter.HttpScopeModificationFilter.*; @@ -193,7 +194,7 @@ private HttpScopeModificationFilter processConfig(String cfg) throws Exception { Errors errors = new Errors(); ConfigurationContextImpl emptyContext = new ConfigurationContextImpl(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(cfg, errors, emptyContext); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(cfg, errors, emptyContext); assertEquals(errors.toString(), 0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -16,6 +16,7 @@ import com.passus.net.http.HttpResponse; import com.passus.net.http.HttpResponseBuilder; import com.passus.st.AppUtils; +import com.passus.st.client.FlowFiltersConfigurator; import com.passus.st.client.http.filter.HttpSequenceFilter.SequenceItem; import com.passus.st.filter.Transformers; import java.io.File; @@ -112,7 +113,7 @@ String filterConfig = new String(Files.readAllBytes(Paths.get(file.toURI()))); Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, null); HttpFilterTestUtils.printErrors(errors); assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSessionCookieFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSessionCookieFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -10,7 +10,7 @@ import static com.passus.st.client.http.HttpConsts.TAG_SESSION_ID; import com.passus.st.client.FlowContext; -import com.passus.st.client.http.HttpFlowContext; + import static com.passus.st.client.http.filter.HttpFilterTestUtils.createMockContext; import static com.passus.st.client.http.filter.HttpFlowUtils.extractHttpContext; import static com.passus.st.utils.TestHttpUtils.*; @@ -19,6 +19,8 @@ import java.util.List; import static org.mockito.Mockito.when; import static org.testng.Assert.*; + +import com.passus.st.client.FlowFiltersConfigurator; import org.testng.annotations.Test; /** @@ -260,7 +262,7 @@ + " removeInvalidSessionId: true\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, null); HttpFilterTestUtils.printErrors(errors); assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSimpleHeaderModificationFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -package com.passus.st.client.http.filter; - -import com.passus.filter.Filter; -import com.passus.data.ByteString; -import com.passus.net.http.HttpRequest; -import com.passus.net.http.HttpRequestBuilder; -import static org.testng.AssertJUnit.assertEquals; -import org.testng.annotations.Test; - -/** - * - * @author Mirosław Hawrot - */ -public class HttpSimpleHeaderModificationFilterTest { - - @Test - public void testAddRule() throws Exception { - HttpRequest req = HttpRequestBuilder.get("http://test/test") - .header("Test", "testValue") - .header("Test2", "testValue2") - .build(); - - HttpSimpleHeaderModificationFilter filter = new HttpSimpleHeaderModificationFilter(); - filter.addRule("Test testValue newTestValue"); - - assertEquals(Filter.DUNNO, filter.filterOutbound(req, null, null)); - assertEquals(ByteString.create("newTestValue"), req.getHeaders().get("Test")); - assertEquals(ByteString.create("testValue2"), req.getHeaders().get("Test2")); - } - -}
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpZoneFilterTest.java Thu May 30 13:09:03 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpZoneFilterTest.java Thu May 30 14:55:34 2019 +0200 @@ -7,6 +7,8 @@ import com.passus.net.http.HttpResponseBuilder; import com.passus.st.AppUtils; import static com.passus.st.client.http.HttpConsts.TAG_ZONE; + +import com.passus.st.client.FlowFiltersConfigurator; import com.passus.st.client.http.filter.HttpZoneFilter.Rule; import java.util.List; import static org.testng.AssertJUnit.assertEquals; @@ -56,7 +58,7 @@ + " \"zone1\": {req.url: {$contains: \"test\"}}\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); + List<HttpFilter> filters = FlowFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());