Mercurial > stress-tester
changeset 814:f27093f7af45
HttpSynchClientWorkerTest.testHandle_SimpleRequestResponse_ConnectPartialSession
author | Devel 2 |
---|---|
date | Mon, 15 Jan 2018 15:08:59 +0100 |
parents | 3a7411ab09e9 |
children | a58bbf4ee5e6 |
files | stress-tester/src/main/java/com/passus/st/client/http/HttpSynchClientWorker.java stress-tester/src/test/java/com/passus/st/client/http/HttpSynchClientWorkerTest.java |
diffstat | 2 files changed, 32 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpSynchClientWorker.java Mon Jan 15 12:26:11 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpSynchClientWorker.java Mon Jan 15 15:08:59 2018 +0100 @@ -197,8 +197,8 @@ currFlowContext = register(sessEvent); if (currFlowContext != null) { try { + currFlowContext.setParameters(currentFlowParameters); emitter.connect(sessEvent.getSessionInfo(), this, index); - currFlowContext.setParameters(currentFlowParameters); } catch (IOException e) { logger.error(e.getMessage(), e); currFlowContext = null; @@ -216,8 +216,8 @@ currFlowContext = register(sessEvent); if (currFlowContext != null) { try { + currFlowContext.setParameters(currentFlowParameters); emitter.connect(sessEvent.getSessionInfo(), this, index); - currFlowContext.setParameters(currentFlowParameters); eventsQueue.addFirst(sessEvent); } catch (IOException e) { logger.error(e.getMessage(), e);
--- a/stress-tester/src/test/java/com/passus/st/client/http/HttpSynchClientWorkerTest.java Mon Jan 15 12:26:11 2018 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/HttpSynchClientWorkerTest.java Mon Jan 15 15:08:59 2018 +0100 @@ -7,6 +7,7 @@ import com.passus.net.http.HttpRequest; import com.passus.net.http.HttpResponse; import com.passus.net.http.HttpResponseEncoder; +import com.passus.st.Log4jConfigurationFactory; import com.passus.st.client.Event; import com.passus.st.client.SessionEvent; import com.passus.st.client.SessionStatusEvent; @@ -202,18 +203,26 @@ listner.clear(); } - @Test(enabled = true) - public void testHandle_SimpleRequestResponse() throws Exception { + private HttpSynchClientWorker createWorker() { + LocalEmitter emitter = new LocalEmitter(); + HttpSynchClientWorker worker = new HttpSynchClientWorker(emitter, "test", 0); + worker.addListener(listner); + return worker; + } + + private List<Event> readEvents(String pcapFile) throws Exception { Properties props = new Properties(); props.put("allowPartialSession", "true"); props.put("ports", "4214"); - List<Event> events = EventUtils.readEvents("pcap/http/http_req_resp.pcap", props); + return EventUtils.readEvents(pcapFile, props); + } + + @Test(enabled = true) + public void testHandle_SimpleRequestResponse() throws Exception { + List<Event> events = readEvents("pcap/http/http_req_resp.pcap"); assertEquals(4, events.size()); - LocalEmitter emitter = new LocalEmitter(); - HttpSynchClientWorker worker = new HttpSynchClientWorker(emitter, "test", 0); - worker.addListener(listner); - + HttpSynchClientWorker worker = createWorker(); worker.start(); SessionEvent sessionEvent = (SessionEvent) events.get(0); worker.handle(new SessionStatusEvent(sessionEvent.getSessionInfo(), SessionStatusEvent.STATUS_ESTABLISHED)); @@ -223,4 +232,18 @@ assertHttpClientEvents(events, listner.events()); } + @Test(enabled = true) + public void testHandle_SimpleRequestResponse_ConnectPartialSession() throws Exception { + Log4jConfigurationFactory.enableFactory("debug"); + List<Event> events = readEvents("pcap/http/http_req_resp.pcap"); + assertEquals(4, events.size()); + + HttpSynchClientWorker worker = createWorker(); + worker.setConnectPartialSession(true); + worker.start(); + events.forEach(worker::handle); + worker.join(); + + assertHttpClientEvents(events, listner.events()); + } }