changeset 627:6c8ad9bd2767

filters switched to faster extractors
author Devel 1
date Tue, 17 Oct 2017 13:10:50 +0200
parents 53957b94f932
children ace9b1e69e96
files stress-tester/src/main/java/com/passus/st/filter/Transformers.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java
diffstat 2 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/filter/Transformers.java	Tue Oct 17 12:45:50 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/filter/Transformers.java	Tue Oct 17 13:10:50 2017 +0200
@@ -1,6 +1,8 @@
 package com.passus.st.filter;
 
+import com.passus.filter.ValueExtractorParser;
 import com.passus.filter.config.ExpressionNodeTransformer;
+import com.passus.filter.config.FieldExtractorFactory;
 import com.passus.filter.config.PredicateNodeTransformer;
 
 /**
@@ -8,8 +10,10 @@
  * @author mikolaj.podbielski
  */
 public class Transformers {
-    
-    public static final PredicateNodeTransformer PREDICATE = new PredicateNodeTransformer();
-    
-    public static final ExpressionNodeTransformer EXPRESSION = new ExpressionNodeTransformer();
+
+    public static final FieldExtractorFactory FIELD_EXTRACTOR_FACTORY = new HttpMessageFieldExtractorFactory();
+
+    public static final PredicateNodeTransformer PREDICATE = new PredicateNodeTransformer(FIELD_EXTRACTOR_FACTORY);
+
+    public static final ExpressionNodeTransformer EXPRESSION = new ExpressionNodeTransformer(new ValueExtractorParser(FIELD_EXTRACTOR_FACTORY));
 }
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java	Tue Oct 17 12:45:50 2017 +0200
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java	Tue Oct 17 13:10:50 2017 +0200
@@ -17,6 +17,7 @@
 import com.passus.net.http.HttpResponseBuilder;
 import com.passus.st.AppUtils;
 import com.passus.st.client.http.filter.HttpSequenceFilter.SequenceItem;
+import com.passus.st.filter.HttpMessageHeaderValueExtractor;
 import com.passus.st.filter.Transformers;
 import java.io.File;
 import java.io.Serializable;
@@ -129,8 +130,15 @@
         assertEquals(2, p0.getSubPredicates().size());
         ComparisonPredicate sp1 = (ComparisonPredicate) p0.getSubPredicates().get(1);
         assertEquals(ComparisonOperator.NOT_EQUAL, sp1.getOperator());
-        BeanValueExtractor bve = (BeanValueExtractor) sp1.getFieldExtractor();
-        assertEquals("resp.getCookie('id')", bve.getFieldName());
+
+        ValueExtractor fieldExtractor = sp1.getFieldExtractor();
+        if (fieldExtractor instanceof BeanValueExtractor) {
+            BeanValueExtractor bve = (BeanValueExtractor) fieldExtractor;
+            assertEquals("resp.getCookie('id')", bve.getFieldName());
+        } else {
+            assertTrue(fieldExtractor instanceof HttpMessageHeaderValueExtractor);
+        }
+
         UnmutableValueExtractor uve = (UnmutableValueExtractor) sp1.getPattern();
         assertEquals(123, uve.extract(null));
 
@@ -138,7 +146,7 @@
         assertEquals(4, values.size());
         ValueExtractor extractor = values.get("header");
         assertTrue(extractor instanceof BeanValueExtractor);
-        bve = (BeanValueExtractor) extractor;
+        BeanValueExtractor bve = (BeanValueExtractor) extractor;
         assertEquals("last.req.getHeader('xyz')", bve.getFieldName());
     }