summaryrefslogtreecommitdiffstats
path: root/context/context-test-utils
diff options
context:
space:
mode:
authorDinh Danh Le <dinh.danh.le@ericsson.com>2018-08-27 15:57:41 +0100
committerDinh Danh Le <dinh.danh.le@ericsson.com>2018-08-27 16:17:04 +0100
commit052038c7a7e0b385462b3b653b7d06094d472df3 (patch)
tree4ba5dd833f7f459d93c80754ee21d64ddcc27f18 /context/context-test-utils
parent6a2abc8402af63dd8941b4652278a6df404d781a (diff)
Fix checkstyle warning in tools & context packages
Change-Id: I5b72c7a35d56296cd5053659a9d4c1e8f3b058be Signed-off-by: Dinh Danh Le <dinh.danh.le@ericsson.com> Issue-ID: POLICY-1034
Diffstat (limited to 'context/context-test-utils')
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java73
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java5
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java15
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java9
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java4
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java9
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java10
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java2
8 files changed, 82 insertions, 45 deletions
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
index b4e9ad37d..0fd013da7 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
@@ -91,12 +91,11 @@ import org.slf4j.ext.XLoggerFactory;
* @author Sergey Sachkov (sergey.sachkov@ericsson.com)
*/
public class ContextInstantiation {
-
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextInstantiation.class);
- private final static TreeSet<String> TEST_TREE_SET = new TreeSet<>();
- private final static Map<String, String> TEST_HASH_MAP = new HashMap<>();
+ private static final TreeSet<String> TEST_TREE_SET = new TreeSet<>();
+ private static final Map<String, String> TEST_HASH_MAP = new HashMap<>();
static {
TEST_TREE_SET.add("one hundred");
@@ -373,6 +372,40 @@ public class ContextInstantiation {
return globalContext;
}
+ private TestGlobalContextItem getTestGlobalContextItem(final Date testDate, final TestContextDateTzItem tci9,
+ final TestContextDateLocaleItem tciA) {
+ final TestGlobalContextItem globalContext = new TestGlobalContextItem();
+
+ final TestContextBooleanItem testGlobalContextItem000 = new TestContextBooleanItem(false);
+ final TestContextByteItem testGlobalContextItem001 = new TestContextByteItem(BYTE_VAL);
+ final TestContextIntItem testGlobalContextItem002 = new TestContextIntItem(INT_VAL);
+ final TestContextLongItem testGlobalContextItem003 = new TestContextLongItem(LONG_VAL);
+ final TestContextFloatItem testGlobalContextItem004 = new TestContextFloatItem(new Float(FLOAT_VAL));
+ final TestContextDoubleItem testGlobalContextItem005 = new TestContextDoubleItem(PI_VAL);
+ final TestContextStringItem testGlobalContextItem006 = new TestContextStringItem(STRING_GLOBAL_VAL);
+ final TestContextLongObjectItem testGlobalContextItem007 = new TestContextLongObjectItem(testDate.getTime());
+
+ final TestContextDateItem testGlobalContextItem008 = new TestContextDateItem(testDate);
+ final TestContextTreeSetItem testGlobalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET);
+ final TestContextTreeMapItem testGlobalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP);
+
+
+ globalContext.setTestGlobalContextItem000(testGlobalContextItem000);
+ globalContext.setTestGlobalContextItem001(testGlobalContextItem001);
+ globalContext.setTestGlobalContextItem002(testGlobalContextItem002);
+ globalContext.setTestGlobalContextItem003(testGlobalContextItem003);
+ globalContext.setTestGlobalContextItem004(testGlobalContextItem004);
+ globalContext.setTestGlobalContextItem005(testGlobalContextItem005);
+ globalContext.setTestGlobalContextItem006(testGlobalContextItem006);
+ globalContext.setTestGlobalContextItem007(testGlobalContextItem007);
+ globalContext.setTestGlobalContextItem008(testGlobalContextItem008);
+ globalContext.setTestGlobalContextItem009(tci9);
+ globalContext.setTestGlobalContextItem00A(tciA);
+ globalContext.setTestGlobalContextItem00B(testGlobalContextItem00B);
+ globalContext.setTestGlobalContextItem00C(testGlobalContextItem00C);
+ return globalContext;
+ }
+
private TestPolicyContextItem getTestPolicyContextItem(final ContextAlbum policyContextAlbum, final Date testDate) {
final TestContextStringItem contextStringItem = new TestContextStringItem(STRING_VAL);
final TestContextLongItem contextLongItem = new TestContextLongItem(LONG_VAL);
@@ -453,40 +486,6 @@ public class ContextInstantiation {
return tci9;
}
- private TestGlobalContextItem getTestGlobalContextItem(final Date testDate, final TestContextDateTzItem tci9,
- final TestContextDateLocaleItem tciA) {
- final TestGlobalContextItem globalContext = new TestGlobalContextItem();
-
- final TestContextBooleanItem testGlobalContextItem000 = new TestContextBooleanItem(false);
- final TestContextByteItem testGlobalContextItem001 = new TestContextByteItem(BYTE_VAL);
- final TestContextIntItem testGlobalContextItem002 = new TestContextIntItem(INT_VAL);
- final TestContextLongItem testGlobalContextItem003 = new TestContextLongItem(LONG_VAL);
- final TestContextFloatItem testGlobalContextItem004 = new TestContextFloatItem(new Float(FLOAT_VAL));
- final TestContextDoubleItem testGlobalContextItem005 = new TestContextDoubleItem(PI_VAL);
- final TestContextStringItem testGlobalContextItem006 = new TestContextStringItem(STRING_GLOBAL_VAL);
- final TestContextLongObjectItem testGlobalContextItem007 = new TestContextLongObjectItem(testDate.getTime());
-
- final TestContextDateItem testGlobalContextItem008 = new TestContextDateItem(testDate);
- final TestContextTreeSetItem testGlobalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET);
- final TestContextTreeMapItem testGlobalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP);
-
-
- globalContext.setTestGlobalContextItem000(testGlobalContextItem000);
- globalContext.setTestGlobalContextItem001(testGlobalContextItem001);
- globalContext.setTestGlobalContextItem002(testGlobalContextItem002);
- globalContext.setTestGlobalContextItem003(testGlobalContextItem003);
- globalContext.setTestGlobalContextItem004(testGlobalContextItem004);
- globalContext.setTestGlobalContextItem005(testGlobalContextItem005);
- globalContext.setTestGlobalContextItem006(testGlobalContextItem006);
- globalContext.setTestGlobalContextItem007(testGlobalContextItem007);
- globalContext.setTestGlobalContextItem008(testGlobalContextItem008);
- globalContext.setTestGlobalContextItem009(tci9);
- globalContext.setTestGlobalContextItem00A(tciA);
- globalContext.setTestGlobalContextItem00B(testGlobalContextItem00B);
- globalContext.setTestGlobalContextItem00C(testGlobalContextItem00C);
- return globalContext;
- }
-
private TestExternalContextItem getTestExternalContextItem(final Date testDate, final TestContextDateTzItem tci9A,
final TestContextDateLocaleItem tciAA) {
final TestExternalContextItem externalContext = new TestExternalContextItem();
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 c0ac36264..228ca7a40 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
@@ -64,6 +64,11 @@ public enum LockType {
return value;
}
+ /**
+ * Get the lock type given an int value.
+ * @param value the value of lock type
+ * @return the lock type
+ */
public static LockType getLockType(final int value) {
for (final LockType lockType : LockType.values()) {
if (lockType.getValue() == value) {
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
index b373e9fa0..4f6dd9b1f 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
@@ -51,7 +51,7 @@ public class ConcurrentContext {
// The context distributor and map used by each test
private Distributor contextDistributor = null;
- private ContextAlbum lTypeAlbum = null;
+ private ContextAlbum ltypeAlbum = null;
private final ConfigrationProvider configrationProvider;
@@ -59,6 +59,13 @@ public class ConcurrentContext {
this.configrationProvider = configrationProvider;
}
+ /**
+ * The method tests concurrent use of context.
+ * @return the verified context
+ * @throws ApexModelException the exception occurs in model handling
+ * @throws IOException the IO exception occurs in handling IO
+ * @throws ApexException the Apex exception occurs in handling Apex
+ */
public Map<String, TestContextLongItem> testConcurrentContext()
throws ApexModelException, IOException, ApexException {
@@ -135,11 +142,11 @@ public class ConcurrentContext {
*/
private void setupAndVerifyContext() throws ContextException {
contextDistributor = configrationProvider.getDistributor();
- lTypeAlbum = configrationProvider.getContextAlbum(contextDistributor);
+ ltypeAlbum = configrationProvider.getContextAlbum(contextDistributor);
final Map<String, Object> initValues = configrationProvider.getContextAlbumInitValues();
for (final Entry<String, Object> entry : initValues.entrySet()) {
- lTypeAlbum.put(entry.getKey(), entry.getValue());
+ ltypeAlbum.put(entry.getKey(), entry.getValue());
}
}
@@ -147,7 +154,7 @@ public class ConcurrentContext {
final Map<String, TestContextLongItem> values = new HashMap<>();
try {
- for (Entry<String, Object> entry : lTypeAlbum.entrySet()) {
+ for (Entry<String, Object> entry : ltypeAlbum.entrySet()) {
values.put(entry.getKey(), (TestContextLongItem) entry.getValue());
}
} catch (final Exception exception) {
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
index 020bc4169..3288f56dd 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
@@ -20,6 +20,8 @@
package org.onap.policy.apex.context.test.locking;
+import com.google.gson.Gson;
+
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.ArrayList;
@@ -46,7 +48,6 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
-import com.google.gson.Gson;
/**
* The Class ConcurrentContextJVM tests concurrent use of context in a single JVM.
@@ -72,6 +73,10 @@ public final class ConcurrentContextJVM {
this.executorService = configrationProvider.getExecutorService(name, configrationProvider.getThreadCount());
}
+ /**
+ * This method executes the test of concurrent use of context in a single JVM.
+ * @throws ApexException the Apex exception occurs while running the test
+ */
public void execute() throws ApexException {
LOGGER.debug("starting JVMs and threads . . .");
@@ -186,7 +191,7 @@ public final class ConcurrentContextJVM {
/**
- * This method setus up any static configuration required by the JVM.
+ * This method sets up any static configuration required by the JVM.
*
* @throws Exception on configuration errors
*/
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
index 049754802..117a396dc 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
@@ -20,6 +20,8 @@
package org.onap.policy.apex.context.test.locking;
+import com.google.gson.Gson;
+
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.InputStream;
@@ -34,7 +36,7 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
-import com.google.gson.Gson;
+
/**
* The Class TestConcurrentContextThread tests concurrent use of context.
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 f04cf5b39..87b81643a 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
@@ -47,6 +47,15 @@ public class ConfigrationProviderImpl implements ConfigrationProvider {
private final int albumSize;
private final LockType lockType;
+ /**
+ * The parameterized ConfigrationProviderImpl constructor.
+ * @param testType the test type
+ * @param jvmCount the JVM count
+ * @param threadCount the thread count
+ * @param loopSize the size of loop
+ * @param albumSize the size of album
+ * @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) {
this.testType = testType;
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 ffcbb351c..5a7813a7e 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
@@ -26,6 +26,8 @@ import java.net.InetSocketAddress;
import org.apache.zookeeper.server.NIOServerCnxnFactory;
import org.apache.zookeeper.server.ZooKeeperServer;
+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;
@@ -46,6 +48,11 @@ public class ZooKeeperServerServiceProvider {
this.addr = new InetSocketAddress(addr, port);
}
+ /**
+ * Start the Zookeeper server.
+ * @throws IOException the IO exception occurs while setting up Zookeeper server
+ * @throws InterruptedException the interrupted exception occurs while setting up Zookeeper server
+ */
public void startZookeeperServer() throws IOException, InterruptedException {
LOGGER.info("Starting up ZooKeeperServer using address: {} and port: {}", addr.getAddress(), addr.getPort());
final ZooKeeperServer server = new ZooKeeperServer(zookeeperDirectory, zookeeperDirectory, 5000);
@@ -54,6 +61,9 @@ public class ZooKeeperServerServiceProvider {
zookeeperFactory.startup(server);
}
+ /**
+ * Stop the Zookeeper server.
+ */
public void stopZookeeperServer() {
LOGGER.info("Stopping ZooKeeperServer for address: {} and port: {}", addr.getAddress(), addr.getPort());
if (zookeeperFactory != null) {
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
index 5d41eee85..80f06ead7 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
@@ -91,7 +91,7 @@ public class TestPersistentContextInstantiation {
final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
final AxArtifactKey[] usedArtifactStackArray = {new AxArtifactKey("testC-top", "0.0.1"),
- new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1")};
+ new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1")};
final DAOParameters daoParameters = new DAOParameters();
daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");