changeset 720:9c3779e7983a

minor
author Devel 1
date Thu, 30 Nov 2017 14:56:15 +0100
parents 0c34e213f467
children 60801bc86e47
files stress-tester/src/main/java/com/passus/st/ConverterHttpClient.java stress-tester/src/main/java/com/passus/st/ConverterMain.java stress-tester/src/main/java/com/passus/st/client/http/HttpClient.java stress-tester/src/main/java/com/passus/st/client/http/HttpFlowBasedClientWorker.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilterTest.java
diffstat 5 files changed, 28 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/ConverterHttpClient.java	Thu Nov 30 08:57:22 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/ConverterHttpClient.java	Thu Nov 30 14:56:15 2017 +0100
@@ -7,7 +7,7 @@
 import com.passus.st.client.http.filter.HttpFilter;
 import com.passus.st.client.http.filter.HttpFilterAware;
 import com.passus.st.client.http.filter.HttpFilterChain;
-import com.passus.st.source.NcEventDestination;
+import com.passus.st.source.EventDestination;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -19,24 +19,13 @@
 
     private static final Logger LOGGER = LogManager.getLogger(ConverterHttpClient.class);
 
-    private final String ncFile;
+    private final EventDestination dst;
     private final HttpFilterChain filterChain = new HttpFilterChain();
 
-    private NcEventDestination dst;
-    private boolean allowOverwrite;
-    private boolean requestOnly;
     private boolean started;
 
-    public ConverterHttpClient(String ncFile) {
-        this.ncFile = ncFile;
-    }
-
-    void setRequestOnly(boolean requestOnly) {
-        this.requestOnly = requestOnly;
-    }
-
-    void setAllowOverwrite(boolean overwrite) {
-        this.allowOverwrite = overwrite;
+    public ConverterHttpClient(EventDestination dst) {
+        this.dst = dst;
     }
 
     @Override
@@ -50,9 +39,6 @@
             return;
         }
 
-        dst = new NcEventDestination(ncFile);
-        dst.setAllowOverwrite(allowOverwrite);
-        dst.setRequestOnly(requestOnly);
         dst.start();
 
         started = true;
@@ -65,7 +51,6 @@
         }
 
         dst.stop();
-        dst = null;
 
         started = false;
     }
--- a/stress-tester/src/main/java/com/passus/st/ConverterMain.java	Thu Nov 30 08:57:22 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/ConverterMain.java	Thu Nov 30 14:56:15 2017 +0100
@@ -7,6 +7,7 @@
 import com.passus.config.validation.ObjectError;
 import com.passus.net.PortRangeSet;
 import com.passus.st.client.http.filter.HttpFiltersConfigurator;
+import com.passus.st.source.NcEventDestination;
 import com.passus.st.source.PcapSessionEventSource;
 import static com.passus.st.utils.CliUtils.option;
 import java.io.File;
@@ -102,7 +103,27 @@
                 Log4jConfigurationFactory.enableFactory(logLevel);
             }
 
-            ConverterHttpClient client = new ConverterHttpClient(output);
+            boolean overwrite;
+            String overwriteOption = cl.getOptionValue("do", "ask").toLowerCase();
+            switch (overwriteOption) {
+                case "yes":
+                    overwrite = true;
+                    break;
+                case "ask":
+                    overwrite = askOverwriteIfExists(output);
+                    break;
+                case "no":
+                    overwrite = false;
+                    break;
+                default:
+                    throw new ParseException("Invalid override option value: " + overwriteOption);
+            }
+
+            NcEventDestination dst = new NcEventDestination(output);
+            dst.setAllowOverwrite(overwrite);
+            dst.setRequestOnly(cl.hasOption("req"));
+            
+            ConverterHttpClient client = new ConverterHttpClient(dst);
 
             if (cl.hasOption("ff")) {
                 File filtersFile = new File(cl.getOptionValue("ff"));
@@ -119,25 +140,6 @@
                 }
             }
 
-            boolean overwrite;
-            String overwriteOption = cl.getOptionValue("do", "ask").toLowerCase();
-            switch (overwriteOption) {
-                case "yes":
-                    overwrite = true;
-                    break;
-                case "ask":
-                    overwrite = askOverwriteIfExists(output);
-                    break;
-                case "no":
-                    overwrite = false;
-                    break;
-                default:
-                    throw new ParseException("Invalid override option value: " + overwriteOption);
-            }
-            client.setAllowOverwrite(overwrite);
-
-            client.setRequestOnly(cl.hasOption("req"));
-
             client.start();
 
             PcapSessionEventSource eventSrc = new PcapSessionEventSource();
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpClient.java	Thu Nov 30 08:57:22 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpClient.java	Thu Nov 30 14:56:15 2017 +0100
@@ -57,18 +57,10 @@
         }
     }
 
-    protected HttpFilterChain getFilterChain(boolean create) {
-        if (filterChain == null && create) {
-            filterChain = new HttpFilterChain();
-        }
-
-        return filterChain;
-    }
-
     @Override
     public void addFilter(HttpFilter filter) {
         Assert.notNull(filter, "filter");
-        getFilterChain(true).addFilter(filter);
+        filterChain.addFilter(filter);
     }
 
     public String getWokerType() {
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpFlowBasedClientWorker.java	Thu Nov 30 08:57:22 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpFlowBasedClientWorker.java	Thu Nov 30 14:56:15 2017 +0100
@@ -71,14 +71,13 @@
 
     private long lastEventTimestamp = -1;
 
-    protected final HttpScopes scopes;
+    protected final HttpScopes scopes = new HttpScopes();
 
     protected TimeGenerator timeGenerator = TimeGenerator.getDefaultGenerator();
 
     public HttpFlowBasedClientWorker(Emitter emitter, String name, int index) {
         super(emitter, name, index);
         timeouts.putAll(DEFAULT_TIMEOUTS);
-        scopes = new HttpScopes();
     }
 
     @Override
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilterTest.java	Thu Nov 30 08:57:22 2017 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilterTest.java	Thu Nov 30 14:56:15 2017 +0100
@@ -36,7 +36,6 @@
 public class HttpBasicAuthLoginFilterTest extends HttpAbstractLoginFilterTest {
 
     private static final String REQS = "GET /basic/index.html HTTP/1.1\r\n"
-            + "Host: 172.16.60.101\r\n"
             + "Authorization: Basic dXNlcjpwYXNzd29yZA==\r\n\r\n";
 
     @BeforeClass