aboutsummaryrefslogtreecommitdiffstats
path: root/context/context-test-utils
diff options
context:
space:
mode:
Diffstat (limited to 'context/context-test-utils')
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java14
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java3
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java47
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java42
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java42
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java38
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java43
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java41
9 files changed, 235 insertions, 43 deletions
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 3288f56dd..0f6900dbb 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
@@ -43,8 +43,8 @@ import org.onap.policy.apex.context.test.utils.Constants;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -144,13 +144,13 @@ public final class ConcurrentContextJVM {
for (int p = 7; p < args.length - 1; p += 2) {
@SuppressWarnings("rawtypes")
final Class parametersClass = Class.forName(args[p]);
- final AbstractParameters parameters =
- (AbstractParameters) new Gson().fromJson(args[p + 1], parametersClass);
- ParameterService.registerParameters(parametersClass, parameters);
+ final ParameterGroup parameters =
+ (ParameterGroup) new Gson().fromJson(args[p + 1], parametersClass);
+ ParameterService.register(parameters);
}
- for (final Entry<Class<?>, AbstractParameters> parameterEntry : ParameterService.getAll()) {
- LOGGER.info("Parameter class " + parameterEntry.getKey().getCanonicalName() + "="
+ for (final Entry<String, ParameterGroup> parameterEntry : ParameterService.getAll()) {
+ LOGGER.info("Parameter class " + parameterEntry.getKey() + "="
+ parameterEntry.getValue().toString());
}
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 117a396dc..0c2aa7a90 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
@@ -31,8 +31,8 @@ import java.util.List;
import java.util.Map.Entry;
import org.onap.policy.apex.context.test.utils.ConfigrationProvider;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -79,8 +79,8 @@ public class ConcurrentContextJVMThread implements Runnable, Closeable {
commandList.add(new Integer(configrationProvider.getLockType().getValue()).toString());
commandList.add(System.getProperty("hazelcast.config", ""));
- for (final Entry<Class<?>, AbstractParameters> parameterServiceEntry : ParameterService.getAll()) {
- commandList.add(parameterServiceEntry.getKey().getCanonicalName());
+ for (final Entry<String, ParameterGroup> parameterServiceEntry : ParameterService.getAll()) {
+ commandList.add(parameterServiceEntry.getValue().getClass().getCanonicalName());
commandList.add(new Gson().toJson(parameterServiceEntry.getValue()));
}
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 5a7813a7e..654040d3f 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,8 +26,7 @@ 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;
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
index 5487a0934..6b9ba15ad 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
@@ -22,11 +22,16 @@ package org.onap.policy.apex.context.test.distribution;
import java.io.IOException;
import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
+import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -34,11 +39,44 @@ public class TestContextAlbumUpdate {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestContextAlbumUpdate.class);
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+
+ @Before
+ public void beforeTest() {
+ contextParameters = new ContextParameters();
+
+ contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
+ contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
+ contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
+
@Test
public void testContextAlbumUpdateJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextAlbumUpdateJVMLocalVarSet test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextAlbumUpdate().testContextAlbumUpdate();
@@ -49,15 +87,8 @@ public class TestContextAlbumUpdate {
public void testContextAlbumUpdateJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextAlbumUpdateJVMLocalVarNotSet test . . .");
- new ContextParameters();
new ContextAlbumUpdate().testContextAlbumUpdate();
logger.debug("Ran testContextAlbumUpdateJVMLocalVarNotSet test");
}
-
- /**
- * Test context update cleardown.
- */
- @After
- public void testContextAlbumUpdateCleardown() {}
}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
index 409033ad4..b10bc685c 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
@@ -25,9 +25,13 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
+import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -40,20 +44,44 @@ public class TestContextInstantiation {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestContextInstantiation.class);
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+
@Before
- public void beforeTest() {}
+ public void beforeTest() {
+ contextParameters = new ContextParameters();
+
+ contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
+ contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
+ contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+ }
- /**
- * Test context instantiation clear down.
- */
@After
- public void afterTest() {}
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
@Test
public void testContextInstantiationJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextInstantiationJVMLocalVarSet test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextInstantiation().testContextInstantiation();
@@ -64,10 +92,8 @@ public class TestContextInstantiation {
public void testContextInstantiationJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextInstantiationJVMLocalVarNotSet test . . .");
- new ContextParameters();
new ContextInstantiation().testContextInstantiation();
logger.debug("Ran testContextInstantiationJVMLocalVarNotSet test");
}
-
}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
index 1a9bc29f1..07a0cbe47 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
@@ -22,11 +22,17 @@ package org.onap.policy.apex.context.test.distribution;
import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
+import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -38,12 +44,45 @@ import org.slf4j.ext.XLoggerFactory;
public class TestContextUpdate {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdate.class);
+
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+
+ @Before
+ public void beforeTest() {
+ contextParameters = new ContextParameters();
+
+ contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
+ contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
+ contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
@Test
public void testContextUpdateJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextUpdateJVMLocalVarSet test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextUpdate().testContextUpdate();
@@ -54,7 +93,6 @@ public class TestContextUpdate {
public void testContextUpdateJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextUpdateJVMLocalVarNotSet test . . .");
- new ContextParameters();
new ContextUpdate().testContextUpdate();
logger.debug("Ran testContextUpdateJVMLocalVarNotSet test");
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
index 6e7430756..b37c8eafa 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
@@ -25,9 +25,13 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
+import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -39,20 +43,48 @@ import org.slf4j.ext.XLoggerFactory;
public class TestSequentialContextInstantiation {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestSequentialContextInstantiation.class);
+
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
@Before
- public void beforeTest() {}
+ public void beforeTest() {
+ contextParameters = new ContextParameters();
+
+ contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
+ contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
+ contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+ }
@After
- public void afterTest() {}
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
@Test
public void testSequentialContextInstantiationJVMLocalVarSet()
throws ApexModelException, IOException, ApexException {
logger.debug("Running testSequentialContextInstantiationJVMLocalVarSet test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
+
new SequentialContextInstantiation().testSequentialContextInstantiation();
logger.debug("Ran testSequentialContextInstantiationJVMLocalVarSet test");
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
index 9d0210e38..8fca90b07 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
@@ -28,14 +28,20 @@ import static org.onap.policy.apex.context.test.utils.Constants.TEST_VALUE;
import java.util.Map;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
import org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager;
+import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.context.test.utils.ConfigrationProvider;
import org.onap.policy.apex.context.test.utils.ConfigrationProviderImpl;
import org.onap.policy.apex.context.test.utils.Constants;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -57,11 +63,44 @@ public class TestConcurrentContext {
private static final int TEST_THREAD_COUNT_MULTI_JVM = 20;
private static final int TEST_THREAD_LOOPS = 100;
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+
+ @Before
+ public void beforeTest() {
+ contextParameters = new ContextParameters();
+
+ contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
+ contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
+ contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
+
@Test
public void testConcurrentContextJVMLocalVarSet() throws Exception {
logger.debug("Running testConcurrentContextJVMLocalVarSet test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalVarSet",
@@ -84,7 +123,6 @@ public class TestConcurrentContext {
public void testConcurrentContextJVMLocalNoVarSet() throws Exception {
logger.debug("Running testConcurrentContextJVMLocalNoVarSet test . . .");
- new ContextParameters();
final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalNoVarSet",
TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
@@ -104,7 +142,6 @@ public class TestConcurrentContext {
public void testConcurrentContextMultiJVMNoLock() throws Exception {
logger.debug("Running testConcurrentContextMultiJVMNoLock test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
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 80f06ead7..d3a8ba163 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
@@ -38,8 +38,10 @@ import org.junit.Test;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.PersistorParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.context.test.concepts.TestContextDateItem;
import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
@@ -53,6 +55,7 @@ import org.onap.policy.apex.model.basicmodel.dao.DAOParameters;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.onap.policy.common.parameters.ParameterService;
/**
* The Class TestContextInstantiation.
@@ -65,6 +68,8 @@ public class TestPersistentContextInstantiation {
// XLoggerFactory.getXLogger(TestPersistentContextInstantiation.class);
private Connection connection;
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
@Before
public void setup() throws Exception {
@@ -78,15 +83,40 @@ public class TestPersistentContextInstantiation {
new File("derby.log").delete();
}
+ @Before
+ public void beforeTest() {
+ contextParameters = new ContextParameters();
+
+ contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
+ contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
+ contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+ }
+
@After
- public void afterTest() throws IOException {}
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
@Test
public void testContextPersistentInstantiation() throws ApexModelException, IOException, ApexException {
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.setPersistorParameters(new PersistorParameters());
-
final AxArtifactKey distributorKey = new AxArtifactKey("AbstractDistributor", "0.0.1");
final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
@@ -181,6 +211,5 @@ public class TestPersistentContextInstantiation {
contextAlbumForLong.flush();
contextDistributor.clear();
-
}
}