diff options
Diffstat (limited to 'context/context-test-utils/src/main')
17 files changed, 513 insertions, 13 deletions
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntity.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntity.java index 49802c2da..2653ca271 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntity.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntity.java @@ -33,6 +33,9 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxConcept; import org.onap.policy.apex.model.basicmodel.concepts.AxKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; +/** + * The Class ArtifactKeyTestEntity is an entity for testing artifact keys. + */ @Entity @Table(name = "ArtifactKeyTestEntity") public class ArtifactKeyTestEntity extends AxConcept { @@ -44,62 +47,130 @@ public class ArtifactKeyTestEntity extends AxConcept { private double doubleValue; + /** + * Instantiates a new artifact key test entity. + */ public ArtifactKeyTestEntity() { this.key = new AxArtifactKey(); this.doubleValue = 0; } + /** + * Instantiates a new artifact key test entity. + * + * @param doubleValue the double value + */ public ArtifactKeyTestEntity(final Double doubleValue) { this.key = new AxArtifactKey(); this.doubleValue = doubleValue; } + /** + * Instantiates a new artifact key test entity. + * + * @param key the key + * @param doubleValue the double value + */ public ArtifactKeyTestEntity(final AxArtifactKey key, final Double doubleValue) { this.key = key; this.doubleValue = doubleValue; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey() + */ @Override public AxArtifactKey getKey() { return key; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys() + */ @Override public List<AxKey> getKeys() { return Arrays.asList((AxKey) getKey()); } + /** + * Sets the key. + * + * @param key the new key + */ public void setKey(final AxArtifactKey key) { this.key = key; } + /** + * Check set key. + * + * @return true, if successful + */ public boolean checkSetKey() { return (this.key != null); } + /** + * Gets the double value. + * + * @return the double value + */ public double getDoubleValue() { return doubleValue; } + /** + * Sets the double value. + * + * @param doubleValue the new double value + */ public void setDoubleValue(final double doubleValue) { this.doubleValue = doubleValue; } + /* + * (non-Javadoc) + * + * @see + * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts. + * AxValidationResult) + */ @Override public AxValidationResult validate(final AxValidationResult result) { return key.validate(result); } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean() + */ @Override public void clean() { key.clean(); } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString() + */ @Override public String toString() { return "ArtifactKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]"; } + /* + * (non-Javadoc) + * + * @see + * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts. + * AxConcept) + */ @Override public AxConcept copyTo(final AxConcept target) { final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target); @@ -117,6 +188,11 @@ public class ArtifactKeyTestEntity extends AxConcept { } } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode() + */ @Override public int hashCode() { final int prime = 31; @@ -125,6 +201,11 @@ public class ArtifactKeyTestEntity extends AxConcept { return result; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang.Object) + */ @Override public boolean equals(final Object obj) { if (obj == null) { @@ -147,6 +228,11 @@ public class ArtifactKeyTestEntity extends AxConcept { return (Double.compare(doubleValue, other.doubleValue) == 0); } + /* + * (non-Javadoc) + * + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ @Override public int compareTo(final AxConcept otherObj) { if (otherObj == null) { diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ReferenceKeyTestEntity.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ReferenceKeyTestEntity.java index 6f276335b..d172f0276 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ReferenceKeyTestEntity.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ReferenceKeyTestEntity.java @@ -35,6 +35,9 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter; +/** + * The Class ReferenceKeyTestEntity provides a reference key test concept. + */ @Entity @Table(name = "ReferenceKeyTestEntity") public class ReferenceKeyTestEntity extends AxConcept { @@ -47,62 +50,130 @@ public class ReferenceKeyTestEntity extends AxConcept { private double doubleValue; + /** + * Instantiates a new reference key test entity. + */ public ReferenceKeyTestEntity() { this.key = new AxReferenceKey(); this.doubleValue = 0; } + /** + * Instantiates a new reference key test entity. + * + * @param doubleValue the double value + */ public ReferenceKeyTestEntity(final Double doubleValue) { this.key = new AxReferenceKey(); this.doubleValue = doubleValue; } + /** + * Instantiates a new reference key test entity. + * + * @param key the key + * @param doubleValue the double value + */ public ReferenceKeyTestEntity(final AxReferenceKey key, final Double doubleValue) { this.key = key; this.doubleValue = doubleValue; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey() + */ @Override public AxReferenceKey getKey() { return key; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys() + */ @Override public List<AxKey> getKeys() { return Arrays.asList((AxKey) getKey()); } + /** + * Sets the key. + * + * @param key the new key + */ public void setKey(final AxReferenceKey key) { this.key = key; } + /** + * Check set key. + * + * @return true, if successful + */ public boolean checkSetKey() { return (this.key != null); } + /** + * Gets the double value. + * + * @return the double value + */ public double getDoubleValue() { return doubleValue; } + /** + * Sets the double value. + * + * @param doubleValue the new double value + */ public void setDoubleValue(final double doubleValue) { this.doubleValue = doubleValue; } + /* + * (non-Javadoc) + * + * @see + * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts. + * AxValidationResult) + */ @Override public AxValidationResult validate(final AxValidationResult result) { return key.validate(result); } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean() + */ @Override public void clean() { key.clean(); } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString() + */ @Override public String toString() { return "ReferenceKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]"; } + /* + * (non-Javadoc) + * + * @see + * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts. + * AxConcept) + */ @Override public AxConcept copyTo(final AxConcept target) { final Object copyObject = ((target == null) ? new ReferenceKeyTestEntity() : target); @@ -120,6 +191,11 @@ public class ReferenceKeyTestEntity extends AxConcept { } } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode() + */ @Override public int hashCode() { final int prime = 31; @@ -128,6 +204,11 @@ public class ReferenceKeyTestEntity extends AxConcept { return result; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang.Object) + */ @Override public boolean equals(final Object obj) { if (obj == null) { @@ -150,6 +231,11 @@ public class ReferenceKeyTestEntity extends AxConcept { return (Double.compare(doubleValue, other.doubleValue) == 0); } + /* + * (non-Javadoc) + * + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ @Override public int compareTo(final AxConcept otherObj) { if (otherObj == null) { diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/package-info.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/package-info.java index 8a4ea4cee..be51a4e7e 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/package-info.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/package-info.java @@ -19,7 +19,7 @@ */ /** - * Contains common test entities + * Contains common test entities. * @author Dinh Danh Le (dinh.danh.le@ericsson.com) * */ diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/AlbumModifier.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/AlbumModifier.java index 14ceba425..1253d2234 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/AlbumModifier.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/AlbumModifier.java @@ -23,8 +23,19 @@ package org.onap.policy.apex.context.test.lock.modifier; import org.onap.policy.apex.context.ContextAlbum; import org.onap.policy.apex.context.ContextException; +/** + * The Interface AlbumModifier defines the interface to allow context albums be modified during context tests. + */ public interface AlbumModifier { + /** + * Modify album. + * + * @param contextAlbum the context album + * @param loopSize the loop size + * @param arraySize the array size + * @throws ContextException the context exception + */ void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) throws ContextException; } diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java index 228ca7a40..82de5b4a7 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java @@ -22,6 +22,9 @@ package org.onap.policy.apex.context.test.lock.modifier; import org.onap.policy.apex.context.ContextRuntimeException; +/** + * The Enum LockType defines the type of lock on a test context album. + */ public enum LockType { NO_LOCK(0) { @@ -56,10 +59,20 @@ public enum LockType { private final int value; + /** + * Instantiates a new lock type. + * + * @param value the value + */ private LockType(final int value) { this.value = value; } + /** + * Gets the value. + * + * @return the value + */ public int getValue() { return value; } @@ -78,6 +91,11 @@ public enum LockType { throw new ContextRuntimeException("Invalid Lock type value: " + value); } + /** + * Gets the album modifier. + * + * @return the album modifier + */ public abstract AlbumModifier getAlbumModifier(); } diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/NoLockAlbumModifier.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/NoLockAlbumModifier.java index 6c273a0ae..4ce7890be 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/NoLockAlbumModifier.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/NoLockAlbumModifier.java @@ -27,9 +27,18 @@ import org.onap.policy.apex.context.test.concepts.TestContextLongItem; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; +/** + * The Class NoLockAlbumModifier implements a non lock context album. + */ public class NoLockAlbumModifier implements AlbumModifier { private static final XLogger LOGGER = XLoggerFactory.getXLogger(NoLockAlbumModifier.class); + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.lock.modifier.AlbumModifier#modifyAlbum(org.onap.policy.apex.context. + * ContextAlbum, int, int) + */ @Override public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) { final Random rand = new Random(); diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/ReadLockAlbumModifier.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/ReadLockAlbumModifier.java index 854179ccd..fbafb1081 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/ReadLockAlbumModifier.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/ReadLockAlbumModifier.java @@ -28,9 +28,18 @@ import org.onap.policy.apex.context.test.concepts.TestContextLongItem; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; +/** + * The Class ReadLockAlbumModifier implements a read lock context album. + */ public class ReadLockAlbumModifier implements AlbumModifier { private static final XLogger LOGGER = XLoggerFactory.getXLogger(ReadLockAlbumModifier.class); + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.lock.modifier.AlbumModifier#modifyAlbum(org.onap.policy.apex.context. + * ContextAlbum, int, int) + */ @Override public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) { final Random rand = new Random(); diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/SingleValueWriteLockAlbumModifier.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/SingleValueWriteLockAlbumModifier.java index 959e93c67..674cf3af2 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/SingleValueWriteLockAlbumModifier.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/SingleValueWriteLockAlbumModifier.java @@ -28,13 +28,21 @@ import org.onap.policy.apex.context.test.concepts.TestContextLongItem; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; +/** + * The Class SingleValueWriteLockAlbumModifier implements a single value lock context album. + */ public class SingleValueWriteLockAlbumModifier implements AlbumModifier { private static final XLogger LOGGER = XLoggerFactory.getXLogger(SingleValueWriteLockAlbumModifier.class); - + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.lock.modifier.AlbumModifier#modifyAlbum(org.onap.policy.apex.context. + * ContextAlbum, int, int) + */ @Override public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) - throws ContextException { + throws ContextException { for (int i = 0; i < loopSize; i++) { try { contextAlbum.lockForWriting(TEST_VALUE); diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/WriteLockAlbumModifier.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/WriteLockAlbumModifier.java index d1f5ec17e..7136121f7 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/WriteLockAlbumModifier.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/WriteLockAlbumModifier.java @@ -28,10 +28,18 @@ import org.onap.policy.apex.context.test.concepts.TestContextLongItem; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; +/** + * The Class WriteLockAlbumModifier implements a write lock context album. + */ public class WriteLockAlbumModifier implements AlbumModifier { private static final XLogger LOGGER = XLoggerFactory.getXLogger(WriteLockAlbumModifier.class); - + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.lock.modifier.AlbumModifier#modifyAlbum(org.onap.policy.apex.context. + * ContextAlbum, int, int) + */ @Override public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) { final Random rand = new Random(); diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/package-info.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/package-info.java new file mode 100644 index 000000000..bf5bcb31c --- /dev/null +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/package-info.java @@ -0,0 +1,25 @@ +/*- + * ============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========================================================= + */ + +/** + * Provides modifiers that allow the locking on a contest album to be modified in various ways. + */ + +package org.onap.policy.apex.context.test.lock.modifier; diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProvider.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProvider.java index b842f7aca..f3a49dfbb 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProvider.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProvider.java @@ -30,35 +30,116 @@ import org.onap.policy.apex.context.test.lock.modifier.AlbumModifier; import org.onap.policy.apex.context.test.lock.modifier.LockType; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +/** + * The Interface ConfigrationProvider provides the configuration for a context test to a context test executor. + */ public interface ConfigrationProvider { + /** + * Gets the test name. + * + * @return the test name + */ String getTestName(); + /** + * Gets the loop size. + * + * @return the loop size + */ int getLoopSize(); + /** + * Gets the thread count. + * + * @return the thread count + */ int getThreadCount(); + /** + * Gets the jvm count. + * + * @return the jvm count + */ int getJvmCount(); + /** + * Gets the album size. + * + * @return the album size + */ int getAlbumSize(); + /** + * Gets the executor service. + * + * @return the executor service + */ ExecutorService getExecutorService(); + /** + * Gets the executor service. + * + * @param threadFactoryName the thread factory name + * @param threadPoolSize the thread pool size + * @return the executor service + */ ExecutorService getExecutorService(final String threadFactoryName, final int threadPoolSize); + /** + * Gets the distributor. + * + * @param key the key + * @return the distributor + */ Distributor getDistributor(final AxArtifactKey key); + /** + * Gets the distributor. + * + * @return the distributor + */ Distributor getDistributor(); + /** + * Gets the context album. + * + * @param distributor the distributor + * @return the context album + */ ContextAlbum getContextAlbum(final Distributor distributor); + /** + * Gets the context album. + * + * @param distributor the distributor + * @param axContextAlbumKey the ax context album key + * @param artifactKeys the artifact keys + * @return the context album + * @throws ContextException the context exception + */ ContextAlbum getContextAlbum(final Distributor distributor, AxArtifactKey axContextAlbumKey, - AxArtifactKey[] artifactKeys) throws ContextException; + AxArtifactKey[] artifactKeys) throws ContextException; + /** + * Gets the context album init values. + * + * @return the context album init values + */ Map<String, Object> getContextAlbumInitValues(); + /** + * Gets the album modifier. + * + * @return the album modifier + */ AlbumModifier getAlbumModifier(); + /** + * Gets the lock type. + * + * @return the lock type + */ LockType getLockType(); } diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java index 87b81643a..c63280966 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java @@ -38,6 +38,9 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel; import org.onap.policy.apex.model.utilities.Assertions; +/** + * The Class ConfigrationProviderImpl provides configuration information for a context test back to the caller. + */ public class ConfigrationProviderImpl implements ConfigrationProvider { private final String testType; @@ -49,6 +52,7 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { /** * The parameterized ConfigrationProviderImpl constructor. + * * @param testType the test type * @param jvmCount the JVM count * @param threadCount the thread count @@ -57,7 +61,7 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { * @param lockType the lock type */ public ConfigrationProviderImpl(final String testType, final int jvmCount, final int threadCount, - final int loopSize, final int albumSize, final int lockType) { + final int loopSize, final int albumSize, final int lockType) { this.testType = testType; this.jvmCount = jvmCount; this.threadCount = threadCount; @@ -66,31 +70,61 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { this.lockType = LockType.getLockType(lockType); } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getTestName() + */ @Override public String getTestName() { return testType; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getLoopSize() + */ @Override public int getLoopSize() { return loopSize; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getThreadCount() + */ @Override public int getThreadCount() { return threadCount; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getJvmCount() + */ @Override public int getJvmCount() { return jvmCount; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getAlbumSize() + */ @Override public int getAlbumSize() { return albumSize; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getExecutorService() + */ @Override public ExecutorService getExecutorService() { final String name = getThreadFactoryName(jvmCount, testType); @@ -99,6 +133,11 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { return executorService; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getExecutorService(java.lang.String, int) + */ @Override public ExecutorService getExecutorService(final String threadFactoryName, final int threadPoolSize) { final IntegrationThreadFactory threadFactory = new IntegrationThreadFactory(threadFactoryName); @@ -106,6 +145,13 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { return executorService; } + /* + * (non-Javadoc) + * + * @see + * org.onap.policy.apex.context.test.utils.ConfigrationProvider#getDistributor(org.onap.policy.apex.model.basicmodel + * .concepts.AxArtifactKey) + */ @Override public Distributor getDistributor(final AxArtifactKey key) { try { @@ -115,20 +161,38 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { } } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getDistributor() + */ @Override public Distributor getDistributor() { final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1"); return getDistributor(distributorKey); } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getContextAlbum(org.onap.policy.apex.context. + * Distributor) + */ @Override public ContextAlbum getContextAlbum(final Distributor distributor) { return getContextAlbum(distributor, Constants.L_TYPE_CONTEXT_ALBUM, Constants.getAxArtifactKeyArray()); } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getContextAlbum(org.onap.policy.apex.context. + * Distributor, org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey, + * org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey[]) + */ @Override public ContextAlbum getContextAlbum(final Distributor distributor, final AxArtifactKey axContextAlbumKey, - final AxArtifactKey[] artifactKeys) { + final AxArtifactKey[] artifactKeys) { final AxContextModel axContextModel = TestContextAlbumFactory.createMultiAlbumsContextModel(); try { distributor.registerModel(axContextModel); @@ -141,6 +205,11 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { } } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getContextAlbumInitValues() + */ @Override public Map<String, Object> getContextAlbumInitValues() { final Map<String, Object> values = new HashMap<>(); @@ -150,27 +219,48 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { return values; } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getAlbumModifier() + */ @Override public AlbumModifier getAlbumModifier() { return lockType.getAlbumModifier(); } + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.context.test.utils.ConfigrationProvider#getLockType() + */ @Override public LockType getLockType() { return lockType; } - + /** + * Gets the thread factory name. + * + * @param jvmCount the jvm count + * @param testType the test type + * @return the thread factory name + */ private String getThreadFactoryName(final int jvmCount, final String testType) { return jvmCount == 1 ? testType + ":TestConcurrentContextThread_0_" - : testType + ":TestConcurrentContextJVMThread_"; + : testType + ":TestConcurrentContextJVMThread_"; } + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ @Override public String toString() { return "ConfigrationProviderImpl [testType=" + testType + ", jvmCount=" + jvmCount + ", threadCount=" - + threadCount + ", loopSize=" + loopSize + ", albumSize=" + albumSize + ", lockType=" + lockType + "]"; + + threadCount + ", loopSize=" + loopSize + ", albumSize=" + albumSize + ", lockType=" + lockType + + "]"; } - } diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java index 118586437..927876e8f 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java @@ -25,6 +25,9 @@ import java.util.TimeZone; import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +/** + * The Class Constants provides constants for context tests. + */ public class Constants { public static final String MAP_CONTEXT_ALBUM = "MapContextAlbum"; public static final String LONG_CONTEXT_ALBUM = "LongContextAlbum"; @@ -61,10 +64,18 @@ public class Constants { private static final AxArtifactKey[] USED_ARTIFACT_STACK_ARRAY = new AxArtifactKey[] {KEY, KEY2, KEY3}; + /** + * Gets the ax artifact key array. + * + * @return the ax artifact key array + */ public static final AxArtifactKey[] getAxArtifactKeyArray() { return USED_ARTIFACT_STACK_ARRAY; } + /** + * Instantiates a new constants. + */ private Constants() {} } diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/IntegrationThreadFactory.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/IntegrationThreadFactory.java index d815c6b74..486a93cb4 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/IntegrationThreadFactory.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/IntegrationThreadFactory.java @@ -26,6 +26,9 @@ import java.util.concurrent.atomic.AtomicInteger; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; +/** + * A factory for creating IntegrationThread objects. + */ public class IntegrationThreadFactory implements ThreadFactory { private static final XLogger LOGGER = XLoggerFactory.getXLogger(IntegrationThreadFactory.class); @@ -34,10 +37,18 @@ public class IntegrationThreadFactory implements ThreadFactory { private final AtomicInteger counter = new AtomicInteger(); + /** + * Instantiates a new integration thread factory. + * + * @param threadFactoryName the thread factory name + */ public IntegrationThreadFactory(final String threadFactoryName) { this.threadFactoryName = threadFactoryName; } + /* (non-Javadoc) + * @see java.util.concurrent.ThreadFactory#newThread(java.lang.Runnable) + */ @Override public Thread newThread(final Runnable runnable) { final Thread thread = new Thread(runnable); @@ -45,5 +56,4 @@ public class IntegrationThreadFactory implements ThreadFactory { LOGGER.debug("started thread " + thread.getName()); return thread; } - } diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/NetworkUtils.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/NetworkUtils.java index 8d2c89254..980384043 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/NetworkUtils.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/NetworkUtils.java @@ -27,8 +27,14 @@ import java.util.Collections; import java.util.Enumeration; import java.util.TreeSet; +/** + * The Class NetworkUtils contains some utility functions for getting network information for context tests. + */ public class NetworkUtils { + /** + * Instantiates a new network utils. + */ private NetworkUtils() {} /** diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java index 654040d3f..301e8cc61 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java @@ -30,6 +30,9 @@ import org.apache.zookeeper.server.ZooKeeperServer; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; +/** + * The Class ZooKeeperServerServiceProvider provides a zookeeper service to a caller. + */ public class ZooKeeperServerServiceProvider { private static final XLogger LOGGER = XLoggerFactory.getXLogger(ZooKeeperServerServiceProvider.class); @@ -37,11 +40,24 @@ public class ZooKeeperServerServiceProvider { private File zookeeperDirectory; private InetSocketAddress addr; + /** + * Instantiates a new zoo keeper server service provider. + * + * @param zookeeperDirectory the zookeeper directory + * @param addr the addr + */ public ZooKeeperServerServiceProvider(final File zookeeperDirectory, final InetSocketAddress addr) { this.zookeeperDirectory = zookeeperDirectory; this.addr = addr; } + /** + * Instantiates a new zoo keeper server service provider. + * + * @param zookeeperDirectory the zookeeper directory + * @param addr the addr + * @param port the port + */ public ZooKeeperServerServiceProvider(final File zookeeperDirectory, final String addr, final int port) { this.zookeeperDirectory = zookeeperDirectory; this.addr = new InetSocketAddress(addr, port); @@ -69,5 +85,4 @@ public class ZooKeeperServerServiceProvider { zookeeperFactory.shutdown(); } } - } diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/package-info.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/package-info.java new file mode 100755 index 000000000..2872d20df --- /dev/null +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/package-info.java @@ -0,0 +1,27 @@ +/*- + * ============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========================================================= + */ + +/** + * Contains utilities for context tests. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ + +package org.onap.policy.apex.context.test.utils; |