diff options
author | 2024-06-19 10:18:27 +0000 | |
---|---|---|
committer | 2024-06-19 10:18:27 +0000 | |
commit | 6040233dcbe4a64b977ee750c6d0d12b2d513c4c (patch) | |
tree | 09c82f5ad4dba38d1bf07a7fca007b93c3009dc1 /testsuites/performance/performance-benchmark-test/src | |
parent | dcaba40dd105b2bcb12fa4b3a5931ee05572927c (diff) | |
parent | feca4bf2915858cef4f82c9822104a7b85732d2c (diff) |
Merge "Convert junit4 to junit5"
Diffstat (limited to 'testsuites/performance/performance-benchmark-test/src')
9 files changed, 162 insertions, 160 deletions
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStatsTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStatsTest.java index 747e9d6fa..2a1f238cd 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStatsTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStatsTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,22 +21,21 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test the EventBatchStats class. - * */ -public class EventBatchStatsTest { +class EventBatchStatsTest { @Test - public void test() { + void test() { EventBatchStats stats = new EventBatchStats(new EventBatch(1, "Label")); assertNotNull(stats); diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchTest.java index 821cb68bd..9ee880f34 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,20 +21,19 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events.InputEvent; /** * Test the EventBatch class. - * */ -public class EventBatchTest { +class EventBatchTest { @Test - public void testEventBatch() { + void testEventBatch() { EventBatch batch = new EventBatch(1, "TheApexClient"); assertNotNull(batch); diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java index 75d6d65f3..b4411a9b0 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,27 +21,25 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import jakarta.inject.Provider; import jakarta.ws.rs.core.Response; import org.glassfish.grizzly.http.server.Request; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events.OutputEvent; /** * Test the EventGeneratorEndpoint class. - * */ -@RunWith(MockitoJUnitRunner.class) -public class EventGeneratorEndpointTest { +@ExtendWith(MockitoExtension.class) +class EventGeneratorEndpointTest { @Mock private Provider<Request> httpRequestProviderMock; @@ -50,21 +48,18 @@ public class EventGeneratorEndpointTest { /** * Set up mocking of the engine service facade. - * - * @throws ApexException on engine service facade setup errors */ - @Before - public void initializeMocking() throws ApexException { - - Mockito.doReturn(httpRequestMock).when(httpRequestProviderMock).get(); + @BeforeEach + void initializeMocking() { - Mockito.doReturn("zooby").when(httpRequestMock).getRemoteHost(); - Mockito.doReturn(12345).when(httpRequestMock).getRemotePort(); + Mockito.lenient().doReturn(httpRequestMock).when(httpRequestProviderMock).get(); + Mockito.lenient().doReturn("zooby").when(httpRequestMock).getRemoteHost(); + Mockito.lenient().doReturn(12345).when(httpRequestMock).getRemotePort(); } @Test - public void testEventGeneratorEndpointGetStats() { + void testEventGeneratorEndpointGetStats() { EventGeneratorEndpoint.clearEventGenerationStats(); EventGeneratorEndpoint.setFinished(false); @@ -73,10 +68,11 @@ public class EventGeneratorEndpointTest { Response stats = egep.serviceGetStats(); assertEquals(200, stats.getStatus()); + stats.close(); } @Test - public void testEventGeneratorEndpointGetEventsZeroBatchCount() { + void testEventGeneratorEndpointGetEventsZeroBatchCount() { EventGeneratorParameters incomingParameters = new EventGeneratorParameters(); incomingParameters.setBatchCount(1); @@ -96,7 +92,7 @@ public class EventGeneratorEndpointTest { } @Test - public void testEventGeneratorEndpointPostBadEvent() { + void testEventGeneratorEndpointPostBadEvent() { EventGeneratorParameters incomingParameters = new EventGeneratorParameters(); incomingParameters.setBatchCount(1); @@ -112,5 +108,6 @@ public class EventGeneratorEndpointTest { Response events = egep.postEventResponse(oe.asJson()); assertEquals(409, events.getStatus()); + events.close(); } } diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java index fd41d81e6..1714f43b4 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation + * Modifications Copyright (C) 2020, 2024 Nordix Foundation * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,162 +23,169 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import org.apache.commons.cli.ParseException; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test event generator parameters. */ -public class EventGeneratorParametersHandlerTest { +class EventGeneratorParametersHandlerTest { @Test - public void testEventGeneratorParameterhandler() throws ParseException { + void testEventGeneratorParameterHandler() throws ParseException { EventGeneratorParameterHandler handler = new EventGeneratorParameterHandler(); assertNotNull(handler); - String[] args = { "-h" }; - EventGeneratorParameters parameters = handler.parse(args); - assertNull(parameters); - assertEquals("usage: EventGenerator [options...]", - handler.getHelp(EventGenerator.class.getSimpleName()).substring(0, 34)); - - args = new String[] {}; - parameters = handler.parse(args); - assertEquals("localhost", parameters.getHost()); - assertEquals(32801, parameters.getPort()); - - args = new String[] { "-H", "MyHost" }; - parameters = handler.parse(args); - assertEquals("MyHost", parameters.getHost()); - - args = new String[] { "-p", "12345" }; - parameters = handler.parse(args); - assertEquals(12345, parameters.getPort()); - - - args = new String[] { "-H", "MyHost", "-p", "12345" }; - parameters = handler.parse(args); - assertEquals("MyHost", parameters.getHost()); - assertEquals(12345, parameters.getPort()); - - args = new String[] { "-c", "src/test/resources/parameters/unit/Valid.json" }; - parameters = handler.parse(args); - assertEquals("ValidPars", parameters.getName()); - assertEquals("FileHost", parameters.getHost()); - assertEquals(54321, parameters.getPort()); - - args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json" }; - parameters = handler.parse(args); - assertEquals("localhost", parameters.getHost()); - assertEquals(32801, parameters.getPort()); - - args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bc", "100" }; - parameters = handler.parse(args); - assertEquals(100, parameters.getBatchCount()); + assertValidInputs(handler); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bc", "-1" }; + String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bc", "-1"}; handler.parse(arguments); }).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters", - "\"batchCount\" value \"-1\" INVALID, is below the minimum"); - args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bs", "12345" }; - parameters = handler.parse(args); - assertEquals(12345, parameters.getBatchSize()); + "\"batchCount\" value \"-1\" INVALID, is below the minimum"); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bs", "0" }; + String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bs", "0"}; handler.parse(arguments); }).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters", - "\"batchSize\" value \"0\" INVALID, is below the minimum"); - args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bd", "1000" }; - parameters = handler.parse(args); + "\"batchSize\" value \"0\" INVALID, is below the minimum"); + + + String[] args = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bd", "1000"}; + EventGeneratorParameters parameters = handler.parse(args); assertEquals(1000, parameters.getDelayBetweenBatches()); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bd", "-1" }; + String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bd", "-1"}; handler.parse(arguments); }).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters", - "\"batchSize\" value \"1\" INVALID, is below the minimum"); + "\"batchSize\" value \"1\" INVALID, is below the minimum"); - args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-o", "Zooby" }; + args = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-o", "Zooby"}; parameters = handler.parse(args); assertEquals("Zooby", parameters.getOutFile()); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-z" }; + String[] arguments = new String[] {"-z"}; handler.parse(arguments); }).hasMessage("Unrecognized option: -z"); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-H" }; + String[] arguments = new String[] {"-H"}; handler.parse(arguments); }).hasMessage("Missing argument for option: H"); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-p" }; + String[] arguments = new String[] {"-p"}; handler.parse(arguments); }).hasMessage("Missing argument for option: p"); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-p", "12345", "-z" }; + String[] arguments = new String[] {"-p", "12345", "-z"}; handler.parse(arguments); }).hasMessage("Unrecognized option: -z"); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-p", "12345", "somethingElse" }; + String[] arguments = new String[] {"-p", "12345", "somethingElse"}; handler.parse(arguments); }).hasMessage("too many command line arguments specified : [somethingElse]"); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-c" }; + String[] arguments = new String[] {"-c"}; handler.parse(arguments); }).hasMessage("Missing argument for option: c"); - args = new String[] { "-H", "MyHost", "-c", "src/test/resources/parameters/unit/Valid.json" }; + args = new String[] {"-H", "MyHost", "-c", "src/test/resources/parameters/unit/Valid.json"}; parameters = handler.parse(args); assertEquals("MyHost", parameters.getHost()); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/NonExistant.json" }; + String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/NonExistant.json"}; handler.parse(arguments); }).hasMessageStartingWith("Could not read parameters from configuration file "); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/BadHost.json" }; + String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/BadHost.json"}; handler.parse(arguments); }).hasMessage("Error parsing JSON parameters from configuration file " - + "\"src/test/resources/parameters/unit/BadHost.json\": " - + "com.google.gson.stream.MalformedJsonException: " - + "Unexpected value at line 3 column 14 path $.host"); + + "\"src/test/resources/parameters/unit/BadHost.json\": " + + "com.google.gson.stream.MalformedJsonException: " + + "Unexpected value at line 3 column 14 path $.host"); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/BadPort.json" }; + String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/BadPort.json"}; handler.parse(arguments); }).hasMessage("Error parsing JSON parameters from configuration file " - + "\"src/test/resources/parameters/unit/BadPort.json\": " - + "java.lang.IllegalStateException: Expected an int " - + "but was BOOLEAN at line 4 column 18 path $.port"); + + "\"src/test/resources/parameters/unit/BadPort.json\": " + + "java.lang.IllegalStateException: Expected an int " + + "but was BOOLEAN at line 4 column 18 path $.port"); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/Empty.json" }; + String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/Empty.json"}; handler.parse(arguments); }).hasMessage("No parameters found in configuration file " - + "\"src/test/resources/parameters/unit/Empty.json\""); + + "\"src/test/resources/parameters/unit/Empty.json\""); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/NullHost.json" }; + String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/NullHost.json"}; handler.parse(arguments); }).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters", - "\"host\" value \"null\" INVALID, is null"); + "\"host\" value \"null\" INVALID, is null"); assertThatThrownBy(() -> { - String[] arguments = new String[] { "-p", "1023" }; + String[] arguments = new String[] {"-p", "1023"}; handler.parse(arguments); }).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters", - "\"port\" value \"1023\" INVALID, is below the minimum"); + "\"port\" value \"1023\" INVALID, is below the minimum"); + } + + private static void assertValidInputs(EventGeneratorParameterHandler handler) throws ParseException { + String[] args = {"-h"}; + EventGeneratorParameters parameters = handler.parse(args); + assertNull(parameters); + assertEquals("usage: EventGenerator [options...]", + handler.getHelp(EventGenerator.class.getSimpleName()).substring(0, 34)); + + args = new String[] {}; + parameters = handler.parse(args); + assertEquals("localhost", parameters.getHost()); + assertEquals(32801, parameters.getPort()); + + args = new String[] {"-H", "MyHost"}; + parameters = handler.parse(args); + assertEquals("MyHost", parameters.getHost()); + + args = new String[] {"-p", "12345"}; + parameters = handler.parse(args); + assertEquals(12345, parameters.getPort()); + + + args = new String[] {"-H", "MyHost", "-p", "12345"}; + parameters = handler.parse(args); + assertEquals("MyHost", parameters.getHost()); + assertEquals(12345, parameters.getPort()); + + args = new String[] {"-c", "src/test/resources/parameters/unit/Valid.json"}; + parameters = handler.parse(args); + assertEquals("ValidPars", parameters.getName()); + assertEquals("FileHost", parameters.getHost()); + assertEquals(54321, parameters.getPort()); + + args = new String[] {"-c", "src/test/resources/parameters/unit/Default.json"}; + parameters = handler.parse(args); + assertEquals("localhost", parameters.getHost()); + assertEquals(32801, parameters.getPort()); + + args = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bc", "100"}; + parameters = handler.parse(args); + assertEquals(100, parameters.getBatchCount()); + + args = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bs", "12345"}; + parameters = handler.parse(args); + assertEquals(12345, parameters.getBatchSize()); } } diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersTest.java index 8d97bb7c5..ebacde846 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,19 +21,19 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test event generator parameters. */ -public class EventGeneratorParametersTest { +class EventGeneratorParametersTest { @Test - public void testEventGeneratorParameters() { + void testEventGeneratorParameters() { EventGeneratorParameters parameters = new EventGeneratorParameters(); parameters.setName("TheName"); diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStatsTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStatsTest.java index f8854b8c7..a8cacf425 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStatsTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStatsTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,20 +21,20 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test the EventGeneratorStats class. - * */ -public class EventGeneratorStatsTest { +class EventGeneratorStatsTest { + @Test - public void testEventGeneratorStats() { + void testEventGeneratorStats() { Map<Integer, EventBatch> batchMap = new LinkedHashMap<>(); EventGeneratorStats egs = new EventGeneratorStats(batchMap); assertNotNull(egs); diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorTest.java index 08860b013..e874ee9c0 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,13 +23,13 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.PrintStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.service.engine.main.ApexMain; @@ -37,7 +38,7 @@ import org.onap.policy.apex.service.engine.main.ApexMain; /** * This class tests the event generator. */ -public class EventGeneratorTest { +class EventGeneratorTest { private final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); private final PrintStream stdout = System.out; @@ -48,14 +49,14 @@ public class EventGeneratorTest { * @throws ApexException on Apex exceptions */ @Test - public void testEventGeneration() throws ApexException { + void testEventGeneration() throws ApexException { EventGeneratorParameters pars = new EventGeneratorParameters(); pars.setBatchCount(1); pars.setBatchSize(10); EventGenerator eventGenerator = new EventGenerator(pars); - final String[] args = { "-rfr", "target", "-p", - "target/examples/config/SampleDomain/REST2RESTJsonEventJavascript.json" }; + final String[] args = {"-rfr", "target", "-p", + "target/examples/config/SampleDomain/REST2RESTJsonEventJavascript.json"}; final ApexMain apexMain = new ApexMain(args); @@ -72,10 +73,10 @@ public class EventGeneratorTest { } @Test - public void testEventGeneratorBadParams() { + void testEventGeneratorBadParams() { System.setOut(new PrintStream(outContent)); - final String[] args = { "-zzz" }; + final String[] args = {"-zzz"}; EventGenerator.main(args); @@ -87,10 +88,10 @@ public class EventGeneratorTest { } @Test - public void testEventGeneratorHelp() { + void testEventGeneratorHelp() { System.setOut(new PrintStream(outContent)); - final String[] args = { "-h" }; + final String[] args = {"-h"}; EventGenerator.main(args); @@ -102,16 +103,11 @@ public class EventGeneratorTest { } @Test - public void testEventGeneratorStart() { + void testEventGeneratorStart() { System.setOut(new PrintStream(outContent)); - (new Thread() { - @Override - public void run() { - EventGenerator.main(null); - } - }).start(); + (new Thread(() -> EventGenerator.main(null))).start(); ThreadUtilities.sleep(1000); final String outString = outContent.toString(); @@ -123,7 +119,7 @@ public class EventGeneratorTest { } @Test - public void testEventGeneratorOutfileGood() { + void testEventGeneratorOutfileGood() { EventGeneratorParameters pars = new EventGeneratorParameters(); pars.setOutFile("target/statsOutFile.json"); @@ -134,11 +130,11 @@ public class EventGeneratorTest { File outFile = new File("target/statsOutFile.json"); assertTrue(outFile.exists()); - outFile.delete(); + assertTrue(outFile.delete()); } @Test - public void testEventGeneratorOutfileBad() { + void testEventGeneratorOutfileBad() { EventGeneratorParameters pars = new EventGeneratorParameters(); pars.setOutFile("/I/Dont/Exist\0"); diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEventTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEventTest.java index 6a3a8cc85..82477f959 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEventTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEventTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,19 +21,18 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test the InputEvent class. - * */ -public class InputEventTest { +class InputEventTest { @Test - public void testInputEvent() { + void testInputEvent() { InputEvent ie = new InputEvent(); assertNotNull(ie); diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEventTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEventTest.java index 8af87ddbd..afcc61e8c 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEventTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEventTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,19 +21,18 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test the OutputEvent class. - * */ -public class OutputEventTest { +class OutputEventTest { @Test - public void test() { + void test() { OutputEvent oe = new OutputEvent(); assertNotNull(oe); |