Mercurial > stress-tester
changeset 1200:e29869666961
unit tests - minor
author | Devel 1 |
---|---|
date | Mon, 22 Jun 2020 12:50:59 +0200 |
parents | 5d7f5a716a8c |
children | fe6f7073034b |
files | stress-tester/src/test/java/com/passus/st/client/dns/FlowExecutorDnsTest.java stress-tester/src/test/java/com/passus/st/utils/server/SimpleDatagramServer.java |
diffstat | 2 files changed, 22 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/test/java/com/passus/st/client/dns/FlowExecutorDnsTest.java Mon Jun 22 12:45:07 2020 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/dns/FlowExecutorDnsTest.java Mon Jun 22 12:50:59 2020 +0200 @@ -8,7 +8,6 @@ import com.passus.net.dns.DnsARecord; import com.passus.net.dns.DnsBuilder; import com.passus.net.dns.DnsEncoder; -import com.passus.st.Log4jConfigurationFactory; import com.passus.st.Protocols; import com.passus.st.client.Event; import com.passus.st.client.FlowExecutor; @@ -70,27 +69,30 @@ NioEmitter emitter = prepareEmitter("192.168.170.20:53 -> localhost:2000"); emitter.start(); - FlowExecutor flowExecutor = new FlowExecutor(); - flowExecutor.setEmitter(emitter); - flowExecutor.setConnectPartialSession(true); try { - MutableObject<Dns> res = new MutableObject<>(); - flowExecutor.setListener((request, response, context) -> { - res.setValue((Dns) response); - }); - flowExecutor.start(); - events.forEach(flowExecutor::handle); - flowExecutor.join(2_000); + FlowExecutor flowExecutor = new FlowExecutor(); + flowExecutor.setEmitter(emitter); + flowExecutor.setConnectPartialSession(true); + try { + MutableObject<Dns> res = new MutableObject<>(); + flowExecutor.setListener((request, response, context) -> { + res.setValue((Dns) response); + }); + flowExecutor.start(); + events.forEach(flowExecutor::handle); + flowExecutor.join(2_000); - Dns dnsResponse = res.getValue(); - assertNotNull(dnsResponse); - assertEquals(1, dnsResponse.getAnswers().size()); + Dns dnsResponse = res.getValue(); + assertNotNull(dnsResponse); + assertEquals(1, dnsResponse.getAnswers().size()); - DnsARecord dnsRecord = (DnsARecord) dnsResponse.getAnswers().get(0); - assertEquals("test.com", dnsRecord.getName()); + DnsARecord dnsRecord = (DnsARecord) dnsResponse.getAnswers().get(0); + assertEquals("test.com", dnsRecord.getName()); + } finally { + ServiceUtils.stopQuietly(flowExecutor); + ServiceUtils.stopQuietly(emitter); + } } finally { - ServiceUtils.stopQuietly(flowExecutor); - ServiceUtils.stopQuietly(emitter); ServiceUtils.stopQuietly(server); }
--- a/stress-tester/src/test/java/com/passus/st/utils/server/SimpleDatagramServer.java Mon Jun 22 12:45:07 2020 +0200 +++ b/stress-tester/src/test/java/com/passus/st/utils/server/SimpleDatagramServer.java Mon Jun 22 12:50:59 2020 +0200 @@ -27,7 +27,7 @@ return; } - System.out.println("Thread: " + Thread.currentThread().getName()); + System.out.println("start() Thread: " + Thread.currentThread().getName()); try { serverSocket = new DatagramSocket(port, InetAddress.getByName(host)); logger.debug("Datagram socket created."); @@ -45,6 +45,7 @@ return; } + System.out.println("stop() Thread: " + Thread.currentThread().getName()); try { serverSocket.close(); } catch (Exception e) {