Mercurial > stress-tester
changeset 989:6414bc0350bb
TestJobConfiguratorTest.TestJobConfiguratorTest
author | Devel 2 |
---|---|
date | Wed, 04 Sep 2019 08:59:30 +0200 |
parents | 1e51ad474197 |
children | ba4568bda0a3 |
files | stress-tester/src/test/java/com/passus/st/config/TestJobConfiguratorTest.java stress-tester/src/test/resources/com/passus/st/config/test_job_socket_emitter.yml |
diffstat | 2 files changed, 24 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/test/java/com/passus/st/config/TestJobConfiguratorTest.java Tue Sep 03 08:46:28 2019 +0200 +++ b/stress-tester/src/test/java/com/passus/st/config/TestJobConfiguratorTest.java Wed Sep 04 08:59:30 2019 +0200 @@ -14,6 +14,8 @@ import com.passus.net.session.SessionAnalyzer; import com.passus.net.type.NetType; import com.passus.st.client.FlowExecutor; +import com.passus.st.emitter.Emitter; +import com.passus.st.emitter.socket.SocketEmitter; import com.passus.st.source.EventSource; import com.passus.st.source.NcEventSource; import com.passus.st.source.PcapSessionEventSource; @@ -42,16 +44,20 @@ NetType.unregisterAll(); } - @Test - public void testConfigure() throws Exception { - File configFile = ResourceUtils.getFile("com/passus/st/config/test_job_config.yml"); + private ConfigurationContext processConfig(String configFileName) throws Exception { + File configFile = ResourceUtils.getFile(configFileName); Configuration config = YamlConfigurationReader.readFromFile(configFile); TestJobConfigurator configurator = new TestJobConfigurator(); ConfigurationContext context = new ConfigurationContextImpl(); configurator.configure(config, errors, context); - errors.getAllErrors().forEach(System.out::println); assertFalse(errors.hasError()); + return context; + } + + @Test + public void testConfigure() throws Exception { + ConfigurationContext context = processConfig("com/passus/st/config/test_job_config.yml"); FlowExecutor flowExecutor = context.get(ConfigurationContextConsts.FLOW_EXECUTOR); assertNotNull(flowExecutor); @@ -69,13 +75,7 @@ @Test public void testConfigure_CustomPcapSourceAnalyzers() throws Exception { - File configFile = ResourceUtils.getFile("com/passus/st/config/test_job_custom_pcap_source_analyzers.yml"); - Configuration config = YamlConfigurationReader.readFromFile(configFile); - - TestJobConfigurator configurator = new TestJobConfigurator(); - ConfigurationContext context = new ConfigurationContextImpl(); - configurator.configure(config, errors, context); - assertFalse(errors.hasError()); + ConfigurationContext context = processConfig("com/passus/st/config/test_job_custom_pcap_source_analyzers.yml"); List<EventSource> sources = context.get(ConfigurationContextConsts.EVENT_SOURCE_SOURCES); assertEquals(1, sources.size()); @@ -90,4 +90,13 @@ assertTrue(analyzers.get(1) instanceof DnsUdpSessionAnalyzer); } + + @Test + public void testConfigure_SocketEmitter() throws Exception { + ConfigurationContext context = processConfig("com/passus/st/config/test_job_socket_emitter.yml"); + + Emitter emitter = context.get(ConfigurationContextConsts.EMITTER_DEFAULT_EMITTER); + + assertTrue(emitter instanceof SocketEmitter); + } }