Mercurial > stress-tester
changeset 833:5935b04ed679
minor
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/ConverterHttpClient.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/ConverterHttpClient.java Fri Jan 19 14:38:13 2018 +0100 @@ -125,7 +125,7 @@ public void setFilters(Collection<HttpFilter> filters) { Assert.notContainsNull(filters, "filters"); filterChain.clear(); - filters.forEach((filter) -> filterChain.addFilter(filter)); + filters.forEach(filterChain::addFilter); } public void join() {
--- a/stress-tester/src/main/java/com/passus/st/ConverterMain.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/ConverterMain.java Fri Jan 19 14:38:13 2018 +0100 @@ -132,7 +132,7 @@ List<HttpFilter> httpFilters = cliHelper.readHttpFilters(cl); if (httpFilters != null) { - httpFilters.forEach((filter) -> client.addFilter(filter)); + httpFilters.forEach(client::addFilter); } client.start();
--- a/stress-tester/src/main/java/com/passus/st/Main.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/Main.java Fri Jan 19 14:38:13 2018 +0100 @@ -77,7 +77,7 @@ System.out.println(""); try { System.out.println("Elapsed time: " + PeriodFormatter.INSTANCE.reverseTransform(endTime - startTime) + "."); - } catch (ConversionException conversionException) { + } catch (ConversionException ignored) { } System.out.println("Metrics:"); @@ -231,7 +231,7 @@ summaryListener = new SummaryHttpClientListener(new File(directory, "summary.txt")); File file = new File(directory, "cmd." + new File(clArgs[0]).getName() + ".txt"); String cmd = String.join(" ", args); - try (FileOutputStream fos = new FileOutputStream(file);) { + try (FileOutputStream fos = new FileOutputStream(file)) { IOUtils.write(cmd, fos); } client.addListener(summaryListener); @@ -265,7 +265,7 @@ List<HttpFilter> httpFilters = cliHelper.readHttpClientFilters(cl); if (httpFilters != null) { - httpFilters.forEach((filter) -> client.addFilter(filter)); + httpFilters.forEach(client::addFilter); } client.start();
--- a/stress-tester/src/main/java/com/passus/st/Main2.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/Main2.java Fri Jan 19 14:38:13 2018 +0100 @@ -225,7 +225,7 @@ summaryListener = new SummaryHttpClientListener(new File(directory, "summary.txt")); File file = new File(directory, "cmd." + new File(clArgs[0]).getName() + ".txt"); String cmd = String.join(" ", args); - try (FileOutputStream fos = new FileOutputStream(file);) { + try (FileOutputStream fos = new FileOutputStream(file)) { IOUtils.write(cmd, fos); } client.addListener(summaryListener); @@ -259,7 +259,7 @@ List<HttpFilter> httpFilters = cliHelper.readHttpClientFilters(cl); if (httpFilters != null) { - httpFilters.forEach((filter) -> client.addFilter(filter)); + httpFilters.forEach(client::addFilter); } client.start();
--- a/stress-tester/src/main/java/com/passus/st/PcapReporter.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/PcapReporter.java Fri Jan 19 14:38:13 2018 +0100 @@ -309,7 +309,7 @@ } public void await() throws InterruptedException { - while (finished == false) { + while (!finished) { Thread.sleep(100); } }
--- a/stress-tester/src/main/java/com/passus/st/PcapScanner.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/PcapScanner.java Fri Jan 19 14:38:13 2018 +0100 @@ -193,9 +193,9 @@ case "url": return (e) -> e.getRequest().getUrl(); case "path": - return (e) -> urlExtract(e, (URL url) -> url.getPath()); + return (e) -> urlExtract(e, URL::getPath); case "query": - return (e) -> urlExtract(e, (URL url) -> url.getQuery()); + return (e) -> urlExtract(e, URL::getQuery); // case "header": //TODO case "reqPost":
--- a/stress-tester/src/main/java/com/passus/st/StatsMain.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/StatsMain.java Fri Jan 19 14:38:13 2018 +0100 @@ -115,7 +115,7 @@ private void readNcFile(NcEventSource src) throws Exception { src.setParallel(false); src.setAllocator(new PooledAllocator(64 * 1024, 100, 0)); - src.setHandler((event) -> stats(event)); + src.setHandler(this::stats); try { src.start(); @@ -125,7 +125,7 @@ } private void readPcapFile(PcapSessionEventSource eventSrc) throws Exception { - eventSrc.setHandler((event) -> stats(event)); + eventSrc.setHandler(this::stats); try { eventSrc.start(); eventSrc.join();
--- a/stress-tester/src/main/java/com/passus/st/client/ArrayListEventHandler.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/ArrayListEventHandler.java Fri Jan 19 14:38:13 2018 +0100 @@ -34,6 +34,7 @@ return null; } + @SuppressWarnings("unchecked") public <E extends Event> E findFirst(Class<E> cls) { for (Event event : events) { if (cls.isInstance(event)) {
--- a/stress-tester/src/main/java/com/passus/st/client/EventBus.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/EventBus.java Fri Jan 19 14:38:13 2018 +0100 @@ -139,7 +139,7 @@ LOGGER.trace("Handle event '" + event.getType() + "'."); } - if (events.offer(event) == false) { + if (!events.offer(event)) { LOGGER.warn("Event queue capacity " + maxBufferSize + " reached."); synchronized (eventHandlers) { if (listeners != null) {
--- a/stress-tester/src/main/java/com/passus/st/client/credentials/CsvUsernamePasswordCredentialsProvider.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/credentials/CsvUsernamePasswordCredentialsProvider.java Fri Jan 19 14:38:13 2018 +0100 @@ -152,7 +152,7 @@ List<Credentials> result = new ArrayList<>(); try (FileInputStream fis = new FileInputStream(csvFile); InputStreamReader isr = new InputStreamReader(fis, Charset.forName("UTF-8")); - CSVReader reader = new CSVReader(isr, separator);) { + CSVReader reader = new CSVReader(isr, separator)) { String tokens[]; while ((tokens = reader.readNext()) != null) { if (tokens.length >= 2) {
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpAsynchClientWorker.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpAsynchClientWorker.java Fri Jan 19 14:38:13 2018 +0100 @@ -32,7 +32,7 @@ private long windowPeriod = 10; - private final Queue<TasksTimeWindow> windows = new ConcurrentLinkedQueue(); + private final Queue<TasksTimeWindow> windows = new ConcurrentLinkedQueue<>(); private TasksTimeWindow currentWindow;
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpClient.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpClient.java Fri Jan 19 14:38:13 2018 +0100 @@ -34,6 +34,7 @@ * * @author Mirosław Hawrot */ +@SuppressWarnings("ALL") @NodeDefinitionCreate(HttpClient.HttpClientNodeDefCreator.class) @Plugin(name = HttpClient.TYPE, category = PluginConstants.CATEGORY_CLIENT) public class HttpClient implements Client, HttpFilterAware { @@ -196,6 +197,7 @@ } } + @SuppressWarnings("unchecked") @Override public void configure(Configuration config) { setFilters((List<HttpFilter>) config.get("filters", Collections.EMPTY_LIST));
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpMessageWriter.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpMessageWriter.java Fri Jan 19 14:38:13 2018 +0100 @@ -30,6 +30,7 @@ responseEncoder.setDecodeContent(decode); } + @SuppressWarnings("unchecked") synchronized public void write(HttpMessage message, OutputStream os) throws IOException { HttpMessageEncoder encoder = message.isRequest() ? requestEncoder : responseEncoder; encoder.encode(message, buffer); @@ -42,7 +43,7 @@ } public void write(HttpMessage message, File file) throws IOException { - try (FileOutputStream fos = new FileOutputStream(file);) { + try (FileOutputStream fos = new FileOutputStream(file)) { write(message, fos); } }
--- a/stress-tester/src/main/java/com/passus/st/client/http/ReporterDestination.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/ReporterDestination.java Fri Jan 19 14:38:13 2018 +0100 @@ -1,10 +1,13 @@ package com.passus.st.client.http; +import com.passus.config.Configurable; +import com.passus.config.Configuration; import com.passus.data.ByteString; import com.passus.net.http.HttpHeaders; import com.passus.net.http.HttpMessage; import com.passus.st.client.http.filter.HttpSequenceListener; import com.passus.st.metric.MetricsCollectionHandler; + import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -14,7 +17,7 @@ * * @author mikolaj.podbielski */ -public interface ReporterDestination extends HttpClientListener, HttpSequenceListener, MetricsCollectionHandler { +public interface ReporterDestination extends HttpClientListener, HttpSequenceListener, MetricsCollectionHandler, Configurable { public static final String SERVICE_NAME = "ReporterDestination"; @@ -26,6 +29,11 @@ HttpHeaders.CONTENT_TYPE )); + @Override + public default void configure(Configuration config) { + + } + public static String getLoopInfo(HttpFlowContext context) { String sourceName = context.sentEvent.getSourceName(); int loop = context.getParameters().getLoop();
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpAbstractLoginFilter.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpAbstractLoginFilter.java Fri Jan 19 14:38:13 2018 +0100 @@ -87,7 +87,7 @@ ParametersBag params = context.scopes().getConversation(request, false); if (params != null) { Boolean blocked = (Boolean) params.get(this, "blocked"); - if (blocked != null && blocked == true) { + if (blocked != null && blocked) { return DUNNO; } }
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCounterFilter.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCounterFilter.java Fri Jan 19 14:38:13 2018 +0100 @@ -73,9 +73,7 @@ limit = config.getInteger("limit"); name = config.getString("name", "counter_" + ID.getAndIncrement()); // TODO: - listener = (e) -> { - System.out.println(e); - }; + listener = System.out::println; } @Override
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFilterExtractorTransformer.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFilterExtractorTransformer.java Fri Jan 19 14:38:13 2018 +0100 @@ -37,6 +37,7 @@ return null; } + @SuppressWarnings("unchecked") @Override public CValueNode transform(CNode node, Errors errors, ConfigurationContext context) { CMapNode mapNode = (CMapNode) node;
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpHostRewriterFilter.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpHostRewriterFilter.java Fri Jan 19 14:38:13 2018 +0100 @@ -48,6 +48,7 @@ } + @SuppressWarnings("unchecked") @Override public void configure(Configuration config) { Map map = (Map) config.get("hostMap", Collections.EMPTY_MAP);
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMarkFilter.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMarkFilter.java Fri Jan 19 14:38:13 2018 +0100 @@ -79,6 +79,7 @@ this.markRules.addAll((Collection<? extends MarkerRule>) config.get("rules", Collections.EMPTY_LIST)); } + @SuppressWarnings("unchecked") @Override public int filterInbound(HttpRequest req, HttpResponse resp, HttpFlowContext context) { if (!markRules.isEmpty()) {
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java Fri Jan 19 14:38:13 2018 +0100 @@ -145,6 +145,7 @@ return op; } + @SuppressWarnings("unchecked") @Override public CValueNode transform(CNode node, Errors errors, ConfigurationContext context) { CMapNode mapNode = (CMapNode) node;
--- a/stress-tester/src/main/java/com/passus/st/emitter/SimpleSocketMatcher.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/emitter/SimpleSocketMatcher.java Fri Jan 19 14:38:13 2018 +0100 @@ -23,10 +23,7 @@ if (this.port != -1 && this.port != port) { return false; } - if (this.ip != null && !this.ip.equals(ip)) { - return false; - } - return true; + return this.ip == null || this.ip.equals(ip); } }
--- a/stress-tester/src/main/java/com/passus/st/job/JobExecutor.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/job/JobExecutor.java Fri Jan 19 14:38:13 2018 +0100 @@ -2,32 +2,19 @@ import com.passus.commons.Assert; import com.passus.commons.metric.MetricsCollection; -import com.passus.commons.service.Registry; import com.passus.commons.utils.StringUtils; -import com.passus.st.project.Project; import com.passus.st.client.MemoryEventsCache; import com.passus.st.client.http.HttpClient; -import com.passus.st.client.http.HttpSourceNameAwareClientWorkerDispatcher; -import com.passus.st.client.http.ReporterDestination; -import com.passus.st.client.http.ReporterFileDestination; -import com.passus.st.emitter.PassThroughSessionMapper; -import com.passus.st.emitter.RuleBasedSessionMapper; -import com.passus.st.emitter.SessionMapper; import com.passus.st.emitter.nio.NioEmitter; import com.passus.st.metric.ScheduledMetricsCollector; +import com.passus.st.project.Project; import com.passus.st.reporter.snmp.SnmpLogger; import com.passus.st.source.PcapSessionEventSource; -import java.io.File; -import java.text.ParseException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.*; + /** * * @author Mirosław Hawrot @@ -424,9 +411,7 @@ metricsCollector.start(); emitter.start(); httpClient.start(); - eventSrcs.forEach((eventSrc) -> { - eventSrc.start(); - }); + eventSrcs.forEach(PcapSessionEventSource::start); changeStatus(JobStatus.RUNNING);
--- a/stress-tester/src/main/java/com/passus/st/metric/MetricsBatchTimeWindowRange.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/metric/MetricsBatchTimeWindowRange.java Fri Jan 19 14:38:13 2018 +0100 @@ -54,14 +54,12 @@ public MetricsBatchTimeWindowRange createPrevious() { long prevEnd = startTimestamp - 1; - MetricsBatchTimeWindowRange range = new MetricsBatchTimeWindowRange(prevEnd - getPeroid(), prevEnd); - return range; + return new MetricsBatchTimeWindowRange(prevEnd - getPeroid(), prevEnd); } public MetricsBatchTimeWindowRange createNext() { long nextStart = endTimestamp + 1; - MetricsBatchTimeWindowRange range = new MetricsBatchTimeWindowRange(nextStart, nextStart + getPeroid()); - return range; + return new MetricsBatchTimeWindowRange(nextStart, nextStart + getPeroid()); } @Override
--- a/stress-tester/src/main/java/com/passus/st/reader/pcapng/PcapNgReader.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/pcapng/PcapNgReader.java Fri Jan 19 14:38:13 2018 +0100 @@ -134,7 +134,7 @@ public void read(String path, PcapNgListener pcapListener, ProgressListener progress) throws IOException { try (FileInputStream fis = new FileInputStream(path); - FileChannel channel = fis.getChannel();) { + FileChannel channel = fis.getChannel()) { long fileSize = channel.size(); progress.progress(0, fileSize);
--- a/stress-tester/src/test/java/com/passus/st/client/http/HttpParallelClientWorkerTest.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/HttpParallelClientWorkerTest.java Fri Jan 19 14:38:13 2018 +0100 @@ -62,9 +62,7 @@ worker.setListeners(Arrays.asList(listner)); worker.start(); - events.forEach((event) -> { - worker.handle(event); - }); + events.forEach(worker::handle); worker.join(); assertTrue(listner.size() > 0);
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFilterChainTest.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFilterChainTest.java Fri Jan 19 14:38:13 2018 +0100 @@ -38,7 +38,7 @@ return new TestHttpFilter(action); } - }; + } private static HttpFilter fAccept() { return new TestHttpFilter(ACCEPT);
--- a/stress-tester/src/test/java/com/passus/st/config/ClientConfiguratorTest.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/test/java/com/passus/st/config/ClientConfiguratorTest.java Fri Jan 19 14:38:13 2018 +0100 @@ -36,6 +36,7 @@ assertTrue(errors.hasError()); } + @SuppressWarnings("unchecked") @Test public void testConfigure() throws Exception { String configStr = "client:\n"
--- a/stress-tester/src/test/java/com/passus/st/emitter/EmitterConfiguratorTest.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/test/java/com/passus/st/emitter/EmitterConfiguratorTest.java Fri Jan 19 14:38:13 2018 +0100 @@ -61,6 +61,7 @@ assertTrue(context.get(EMITTER_SESSION_MAPPER) instanceof PassThroughSessionMapper); } + @SuppressWarnings("unchecked") @Test public void testConfigure_DefaultMapper() throws Exception { String configStr = "sessionMapper: '1.1.1.1:80->2.2.2.2:90'\n" +
--- a/stress-tester/src/test/java/com/passus/st/emitter/SessionInfoTest.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/test/java/com/passus/st/emitter/SessionInfoTest.java Fri Jan 19 14:38:13 2018 +0100 @@ -1,13 +1,9 @@ package com.passus.st.emitter; import com.passus.net.Ip4Address; -import com.passus.net.IpAddress; import com.passus.net.session.SessionBean; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; + import org.testng.annotations.Test; /**
--- a/stress-tester/src/test/java/com/passus/st/emitter/SocketAddressProviderBaseTest.java Fri Jan 19 14:10:16 2018 +0100 +++ b/stress-tester/src/test/java/com/passus/st/emitter/SocketAddressProviderBaseTest.java Fri Jan 19 14:38:13 2018 +0100 @@ -52,7 +52,7 @@ try { r.run(); fail("Should throw IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + } catch (IllegalArgumentException ignored) { } }