changeset 615:6019422b29de

do not use ComparisonPredicate.getFieldName()
author Devel 1
date Tue, 10 Oct 2017 12:28:09 +0200
parents 50ef5ab06550
children 962b0184d05e
files stress-tester-benchmark/src/main/java/com/passus/st/client/http/filter/HttpMessagePredicateBenchmark.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java
diffstat 2 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester-benchmark/src/main/java/com/passus/st/client/http/filter/HttpMessagePredicateBenchmark.java	Tue Oct 10 10:55:13 2017 +0200
+++ b/stress-tester-benchmark/src/main/java/com/passus/st/client/http/filter/HttpMessagePredicateBenchmark.java	Tue Oct 10 12:28:09 2017 +0200
@@ -38,19 +38,18 @@
 
     private static final PredicateNodeTransformer TRANSFORMER = new PredicateNodeTransformer();
 
-    private static HttpMessagePredicate predicate(String config) {
+    private static Predicate predicate(String config) {
         try {
-            Predicate predicate = TRANSFORMER.transform(config);
-            return new HttpMessagePredicate(predicate);
+            return TRANSFORMER.transform(config);
         } catch (Exception e) {
             throw new RuntimeException(e.getMessage(), e);
         }
     }
 
-    private final HttpMessagePredicate reqUriPred = predicate("{req.uri: '/logout'}");
-    private final HttpMessagePredicate reqUrlPred = predicate("{req.url: '/logout'}");
-    private final HttpMessagePredicate respStatusCodePred = predicate("{resp.status.code: 200}");
-    private final HttpMessagePredicate compound = predicate("{req.uri: '/logout', req.url: '/logout', resp.status.code: 200}");
+    private final Predicate reqUriPred = predicate("{req.uri: '/logout'}");
+    private final Predicate reqUrlPred = predicate("{req.url: '/logout'}");
+    private final Predicate respStatusCodePred = predicate("{resp.status.code: 200}");
+    private final Predicate compound = predicate("{req.uri: '/logout', req.url: '/logout', resp.status.code: 200}");
 
     private final HttpRequest req = HttpRequestBuilder.get("http://test.com/logout").build();
     private final HttpResponse resp = HttpResponseBuilder.ok().build();
@@ -99,5 +98,10 @@
         au.checkAllocation("reqUri", bench::reqUriPred);
         au.checkAllocation("reqUrl", bench::reqUrlPred);
         au.checkAllocation("respStatusCode", bench::respStatusCodePred);
+
+        System.out.println(bench.compound());
+        System.out.println(bench.reqUrlPred());
+        System.out.println(bench.reqUriPred());
+        System.out.println(bench.respStatusCodePred());
     }
 }
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java	Tue Oct 10 10:55:13 2017 +0200
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java	Tue Oct 10 12:28:09 2017 +0200
@@ -128,7 +128,8 @@
         assertEquals(2, p0.getSubPredicates().size());
         ComparisonPredicate sp1 = (ComparisonPredicate) p0.getSubPredicates().get(1);
         assertEquals(ComparisonOperator.NOT_EQUAL, sp1.getOperator());
-        assertEquals("resp.getCookie('id')", sp1.getFieldName());
+        BeanValueExtractor bve = (BeanValueExtractor) sp1.getFieldExtractor();
+        assertEquals("resp.getCookie('id')", bve.getFieldName());
         UnmutableValueExtractor uve = (UnmutableValueExtractor) sp1.getPattern();
         assertEquals(123, uve.extract(null));
 
@@ -136,7 +137,7 @@
         assertEquals(4, values.size());
         ValueExtractor extractor = values.get("header");
         assertTrue(extractor instanceof BeanValueExtractor);
-        BeanValueExtractor bve = (BeanValueExtractor) extractor;
+        bve = (BeanValueExtractor) extractor;
         assertEquals("last.req.getHeader('xyz')", bve.getFieldName());
     }