changeset 622:bb4d01b23f40

minor fixes
author Devel 1
date Fri, 13 Oct 2017 14:44:36 +0200
parents aa6f7460c240
children 758409ac6dad
files stress-tester-benchmark/src/main/java/com/passus/st/client/http/filter/AbstractHttpMessagePredicateBenchmark.java stress-tester/src/test/java/com/passus/st/filter/HttpMessageHeaderValueExtractorTest.java stress-tester/src/test/java/com/passus/st/filter/HttpMessageValueExtractorTest.java
diffstat 3 files changed, 21 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester-benchmark/src/main/java/com/passus/st/client/http/filter/AbstractHttpMessagePredicateBenchmark.java	Fri Oct 13 07:45:01 2017 +0200
+++ b/stress-tester-benchmark/src/main/java/com/passus/st/client/http/filter/AbstractHttpMessagePredicateBenchmark.java	Fri Oct 13 14:44:36 2017 +0200
@@ -5,6 +5,7 @@
 import com.passus.net.http.HttpResponse;
 import com.passus.net.http.HttpResponseBuilder;
 import com.passus.st.AppUtils;
+import static com.passus.st.client.http.HttpConsts.TAG_SESSION_ID;
 import com.passus.utils.AllocationUtils;
 import java.util.function.Predicate;
 import org.openjdk.jmh.annotations.Benchmark;
@@ -24,11 +25,13 @@
     private final Predicate respGetHeader = predicate("{resp.getHeader('abc'): '/logout'}");
     private final Predicate reqUri = predicate("{req.uri: '/logout'}");
     private final Predicate reqUrl = predicate("{req.url: '/logout'}");
+    private final Predicate reqUrlHost = predicate("{req.url.host: 'test.com'}");
+    private final Predicate reqSid = predicate("{req.sessionId: 'sid'}");
     private final Predicate respStatusCode = 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")
-            .cookie("abc", "def").build();
+            .tag(TAG_SESSION_ID, "sid1").cookie("abc", "def").build();
     private final HttpResponse resp = HttpResponseBuilder.ok().header("abc", "def").build();
     private final HttpMessageWrapper wrapper = new HttpMessageWrapper(req, resp, null);
 
@@ -55,6 +58,16 @@
     }
 
     @Benchmark
+    public Object reqSid() {
+        return reqSid.test(wrapper);
+    }
+
+    @Benchmark
+    public Object reqUrlHost() {
+        return reqUrlHost.test(wrapper);
+    }
+
+    @Benchmark
     public Object compound() {
         return compound.test(wrapper);
     }
@@ -90,6 +103,8 @@
         System.out.println(bench.xRespGetHeader());
         System.out.println(bench.compound());
         System.out.println(bench.reqUrl());
+        System.out.println(bench.reqUrlHost());
+        System.out.println(bench.reqSid());
         System.out.println(bench.reqUri());
         System.out.println(bench.respStatusCode());
     }
--- a/stress-tester/src/test/java/com/passus/st/filter/HttpMessageHeaderValueExtractorTest.java	Fri Oct 13 07:45:01 2017 +0200
+++ b/stress-tester/src/test/java/com/passus/st/filter/HttpMessageHeaderValueExtractorTest.java	Fri Oct 13 14:44:36 2017 +0200
@@ -56,13 +56,13 @@
         assertNotNull(createForFunction(F_REQ_COOKIE));
 
         assertEquals("def", matchAndExtract(REQ_HEADER_FUN, F_REQ_HEADER));
-        assertNotNull(createForFunction(F_REQ_COOKIE));
+        assertNotNull(createForFunction(F_REQ_HEADER));
 
         assertEquals("ghi", matchAndExtract(RESP_COOKIE_FUN, F_RESP_COOKIE));
-        assertNotNull(createForFunction(F_REQ_COOKIE));
+        assertNotNull(createForFunction(F_RESP_COOKIE));
 
         assertEquals("jkl", matchAndExtract(RESP_HEADER_FUN, F_RESP_HEADER));
-        assertNotNull(createForFunction(F_REQ_COOKIE));
+        assertNotNull(createForFunction(F_RESP_HEADER));
 
         assertNull(createForFunction("req.getVersion()"));
     }
--- a/stress-tester/src/test/java/com/passus/st/filter/HttpMessageValueExtractorTest.java	Fri Oct 13 07:45:01 2017 +0200
+++ b/stress-tester/src/test/java/com/passus/st/filter/HttpMessageValueExtractorTest.java	Fri Oct 13 14:44:36 2017 +0200
@@ -16,16 +16,13 @@
  */
 public class HttpMessageValueExtractorTest {
 
-    private static final HttpRequest REQ = HttpRequestBuilder.get("http://www.example.com/1").build();
+    private static final HttpRequest REQ = HttpRequestBuilder.get("http://www.example.com/1")
+            .tag(TAG_SESSION_ID, "sid1").build();
 
     private static final HttpResponse RESP = HttpResponseBuilder.ok().build();
 
     private static final HttpMessageWrapper WRAPPER = new HttpMessageWrapper(REQ, RESP, null);
 
-    static {
-        REQ.setTag(TAG_SESSION_ID, "sid1");
-    }
-
     private static Object extract(String expr) {
         return new HttpMessageValueExtractor(expr, null).extract(WRAPPER);
     }