changeset 805:4f6b12b34947

adjusted to passus-filter r239 (fieldName without @)
author Devel 1
date Thu, 04 Jan 2018 16:14:45 +0100
parents 3700c4a39b27
children 763539ab7343
files stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSequenceFilter.java stress-tester/src/main/java/com/passus/st/filter/Transformers.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCounterFilterTest.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFilterTestUtils.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMatchFilterTest.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java
diffstat 6 files changed, 24 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSequenceFilter.java	Thu Jan 04 15:08:34 2018 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSequenceFilter.java	Thu Jan 04 16:14:45 2018 +0100
@@ -205,8 +205,8 @@
         }
 
         public void updateValue(HttpMessageWrapper wrapper) {
-            valueMap.put("@req", wrapper.getReq());
-            valueMap.put("@resp", wrapper.getResp());
+            valueMap.put("req", wrapper.getReq());
+            valueMap.put("resp", wrapper.getResp());
         }
 
         public void persistsValue(HttpMessageWrapper wrapper, String[] aliases) {
@@ -316,8 +316,8 @@
 
         // TODO: refactor
         final Map<String, Object> valueMap = new HashMap<>();
-        valueMap.put("@req", value.getReq());
-        valueMap.put("@resp", value.getResp());
+        valueMap.put("req", value.getReq());
+        valueMap.put("resp", value.getResp());
 
         if (seqItems[0].match(valueMap)) {
             SeqChain chain = new SeqChain(seqItems, now, valueMap);
--- a/stress-tester/src/main/java/com/passus/st/filter/Transformers.java	Thu Jan 04 15:08:34 2018 +0100
+++ b/stress-tester/src/main/java/com/passus/st/filter/Transformers.java	Thu Jan 04 16:14:45 2018 +0100
@@ -11,9 +11,9 @@
  */
 public class Transformers {
 
-    public static final ValueExtractorResolver FIELD_EXTRACTOR_FACTORY = new HttpMessageValueExtractorResolver();
+    public static final ValueExtractorResolver VALUE_EXTRACTOR_RESOLVER = new HttpMessageValueExtractorResolver();
 
-    public static final PredicateNodeTransformer PREDICATE = new PredicateNodeTransformer(FIELD_EXTRACTOR_FACTORY);
+    public static final PredicateNodeTransformer PREDICATE = new PredicateNodeTransformer(VALUE_EXTRACTOR_RESOLVER);
 
-    public static final ExpressionNodeTransformer EXPRESSION = new ExpressionNodeTransformer(new ValueExtractorParser(FIELD_EXTRACTOR_FACTORY));
+    public static final ExpressionNodeTransformer EXPRESSION = new ExpressionNodeTransformer(new ValueExtractorParser(VALUE_EXTRACTOR_RESOLVER));
 }
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCounterFilterTest.java	Thu Jan 04 15:08:34 2018 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCounterFilterTest.java	Thu Jan 04 16:14:45 2018 +0100
@@ -63,7 +63,7 @@
         AndPredicate<? extends Object> andPredicate = (AndPredicate) filter.getPredicate().getPredicate();
         assertEquals(1, andPredicate.getSubPredicates().size());
         ComparisonPredicate predicate = (ComparisonPredicate) andPredicate.getSubPredicates().get(0);
-        assertEquals("@resp.status.code", predicate.getFieldName());
+        assertEquals("resp.status.code", predicate.getFieldName());
         assertEquals(ComparisonOperator.EQUAL, predicate.getOperator());
     }
 
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFilterTestUtils.java	Thu Jan 04 15:08:34 2018 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFilterTestUtils.java	Thu Jan 04 16:14:45 2018 +0100
@@ -3,6 +3,7 @@
 import com.passus.commons.utils.ReflectionUtils;
 import com.passus.config.validation.Errors;
 import com.passus.config.validation.ObjectError;
+import com.passus.filter.config.PredicateNodeTransformer;
 import com.passus.net.http.HttpMessage;
 import com.passus.st.ParametersBag;
 import static com.passus.st.client.http.HttpConsts.TAG_SESSION_ID;
@@ -22,6 +23,8 @@
  */
 public class HttpFilterTestUtils {
 
+    private static final boolean DEFAULT_USE_ACCELERATED_EXTRACTORS = true;
+
     public static HttpFlowContext createMockContext() {
         HttpFlowContext mockContext = mock(HttpFlowContext.class);
         final HttpScopes scopes = new HttpScopes();
@@ -30,8 +33,14 @@
     }
 
     public static HttpMessagePredicate createPredicate(String config) {
+        return createPredicate(config, DEFAULT_USE_ACCELERATED_EXTRACTORS);
+    }
+
+    public static HttpMessagePredicate createPredicate(String config, boolean useAcceleratedExtractor) {
         try {
-            Predicate predicate = Transformers.PREDICATE.transform(config);
+            PredicateNodeTransformer transformer = useAcceleratedExtractor
+                    ? Transformers.PREDICATE : PredicateNodeTransformer.DEFAULT;
+            Predicate predicate = transformer.transform(config);
             return new HttpMessagePredicate(predicate);
         } catch (Exception e) {
             throw new RuntimeException(e.getMessage(), e);
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMatchFilterTest.java	Thu Jan 04 15:08:34 2018 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMatchFilterTest.java	Thu Jan 04 16:14:45 2018 +0100
@@ -84,6 +84,11 @@
 
         resps = filter(responses, "{'@resp.status.code': {$gt: 200}}");
         assertEquals(2, resps.size());
+
+        HttpMessagePredicate predicate = HttpFilterTestUtils.createPredicate(
+                "{'@resp.status.code': {$gt: 200}}", false);
+        resps = filter(responses, predicate);
+        assertEquals(2, resps.size());
     }
 
     @Test
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java	Thu Jan 04 15:08:34 2018 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java	Thu Jan 04 16:14:45 2018 +0100
@@ -130,7 +130,7 @@
         ComparisonPredicate sp1 = (ComparisonPredicate) p0.getSubPredicates().get(1);
         assertEquals(ComparisonOperator.NOT_EQUAL, sp1.getOperator());
 
-        assertEquals("@resp.getCookie('id')", sp1.getFieldName());
+        assertEquals("resp.getCookie('id')", sp1.getFieldName());
 
         UnmutableValueExtractor uve = (UnmutableValueExtractor) sp1.getPattern();
         assertEquals(123, uve.extract(null));