Mercurial > stress-tester
changeset 1017:f8c9c14d507f
MatchFilterTest - DNS tests
author | Devel 2 |
---|---|
date | Wed, 25 Mar 2020 11:57:49 +0100 |
parents | d25e9c9f0e28 |
children | c53bda023d8c |
files | stress-tester/src/test/java/com/passus/st/client/filter/MatchFilterTest.java |
diffstat | 1 files changed, 40 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/test/java/com/passus/st/client/filter/MatchFilterTest.java Wed Mar 25 11:42:32 2020 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/filter/MatchFilterTest.java Wed Mar 25 11:57:49 2020 +0100 @@ -1,6 +1,8 @@ package com.passus.st.client.filter; import com.passus.config.validation.Errors; +import com.passus.net.dns.DnsARecord; +import com.passus.net.dns.DnsRecord; import com.passus.net.http.*; import com.passus.st.AppUtils; import org.testng.annotations.AfterClass; @@ -20,17 +22,6 @@ */ public class MatchFilterTest { - private final List<HttpRequest> httpRequests = Arrays.asList( - HttpRequestBuilder.get("http://test.com/test").header("Header", "TheValue").build(), - HttpRequestBuilder.get("http://test2.com/test2").build() - ); - - private final List<HttpResponse> httpResponses = Arrays.asList( - HttpResponseBuilder.ok().build(), - HttpResponseBuilder.status(HttpStatus.CREATED).build(), - HttpResponseBuilder.status(HttpStatus.ACCEPTED).build() - ); - private <T> List<T> filter(List<T> messages, String config) { MessagePredicate predicate = FilterTestUtils.createPredicate(config); return filter(messages, predicate); @@ -47,6 +38,31 @@ return out; } + private List<HttpRequest> httpRequests() { + return Arrays.asList( + HttpRequestBuilder.get("http://test.com/test").header("Header", "TheValue").build(), + HttpRequestBuilder.get("http://test2.com/test2").build() + ); + } + + private List<HttpResponse> httpResponses() { + return Arrays.asList( + HttpResponseBuilder.ok().build(), + HttpResponseBuilder.status(HttpStatus.CREATED).build(), + HttpResponseBuilder.status(HttpStatus.ACCEPTED).build() + ); + } + + private List<DnsRecord> dnsRecords() { + DnsRecord dnsRecord1 = new DnsARecord(); + dnsRecord1.setName("test1.com"); + + DnsRecord dnsRecord2 = new DnsARecord(); + dnsRecord2.setName("test2.com"); + + return Arrays.asList(dnsRecord1, dnsRecord2); + } + @BeforeClass public static void beforeClass() { AppUtils.registerAll(); @@ -59,6 +75,9 @@ @Test public void testHttpFilterOutbound() { + List<HttpRequest> httpRequests = httpRequests(); + List<HttpResponse> httpResponses = httpResponses(); + List<HttpRequest> reqs; reqs = filter(httpRequests, "{'@req.url': {$contains: \"test2\"}}"); assertEquals(1, reqs.size()); @@ -90,6 +109,8 @@ @Test public void testHttpConfigureAndFilterOutbound() throws Exception { + List<HttpRequest> httpRequests = httpRequests(); + String filterConfig = "filters:\n" + " - type: matcher\n" + " matches:\n" @@ -115,4 +136,12 @@ assertEquals("/test2", res.get(0).getUri().toString()); } + @Test + public void testDnsFilterOutbound() { + List<DnsRecord> dnsRecords = dnsRecords(); + List<DnsRecord> filtered = filter(dnsRecords, "{'@req.name': {$contains: \"test1\"}}"); + assertEquals(1, filtered.size()); + assertEquals("test1.com", filtered.get(0).getName()); + } + }