From 3f300de4a4ab68feef455e43b18cac804323fd8e Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Thu, 5 Jul 2018 18:57:02 +0100 Subject: Refactoring existing integration tests Change-Id: I1aedd94d5197b8c6513fc701e9df2aab4edec088 Issue-ID: POLICY-865 Signed-off-by: waqas.ikram --- .../context-distribution-hazelcast/pom.xml | 6 ++ .../hazelcast/HazelcastContextDistributorTest.java | 74 +++++++++++++++++ .../context-distribution-infinispan/pom.xml | 6 ++ .../InfinispanContextDistributorTest.java | 93 ++++++++++++++++++++++ 4 files changed, 179 insertions(+) create mode 100644 plugins/plugins-context/context-distribution/context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java create mode 100644 plugins/plugins-context/context-distribution/context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java (limited to 'plugins/plugins-context/context-distribution') diff --git a/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml index ce80a7a89..71806c54f 100644 --- a/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml +++ b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml @@ -36,5 +36,11 @@ hazelcast ${version.hazelcast} + + org.onap.policy.apex-pdp.context + context-test-utils + ${project.version} + test + \ No newline at end of file diff --git a/plugins/plugins-context/context-distribution/context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java new file mode 100644 index 000000000..c999c95f0 --- /dev/null +++ b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java @@ -0,0 +1,74 @@ +/*- + * ============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.plugins.context.distribution.hazelcast; + +import java.io.IOException; + +import org.junit.Test; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate; +import org.onap.policy.apex.context.test.distribution.ContextInstantiation; +import org.onap.policy.apex.context.test.distribution.ContextUpdate; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +public class HazelcastContextDistributorTest { + private static final String HAZEL_CAST_PLUGIN_CLASS = HazelcastContextDistributor.class.getCanonicalName(); + // Logger for this class + private static final XLogger logger = XLoggerFactory.getXLogger(HazelcastContextDistributorTest.class); + + + @Test + public void testContextAlbumUpdateHazelcast() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextAlbumUpdateHazelcast test . . ."); + + final ContextParameters contextParameters = new ContextParameters(); + contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS); + new ContextAlbumUpdate().testContextAlbumUpdate(); + + logger.debug("Ran testContextAlbumUpdateHazelcast test"); + } + + @Test + public void testContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextInstantiationHazelcast test . . ."); + + final ContextParameters contextParameters = new ContextParameters(); + contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS); + new ContextInstantiation().testContextInstantiation(); + + logger.debug("Ran testContextInstantiationHazelcast test"); + } + + @Test + public void testContextUpdateHazelcast() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextUpdateHazelcast test . . ."); + + final ContextParameters contextParameters = new ContextParameters(); + contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS); + new ContextUpdate().testContextUpdate(); + + logger.debug("Ran testContextUpdateHazelcast test"); + } + +} diff --git a/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml b/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml index 7592edd91..c6985a952 100644 --- a/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml +++ b/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml @@ -42,6 +42,12 @@ + + org.onap.policy.apex-pdp.context + context-test-utils + ${project.version} + test + \ No newline at end of file diff --git a/plugins/plugins-context/context-distribution/context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java b/plugins/plugins-context/context-distribution/context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java new file mode 100644 index 000000000..34fa7d439 --- /dev/null +++ b/plugins/plugins-context/context-distribution/context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java @@ -0,0 +1,93 @@ +/*- + * ============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.plugins.context.distribution.infinispan; + +import java.io.IOException; + +import org.junit.Test; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate; +import org.onap.policy.apex.context.test.distribution.ContextInstantiation; +import org.onap.policy.apex.context.test.distribution.ContextUpdate; +import org.onap.policy.apex.context.test.distribution.SequentialContextInstantiation; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +public class InfinispanContextDistributorTest { + private static final XLogger logger = XLoggerFactory.getXLogger(InfinispanContextDistributorTest.class); + + private static final String PLUGIN_CLASS = InfinispanContextDistributor.class.getCanonicalName(); + + @Test + public void testContextAlbumUpdateInfinispan() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextAlbumUpdateInfinispan test . . ."); + + final ContextParameters contextParameters = new ContextParameters(); + contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS); + new InfinispanDistributorParameters(); + + new ContextAlbumUpdate().testContextAlbumUpdate(); + + logger.debug("Ran testContextAlbumUpdateInfinispan test"); + } + + @Test + public void testContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextInstantiationInfinispan test . . ."); + + final ContextParameters contextParameters = new ContextParameters(); + contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS); + new InfinispanDistributorParameters(); + + new ContextInstantiation().testContextInstantiation(); + + logger.debug("Ran testContextInstantiationInfinispan test"); + } + + @Test + public void testContextUpdateInfinispan() throws ApexModelException, IOException, ApexException { + logger.debug("Running testContextUpdateInfinispan test . . ."); + + final ContextParameters contextParameters = new ContextParameters(); + contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS); + new InfinispanDistributorParameters(); + + new ContextUpdate().testContextUpdate(); + + logger.debug("Ran testContextUpdateInfinispan test"); + } + + @Test + public void testSequentialContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException { + logger.debug("Running testSequentialContextInstantiationInfinispan test . . ."); + + final ContextParameters contextParameters = new ContextParameters(); + contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS); + new InfinispanDistributorParameters(); + + new SequentialContextInstantiation().testSequentialContextInstantiation(); + + logger.debug("Ran testSequentialContextInstantiationInfinispan test"); + } + + +} -- cgit 1.2.3-korg