Mercurial > stress-tester
changeset 721:60801bc86e47
in progress
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/ArrayListEventHandler.java Thu Nov 30 14:56:15 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/ArrayListEventHandler.java Thu Nov 30 23:26:48 2017 +0100 @@ -34,6 +34,16 @@ return null; } + public <E extends Event> E findFirst(Class<E> cls) { + for (Event event : events) { + if (cls.isInstance(event)) { + return (E) event; + } + } + + return null; + } + public int size() { return events.size(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/source/ArrayListEventDestination.java Thu Nov 30 23:26:48 2017 +0100 @@ -0,0 +1,29 @@ +package com.passus.st.source; + +import com.passus.config.Configuration; +import com.passus.st.client.ArrayListEventHandler; + +/** + * + * @author mikolaj.podbielski + */ +public class ArrayListEventDestination extends ArrayListEventHandler implements EventDestination { + + @Override + public boolean isStarted() { + return true; + } + + @Override + public void start() { + } + + @Override + public void stop() { + } + + @Override + public void configure(Configuration config) { + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/source/NullEventDestination.java Thu Nov 30 23:26:48 2017 +0100 @@ -0,0 +1,33 @@ +package com.passus.st.source; + +import com.passus.config.Configuration; +import com.passus.st.client.Event; + +/** + * + * @author mikolaj.podbielski + */ +public class NullEventDestination implements EventDestination { + + @Override + public boolean isStarted() { + return true; + } + + @Override + public void start() { + } + + @Override + public void stop() { + } + + @Override + public void configure(Configuration config) { + } + + @Override + public void handle(Event event) { + } + +}
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpAbstractLoginFilterTest.java Thu Nov 30 14:56:15 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpAbstractLoginFilterTest.java Thu Nov 30 23:26:48 2017 +0100 @@ -12,7 +12,7 @@ */ public class HttpAbstractLoginFilterTest { - protected static CredentialsProvider provider(Credentials cred) { + public static CredentialsProvider provider(Credentials cred) { return new SingleCredentialsProvider(cred); }
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilterTest.java Thu Nov 30 14:56:15 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilterTest.java Thu Nov 30 23:26:48 2017 +0100 @@ -48,7 +48,7 @@ AppUtils.unregisterAll(); } - private static HttpBasicAuthLoginFilter createFilter(CredentialsProvider provider) { + public static HttpBasicAuthLoginFilter createFilter(CredentialsProvider provider) { ConfigurationImpl cfg = new ConfigurationImpl(); cfg.set("provider", provider); HttpBasicAuthLoginFilter filter = new HttpBasicAuthLoginFilter();
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpDigestAuthLoginFilterTest.java Thu Nov 30 14:56:15 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpDigestAuthLoginFilterTest.java Thu Nov 30 23:26:48 2017 +0100 @@ -26,20 +26,15 @@ private static final String RESP1S = "HTTP/1.1 401 Unauthorized\r\n" + "Date: Fri, 09 Jun 2017 06:25:27 GMT\r\n" - + "Server: Apache/2.4.20 (Debian)\r\n" + "WWW-Authenticate: Digest realm=\"realm\", nonce=\"old-nonce\", algorithm=MD5, qop=\"auth\"\r\n" - + "Content-Length: 12\r\n" - + "Keep-Alive: timeout=5, max=98\r\n" - + "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" + + "Content-Length: 12\r\n\r\n" + "Unauthorized"; private static final String REQ2S = "GET /html/digest/index2.html HTTP/1.1\r\n" + "Host: 172.16.60.101\r\n" - + "User-Agent: Mozilla/5.0\r\n" - + "Accept: text/html;q=0.9,*/*;q=0.8\r\n" + "Authorization: Digest username=\"user\", realm=\"realm\", nonce=\"old-nonce\"," - + " uri=\"/html/digest/index2.html\", algorithm=MD5, response=\"774280b22c9ed40bc500bba5c431d8c7\", qop=auth, nc=00000001, cnonce=\"cnonce\"\r\n" - + "\r\n"; + + " uri=\"/html/digest/index2.html\", algorithm=MD5, response=\"774280b22c9ed40bc500bba5c431d8c7\"," + + " qop=auth, nc=00000001, cnonce=\"cnonce\"\r\n\r\n"; private static final String RESP2S = "HTTP/1.1 200 OK\n" + "Authentication-Info: rspauth=\"?\", cnonce=\"?\", nc=00000001, qop=auth\n" @@ -47,7 +42,7 @@ + "Content-Type: text/html\r\n\r\n" + "<html><body>content</body></html>"; - private static HttpDigestAuthLoginFilter createFilter(Credentials cred) { + public static HttpDigestAuthLoginFilter createFilter(Credentials cred) { ConfigurationImpl cfg = new ConfigurationImpl(); cfg.set("provider", new SingleCredentialsProvider(cred)); HttpDigestAuthLoginFilter filter = new HttpDigestAuthLoginFilter();
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFormLoginFilterTest.java Thu Nov 30 14:56:15 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFormLoginFilterTest.java Thu Nov 30 23:26:48 2017 +0100 @@ -38,17 +38,16 @@ private final String RESPS = "HTTP/1.1 302 Found\r\n" + "Set-Cookie: PHPSESSID=pcap_post; path=/; HttpOnly\r\n" + "Location: http://172.16.60.23/\r\n" - + "Content-Length: 106\r\n" - + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "Content-Length: 106\r\n\r\n" + "<!DOCTYPE html><html><body><a href=\"http://172.16.60.23/login\">http://172.16.60.23/login</a></body></html>"; final HttpFlowContext mockContext = mock(HttpFlowContext.class); - private static HttpFormLoginFilter createFilter(CredentialsProvider provider) { + public static HttpFormLoginFilter createFilter(CredentialsProvider provider) { return createFilter(provider, (http) -> true); } - private static HttpFormLoginFilter createFilter(CredentialsProvider provider, Predicate predicate) { + public static HttpFormLoginFilter createFilter(CredentialsProvider provider, Predicate predicate) { ConfigurationImpl cfg = new ConfigurationImpl(); cfg.set("applyIf", new HttpMessagePredicate(predicate)); cfg.set("provider", provider);