diff options
Diffstat (limited to 'testsuites/integration')
7 files changed, 96 insertions, 100 deletions
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/BaseEventTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/BaseEventTest.java index 9199d2a98..021707141 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/BaseEventTest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/BaseEventTest.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -27,8 +28,8 @@ import java.io.IOException; import org.apache.commons.lang3.StringUtils; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.apex.service.engine.main.ApexMain; +import org.onap.policy.common.utils.resources.TextFileUtils; public class BaseEventTest { private static final long TIME_OUT_IN_MS = 10000; @@ -38,7 +39,7 @@ public class BaseEventTest { long startWaitTime = System.currentTimeMillis(); long lastTotalSize = 0; - + do { long totalSize = 0; @@ -49,13 +50,13 @@ public class BaseEventTest { if (totalSize >= totalExpectedSize) { return; } - + // We're making progress, extend the timeout if (totalSize > lastTotalSize) { lastTotalSize = totalSize; startWaitTime = System.currentTimeMillis(); } - + ThreadUtilities.sleep(100); } while (TIME_OUT_IN_MS >= System.currentTimeMillis() - startWaitTime); @@ -63,18 +64,18 @@ public class BaseEventTest { private int getEventCount(final String expectedFileName) throws IOException { File expectedFile = new File(expectedFileName); - + if (!expectedFile.exists()) { return 0; } String expectedFileContents = TextFileUtils.getTextFileAsString(expectedFileName); - + return StringUtils.countMatches(expectedFileContents, "{"); } protected void testFileEvents(final String[] args, final String[] expectedFileNames, final long expectedFileSize) - throws Exception { + throws Exception { final ApexMain apexMain = new ApexMain(args); waitForOutFiles(expectedFileNames, expectedFileSize); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java index 709c67c87..0c500d5ae 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -30,8 +31,8 @@ import org.junit.Test; import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.apex.service.engine.main.ApexMain; +import org.onap.policy.common.utils.resources.TextFileUtils; public class TestFile2File { /** @@ -83,18 +84,13 @@ public class TestFile2File { /** * Strip variable length text from file string. - * + * * @param textFileAsString the file to read and strip * @return the stripped string * @throws IOException on out file read exceptions */ private String stripVariableLengthText(final String outFile) throws IOException { - return TextFileUtils.getTextFileAsString(outFile) - .replaceAll("\\s+", "") - .replaceAll(":\\d*\\.?\\d*,", ":0,") - .replaceAll(":\\d*}", ":0}") - .replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>"); + return TextFileUtils.getTextFileAsString(outFile).replaceAll("\\s+", "").replaceAll(":\\d*\\.?\\d*,", ":0,") + .replaceAll(":\\d*}", ":0}").replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>"); } } - - diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java index 59d36374a..45938cbe4 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -30,8 +31,8 @@ import org.junit.Test; import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.apex.service.engine.main.ApexMain; +import org.onap.policy.common.utils.resources.TextFileUtils; public class TestFile2FileFiltered { /** @@ -44,6 +45,7 @@ public class TestFile2FileFiltered { @Test public void testJsonFilteredFileInOutEvents() throws MessagingException, ApexException, IOException { + // @formatter:off final String[] args = { "-rfr", "target", "-c", "target/examples/config/SampleDomain/File2FileFilteredInOutJsonEvent.json" }; @@ -55,10 +57,12 @@ public class TestFile2FileFiltered { { 22366, 19834 }; testFilteredFileEvents(args, outFilePaths, expectedFileSizes); + // @formatter:on } @Test public void testJsonFilteredFileOutEvents() throws MessagingException, ApexException, IOException { + // @formatter:off final String[] args = { "-rfr", "target", "-c", "target/examples/config/SampleDomain/File2FileFilteredOutJsonEvent.json" }; @@ -70,10 +74,12 @@ public class TestFile2FileFiltered { { 22366, 19834 }; testFilteredFileEvents(args, outFilePaths, expectedFileSizes); + // @formatter:on } @Test public void testJsonFilteredFileInEvents() throws MessagingException, ApexException, IOException { + // @formatter:off final String[] args = { "-rfr", "target", "-c", "target/examples/config/SampleDomain/File2FileFilteredInJsonEvent.json" }; @@ -84,10 +90,11 @@ public class TestFile2FileFiltered { { 22366 }; testFilteredFileEvents(args, outFilePaths, expectedFileSizes); + // @formatter:on } private void testFilteredFileEvents(final String[] args, final String[] outFilePaths, - final long[] expectedFileSizes) throws MessagingException, ApexException, IOException { + final long[] expectedFileSizes) throws MessagingException, ApexException, IOException { final ApexMain apexMain = new ApexMain(args); final File outFile0 = new File(outFilePaths[0]); @@ -125,16 +132,13 @@ public class TestFile2FileFiltered { /** * Strip variable length text from file string. - * + * * @param textFileAsString the file to read and strip * @return the stripped string * @throws IOException on out file read exceptions */ private String stripVariableLengthText(final String outFile) throws IOException { - return TextFileUtils.getTextFileAsString(outFile) - .replaceAll("\\s+", "") - .replaceAll(":\\d*\\.?\\d*,", ":0,") - .replaceAll(":\\d*}", ":0}") - .replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>"); + return TextFileUtils.getTextFileAsString(outFile).replaceAll("\\s+", "").replaceAll(":\\d*\\.?\\d*,", ":0,") + .replaceAll(":\\d*}", ":0}").replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>"); } } diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java index b3fa512d5..6aa73fb07 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -28,8 +29,8 @@ import java.io.IOException; import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.apex.service.engine.main.ApexMain; +import org.onap.policy.common.utils.resources.TextFileUtils; /** * The Class TestFile2FileIgnore. @@ -91,22 +92,16 @@ public class TestFile2FileIgnore { outFile.delete(); assertEquals(outFileSize, expectedFileSize); } - /** * Strip variable length text from file string. - * + * * @param textFileAsString the file to read and strip * @return the stripped string * @throws IOException on out file read exceptions */ private static String stripVariableLengthText(final String outFile) throws IOException { - return TextFileUtils.getTextFileAsString(outFile) - .replaceAll("\\s+", "") - .replaceAll(":\\d*\\.?\\d*,", ":0,") - .replaceAll(":\\d*}", ":0}") - .replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>"); + return TextFileUtils.getTextFileAsString(outFile).replaceAll("\\s+", "").replaceAll(":\\d*\\.?\\d*,", ":0,") + .replaceAll(":\\d*}", ":0}").replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>"); } } - - diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/TestKafka2Kafka.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/TestKafka2Kafka.java index 7afef538b..b35b961e4 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/TestKafka2Kafka.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/TestKafka2Kafka.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -34,8 +35,8 @@ import org.junit.Test; import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.apex.service.engine.main.ApexMain; +import org.onap.policy.common.utils.resources.TextFileUtils; /** * The Class TestKafka2Kafka tests Kafka event sending and reception. @@ -56,10 +57,10 @@ public class TestKafka2Kafka { @ClassRule public static final SharedKafkaTestResource sharedKafkaTestResource = new SharedKafkaTestResource() - // Start a cluster with 1 brokers. - .withBrokers(1) - // Disable topic auto-creation. - .withBrokerProperty("auto.create.topics.enable", "false"); + // Start a cluster with 1 brokers. + .withBrokers(1) + // Disable topic auto-creation. + .withBrokerProperty("auto.create.topics.enable", "false"); /** * Test json kafka events. @@ -70,9 +71,8 @@ public class TestKafka2Kafka { @Test public void testJsonKafkaEvents() throws MessagingException, ApexException { final String conditionedConfigFile = getConditionedConfigFile( - "target" + File.separator + "examples/config/SampleDomain/Kafka2KafkaJsonEvent.json"); - final String[] args = - { "-rfr", "target", "-c", conditionedConfigFile }; + "target" + File.separator + "examples/config/SampleDomain/Kafka2KafkaJsonEvent.json"); + final String[] args = {"-rfr", "target", "-c", conditionedConfigFile}; testKafkaEvents(args, false, "json"); } @@ -85,9 +85,8 @@ public class TestKafka2Kafka { @Test public void testXmlKafkaEvents() throws MessagingException, ApexException { final String conditionedConfigFile = getConditionedConfigFile( - "target" + File.separator + "examples/config/SampleDomain/Kafka2KafkaXmlEvent.json"); - final String[] args = - { "-rfr", "target", "-c", conditionedConfigFile }; + "target" + File.separator + "examples/config/SampleDomain/Kafka2KafkaXmlEvent.json"); + final String[] args = {"-rfr", "target", "-c", conditionedConfigFile}; testKafkaEvents(args, true, "xml"); } @@ -102,19 +101,19 @@ public class TestKafka2Kafka { * @throws ApexException the apex exception */ private void testKafkaEvents(String[] args, final Boolean xmlEvents, final String topicSuffix) - throws MessagingException, ApexException { + throws MessagingException, ApexException { sharedKafkaTestResource.getKafkaTestUtils().createTopic("apex-out-" + topicSuffix, 1, (short) 1); sharedKafkaTestResource.getKafkaTestUtils().createTopic("apex-in-" + topicSuffix, 1, (short) 1); - final KafkaEventSubscriber subscriber = new KafkaEventSubscriber("apex-out-" + topicSuffix, - sharedKafkaTestResource); + final KafkaEventSubscriber subscriber = + new KafkaEventSubscriber("apex-out-" + topicSuffix, sharedKafkaTestResource); final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(3000); final KafkaEventProducer producer = new KafkaEventProducer("apex-in-" + topicSuffix, sharedKafkaTestResource, - EVENT_COUNT, xmlEvents, EVENT_INTERVAL); + EVENT_COUNT, xmlEvents, EVENT_INTERVAL); producer.sendEvents(); @@ -122,12 +121,12 @@ public class TestKafka2Kafka { // Wait for the producer to send all tis events while (System.currentTimeMillis() < testStartTime + MAX_TEST_LENGTH - && producer.getEventsSentCount() < EVENT_COUNT) { + && producer.getEventsSentCount() < EVENT_COUNT) { ThreadUtilities.sleep(EVENT_INTERVAL); } while (System.currentTimeMillis() < testStartTime + MAX_TEST_LENGTH - && subscriber.getEventsReceivedCount() < EVENT_COUNT) { + && subscriber.getEventsReceivedCount() < EVENT_COUNT) { ThreadUtilities.sleep(EVENT_INTERVAL); } @@ -145,7 +144,7 @@ public class TestKafka2Kafka { File tempConfigFile = File.createTempFile("Kafka_", ".json"); tempConfigFile.deleteOnExit(); String configAsString = TextFileUtils.getTextFileAsString(configurationFileName) - .replaceAll("localhost:39902", sharedKafkaTestResource.getKafkaConnectString()); + .replaceAll("localhost:39902", sharedKafkaTestResource.getKafkaConnectString()); TextFileUtils.putStringAsFile(configAsString, tempConfigFile.getCanonicalFile()); return tempConfigFile.getCanonicalPath(); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java index 1a0570c1f..e799f5973 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,12 +35,12 @@ import org.junit.Test; import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.apex.service.engine.main.ApexMain; import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.gson.GsonMessageBodyHandler; import org.onap.policy.common.utils.network.NetworkUtil; +import org.onap.policy.common.utils.resources.TextFileUtils; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -74,8 +74,8 @@ public class TestRest2File { */ @Before public void setUp() throws Exception { - server = HttpServletServerFactoryInstance.getServerFactory().build( - "TestRest2File", false, null, PORT, "/TestRest2File", false, false); + server = HttpServletServerFactoryInstance.getServerFactory().build("TestRest2File", false, null, PORT, + "/TestRest2File", false, false); server.addServletClass(null, TestRestClientEndpoint.class.getName()); server.setSerializationProvider(GsonMessageBodyHandler.class.getName()); @@ -116,18 +116,18 @@ public class TestRest2File { */ @Test public void testRestEventsIn() throws MessagingException, ApexException, IOException { - final String[] args = { "-rfr", "target", "-c", "target/examples/config/SampleDomain/REST2FileJsonEvent.json" }; + final String[] args = {"-rfr", "target", "-c", "target/examples/config/SampleDomain/REST2FileJsonEvent.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(5000); apexMain.shutdown(); - final String outputEventText = TextFileUtils - .getTextFileAsString("target/examples/events/SampleDomain/EventsOut.json"); + final String outputEventText = + TextFileUtils.getTextFileAsString("target/examples/events/SampleDomain/EventsOut.json"); checkRequiredString(outputEventText, - "04\",\n" + " \"version\": \"0.0.1\",\n" + " \"nameSpace\": \"org.onap.policy.apex.sample.events\""); + "04\",\n" + " \"version\": \"0.0.1\",\n" + " \"nameSpace\": \"org.onap.policy.apex.sample.events\""); } /** @@ -142,7 +142,7 @@ public class TestRest2File { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/prodcons/REST2FileJsonEmptyEvents.json" }; + final String[] args = {"src/test/resources/prodcons/REST2FileJsonEmptyEvents.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(5000); @@ -153,8 +153,8 @@ public class TestRest2File { System.setOut(stdout); System.setErr(stderr); - checkRequiredString(outString, - "received an empty event from URL " + "\"http://localhost:32801/TestRest2File/apex/event/GetEmptyEvent\""); + checkRequiredString(outString, "received an empty event from URL " + + "\"http://localhost:32801/TestRest2File/apex/event/GetEmptyEvent\""); } /** @@ -169,7 +169,7 @@ public class TestRest2File { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/prodcons/REST2FileJsonEventNoURL.json" }; + final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventNoURL.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(5000); @@ -195,7 +195,7 @@ public class TestRest2File { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/prodcons/REST2FileJsonEventBadURL.json" }; + final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventBadURL.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(5000); @@ -207,7 +207,7 @@ public class TestRest2File { System.setErr(stderr); checkRequiredString(outString, "reception of event from URL " - + "\"http://localhost:32801/TestRest2File/apex/event/Bad\" failed with status code 404"); + + "\"http://localhost:32801/TestRest2File/apex/event/Bad\" failed with status code 404"); } /** @@ -222,7 +222,7 @@ public class TestRest2File { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/prodcons/REST2FileJsonEventBadHTTPMethod.json" }; + final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventBadHTTPMethod.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(5000); @@ -234,7 +234,7 @@ public class TestRest2File { System.setErr(stderr); checkRequiredString(outString, "specified HTTP method of \"POST\" is invalid, " - + "only HTTP method \"GET\" is supported for event reception on REST client consumer"); + + "only HTTP method \"GET\" is supported for event reception on REST client consumer"); } /** @@ -249,7 +249,7 @@ public class TestRest2File { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/prodcons/REST2FileJsonEventBadResponse.json" }; + final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventBadResponse.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(5000); @@ -261,8 +261,9 @@ public class TestRest2File { System.setErr(stderr); checkRequiredString(outString, - "reception of event from URL " + "\"http://localhost:32801/TestRest2File/apex/event/GetEventBadResponse\" " - + "failed with status code 400 and message \""); + "reception of event from URL " + + "\"http://localhost:32801/TestRest2File/apex/event/GetEventBadResponse\" " + + "failed with status code 400 and message \""); } /** diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/context/EventAlbumContextTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/context/EventAlbumContextTest.java index d57f280ed..18b8f37cb 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/context/EventAlbumContextTest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/context/EventAlbumContextTest.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -33,9 +34,9 @@ import org.junit.rules.TemporaryFolder; import org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.apex.service.engine.main.ApexMain; import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.common.utils.resources.TextFileUtils; public class EventAlbumContextTest { private File tempCommandFile; @@ -48,7 +49,7 @@ public class EventAlbumContextTest { @Rule public TemporaryFolder tempTestDir = new TemporaryFolder(); - + /** * Clear relative file root environment variable. */ @@ -68,7 +69,7 @@ public class EventAlbumContextTest { configFile = "src/test/resources/prodcons/Context_JavaEventAlbum_file2file.json"; outputFile = "target/Context_JavaEventAlbum_EventOut.json"; compareFile = "src/test/resources/events/Context_JavaEventAlbum_EventOutCompare.json"; - + testEventAlbumContextTest(); } @@ -83,19 +84,19 @@ public class EventAlbumContextTest { configFile = "src/test/resources/prodcons/Context_AvroEventAlbum_file2file.json"; outputFile = "target/Context_AvroEventAlbum_EventOut.json"; compareFile = "src/test/resources/events/Context_AvroEventAlbum_EventOutCompare.json"; - + testEventAlbumContextTest(); } private void testEventAlbumContextTest() throws IOException, ApexException { TextFileUtils.putStringAsFile(eventContextString, tempCommandFile); - final String[] cliArgs = new String[] { "-c", tempCommandFile.getCanonicalPath(), "-l", - tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath() }; + final String[] cliArgs = new String[] {"-c", tempCommandFile.getCanonicalPath(), "-l", + tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath()}; new ApexCommandLineEditorMain(cliArgs); - final String[] args = new String[] { "-m", tempModelFile.getAbsolutePath(), "-c", configFile }; + final String[] args = new String[] {"-m", tempModelFile.getAbsolutePath(), "-c", configFile}; final ApexMain apexMain = new ApexMain(args); // The output event will be in this file @@ -104,8 +105,8 @@ public class EventAlbumContextTest { for (int tenthsOfSecondsToWait = 100; tenthsOfSecondsToWait > 0; tenthsOfSecondsToWait--) { if (outputEventFile.exists() && outputEventFile.length() > 0) { // The output event is in this file - receivedApexOutputString = TextFileUtils.getTextFileAsString(outputEventFile.getCanonicalPath()) - .replaceAll("\\s+", ""); + receivedApexOutputString = + TextFileUtils.getTextFileAsString(outputEventFile.getCanonicalPath()).replaceAll("\\s+", ""); break; } @@ -121,8 +122,7 @@ public class EventAlbumContextTest { assertTrue("Test failed, the output event file was empty", receivedApexOutputString.length() > 0); // We compare the output to what we expect to get - final String expectedFileContent = TextFileUtils - .getTextFileAsString(compareFile); + final String expectedFileContent = TextFileUtils.getTextFileAsString(compareFile); final String outputEventCompareString = expectedFileContent.replaceAll("\\s+", ""); assertEquals(outputEventCompareString, receivedApexOutputString); |