diff options
author | rameshiyer27 <ramesh.murugan.iyer@est.tech> | 2024-10-14 16:09:34 +0100 |
---|---|---|
committer | rameshiyer27 <ramesh.murugan.iyer@est.tech> | 2024-10-22 21:08:59 +0100 |
commit | 6b164a94d894c969811c9388b6af8c9a1fca2be2 (patch) | |
tree | b62eb7be108d5eb7faa9986c500c30fa7d653594 /plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan | |
parent | 85f95e93a19c778e72b6022a713f0eea55002585 (diff) |
Improve coverage on apex-pdp
Issue-ID: POLICY-5059
Signed-off-by: rameshiyer27 <ramesh.murugan.iyer@est.tech>
Change-Id: I3d8d71f4ee9db10fe43bfe51586156cf768a8560
Diffstat (limited to 'plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan')
2 files changed, 79 insertions, 1 deletions
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java index a9346bcc3..05d7cefb6 100644 --- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java +++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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. @@ -59,7 +60,7 @@ public class InfinispanManager { } catch (final IOException ioException) { final String errorMessage = "failed to start infinispan cache manager, " + "no infinispan configuration found on local file system or in classpath, " - + "try setting Infinspan \"configFile\" parameter"; + + "try setting Infinispan \"configFile\" parameter"; LOGGER.error(errorMessage); throw new ContextException(errorMessage, ioException); } catch (final Exception e) { diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorTest.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorTest.java new file mode 100644 index 000000000..4a87b5410 --- /dev/null +++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorTest.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2024 Nordix Foundation. 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 static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.onap.policy.apex.context.ContextException; +import org.onap.policy.apex.context.parameters.ContextParameterConstants; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.common.parameters.ParameterService; + + +class InfinispanDistributorTest { + + private static InfinispanDistributorParameters distributorParams; + + @BeforeAll + static void prepareForTest() { + final ContextParameters contextParameters = new ContextParameters(); + + contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME); + contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME); + contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + + ParameterService.register(contextParameters); + ParameterService.register(contextParameters.getLockManagerParameters()); + ParameterService.register(contextParameters.getPersistorParameters()); + + distributorParams = new InfinispanDistributorParameters(); + ParameterService.register(distributorParams); + } + + /** + * Clear down the test data. + */ + @AfterAll + static void cleanUpAfterTest() { + ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME); + ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + ParameterService.clear(); + } + + @Test + void testInvalidParameters() throws ContextException { + var infiniSpanDistributor = new InfinispanContextDistributor(); + var key = new AxArtifactKey("test", "1.1.1"); + assertThatThrownBy(() -> infiniSpanDistributor.init(key)).isInstanceOf(NoClassDefFoundError.class) + .hasMessageContaining("TransactionManager"); + assertThatThrownBy(() -> infiniSpanDistributor.getContextAlbumMap(key)) + .hasMessageContaining("infinispanManager\" is null"); + assertDoesNotThrow(infiniSpanDistributor::shutdown); + } + +} |