Mercurial > stress-tester
changeset 803:91e8f64cae1e
HttpScopeModificationFilter.direction
author | Devel 2 |
---|---|
date | Thu, 04 Jan 2018 15:03:34 +0100 |
parents | 01ee64902f6a |
children | 3700c4a39b27 |
files | stress-tester/src/main/java/com/passus/st/client/http/filter/HttpScopeModificationFilter.java |
diffstat | 1 files changed, 32 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpScopeModificationFilter.java Thu Jan 04 10:15:56 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpScopeModificationFilter.java Thu Jan 04 15:03:34 2018 +0100 @@ -4,6 +4,7 @@ import com.passus.commons.annotations.Plugin; import com.passus.config.Configuration; import com.passus.config.annotations.NodeDefinitionCreate; +import static com.passus.config.schema.ConfigurationSchemaBuilder.enumDef; import static com.passus.config.schema.ConfigurationSchemaBuilder.mapDef; import static com.passus.config.schema.ConfigurationSchemaBuilder.nullValueDef; import static com.passus.config.schema.ConfigurationSchemaBuilder.tupleDef; @@ -176,6 +177,8 @@ private HttpMessagePredicate predicate; + private HttpFilterDirection direction = HttpFilterDirection.OUT; + public HttpMessagePredicate getPredicate() { return predicate; } @@ -184,6 +187,15 @@ this.predicate = predicate; } + public HttpFilterDirection getDirection() { + return direction; + } + + public void setDirection(HttpFilterDirection direction) { + Assert.notNull(direction, "direction"); + this.direction = direction; + } + public void addOperation(Operation operation) { Assert.notNull(operation, "operation"); operations.add(operation); @@ -213,11 +225,11 @@ } } + direction = (HttpFilterDirection) config.get("dir", HttpFilterDirection.OUT); predicate = (HttpMessagePredicate) config.get("applyIf", null); } - @Override - public int filterOutbound(HttpRequest req, HttpResponse resp, HttpFlowContext context) { + private void filter(HttpRequest req, HttpResponse resp, HttpFlowContext context) { if (req != null && !operations.isEmpty()) { boolean exec = true; if (predicate != null) { @@ -231,6 +243,22 @@ } } } + } + + @Override + public int filterOutbound(HttpRequest req, HttpResponse resp, HttpFlowContext context) { + if (direction == HttpFilterDirection.BOTH || direction == HttpFilterDirection.OUT) { + filter(req, resp, context); + } + + return DUNNO; + } + + @Override + public int filterInbound(HttpRequest req, HttpResponse resp, HttpFlowContext context) { + if (direction == HttpFilterDirection.BOTH || direction == HttpFilterDirection.IN) { + filter(req, resp, context); + } return DUNNO; } @@ -268,7 +296,8 @@ return mapDef( tupleDef("operations", operationsDef), - tupleDef("applyIf", new HttpFilterMessagePredicateNodeDefinition()).setRequired(false) + tupleDef("applyIf", new HttpFilterMessagePredicateNodeDefinition()).setRequired(false), + tupleDef("dir", enumDef(HttpFilterDirection.class)).setRequired(false) ); } }