changeset 493:5be5e6e2288c

HttpFilterRequestWrapper.getHeader()
author Devel 1
date Sat, 12 Aug 2017 17:05:43 +0200
parents f7ad421d783b
children 9d398ff524b2
files stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterRequestWrapper.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessagePredicate.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/HttpMessageModificationFilterTest.java
diffstat 4 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterRequestWrapper.java	Fri Aug 11 12:33:48 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterRequestWrapper.java	Sat Aug 12 17:05:43 2017 +0200
@@ -1,6 +1,7 @@
 package com.passus.st.client.http.filter;
 
 import com.passus.data.ByteString;
+import com.passus.net.http.HttpHeaders;
 import com.passus.net.http.HttpRequest;
 import com.passus.net.http.URL;
 import static com.passus.st.client.http.HttpConsts.TAG_SESSION_ID;
@@ -33,4 +34,8 @@
         return (String) message.getTag(TAG_SESSION_ID);
     }
 
+    public ByteString getHeader(CharSequence name) {
+        HttpHeaders headers = message.getHeaders();
+        return headers.get(name);
+    }
 }
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessagePredicate.java	Fri Aug 11 12:33:48 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessagePredicate.java	Sat Aug 12 17:05:43 2017 +0200
@@ -4,8 +4,6 @@
 import com.passus.net.http.HttpMessage;
 import com.passus.net.http.HttpRequest;
 import com.passus.net.http.HttpResponse;
-import com.passus.st.client.http.HttpFlowContext;
-import com.passus.st.emitter.SessionInfo;
 import java.util.function.Predicate;
 
 /**
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMatchFilterTest.java	Fri Aug 11 12:33:48 2017 +0200
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMatchFilterTest.java	Sat Aug 12 17:05:43 2017 +0200
@@ -24,7 +24,7 @@
     private final PredicateNodeTransformer nodeTransformer = new PredicateNodeTransformer();
 
     private final List<HttpRequest> requests = Arrays.asList(
-            HttpRequestBuilder.get("http://test.com/test").build(),
+            HttpRequestBuilder.get("http://test.com/test").header("Header", "TheValue").build(),
             HttpRequestBuilder.get("http://test2.com/test2").build()
     );
 
@@ -72,6 +72,10 @@
         res = filter(requests, "{req.uri: {$contains: \"test2\"}}");
         assertEquals(1, res.size());
         assertEquals("/test2", res.get(0).getUri().toString());
+
+        res = filter(requests, "{\"req.getHeader('Header')\": {$contains: \"Val\"}}");
+        assertEquals(1, res.size());
+        assertEquals("/test", res.get(0).getUri().toString());
     }
 
     @Test
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java	Fri Aug 11 12:33:48 2017 +0200
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java	Sat Aug 12 17:05:43 2017 +0200
@@ -9,7 +9,6 @@
 import com.passus.st.AppUtils;
 import static com.passus.st.client.http.HttpConsts.TAG_SESSION_ID;
 import com.passus.st.client.http.HttpFlowContext;
-import com.passus.st.client.http.HttpScopes;
 import com.passus.st.client.http.filter.HttpMessageModificationFilter.AddCookieOperation;
 import com.passus.st.client.http.filter.HttpMessageModificationFilter.AddHeaderOperation;
 import com.passus.st.client.http.filter.HttpMessageModificationFilter.AddQueryParameterOperation;
@@ -24,7 +23,6 @@
 import com.passus.st.client.http.filter.HttpMessageModificationFilter.SetQueryParameterOperation;
 import java.util.Arrays;
 import java.util.List;
-import static org.mockito.Mockito.when;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;