Mercurial > stress-tester
changeset 1012:cd6132690104
Filters generalization in progress
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/CliHelper.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/CliHelper.java Tue Mar 24 12:51:41 2020 +0100 @@ -10,8 +10,8 @@ import com.passus.net.PortRangeSet; import com.passus.net.http.session.HttpSessionAnalyzer; import com.passus.st.client.FlowExecutor; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import com.passus.st.client.http.filter.HttpVarsFilter; import com.passus.st.emitter.Emitter; import com.passus.st.emitter.PassThroughSessionMapper;
--- a/stress-tester/src/main/java/com/passus/st/ConverterHttpClient.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/ConverterHttpClient.java Tue Mar 24 12:51:41 2020 +0100 @@ -3,6 +3,8 @@ import com.passus.commons.Assert; import com.passus.commons.service.Service; import com.passus.st.client.*; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFilterChain; import com.passus.st.client.http.HttpScopes; import com.passus.st.client.http.filter.HttpFilter; import com.passus.st.client.http.filter.HttpFlowUtils;
--- a/stress-tester/src/main/java/com/passus/st/ConverterMain.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/ConverterMain.java Tue Mar 24 12:51:41 2020 +0100 @@ -1,8 +1,7 @@ package com.passus.st; import com.passus.config.ConfigurationContext; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.http.filter.HttpFilter; +import com.passus.st.client.filter.FlowFilter; import com.passus.st.reader.nc.HttpWriteMode; import com.passus.st.source.NcEventDestination; import com.passus.st.source.PcapSessionEventSource;
--- a/stress-tester/src/main/java/com/passus/st/Main.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/Main.java Tue Mar 24 12:51:41 2020 +0100 @@ -5,8 +5,8 @@ import com.passus.commons.service.Registry; import com.passus.config.ConfigurationContext; import com.passus.st.client.*; +import com.passus.st.client.filter.FlowFilter; import com.passus.st.client.http.*; -import com.passus.st.client.http.filter.HttpFilter; import com.passus.st.emitter.SessionMapper; import com.passus.st.emitter.nio.NioEmitter; import com.passus.st.metric.FileMetricsCollectionAppender;
--- a/stress-tester/src/main/java/com/passus/st/Main2.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/Main2.java Tue Mar 24 12:51:41 2020 +0100 @@ -5,6 +5,7 @@ import com.passus.commons.service.Registry; import com.passus.config.ConfigurationContext; import com.passus.st.client.*; +import com.passus.st.client.filter.FlowFilter; import com.passus.st.client.http.*; import com.passus.st.emitter.SessionMapper; import com.passus.st.emitter.nio.NioEmitter;
--- a/stress-tester/src/main/java/com/passus/st/client/FilterAware.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/FilterAware.java Tue Mar 24 12:51:41 2020 +0100 @@ -1,5 +1,7 @@ package com.passus.st.client; +import com.passus.st.client.filter.FlowFilter; + import java.util.Collection; import java.util.List;
--- a/stress-tester/src/main/java/com/passus/st/client/Flow.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/Flow.java Tue Mar 24 12:51:41 2020 +0100 @@ -1,6 +1,7 @@ package com.passus.st.client; import com.passus.config.Configurable; +import com.passus.st.client.filter.FlowFilter; import com.passus.st.emitter.Emitter; import com.passus.st.metric.MetricSource;
--- a/stress-tester/src/main/java/com/passus/st/client/FlowExecutor.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/FlowExecutor.java Tue Mar 24 12:51:41 2020 +0100 @@ -13,6 +13,9 @@ import com.passus.config.validation.EnumValidator; import com.passus.config.validation.Errors; import com.passus.config.validation.LongValidator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFilterChain; +import com.passus.st.client.filter.FlowFilterNodeDefinitionCreator; import com.passus.st.emitter.Emitter; import com.passus.st.metric.MetricSource; import com.passus.st.metric.MetricsContainer;
--- a/stress-tester/src/main/java/com/passus/st/client/FlowFilter.java Tue Mar 24 12:11:15 2020 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -package com.passus.st.client; - -import com.passus.config.Configurable; -import com.passus.config.Configuration; -import com.passus.config.ConfigurationContext; - -public interface FlowFilter extends Configurable { - - int DENY = -1; - - int DUNNO = 0; - - int ACCEPT = 1; - - default void reset() { - - } - - @Override - default void configure(Configuration config, ConfigurationContext context) { - - } - - default int filterInbound(Object req, Object resp, FlowContext context) { - return DUNNO; - } - - default int filterOutbound(Object req, Object resp, FlowContext context) { - return DUNNO; - } - - FlowFilter instanceForWorker(int index); -}
--- a/stress-tester/src/main/java/com/passus/st/client/FlowFilterChain.java Tue Mar 24 12:11:15 2020 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -package com.passus.st.client; - -import com.passus.filter.Filter; - -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -public class FlowFilterChain { - - protected final LinkedList<FlowFilter> filters = new LinkedList<>(); - - public List<FlowFilter> getFilters() { - return Collections.unmodifiableList(filters); - } - - @SuppressWarnings("unchecked") - public void addFilter(FlowFilter filter) { - filters.add(filter); - } - - public void clear() { - filters.clear(); - } - - public boolean isEmpty() { - return filters.isEmpty(); - } - - @SuppressWarnings("unchecked") - public int filterOutbound(Object request, Object resp, FlowContext context) { - Iterator<FlowFilter> it = filters.iterator(); - while (it.hasNext()) { - FlowFilter f = it.next(); - int res = f.filterOutbound(request, resp, context); - if (res != Filter.DUNNO) { - return res; - } - } - - return Filter.ACCEPT; - } - - @SuppressWarnings("unchecked") - public int filterInbound(Object request, Object resp, FlowContext context) { - Iterator<FlowFilter> it = filters.iterator(); - while (it.hasNext()) { - FlowFilter f = it.next(); - int res = f.filterInbound(request, resp, context); - if (res != Filter.DUNNO) { - return res; - } - } - - return Filter.ACCEPT; - } - - public void reset() { - Iterator<FlowFilter> it = filters.iterator(); - while (it.hasNext()) { - FlowFilter f = it.next(); - f.reset(); - } - } - - public FlowFilterChain instanceForWorker(int index) { - FlowFilterChain copy = new FlowFilterChain(); - - Iterator<FlowFilter> it = filters.iterator(); - while (it.hasNext()) { - FlowFilter f = it.next(); - copy.addFilter(f.instanceForWorker(index)); - } - - return copy; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("FlowFilterChain@").append(System.identityHashCode(this)); - sb.append(" {"); - - Iterator<FlowFilter> it = filters.iterator(); - while (it.hasNext()) { - FlowFilter f = it.next(); - sb.append(f).append(", "); - } - sb.append("}"); - - return sb.toString(); - } - -}
--- a/stress-tester/src/main/java/com/passus/st/client/FlowFilterFactory.java Tue Mar 24 12:11:15 2020 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -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; - } -}
--- a/stress-tester/src/main/java/com/passus/st/client/FlowFilterNodeDefinitionCreator.java Tue Mar 24 12:11:15 2020 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -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); - } - -}
--- a/stress-tester/src/main/java/com/passus/st/client/FlowFiltersConfigurator.java Tue Mar 24 12:11:15 2020 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -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.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<FlowFilter> filters = ConfigurationUtils.convertToList(rootNode, FlowFilter.class); - context.add(ConfigurationContextConsts.FLOW_FILTERS, filters); - } catch (Exception e) { - throw new RuntimeException(e.getMessage(), e); - } - - } - } - -}
--- a/stress-tester/src/main/java/com/passus/st/client/FlowWorker.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/FlowWorker.java Tue Mar 24 12:51:41 2020 +0100 @@ -3,6 +3,7 @@ import com.passus.commons.Assert; import com.passus.commons.time.TimeAware; import com.passus.commons.time.TimeGenerator; +import com.passus.st.client.filter.FlowFilterChain; import com.passus.st.emitter.Emitter; import com.passus.st.emitter.EmitterHandler; import com.passus.st.emitter.SessionInfo;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/filter/CounterFilter.java Tue Mar 24 12:51:41 2020 +0100 @@ -0,0 +1,115 @@ +package com.passus.st.client.filter; + +import com.passus.commons.annotations.Plugin; +import com.passus.config.Configuration; +import com.passus.config.ConfigurationContext; +import com.passus.config.annotations.NodeDefinitionCreate; +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.filter.HttpFilter; +import com.passus.st.client.http.filter.HttpFilterMessagePredicateNodeDefinition; +import com.passus.st.client.http.filter.HttpMessagePredicate; +import com.passus.st.plugin.PluginConstants; + +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Predicate; + +import static com.passus.config.schema.ConfigurationSchemaBuilder.*; + +/** + * + * @author mikolaj.podbielski + */ +@NodeDefinitionCreate(CounterFilter.NodeDefCreator.class) +//@Plugin(name = CounterFilter.TYPE, category = PluginConstants.CATEGORY_FLOW_FILTER) +public class CounterFilter implements FlowFilter { + + public static final String TYPE = "counter"; + + private static final AtomicInteger ID = new AtomicInteger(); + + private MessagePredicate predicate; + private String name; + private int limit; + private CounterListener listener = (e) -> { + }; + + private int count; + + MessagePredicate getPredicate() { + return predicate; + } + + void setPredicate(MessagePredicate predicate) { + this.predicate = predicate; + } + + String getName() { + return name; + } + + void setName(String name) { + this.name = name; + } + + int getLimit() { + return limit; + } + + void setLimit(int limit) { + this.limit = limit; + } + + CounterListener getListener() { + return listener; + } + + void setListener(CounterListener listener) { + this.listener = listener; + } + + @Override + public void configure(Configuration config, ConfigurationContext context) { + predicate = (MessagePredicate) config.get("applyIf"); + limit = config.getInteger("limit"); + name = config.getString("name", "counter_" + ID.getAndIncrement()); + // TODO: + listener = System.out::println; + } + + @Override + public int filterInbound(Object req, Object resp, FlowContext context) { + if (predicate.test(req, resp, context)) { + if (++count >= limit) { + listener.limitReached(new CounterListener.Event(this)); + } + } + return DUNNO; + } + + @Override + public CounterFilter instanceForWorker(int index) { + CounterFilter filter = new CounterFilter(); + filter.predicate = predicate; + filter.name = name; + filter.limit = limit; + filter.listener = listener; + return filter; + } + + public static class NodeDefCreator implements NodeDefinitionCreator { + + @Override + public NodeDefinition create() { + return mapDef( + tupleDef("applyIf", new HttpFilterMessagePredicateNodeDefinition()), + tupleDef("limit", valueDefInteger()), + tupleDef("name", valueDef()).setRequired(false) + ); + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/filter/CounterListener.java Tue Mar 24 12:51:41 2020 +0100 @@ -0,0 +1,20 @@ +package com.passus.st.client.filter; + +/** + * + * @author mikolaj.podbielski + */ +public interface CounterListener { + + public void limitReached(Event event); + + public static final class Event { + private final CounterFilter filter; +// HttpRequest req + + public Event(CounterFilter filter) { + this.filter = filter; + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/filter/FlowFilter.java Tue Mar 24 12:51:41 2020 +0100 @@ -0,0 +1,34 @@ +package com.passus.st.client.filter; + +import com.passus.config.Configurable; +import com.passus.config.Configuration; +import com.passus.config.ConfigurationContext; +import com.passus.st.client.FlowContext; + +public interface FlowFilter extends Configurable { + + int DENY = -1; + + int DUNNO = 0; + + int ACCEPT = 1; + + default void reset() { + + } + + @Override + default void configure(Configuration config, ConfigurationContext context) { + + } + + default int filterInbound(Object req, Object resp, FlowContext context) { + return DUNNO; + } + + default int filterOutbound(Object req, Object resp, FlowContext context) { + return DUNNO; + } + + FlowFilter instanceForWorker(int index); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/filter/FlowFilterChain.java Tue Mar 24 12:51:41 2020 +0100 @@ -0,0 +1,96 @@ +package com.passus.st.client.filter; + +import com.passus.filter.Filter; +import com.passus.st.client.FlowContext; + +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +public class FlowFilterChain { + + protected final LinkedList<FlowFilter> filters = new LinkedList<>(); + + public List<FlowFilter> getFilters() { + return Collections.unmodifiableList(filters); + } + + @SuppressWarnings("unchecked") + public void addFilter(FlowFilter filter) { + filters.add(filter); + } + + public void clear() { + filters.clear(); + } + + public boolean isEmpty() { + return filters.isEmpty(); + } + + @SuppressWarnings("unchecked") + public int filterOutbound(Object request, Object resp, FlowContext context) { + Iterator<FlowFilter> it = filters.iterator(); + while (it.hasNext()) { + FlowFilter f = it.next(); + int res = f.filterOutbound(request, resp, context); + if (res != Filter.DUNNO) { + return res; + } + } + + return Filter.ACCEPT; + } + + @SuppressWarnings("unchecked") + public int filterInbound(Object request, Object resp, FlowContext context) { + Iterator<FlowFilter> it = filters.iterator(); + while (it.hasNext()) { + FlowFilter f = it.next(); + int res = f.filterInbound(request, resp, context); + if (res != Filter.DUNNO) { + return res; + } + } + + return Filter.ACCEPT; + } + + public void reset() { + Iterator<FlowFilter> it = filters.iterator(); + while (it.hasNext()) { + FlowFilter f = it.next(); + f.reset(); + } + } + + public FlowFilterChain instanceForWorker(int index) { + FlowFilterChain copy = new FlowFilterChain(); + + Iterator<FlowFilter> it = filters.iterator(); + while (it.hasNext()) { + FlowFilter f = it.next(); + copy.addFilter(f.instanceForWorker(index)); + } + + return copy; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("FlowFilterChain@").append(System.identityHashCode(this)); + sb.append(" {"); + + Iterator<FlowFilter> it = filters.iterator(); + while (it.hasNext()) { + FlowFilter f = it.next(); + sb.append(f).append(", "); + } + sb.append("}"); + + return sb.toString(); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/filter/FlowFilterFactory.java Tue Mar 24 12:51:41 2020 +0100 @@ -0,0 +1,24 @@ +package com.passus.st.client.filter; + +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/filter/FlowFilterNodeDefinitionCreator.java Tue Mar 24 12:51:41 2020 +0100 @@ -0,0 +1,22 @@ +package com.passus.st.client.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 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/filter/FlowFiltersConfigurator.java Tue Mar 24 12:51:41 2020 +0100 @@ -0,0 +1,67 @@ +package com.passus.st.client.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 = 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<FlowFilter> filters = ConfigurationUtils.convertToList(rootNode, FlowFilter.class); + context.add(ConfigurationContextConsts.FLOW_FILTERS, filters); + } catch (Exception e) { + throw new RuntimeException(e.getMessage(), e); + } + + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/filter/MessagePredicate.java Tue Mar 24 12:51:41 2020 +0100 @@ -0,0 +1,58 @@ +package com.passus.st.client.filter; + +import com.passus.commons.Assert; +import com.passus.commons.ConversionException; +import com.passus.config.NodeException; +import com.passus.st.client.FlowContext; +import com.passus.st.client.http.filter.HttpMessagePredicate; + +import java.io.IOException; +import java.util.function.Predicate; + +public class MessagePredicate<T> implements Predicate<T> { + + private final Predicate predicate; + + public MessagePredicate(Predicate predicate) { + Assert.notNull(predicate, "predicate"); + this.predicate = predicate; + } + + public Predicate getPredicate() { + return predicate; + } + + public boolean test(Object req, Object resp, FlowContext context) { + throw new RuntimeException("Not implemented."); + //return test(new HttpMessageWrapper(req, resp, context)); + } + + public boolean test(MessageWrapper wrapper) { + return predicate.test(wrapper); + } + + @Override + public boolean test(T message) { + /*HttpMessageWrapper wrapper; + if (message.isRequest()) { + wrapper = new HttpMessageWrapper((HttpRequest) message, null, null); + } else { + wrapper = new HttpMessageWrapper(null, (HttpResponse) message, null); + } + + return predicate.test(wrapper);*/ + throw new RuntimeException("Not implemented."); + } + + @Override + public String toString() { + return predicate.toString(); + } + + public static HttpMessagePredicate parse(String content) throws ConversionException, IOException, NodeException { + /*Predicate predicate = Transformers.PREDICATE.transform(content); + return new HttpMessagePredicate(predicate);*/ + + throw new RuntimeException("Not implemented."); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/filter/MessageWrapper.java Tue Mar 24 12:51:41 2020 +0100 @@ -0,0 +1,22 @@ +package com.passus.st.client.filter; + +public class MessageWrapper<R, S> { + + private final R req; + + private final S resp; + + public MessageWrapper(R req, S resp) { + this.req = req; + this.resp = resp; + } + + public R getReq() { + return req; + } + + public S getResp() { + return resp; + } + +}
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilter.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilter.java Tue Mar 24 12:51:41 2020 +0100 @@ -3,7 +3,7 @@ import com.passus.net.http.HttpRequest; import com.passus.net.http.HttpResponse; import com.passus.st.client.FlowContext; -import com.passus.st.client.FlowFilter; +import com.passus.st.client.filter.FlowFilter; /** * @author Mirosław Hawrot
--- a/stress-tester/src/main/java/com/passus/st/job/TestJob.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/main/java/com/passus/st/job/TestJob.java Tue Mar 24 12:51:41 2020 +0100 @@ -4,6 +4,7 @@ import com.passus.config.ConfigurationContext; import com.passus.filter.ValueExtractor; import com.passus.st.client.*; +import com.passus.st.client.filter.FlowFilter; import com.passus.st.client.http.ReporterDestination; import com.passus.st.client.http.filter.HttpVarsFilter; import com.passus.st.emitter.Emitter;
--- a/stress-tester/src/test/java/com/passus/st/FilterScanner.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/FilterScanner.java Tue Mar 24 12:51:41 2020 +0100 @@ -1,6 +1,6 @@ package com.passus.st; -import com.passus.st.client.FlowFilterFactory; +import com.passus.st.client.filter.FlowFilterFactory; /** *
--- a/stress-tester/src/test/java/com/passus/st/client/FlowExecutorTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/FlowExecutorTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -2,14 +2,16 @@ import com.passus.commons.service.ServiceUtils; import com.passus.st.AbstractWireMockTest; -import com.passus.st.Log4jConfigurationFactory; import com.passus.st.emitter.RuleBasedSessionMapper; import com.passus.st.emitter.nio.NioEmitter; import com.passus.st.utils.EventUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.util.*; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static org.testng.AssertJUnit.assertEquals;
--- a/stress-tester/src/test/java/com/passus/st/client/FlowFilterChainTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/FlowFilterChainTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -1,5 +1,7 @@ package com.passus.st.client; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFilterChain; import org.testng.annotations.Test; import static com.passus.st.client.http.filter.HttpFilter.*;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -11,8 +11,8 @@ import com.passus.net.http.HttpResponseBuilder; import com.passus.st.AppUtils; import com.passus.st.client.FlowContext; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import com.passus.st.client.credentials.Credentials; import com.passus.st.client.credentials.CredentialsProvider; import com.passus.st.client.credentials.CsvUsernamePasswordCredentialsProvider;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCounterFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCounterFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -13,8 +13,8 @@ import java.util.List; import static org.testng.AssertJUnit.*; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import org.testng.annotations.Test; /**
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -8,8 +8,8 @@ import com.passus.net.http.HttpResponseBuilder; import com.passus.st.ParametersBag; import com.passus.st.client.FlowContext; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import com.passus.st.client.http.HttpScopes; import com.passus.st.client.http.filter.HttpCsrfFilter.*; import com.passus.st.emitter.SessionInfo;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFormFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFormFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -19,8 +19,8 @@ import static org.mockito.Mockito.when; import static org.testng.AssertJUnit.*; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import org.testng.annotations.Test; /**
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersConfiguratorTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersConfiguratorTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -3,8 +3,8 @@ import com.passus.commons.utils.ResourceUtils; import com.passus.config.ConfigurationContext; import com.passus.config.validation.Errors; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import com.passus.st.client.credentials.MultiCredentialsProvider; import com.passus.st.client.credentials.UsernamePasswordCredentialsProvider; import java.io.File;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreatorTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreatorTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -10,7 +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.filter.FlowFilterNodeDefinitionCreator; import com.passus.st.client.http.filter.HttpMessageModificationOperations.*; import java.io.File; import java.util.List;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpHostRewriterFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpHostRewriterFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -8,8 +8,8 @@ import static com.passus.net.http.HttpHeaders.*; import com.passus.net.http.HttpRequest; import com.passus.net.http.HttpRequestBuilder; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import com.passus.st.client.http.filter.HttpHostRewriterFilter.HostPort; import java.util.List; import java.util.Map;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpLogoutFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpLogoutFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -7,8 +7,8 @@ import com.passus.net.http.HttpResponseBuilder; import com.passus.st.AppUtils; import com.passus.st.client.FlowContext; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import com.passus.st.client.http.HttpScopes; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMarkFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMarkFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -6,8 +6,8 @@ import com.passus.st.AppUtils; import static com.passus.st.client.http.HttpConsts.TAG_MARKER; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import com.passus.st.client.http.filter.HttpMarkFilter.Marker; import com.passus.st.client.http.filter.HttpMarkFilter.MarkerRule; import java.util.List;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMatchFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMatchFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -14,8 +14,8 @@ import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -7,8 +7,8 @@ import com.passus.net.http.*; import com.passus.st.AppUtils; import com.passus.st.client.FlowContext; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import com.passus.st.extractor.ContentExtractorUtils; import com.passus.st.client.http.filter.HttpMessageModificationOperations.*; import com.passus.st.utils.ConfigurationContextConsts;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMvelFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMvelFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -8,8 +8,8 @@ import java.io.File; import java.util.List; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import org.mvel2.MVEL; import org.mvel2.compiler.ExecutableStatement; import static org.testng.AssertJUnit.*;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpScopeModificationFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpScopeModificationFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -8,8 +8,8 @@ import com.passus.net.http.HttpRequestBuilder; import com.passus.st.AppUtils; import com.passus.st.client.FlowContext; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import com.passus.st.client.http.HttpConsts; import com.passus.st.client.http.HttpScopes; import com.passus.st.client.http.filter.HttpScopeModificationFilter.*;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -16,8 +16,8 @@ import com.passus.net.http.HttpResponse; import com.passus.net.http.HttpResponseBuilder; import com.passus.st.AppUtils; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import com.passus.st.client.http.filter.HttpSequenceFilter.SequenceItem; import com.passus.st.filter.Transformers; import java.io.File;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSessionCookieFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSessionCookieFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -20,8 +20,8 @@ import static org.mockito.Mockito.when; import static org.testng.Assert.*; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import org.testng.annotations.Test; /**
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpZoneFilterTest.java Tue Mar 24 12:11:15 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpZoneFilterTest.java Tue Mar 24 12:51:41 2020 +0100 @@ -8,8 +8,8 @@ import com.passus.st.AppUtils; import static com.passus.st.client.http.HttpConsts.TAG_ZONE; -import com.passus.st.client.FlowFilter; -import com.passus.st.client.FlowFiltersConfigurator; +import com.passus.st.client.filter.FlowFilter; +import com.passus.st.client.filter.FlowFiltersConfigurator; import com.passus.st.client.http.filter.HttpZoneFilter.Rule; import java.util.List; import static org.testng.AssertJUnit.assertEquals;