aboutsummaryrefslogtreecommitdiffstats
path: root/context
diff options
context:
space:
mode:
Diffstat (limited to 'context')
-rw-r--r--context/context-management/pom.xml4
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java22
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java14
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java22
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java18
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java5
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java41
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java41
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java46
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java46
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java45
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java45
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java29
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java29
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java18
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java18
-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
25 files changed, 527 insertions, 194 deletions
diff --git a/context/context-management/pom.xml b/context/context-management/pom.xml
index 3826ba6dc..d9d9147e5 100644
--- a/context/context-management/pom.xml
+++ b/context/context-management/pom.xml
@@ -32,6 +32,10 @@
<dependencies>
<dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>common-parameters</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.policy.apex-pdp.model</groupId>
<artifactId>context-model</artifactId>
<version>${project.version}</version>
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
index 1af13cbea..dba81d321 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
@@ -22,10 +22,11 @@ package org.onap.policy.apex.context.impl.distribution;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -51,24 +52,23 @@ public class DistributorFactory {
Assertions.argumentNotNull(key, ContextException.class, "Parameter \"key\" may not be null");
// Get the class for the distributor using reflection
- final DistributorParameters distributorParameters = ParameterService.getParameters(DistributorParameters.class);
+ final DistributorParameters distributorParameters = ParameterService
+ .get(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
final String pluginClass = distributorParameters.getPluginClass();
Object contextDistributorObject = null;
try {
contextDistributorObject = Class.forName(pluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
- LOGGER.error(
- "Apex context distributor class not found for context distributor plugin \"" + pluginClass + "\"",
- e);
- throw new ContextException(
- "Apex context distributor class not found for context distributor plugin \"" + pluginClass + "\"",
- e);
+ LOGGER.error("Apex context distributor class not found for context distributor plugin \"" + pluginClass
+ + "\"", e);
+ throw new ContextException("Apex context distributor class not found for context distributor plugin \""
+ + pluginClass + "\"", e);
}
// Check the class is a distributor
if (!(contextDistributorObject instanceof Distributor)) {
final String returnString = "Specified Apex context distributor plugin class \"" + pluginClass
- + "\" does not implement the ContextDistributor interface";
+ + "\" does not implement the ContextDistributor interface";
LOGGER.error(returnString);
throw new ContextException(returnString);
}
@@ -79,8 +79,8 @@ public class DistributorFactory {
// Lock and load the context distributor
contextDistributor.init(key);
- LOGGER.exit(
- "Distributor factory, key=" + key + ", selected distributor of class " + contextDistributor.getClass());
+ LOGGER.exit("Distributor factory, key=" + key + ", selected distributor of class "
+ + contextDistributor.getClass());
return contextDistributor;
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
index 467d43f9d..19bb3602e 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
@@ -25,8 +25,9 @@ import java.util.TimerTask;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.PersistorParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -59,7 +60,8 @@ public class DistributorFlushTimerTask extends TimerTask {
this.contextDistributor = contextDistributor;
// Set the period for persistence flushing
- final PersistorParameters persistorParameters = ParameterService.getParameters(PersistorParameters.class);
+ final PersistorParameters persistorParameters = ParameterService
+ .get(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
period = persistorParameters.getFlushPeriod();
// Set up the timer
@@ -67,7 +69,7 @@ public class DistributorFlushTimerTask extends TimerTask {
timer.schedule(this, period, period);
LOGGER.debug("context distributor " + contextDistributor.getKey().getID() + " flushing set up with interval: "
- + period + "ms");
+ + period + "ms");
}
/**
@@ -79,14 +81,14 @@ public class DistributorFlushTimerTask extends TimerTask {
flushCount++;
LOGGER.debug("context distributor " + contextDistributor.getKey().getID() + " flushing: period=" + period
- + ": count=" + flushCount);
+ + ": count=" + flushCount);
try {
contextDistributor.flush();
LOGGER.debug("context distributor " + contextDistributor.getKey().getID() + " flushed: period=" + period
- + ": count=" + flushCount);
+ + ": count=" + flushCount);
} catch (final ContextException e) {
LOGGER.error("flush error on context distributor " + contextDistributor.getKey().getID() + ": period="
- + period + ": count=" + flushCount, e);
+ + period + ": count=" + flushCount, e);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
index f3f4a6240..c45e3bd27 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
@@ -22,9 +22,10 @@ package org.onap.policy.apex.context.impl.locking;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.LockManager;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -48,7 +49,8 @@ public class LockManagerFactory {
public LockManager createLockManager(final AxArtifactKey key) throws ContextException {
LOGGER.entry("Lock Manager factory, key=" + key);
- final LockManagerParameters lockManagerParameters = ParameterService.getParameters(LockManagerParameters.class);
+ final LockManagerParameters lockManagerParameters = ParameterService
+ .get(ContextParameterConstants.LOCKING_GROUP_NAME);
// Get the class for the lock manager using reflection
Object lockManagerObject = null;
@@ -56,20 +58,18 @@ public class LockManagerFactory {
try {
lockManagerObject = Class.forName(pluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
- LOGGER.error(
- "Apex context lock manager class not found for context lock manager plugin \"" + pluginClass + "\"",
- e);
- throw new ContextException(
- "Apex context lock manager class not found for context lock manager plugin \"" + pluginClass + "\"",
- e);
+ LOGGER.error("Apex context lock manager class not found for context lock manager plugin \"" + pluginClass
+ + "\"", e);
+ throw new ContextException("Apex context lock manager class not found for context lock manager plugin \""
+ + pluginClass + "\"", e);
}
// Check the class is a lock manager
if (!(lockManagerObject instanceof LockManager)) {
- LOGGER.error("Specified Apex context lock manager plugin class \"" + pluginClass
- + "\" does not implement the LockManager interface");
+ LOGGER.error("Specified Apex context lock manager plugin class \"{}\" does not implement the LockManager interface",
+ pluginClass);
throw new ContextException("Specified Apex context lock manager plugin class \"" + pluginClass
- + "\" does not implement the LockManager interface");
+ + "\" does not implement the LockManager interface");
}
// The context lock manager to return
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
index af6f922d3..34fa15dcb 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
@@ -22,10 +22,11 @@ package org.onap.policy.apex.context.impl.persistence;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Persistor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.PersistorParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -49,7 +50,8 @@ public class PersistorFactory {
LOGGER.entry("persistor factory, key=" + key);
Assertions.argumentNotNull(key, ContextException.class, "Parameter \"key\" may not be null");
- final PersistorParameters persistorParameters = ParameterService.getParameters(PersistorParameters.class);
+ final PersistorParameters persistorParameters = ParameterService
+ .get(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
// Get the class for the persistor using reflection
Object persistorObject = null;
@@ -58,17 +60,17 @@ public class PersistorFactory {
persistorObject = Class.forName(pluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
LOGGER.error("Apex context persistor class not found for context persistor plugin \"" + pluginClass + "\"",
- e);
- throw new ContextException(
- "Apex context persistor class not found for context persistor plugin \"" + pluginClass + "\"", e);
+ e);
+ throw new ContextException("Apex context persistor class not found for context persistor plugin \""
+ + pluginClass + "\"", e);
}
// Check the class is a persistor
if (!(persistorObject instanceof Persistor)) {
- LOGGER.error("Specified Apex context persistor plugin class \"" + pluginClass
- + "\" does not implement the ContextDistributor interface");
+ LOGGER.error("Specified Apex context persistor plugin class \"{}\" does not implement the ContextDistributor interface",
+ pluginClass);
throw new ContextException("Specified Apex context persistor plugin class \"" + pluginClass
- + "\" does not implement the ContextDistributor interface");
+ + "\" does not implement the ContextDistributor interface");
}
// The persistor to return
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
index 54689e3fb..84025fc25 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
@@ -22,15 +22,16 @@ package org.onap.policy.apex.context.impl.schema;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.SchemaHelper;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaHelperParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -67,7 +68,7 @@ public class SchemaHelperFactory {
}
// Get the schema class using the parameter service
- final SchemaParameters schemaParameters = ParameterService.getParameters(SchemaParameters.class);
+ final SchemaParameters schemaParameters = ParameterService.get(ContextParameterConstants.SCHEMA_GROUP_NAME);
// Get the class for the schema helper from the schema parameters
final SchemaHelperParameters schemaHelperParameters =
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java
new file mode 100644
index 000000000..af712706d
--- /dev/null
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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.context.parameters;
+
+/**
+ * This class holds constants used when managing context parameter groups in apex.
+ */
+public abstract class ContextParameterConstants {
+ public static final String MAIN_GROUP_NAME = "CONTEXT_PARAMETERS";
+ public static final String SCHEMA_GROUP_NAME = "CONTEXT_SCHEMA_PARAMETERS";
+ public static final String SCHEMA_HELPER_GROUP_NAME = "CONTEXT_SCHEMA_HELPER_PARAMETERS";
+ public static final String DISTRIBUTOR_GROUP_NAME = "CONTEXT_DISTRIBUTOR_PARAMETERS";
+ public static final String LOCKING_GROUP_NAME = "CONTEXT_LOCKING_PARAMETERS";
+ public static final String PERSISTENCE_GROUP_NAME = "CONTEXT_PERSISTENCE_PARAMETERS";
+
+ /**
+ * Private default constructor to prevent subclassing
+ */
+ private ContextParameterConstants() {
+ // Prevents subclassing
+ }
+
+}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java
index 8bda76d21..2a109d48f 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java
@@ -20,8 +20,8 @@
package org.onap.policy.apex.context.parameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* Bean class to hold parameters for context handling in Apex. This class contains all the context
@@ -43,9 +43,10 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ContextParameters extends AbstractParameters {
+public class ContextParameters implements ParameterGroup {
// @formatter:off
// Plugin Parameters
+ private String name;
private DistributorParameters distributorParameters = new DistributorParameters();
private SchemaParameters schemaParameters = new SchemaParameters();
private LockManagerParameters lockManagerParameters = new LockManagerParameters();
@@ -57,8 +58,10 @@ public class ContextParameters extends AbstractParameters {
* parameter service.
*/
public ContextParameters() {
- super(ContextParameters.class.getCanonicalName());
- ParameterService.registerParameters(ContextParameters.class, this);
+ super();
+
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.MAIN_GROUP_NAME;
}
/**
@@ -132,16 +135,26 @@ public class ContextParameters extends AbstractParameters {
public void setPersistorParameters(final PersistorParameters persistorParameters) {
this.persistorParameters = persistorParameters;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
+
@Override
public String toString() {
- return "ContextParameters [distributorParameters=" + distributorParameters + ", schemaParameters="
- + schemaParameters + ", lockManagerParameters=" + lockManagerParameters + ", persistorParameters="
- + persistorParameters + "]";
+ return "ContextParameters [name=" + name + ", distributorParameters=" + distributorParameters
+ + ", schemaParameters=" + schemaParameters + ", lockManagerParameters=" + lockManagerParameters
+ + ", persistorParameters=" + persistorParameters + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
index cb4c6128e..e3f58cae4 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.context.parameters;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* An empty distributor parameter class that may be specialized by context distributor plugins that
@@ -31,11 +31,11 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class DistributorParameters extends AbstractParameters {
+public class DistributorParameters implements ParameterGroup {
/** The default distributor makes context albums available to all threads in a single JVM. */
public static final String DEFAULT_DISTRIBUTOR_PLUGIN_CLASS = JVMLocalDistributor.class.getCanonicalName();
- // Plugin class names
+ private String name;
private String pluginClass = DEFAULT_DISTRIBUTOR_PLUGIN_CLASS;
/**
@@ -43,18 +43,10 @@ public class DistributorParameters extends AbstractParameters {
* parameter service.
*/
public DistributorParameters() {
- super(DistributorParameters.class.getCanonicalName());
- ParameterService.registerParameters(DistributorParameters.class, this);
- }
-
- /**
- * Constructor to create a distributor parameters instance with the name of a sub class of this
- * class and register the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public DistributorParameters(final String parameterClassName) {
- super(parameterClassName);
+ super();
+
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.DISTRIBUTOR_GROUP_NAME;
}
/**
@@ -75,13 +67,23 @@ public class DistributorParameters extends AbstractParameters {
this.pluginClass = pluginClass;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
@Override
public String toString() {
- return "DistributorParameters [pluginClass=" + pluginClass + "]";
+ return "DistributorParameters [name=" + name + ", pluginClass=" + pluginClass + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
index 1aaee2cc7..27fc05a0b 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.context.parameters;
import org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* An empty lock manager parameter class that may be specialized by context lock manager plugins
@@ -31,13 +31,13 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class LockManagerParameters extends AbstractParameters {
+public class LockManagerParameters implements ParameterGroup {
/**
* The default lock manager can lock context album instance across all threads in a single JVM.
*/
public static final String DEFAULT_LOCK_MANAGER_PLUGIN_CLASS = JVMLocalLockManager.class.getCanonicalName();
- // Plugin class names
+ private String name;
private String pluginClass = DEFAULT_LOCK_MANAGER_PLUGIN_CLASS;
/**
@@ -45,18 +45,10 @@ public class LockManagerParameters extends AbstractParameters {
* parameter service.
*/
public LockManagerParameters() {
- super(LockManagerParameters.class.getCanonicalName());
- ParameterService.registerParameters(LockManagerParameters.class, this);
- }
+ super();
- /**
- * Constructor to create a lock manager parameters instance with the name of a sub class of this
- * class and register the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public LockManagerParameters(final String parameterClassName) {
- super(parameterClassName);
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.LOCKING_GROUP_NAME;
}
/**
@@ -76,14 +68,24 @@ public class LockManagerParameters extends AbstractParameters {
public void setPluginClass(final String pluginClass) {
this.pluginClass = pluginClass;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
+
@Override
public String toString() {
- return "LockManagerParameters [pluginClass=" + pluginClass + "]";
+ return "LockManagerParameters [name=" + name + ", pluginClass=" + pluginClass + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java
index 6fd320001..3616b526e 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java
@@ -20,8 +20,8 @@
package org.onap.policy.apex.context.parameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* A persistor parameter class that may be specialized by context persistor plugins that require
@@ -36,7 +36,7 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class PersistorParameters extends AbstractParameters {
+public class PersistorParameters implements ParameterGroup {
/** The default persistor is a dummy persistor that stubs the Persistor interface. */
public static final String DEFAULT_PERSISTOR_PLUGIN_CLASS =
"org.onap.policy.apex.context.impl.persistence.ephemeral.EphemeralPersistor";
@@ -44,7 +44,7 @@ public class PersistorParameters extends AbstractParameters {
/** Default periodic flushing interval, 5 minutes in milliseconds. */
public static final long DEFAULT_FLUSH_PERIOD = 300000;
- // Plugin class names
+ private String name;
private String pluginClass = DEFAULT_PERSISTOR_PLUGIN_CLASS;
// Parameters for flushing
@@ -55,18 +55,10 @@ public class PersistorParameters extends AbstractParameters {
* parameter service.
*/
public PersistorParameters() {
- super(PersistorParameters.class.getCanonicalName());
- ParameterService.registerParameters(PersistorParameters.class, this);
- }
+ super();
- /**
- * Constructor to create a persistor parameters instance with the name of a sub class of this
- * class and register the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public PersistorParameters(final String parameterClassName) {
- super(parameterClassName);
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.PERSISTENCE_GROUP_NAME;
}
/**
@@ -109,13 +101,24 @@ public class PersistorParameters extends AbstractParameters {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
@Override
public String toString() {
- return "PersistorParameters [pluginClass=" + pluginClass + ", flushPeriod=" + flushPeriod + "]";
+ return "PersistorParameters [name=" + name + ", pluginClass=" + pluginClass + ", flushPeriod=" + flushPeriod
+ + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java
index 9ccd431a5..e2bb4d6b9 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java
@@ -20,8 +20,8 @@
package org.onap.policy.apex.context.parameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* An empty schema helper parameter class that may be specialized by context schema helper plugins that require plugin
@@ -29,26 +29,15 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class SchemaHelperParameters extends AbstractParameters {
- // Schema helper plugin class for the schema
+public class SchemaHelperParameters implements ParameterGroup {
+ private String name;
private String schemaHelperPluginClass;
/**
* Constructor to create a schema helper parameters instance and register the instance with the parameter service.
*/
public SchemaHelperParameters() {
- super(SchemaHelperParameters.class.getCanonicalName());
- ParameterService.registerParameters(SchemaHelperParameters.class, this);
- }
-
- /**
- * Constructor to create a schema helper parameters instance with the name of a sub class of this class and register
- * the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public SchemaHelperParameters(final String parameterClassName) {
- super(parameterClassName);
+ super();
}
/**
@@ -68,14 +57,24 @@ public class SchemaHelperParameters extends AbstractParameters {
public void setSchemaHelperPluginClass(final String pluginClass) {
schemaHelperPluginClass = pluginClass;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
+
@Override
public String toString() {
- return "SchemaHelperParameters [schemaHelperPluginClass=" + schemaHelperPluginClass + "]";
+ return "SchemaHelperParameters [name=" + name + ", schemaHelperPluginClass=" + schemaHelperPluginClass + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java
index 12e203c30..9992b9f3c 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java
@@ -24,8 +24,8 @@ import java.util.Map;
import java.util.TreeMap;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* Bean class holding schema parameters for schemas and their helpers. As more than one schema can
@@ -38,10 +38,12 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class SchemaParameters extends AbstractParameters {
+public class SchemaParameters implements ParameterGroup {
/** The Java schema flavour is always available for use. */
public static final String DEFAULT_SCHEMA_FLAVOUR = "Java";
+ private String name;
+
// A map of parameters for executors of various logic types
private Map<String, SchemaHelperParameters> schemaHelperParameterMap;
@@ -50,8 +52,10 @@ public class SchemaParameters extends AbstractParameters {
* parameter service.
*/
public SchemaParameters() {
- super(SchemaParameters.class.getCanonicalName());
- ParameterService.registerParameters(SchemaParameters.class, this);
+ super();
+
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.SCHEMA_GROUP_NAME;
schemaHelperParameterMap = new TreeMap<>();
@@ -86,4 +90,19 @@ public class SchemaParameters extends AbstractParameters {
public SchemaHelperParameters getSchemaHelperParameters(final String schemaFlavour) {
return schemaHelperParameterMap.get(schemaFlavour);
}
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
}
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
index bf363058b..5f2b426bd 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
import java.util.LinkedHashMap;
import java.util.Map;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.apex.context.ContextAlbum;
@@ -35,6 +36,7 @@ import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.Distributor;
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.ApexRuntimeException;
@@ -42,10 +44,10 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
+import org.onap.policy.common.parameters.ParameterService;
public class ContextAlbumImplTest {
/**
@@ -56,11 +58,32 @@ public class ContextAlbumImplTest {
final ContextParameters contextParameters = new ContextParameters();
contextParameters.getLockManagerParameters()
.setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager");
- ParameterService.registerParameters(ContextParameters.class, 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());
final SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
- ParameterService.registerParameters(SchemaParameters.class, schemaParameters);
+
+ ParameterService.register(schemaParameters);
+ }
+
+ @AfterClass
+ public static void cleanUpAfterTest() {
+ ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.MAIN_GROUP_NAME);
+ ParameterService.clear();
}
@Test
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
index fed79e713..7bf836c3c 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
@@ -24,15 +24,18 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.apex.context.ContextRuntimeException;
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.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
+import org.onap.policy.common.parameters.ParameterService;
public class SchemaHelperFactoryTest {
private static AxContextSchema intSchema;
@@ -51,6 +54,11 @@ public class SchemaHelperFactoryTest {
badSchema = new AxContextSchema(new AxArtifactKey("IntSchema", "0.0.1"), "JAVA", "java.lang.Bad");
}
+ @AfterClass
+ public static void clearParameters() {
+ ParameterService.clear();
+ }
+
@Test
public void testSchemaHelperFactory() {
try {
@@ -76,15 +84,21 @@ public class SchemaHelperFactoryTest {
}
schemas.getSchemasMap().put(intSchema.getKey(), intSchema);
- new SchemaParameters();
+ SchemaParameters schemaParameters0 = new SchemaParameters();
+ schemaParameters0.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ ParameterService.register(schemaParameters0);
try {
new SchemaHelperFactory().createSchemaHelper(ownerKey, intSchema.getKey());
fail("this test should throw an exception");
} catch (ContextRuntimeException e) {
assertEquals("context schema helper parameters not found for context schema \"JAVA\"", e.getMessage());
}
+ ParameterService.deregister(schemaParameters0);
- new SchemaParameters().getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+ SchemaParameters schemaParameters1 = new SchemaParameters();
+ schemaParameters1.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ ParameterService.register(schemaParameters1);
+ schemaParameters1.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
assertNotNull(new SchemaHelperFactory().createSchemaHelper(ownerKey, intSchema.getKey()));
schemas.getSchemasMap().put(intSchema.getKey(), badSchema);
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
index 1ca3702e8..a71ba3675 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
@@ -23,16 +23,21 @@ package org.onap.policy.apex.context.impl.schema.java;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+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.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
+import org.onap.policy.common.parameters.ParameterService;
/**
* JavaSchemaHelperInstanceCreationTest.
@@ -50,9 +55,20 @@ public class JavaSchemaHelperInstanceCreationTest {
public void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters();
+
+ final SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
}
+ @AfterClass
+ public static void cleanUpAfterTest() {
+ ParameterService.clear();
+ }
+
+
@Test
public void testNullEncoding() {
final AxContextSchema javaBooleanSchema =
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();
-
}
}