changeset 995:c5adbd85528f

Bugfixes
author Devel 2
date Thu, 26 Sep 2019 14:54:18 +0200
parents 594cf55e9e91
children 14489dda952a
files stress-tester/src/main/java/com/passus/st/client/http/ReporterFileDestination.java stress-tester/src/main/java/com/passus/st/client/http/ReporterRemoteDestination.java stress-tester/src/main/java/com/passus/st/client/http/SummaryHttpClientListener.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterMessageWrapper.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationOperations.java stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataReader.java stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java stress-tester/src/main/java/com/passus/st/validation/HttpValidators.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformerTest.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationOperationsTest.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageWrapperTest.java stress-tester/src/test/java/com/passus/st/filter/HttpMessageValueExtractorTest.java stress-tester/src/test/java/com/passus/st/filter/HttpMessageWrapperDynamicExtractorTest.java
diffstat 14 files changed, 36 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/ReporterFileDestination.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/ReporterFileDestination.java	Thu Sep 26 14:54:18 2019 +0200
@@ -29,6 +29,7 @@
 import java.util.Map;
 
 import static com.passus.config.schema.ConfigurationSchemaBuilder.*;
+import static com.passus.net.http.HttpUtils.intToVersionString;
 import static com.passus.st.client.http.HttpConsts.*;
 import static com.passus.st.reporter.ReporterImpl.addValue;
 
@@ -156,7 +157,7 @@
                     reqId = request.getId();
                     addValue(builder, request.getId());
                     addValue(builder, request.getMethod().toString());
-                    addValue(builder, request.getVersion().toString());
+                    addValue(builder, intToVersionString(request.getVersion()).toString());
                     addValue(builder, request.getUrl().toString());
                     addValue(builder, request.getTag(TAG_TIME_START));
                     addValue(builder, request.getTag(TAG_TIME_END));
--- a/stress-tester/src/main/java/com/passus/st/client/http/ReporterRemoteDestination.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/ReporterRemoteDestination.java	Thu Sep 26 14:54:18 2019 +0200
@@ -34,6 +34,7 @@
 import java.util.Set;
 
 import static com.passus.config.schema.ConfigurationSchemaBuilder.*;
+import static com.passus.net.http.HttpUtils.intToVersionString;
 import static com.passus.st.client.http.HttpConsts.*;
 import static com.passus.st.client.http.filter.HttpFlowUtils.extractHttpContext;
 
@@ -234,7 +235,7 @@
 
                 metric.setMethod(request.getMethod().toString());
                 metric.setUrl(request.getUrl().toString());
-                metric.setReqVersion(request.getVersion().toString());
+                metric.setReqVersion(intToVersionString(request.getVersion()).toString());
                 metric.setReqMarkers(ReporterDestination.getMarkers(request));
             }
 
@@ -248,7 +249,7 @@
 
                 metric.setCode(response.getStatus().getCode());
                 metric.setReason(response.getStatus().getReasonPhrase().toString());
-                metric.setRespVersion(response.getVersion().toString());
+                metric.setRespVersion(intToVersionString(response.getVersion()).toString());
                 metric.setRespMarkers(ReporterDestination.getMarkers(request));
             }
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/SummaryHttpClientListener.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/SummaryHttpClientListener.java	Thu Sep 26 14:54:18 2019 +0200
@@ -18,6 +18,7 @@
 import java.io.*;
 
 import static com.passus.config.schema.ConfigurationSchemaBuilder.*;
+import static com.passus.net.http.HttpUtils.intToVersionString;
 import static com.passus.st.plugin.PluginConstants.CATEGORY_CLIENT_LISTENER;
 
 /**
@@ -68,7 +69,7 @@
             synchronized (os) {
                 write(request.getMethod().getName());
                 write(request.getUri());
-                write(request.getVersion());
+                write(intToVersionString(request.getVersion()));
                 os.write('=');
                 os.write(' ');
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterMessageWrapper.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterMessageWrapper.java	Thu Sep 26 14:54:18 2019 +0200
@@ -36,7 +36,7 @@
         return message.getHeaders();
     }
 
-    public ByteString getVersion() {
+    public int getVersion() {
         return message.getVersion();
     }
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationOperations.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationOperations.java	Thu Sep 26 14:54:18 2019 +0200
@@ -15,6 +15,8 @@
 import java.util.Arrays;
 import java.util.List;
 
+import static com.passus.net.http.HttpUtils.versionStringToInt;
+
 /**
  * @author mikolaj.podbielski
  */
@@ -574,13 +576,13 @@
 
     public static class SetVersionOperation implements Operation {
 
-        private final ByteString version;
+        private final int version;
 
         public SetVersionOperation(CharSequence version) {
-            if (!HttpUtils.isValidVersion(version)) {
+            if (!HttpUtils.isValidVersionString(version)) {
                 throw new IllegalArgumentException("Invalid HTTP version '" + version + "'");
             }
-            this.version = ByteString.create(version);
+            this.version = versionStringToInt(ByteString.create(version));
         }
 
         @Override
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataReader.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataReader.java	Thu Sep 26 14:54:18 2019 +0200
@@ -42,7 +42,7 @@
         skipHeaders(buffer);
     }
 
-    public ByteString decodeVersion(ByteBuff buffer) throws IOException {
+    public int decodeVersion(ByteBuff buffer) throws IOException {
         byte b = buffer.read();
         if (b == NcHttpDataUtils.VERSION_1_0) {
             return HttpConsts.VERSION_1_0;
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java	Thu Sep 26 14:54:18 2019 +0200
@@ -89,9 +89,9 @@
     }
 
     private long encodeVersion(HttpMessage msg, ByteBuff buff) throws IOException {
-        if (HttpConsts.VERSION_1_0.equals(msg.getVersion())) {
+        if (HttpConsts.VERSION_1_0 == msg.getVersion()) {
             buff.append(NcHttpDataUtils.VERSION_1_0);
-        } else if (HttpConsts.VERSION_1_1.equals(msg.getVersion())) {
+        } else if (HttpConsts.VERSION_1_1 == msg.getVersion()) {
             buff.append(NcHttpDataUtils.VERSION_1_1);
         } else {
             throw new IOException("Not supported HTTP version '" + msg.getVersion() + "'.");
--- a/stress-tester/src/main/java/com/passus/st/validation/HttpValidators.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/main/java/com/passus/st/validation/HttpValidators.java	Thu Sep 26 14:54:18 2019 +0200
@@ -46,7 +46,7 @@
         @Override
         public void validate(Object target, Errors errors) {
             CharSequence value = ((CharSequence) target);
-            if (!HttpUtils.isValidVersion(value)) {
+            if (!HttpUtils.isValidVersionString(value)) {
                 errors.reject("Invalid HTTP method \"%s\"", value);
             }
         }
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java	Thu Sep 26 14:54:18 2019 +0200
@@ -23,6 +23,7 @@
 
 import static com.passus.commons.collection.FluentBuilder.e;
 import static com.passus.commons.collection.FluentBuilder.map;
+import static com.passus.net.http.HttpUtils.intToVersionString;
 import static com.passus.st.client.http.HttpConsts.TAG_SESSION_ID;
 import static com.passus.st.client.http.filter.HttpFlowUtils.extractHttpContext;
 import static com.passus.st.client.http.filter.HttpVarsFilterTest.expr;
@@ -229,7 +230,7 @@
                 + "    - type: modifyMessage\n"
                 + "      operations:\n"
                 + "        setMethod: HEAD\n"
-                + "        setVersion: 'HTTP/1.2'\n"
+                + "        setVersion: 'HTTP/1.1'\n"
                 + "        setUri: '/aaa/bbb/ccc?q1x=v1x'\n"
                 + "    - type: modifyMessage\n"
                 + "      operations:\n"
@@ -254,7 +255,7 @@
         HttpRequest req0 = HttpRequestBuilder.get("http://example.com?q=1#a1").build();
         f0.filterOutbound(req0, null, null);
         assertEquals(HttpMethod.HEAD, req0.getMethod());
-        assertEquals("HTTP/1.2", req0.getVersion().toString());
+        assertEquals("HTTP/1.1", intToVersionString(req0.getVersion()).toString());
         assertEquals("/aaa/bbb/ccc?q1x=v1x", req0.getUri().toString());
         assertEquals("example.com/aaa/bbb/ccc?q1x=v1x", req0.getUrl().toString());
 
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformerTest.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformerTest.java	Thu Sep 26 14:54:18 2019 +0200
@@ -127,7 +127,7 @@
                 + "  setMethod: HEAD\n"
                 + "  setMethod: head\n"
                 //                + "  setMethod: blah\n"
-                + "  setVersion: 'HTTP/1.2'\n"
+                + "  setVersion: 'HTTP/1.1'\n"
                 + "  setUri: '/part0x/part1x/part2x?q1x=v1x'\n"
                 + "  setUrlQuery: 'qqq=vvv'\n"
                 + "  setUrlRef: anchor\n"
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationOperationsTest.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationOperationsTest.java	Thu Sep 26 14:54:18 2019 +0200
@@ -4,6 +4,8 @@
 import com.passus.net.http.HttpRequest;
 import com.passus.net.http.HttpRequestBuilder;
 import com.passus.st.client.http.filter.HttpMessageModificationOperations.*;
+
+import static com.passus.net.http.HttpUtils.intToVersionString;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -38,9 +40,9 @@
 
     @Test
     public void testSetVersionOperation() {
-        SetVersionOperation op = new SetVersionOperation("HTTP/1.2");
+        SetVersionOperation op = new SetVersionOperation("HTTP/1.1");
         HttpRequest req = process(op);
-        assertEquals("HTTP/1.2", req.getVersion().toString());
+        assertEquals("HTTP/1.1", intToVersionString(req.getVersion()).toString());
     }
 
     @Test
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageWrapperTest.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageWrapperTest.java	Thu Sep 26 14:54:18 2019 +0200
@@ -99,7 +99,7 @@
 
         e = bean("@request.version");
         value = e.extract(map);
-        assertEquals("HTTP/1.1", value.toString());
+        assertEquals("1", value.toString());
     }
 
     @Test
@@ -109,12 +109,12 @@
 
         e = mvel("req.getVersion()");
         value = e.extract(wrapper);
-        assertEquals("HTTP/1.1", value.toString());
-        assertTrue(value instanceof ByteString);
+        assertEquals("1", value.toString());
+        assertTrue(value instanceof Number);
 
         e = mvel("req.version");
         value = e.extract(wrapper);
-        assertEquals("HTTP/1.1", value.toString());
+        assertEquals("1", value.toString());
 
         e = mvel("req.url.query");
         value = e.extract(wrapper);
--- a/stress-tester/src/test/java/com/passus/st/filter/HttpMessageValueExtractorTest.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/test/java/com/passus/st/filter/HttpMessageValueExtractorTest.java	Thu Sep 26 14:54:18 2019 +0200
@@ -13,6 +13,7 @@
 
 import java.util.Objects;
 
+import static com.passus.net.http.HttpConsts.VERSION_1_1;
 import static com.passus.st.client.http.HttpConsts.TAG_SESSION_ID;
 import static org.testng.AssertJUnit.assertEquals;
 
@@ -64,8 +65,8 @@
     public Object[][] expressions() {
         return new Object[][]{
                 //Request
-                {"req.getVersion()", "HTTP/1.1"},
-                {"req.version", "HTTP/1.1"},
+                {"req.getVersion()", "" + VERSION_1_1},
+                {"req.version", "" + VERSION_1_1},
                 {"req.method", "GET"},
                 {"req.uri", "/index?action=delete"},
                 {"req.url", URL.class},
--- a/stress-tester/src/test/java/com/passus/st/filter/HttpMessageWrapperDynamicExtractorTest.java	Thu Sep 26 14:19:56 2019 +0200
+++ b/stress-tester/src/test/java/com/passus/st/filter/HttpMessageWrapperDynamicExtractorTest.java	Thu Sep 26 14:54:18 2019 +0200
@@ -42,8 +42,8 @@
 
     @Test
     public void testExtract_HttpMessageWrapper() {
-        assertEquals("HTTP/1.1", extract("req.version").toString());
-        assertEquals("HTTP/1.1", extract("req.getVersion()").toString());
+        assertEquals("1", extract("req.version").toString());
+        assertEquals("1", extract("req.getVersion()").toString());
         assertEquals("GET", extract("req.method").toString());
         assertEquals("GET", extract("req.getMethod()").toString());
         assertEquals("sid1", extract("req.sessionId"));
@@ -52,8 +52,8 @@
         assertEquals("http://www.example.com/1", extract("req.getUrl()").toString());
         assertEquals("/1", extract("req.uri").toString());
         assertEquals("/1", extract("req.getUri()").toString());
-        assertEquals("HTTP/1.1", extract("resp.version").toString());
-        assertEquals("HTTP/1.1", extract("resp.getVersion()").toString());
+        assertEquals("1", extract("resp.version").toString());
+        assertEquals("1", extract("resp.getVersion()").toString());
         assertEquals(HttpStatus.OK, extract("resp.status"));
         assertEquals(HttpStatus.OK, extract("resp.getStatus()"));
         assertEquals(200, extract("resp.status.code"));