summaryrefslogtreecommitdiffstats
path: root/testsuites/integration/integration-uservice-test
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/integration/integration-uservice-test')
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java56
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java54
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java58
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java53
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/BaseEventTest.java88
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java57
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java53
7 files changed, 419 insertions, 0 deletions
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java
new file mode 100644
index 000000000..cb01af388
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Test;
+
+public class AsyncEventMimoTest extends BaseEventTest {
+ private final String[] outFilePaths = {
+ "target/examples/events/SampleDomain/EventsOutMulti0.json",
+ "target/examples/events/SampleDomain/EventsOutMulti1.json",
+ "target/examples/events/SampleDomain/EventsOutMulti2.json"
+ };
+
+ /**
+ * Delete output files.
+ */
+ @After
+ public void deleteOutputFiles() {
+ for (String filePath : outFilePaths) {
+ new File(filePath).delete();
+ }
+ }
+
+ @Test
+ public void testJsonFileAsyncMimo() throws Exception {
+ final String[] args = {
+ "-rfr",
+ "target",
+ "-c",
+ "target/examples/config/SampleDomain/File2FileJsonEventAsyncMIMO.json"
+ };
+
+ testFileEvents(args, outFilePaths, 300);
+ }
+}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java
new file mode 100644
index 000000000..ca4e1ecc1
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Test;
+
+public class AsyncEventMisoTest extends BaseEventTest {
+ private final String[] outFilePaths = {
+ "target/examples/events/SampleDomain/EventsOutSingle.json"
+ };
+
+ /**
+ * Delete output files.
+ */
+ @After
+ public void deleteOutputFiles() {
+ for (String filePath : outFilePaths) {
+ new File(filePath).delete();
+ }
+ }
+
+ @Test
+ public void testJsonFileAsyncMiso() throws Exception {
+ final String[] args = {
+ "-rfr",
+ "target",
+ "-c",
+ "target/examples/config/SampleDomain/File2FileJsonEventAsyncMISO.json"
+ };
+
+ testFileEvents(args, outFilePaths, 300);
+ }
+}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java
new file mode 100644
index 000000000..d11fc012d
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Test;
+
+public class AsyncEventSimoTest extends BaseEventTest {
+ private final String[] outFilePaths = {
+ "target/examples/events/SampleDomain/EventsOutMulti0.json",
+ "target/examples/events/SampleDomain/EventsOutMulti1.json",
+ "target/examples/events/SampleDomain/EventsOutMulti2.json"
+ };
+
+ /**
+ * Delete output files.
+ */
+ @After
+ public void deleteOutputFiles() {
+ for (String filePath : outFilePaths) {
+ new File(filePath).delete();
+ }
+ }
+
+ @Test
+ public void testJsonFileAsyncSimo() throws Exception {
+ final String[] args = {
+ "-rfr",
+ "target",
+ "-c",
+ "target/examples/config/SampleDomain/File2FileJsonEventAsyncSIMO.json"
+ };
+
+
+ testFileEvents(args, outFilePaths, 100);
+ }
+
+}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java
new file mode 100644
index 000000000..bd77b424b
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Test;
+
+public class AsyncEventSisoTest extends BaseEventTest {
+ private final String[] outFilePaths = {
+ "target/examples/events/SampleDomain/EventsOutSingle.json"
+ };
+
+ /**
+ * Delete output files.
+ */
+ @After
+ public void deleteOutputFiles() {
+ for (String filePath : outFilePaths) {
+ new File(filePath).delete();
+ }
+ }
+
+ @Test
+ public void testJsonFileAsyncSiso() throws Exception {
+ final String[] args = {
+ "-rfr",
+ "target",
+ "-c",
+ "target/examples/config/SampleDomain/File2FileJsonEventAsyncSISO.json"};
+
+ testFileEvents(args, outFilePaths, 100);
+ }
+}
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
new file mode 100644
index 000000000..9199d2a98
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/BaseEventTest.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+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;
+
+public class BaseEventTest {
+ private static final long TIME_OUT_IN_MS = 10000;
+
+ private void waitForOutFiles(final String[] expectedFileNames, final long expectedFileSize) throws IOException {
+ final long totalExpectedSize = expectedFileSize * expectedFileNames.length;
+
+ long startWaitTime = System.currentTimeMillis();
+ long lastTotalSize = 0;
+
+ do {
+ long totalSize = 0;
+
+ for (String expectedFileName : expectedFileNames) {
+ totalSize += getEventCount(expectedFileName);
+ }
+
+ 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);
+ }
+
+ 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 {
+ final ApexMain apexMain = new ApexMain(args);
+
+ waitForOutFiles(expectedFileNames, expectedFileSize);
+
+ apexMain.shutdown();
+
+ for (final String expectedFileName : expectedFileNames) {
+ assertEquals(expectedFileSize, getEventCount(expectedFileName));
+ }
+ }
+}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java
new file mode 100644
index 000000000..cf86d2fc1
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Test;
+
+public class SyncEventMimoTest extends BaseEventTest {
+ private final String[] outFilePaths = {
+ "target/examples/events/SampleDomain/EventsOutMulti0.json",
+ "target/examples/events/SampleDomain/EventsOutMulti1.json",
+ "target/examples/events/SampleDomain/EventsOutMulti2.json"
+ };
+
+ /**
+ * Delete output files.
+ */
+ @After
+ public void deleteOutputFiles() {
+ for (String filePath : outFilePaths) {
+ new File(filePath).delete();
+ }
+ }
+
+ @Test
+ public void testJsonFileAsyncMimo() throws Exception {
+ final String[] args = {
+ "-rfr",
+ "target",
+ "-c",
+ "target/examples/config/SampleDomain/File2FileJsonEventSyncMIMO.json"
+ };
+
+ testFileEvents(args, outFilePaths, 300);
+ }
+
+}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java
new file mode 100644
index 000000000..7fed77bf2
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Test;
+
+public class SyncEventSisoTest extends BaseEventTest {
+ private final String[] outFilePaths = {
+ "target/examples/events/SampleDomain/EventsOutSingle.json"
+ };
+
+ /**
+ * Delete output files.
+ */
+ @After
+ public void deleteOutputFiles() {
+ for (String filePath : outFilePaths) {
+ new File(filePath).delete();
+ }
+ }
+
+ @Test
+ public void testJsonFileAsyncSiso() throws Exception {
+ final String[] args = {
+ "-rfr",
+ "target",
+ "-c",
+ "target/examples/config/SampleDomain/File2FileJsonEventSyncSISO.json"};
+
+ testFileEvents(args, outFilePaths, 100);
+ }
+}