Mercurial > stress-tester
changeset 709:6505c7c305e6
HttpSessionPayloadEventDataWriter bugfix
author | Devel 2 |
---|---|
date | Wed, 29 Nov 2017 11:26:43 +0100 |
parents | 3abcfc512e5f |
children | da8f7d56a505 |
files | stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java stress-tester/src/test/java/com/passus/st/source/NcEventSourceTest.java stress-tester/src/test/java/com/passus/st/utils/HttpMessageAssert.java stress-tester/src/test/resources/pcap/http/http_ndiag_tcp_conn.pcap |
diffstat | 4 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java Wed Nov 29 10:12:08 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java Wed Nov 29 11:26:43 2017 +0100 @@ -16,6 +16,7 @@ import static com.passus.st.reader.nc.NcHttpDataUtils.FLAG_REQUEST; import static com.passus.st.reader.nc.NcHttpDataUtils.FLAG_RESPONSE; import java.io.IOException; +import java.nio.ByteBuffer; import java.nio.ByteOrder; /** @@ -160,6 +161,8 @@ if (reqContent != null) { size += reqContent.available(); size += ncDataHelper.writeLongVLC(reqBuffer, reqContent.available()); + } else { + size += ncDataHelper.writeLongVLC(reqBuffer, 0); } } @@ -172,6 +175,8 @@ if (respContent != null) { size += respContent.available(); size += ncDataHelper.writeLongVLC(respBuffer, respContent.available()); + } else { + size += ncDataHelper.writeLongVLC(respBuffer, 0); } }
--- a/stress-tester/src/test/java/com/passus/st/source/NcEventSourceTest.java Wed Nov 29 10:12:08 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/source/NcEventSourceTest.java Wed Nov 29 11:26:43 2017 +0100 @@ -13,7 +13,9 @@ import java.util.List; import java.util.Properties; import java.util.stream.Collectors; +import org.apache.commons.io.FileUtils; import static org.testng.AssertJUnit.*; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -25,7 +27,7 @@ private FileEvents writeEvents(String pcapFile) throws IOException { Properties props = new Properties(); props.put("allowPartialSession", "true"); - props.put("ports", "4214"); + props.put("ports", "4214,8080"); List<Event> events = EventUtils.readEvents(pcapFile, props); File tmpFile = createTmpFile(false); @@ -42,9 +44,17 @@ return new FileEvents(tmpFile, events); } - @Test - public void testRead() throws Exception { - FileEvents fileEvents = writeEvents("pcap/http/http_req_resp.pcap"); + @DataProvider(name = "pcapFiles") + public Object[][] pcapFiles() { + return new Object[][]{ + {"pcap/http/http_req_resp.pcap"}, + {"pcap/http/http_ndiag_tcp_conn.pcap"} + }; + } + + @Test(dataProvider = "pcapFiles") + public void testRead(String pcapFile) throws Exception { + FileEvents fileEvents = writeEvents(pcapFile); try { ArrayListEventHandler handler = new ArrayListEventHandler(); NcEventSource eventSource = new NcEventSource(fileEvents.ncFile); @@ -71,6 +81,7 @@ } } finally { + FileUtils.copyFile(fileEvents.ncFile, new File("c:\\tmp\\a")); fileEvents.ncFile.delete(); } }
--- a/stress-tester/src/test/java/com/passus/st/utils/HttpMessageAssert.java Wed Nov 29 10:12:08 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/utils/HttpMessageAssert.java Wed Nov 29 11:26:43 2017 +0100 @@ -11,6 +11,7 @@ import java.util.List; import java.util.Set; import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.fail; /** * @@ -39,6 +40,14 @@ return; } + if (expectedMsg.getContent() == null) { + if (msg.getContent() != null) { + fail("expectedMsg.getContent() == null msg.getContent() != null"); + } + + return; + } + try { ByteBuff content1 = new HeapByteBuff(); ByteBuff content2 = new HeapByteBuff();