Refactoring existing integration tests
Change-Id: I1aedd94d5197b8c6513fc701e9df2aab4edec088
Issue-ID: POLICY-865
Signed-off-by: waqas.ikram <waqas.ikram@ericsson.com>
diff --git a/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex
index 265f924..9f62eca 100644
--- a/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex
+++ b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex
@@ -82,7 +82,7 @@
schema create name=CustomBoolean_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem000",
+ "name" : "TestContextBooleanItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "flag", "type": "boolean"}
@@ -93,7 +93,7 @@
schema create name=CustomByte_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem001",
+ "name" : "TestContextByteItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "byteValue", "type": "int"}
@@ -104,7 +104,7 @@
schema create name=CustomInteger_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem002",
+ "name" : "TestContextIntItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "intValue", "type": "int"}
@@ -115,7 +115,7 @@
schema create name=CustomLong_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem003",
+ "name" : "TestContextLongItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "longValue", "type": "long"}
@@ -126,7 +126,7 @@
schema create name=CustomFloat_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem004",
+ "name" : "TestContextFloatItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "floatValue", "type": "float"}
@@ -137,7 +137,7 @@
schema create name=CustomDouble_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem005",
+ "name" : "TestContextDoubleItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "doubleValue", "type": "double"}
@@ -148,7 +148,7 @@
schema create name=CustomString_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem006",
+ "name" : "TestContextStringItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "stringValue", "type": "string"}
@@ -159,7 +159,7 @@
schema create name=CustomALong_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem007",
+ "name" : "TestContextLongObjectItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "longValue", "type": "long"}
@@ -170,7 +170,7 @@
schema create name=CustomDate0_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem008",
+ "name" : "TestContextDateItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "time" , "type": "long"},
@@ -188,7 +188,7 @@
schema create name=CustomDate1_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem009",
+ "name" : "TestContextDateTzItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "dateValue" , "type": {
@@ -216,12 +216,12 @@
schema create name=CustomDate2_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem00A",
+ "name" : "TestContextDateLocaleItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "dateValue" , "type": {
"type" : "record",
- "name" : "TestContextItem008",
+ "name" : "TestContextDateItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "time" , "type": "long"},
@@ -247,7 +247,7 @@
schema create name=CustomSet_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem00B",
+ "name" : "TestContextTreeSetItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "setValue", "type": {
@@ -261,7 +261,7 @@
schema create name=CustomMap_type flavour=Avro schema=LS
{
"type" : "record",
- "name" : "TestContextItem00C",
+ "name" : "TestContextTreeMapItem",
"namespace" : "org.onap.policy.apex.context.test.avro.concepts",
"fields" : [
{"name": "mapValue", "type": {
diff --git a/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex
index 8d17116..e978f15 100644
--- a/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex
+++ b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex
@@ -28,19 +28,19 @@
schema create name=JavaFloat_type flavour=Java schema=java.lang.Float
schema create name=JavaDouble_type flavour=Java schema=java.lang.Double
schema create name=JavaString_type flavour=Java schema=java.lang.String
-schema create name=CustomBoolean_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem000
-schema create name=CustomByte_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem001
-schema create name=CustomInteger_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem002
-schema create name=CustomLong_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem003
-schema create name=CustomFloat_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem004
-schema create name=CustomDouble_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem005
-schema create name=CustomString_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem006
-schema create name=CustomJLong_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem007
-schema create name=CustomDate0_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem008
-schema create name=CustomDate1_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem009
-schema create name=CustomDate2_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem00A
-schema create name=CustomSet_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem00B
-schema create name=CustomMap_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem00C
+schema create name=CustomBoolean_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextBooleanItem
+schema create name=CustomByte_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextByteItem
+schema create name=CustomInteger_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextIntItem
+schema create name=CustomLong_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextLongItem
+schema create name=CustomFloat_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextFloatItem
+schema create name=CustomDouble_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextDoubleItem
+schema create name=CustomString_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextStringItem
+schema create name=CustomJLong_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextLongObjectItem
+schema create name=CustomDate0_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextDateItem
+schema create name=CustomDate1_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextDateTzItem
+schema create name=CustomDate2_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem
+schema create name=CustomSet_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextTreeSetItem
+schema create name=CustomMap_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem
event create name=Test_InputEvent nameSpace=org.onap.policy.apex.test source=External target=Apex
@@ -247,14 +247,14 @@
customString .setStringValue(customString .getStringValue() + " added to end of string");
customJLong .setLongValue (customJLong .getLongValue() + 1);
-customDate0Type = Java.type("org.onap.policy.apex.context.test.concepts.TestContextItem008");
+customDate0Type = Java.type("org.onap.policy.apex.context.test.concepts.TestContextDateItem");
customDate0 = new customDate0Type(1499868391);
-customDate1Type = Java.type("org.onap.policy.apex.context.test.concepts.TestContextItem009");
+customDate1Type = Java.type("org.onap.policy.apex.context.test.concepts.TestContextDateTzItem");
customDate1 = new customDate1Type();
customDate1.setDateValue(customDate0);
-customDate2Type = Java.type("org.onap.policy.apex.context.test.concepts.TestContextItem00A");
+customDate2Type = Java.type("org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem");
customDate2 = new customDate2Type();
customDate2.setDateValue(customDate0);
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorEventsContext.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorEventsContext.java
index 6e489ad..bd75ddf 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorEventsContext.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorEventsContext.java
@@ -84,8 +84,8 @@
final int logCharCount = logString.replaceAll(SPACES, EMPTY_STRING).length();
final int modelCharCount = modelString.replaceAll(SPACES, EMPTY_STRING).length();
- assertEquals(25911, logCharCount);
- assertEquals(46138, modelCharCount);
+ assertEquals(25962, logCharCount);
+ assertEquals(46189, modelCharCount);
}
/**
@@ -114,8 +114,8 @@
final int logCharCount = logString.replaceAll(SPACES, EMPTY_STRING).length();
final int modelCharCount = modelString.replaceAll(SPACES, EMPTY_STRING).length();
- assertEquals(30366, logCharCount);
- assertEquals(52981, modelCharCount);
+ assertEquals(30407, logCharCount);
+ assertEquals(53022, modelCharCount);
}
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 147e4eb..cb4c612 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
@@ -20,25 +20,27 @@
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;
/**
- * An empty distributor parameter class that may be specialized by context distributor plugins that require plugin
- * specific parameters. The class defines the default distributor plugin as the JVM local distributor.
+ * An empty distributor parameter class that may be specialized by context distributor plugins that
+ * require plugin specific parameters. The class defines the default distributor plugin as the JVM
+ * local distributor.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class DistributorParameters extends AbstractParameters {
/** The default distributor makes context albums available to all threads in a single JVM. */
- public static final String DEFAULT_DISTRIBUTOR_PLUGIN_CLASS =
- "org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor";
+ public static final String DEFAULT_DISTRIBUTOR_PLUGIN_CLASS = JVMLocalDistributor.class.getCanonicalName();
// Plugin class names
private String pluginClass = DEFAULT_DISTRIBUTOR_PLUGIN_CLASS;
/**
- * Constructor to create a distributor parameters instance and register the instance with the parameter service.
+ * Constructor to create a distributor parameters instance and register the instance with the
+ * parameter service.
*/
public DistributorParameters() {
super(DistributorParameters.class.getCanonicalName());
@@ -46,8 +48,8 @@
}
/**
- * 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.
+ * 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
*/
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 93e4223..1aaee2c 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
@@ -20,25 +20,29 @@
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;
/**
- * An empty lock manager parameter class that may be specialized by context lock manager plugins that require plugin
- * specific parameters. The class defines the default lock manager plugin as the JVM local lock manager.
+ * An empty lock manager parameter class that may be specialized by context lock manager plugins
+ * that require plugin specific parameters. The class defines the default lock manager plugin as the
+ * JVM local lock manager.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class LockManagerParameters extends AbstractParameters {
- /** 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 =
- "org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager";
+ /**
+ * 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 pluginClass = DEFAULT_LOCK_MANAGER_PLUGIN_CLASS;
/**
- * Constructor to create a lock manager parameters instance and register the instance with the parameter service.
+ * Constructor to create a lock manager parameters instance and register the instance with the
+ * parameter service.
*/
public LockManagerParameters() {
super(LockManagerParameters.class.getCanonicalName());
@@ -46,8 +50,8 @@
}
/**
- * 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.
+ * 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
*/
diff --git a/context/context-test/pom.xml b/context/context-test-utils/pom.xml
similarity index 86%
rename from context/context-test/pom.xml
rename to context/context-test-utils/pom.xml
index ded707a..dc8ec6e 100644
--- a/context/context-test/pom.xml
+++ b/context/context-test-utils/pom.xml
@@ -26,9 +26,9 @@
<version>2.0.0-SNAPSHOT</version>
</parent>
- <artifactId>context-test</artifactId>
+ <artifactId>context-test-utils</artifactId>
<name>${project.artifactId}</name>
- <description>[${project.parent.artifactId}] module to hold test context date for testing</description>
+ <description>[${project.parent.artifactId}] module contain default distributor tests and common test utils</description>
<dependencies>
<dependency>
@@ -51,5 +51,10 @@
<version>${version.derby}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem000.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java
similarity index 91%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem000.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java
index 49e5278..7f019f5 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem000.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java
@@ -25,7 +25,7 @@
/**
* The Class TestContextItem000.
*/
-public class TestContextItem000 implements Serializable {
+public class TestContextBooleanItem implements Serializable {
private static final int HASH_PRIME_1 = 31;
private static final int HASH_PRIME_2 = 1231;
private static final int HASH_PRIME_3 = 1237;
@@ -37,14 +37,14 @@
/**
* The Constructor.
*/
- public TestContextItem000() {}
+ public TestContextBooleanItem() {}
/**
* The Constructor.
*
* @param flag the flag
*/
- public TestContextItem000(final Boolean flag) {
+ public TestContextBooleanItem(final Boolean flag) {
this.flag = flag;
}
@@ -95,7 +95,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem000 other = (TestContextItem000) obj;
+ final TestContextBooleanItem other = (TestContextBooleanItem) obj;
if (flag != other.flag) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem001.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java
similarity index 91%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem001.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java
index 5d41269..2b107b4 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem001.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java
@@ -25,7 +25,7 @@
/**
* The Class TestContextItem001.
*/
-public class TestContextItem001 implements Serializable {
+public class TestContextByteItem implements Serializable {
private static final long serialVersionUID = 1361938145823720386L;
private static final int HASH_PRIME_1 = 31;
@@ -35,14 +35,14 @@
/**
* The Constructor.
*/
- public TestContextItem001() {}
+ public TestContextByteItem() {}
/**
* The Constructor.
*
* @param byteValue the byte value
*/
- public TestContextItem001(final Byte byteValue) {
+ public TestContextByteItem(final Byte byteValue) {
this.byteValue = byteValue;
}
@@ -93,7 +93,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem001 other = (TestContextItem001) obj;
+ final TestContextByteItem other = (TestContextByteItem) obj;
if (byteValue != other.byteValue) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem008.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java
similarity index 94%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem008.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java
index 82a02a8..f7c8490 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem008.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java
@@ -28,7 +28,7 @@
/**
* The Class TestContextItem008.
*/
-public class TestContextItem008 implements Serializable {
+public class TestContextDateItem implements Serializable {
private static final long serialVersionUID = -6984963129968805460L;
private static final int HASH_PRIME_1 = 31;
@@ -47,7 +47,7 @@
/**
* The Constructor.
*/
- public TestContextItem008() {
+ public TestContextDateItem() {
this(new Date(System.currentTimeMillis()));
}
@@ -56,7 +56,7 @@
*
* @param dateValue the date value
*/
- public TestContextItem008(final Date dateValue) {
+ public TestContextDateItem(final Date dateValue) {
setDateValue(dateValue.getTime());
}
@@ -65,7 +65,7 @@
*
* @param time the time
*/
- public TestContextItem008(final long time) {
+ public TestContextDateItem(final long time) {
setDateValue(time);
}
@@ -217,7 +217,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem008 other = (TestContextItem008) obj;
+ final TestContextDateItem other = (TestContextDateItem) obj;
if (day != other.day) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00A.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java
similarity index 91%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00A.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java
index db380cc..0c94bcb 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00A.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java
@@ -27,14 +27,14 @@
/**
* The Class TestContextItem00A.
*/
-public class TestContextItem00A implements Serializable {
+public class TestContextDateLocaleItem implements Serializable {
private static final long serialVersionUID = -6579903685538233754L;
private static final int HASH_PRIME_1 = 31;
private static final int HASH_PRIME_2 = 1231;
private static final int HASH_PRIME_3 = 1237;
- private TestContextItem008 dateValue = new TestContextItem008(System.currentTimeMillis());
+ private TestContextDateItem dateValue = new TestContextDateItem(System.currentTimeMillis());
private String timeZoneString = TimeZone.getTimeZone("Europe/Dublin").getDisplayName();
private boolean dst = false;
private int utcOffset = 0;
@@ -44,7 +44,7 @@
/**
* The Constructor.
*/
- public TestContextItem00A() {}
+ public TestContextDateLocaleItem() {}
/**
* The Constructor.
@@ -56,7 +56,7 @@
* @param language the language
* @param country the country
*/
- public TestContextItem00A(final TestContextItem008 dateValue, final String tzValue, final boolean dst,
+ public TestContextDateLocaleItem(final TestContextDateItem dateValue, final String tzValue, final boolean dst,
final int utcOffset, final String language, final String country) {
this.dateValue = dateValue;
this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName();
@@ -73,7 +73,7 @@
*
* @param original the original
*/
- public TestContextItem00A(final TestContextItem00A original) {
+ public TestContextDateLocaleItem(final TestContextDateLocaleItem original) {
this.dateValue = original.dateValue;
this.timeZoneString = TimeZone.getTimeZone(original.timeZoneString).getDisplayName();
this.dst = original.dst;
@@ -89,7 +89,7 @@
*
* @return the date value
*/
- public TestContextItem008 getDateValue() {
+ public TestContextDateItem getDateValue() {
return dateValue;
}
@@ -98,7 +98,7 @@
*
* @param dateValue the date value
*/
- public void setDateValue(final TestContextItem008 dateValue) {
+ public void setDateValue(final TestContextDateItem dateValue) {
this.dateValue = dateValue;
}
@@ -209,7 +209,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem00A other = (TestContextItem00A) obj;
+ final TestContextDateLocaleItem other = (TestContextDateLocaleItem) obj;
if (dateValue == null) {
if (other.dateValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem009.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java
similarity index 88%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem009.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java
index f3e8953..7d3ed80 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem009.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java
@@ -26,21 +26,21 @@
/**
* The Class TestContextItem009.
*/
-public class TestContextItem009 implements Serializable {
+public class TestContextDateTzItem implements Serializable {
private static final long serialVersionUID = 5604426823170331706L;
private static final int HASH_PRIME_1 = 31;
private static final int HASH_PRIME_2 = 1231;
private static final int HASH_PRIME_3 = 1237;
- private TestContextItem008 dateValue = new TestContextItem008(System.currentTimeMillis());
+ private TestContextDateItem dateValue = new TestContextDateItem(System.currentTimeMillis());
private String timeZoneString = TimeZone.getTimeZone("Europe/Dublin").getDisplayName();
private boolean dst = false;
/**
* The Constructor.
*/
- public TestContextItem009() {
+ public TestContextDateTzItem() {
dst = true;
}
@@ -51,7 +51,7 @@
* @param tzValue the tz value
* @param dst the dst
*/
- public TestContextItem009(final TestContextItem008 dateValue, final String tzValue, final boolean dst) {
+ public TestContextDateTzItem(final TestContextDateItem dateValue, final String tzValue, final boolean dst) {
this.dateValue = dateValue;
this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName();
this.dst = dst;
@@ -62,7 +62,7 @@
*
* @param original the original
*/
- public TestContextItem009(final TestContextItem009 original) {
+ public TestContextDateTzItem(final TestContextDateTzItem original) {
this.dateValue = original.dateValue;
this.timeZoneString = original.timeZoneString;
this.dst = original.dst;
@@ -73,7 +73,7 @@
*
* @return the date value
*/
- public TestContextItem008 getDateValue() {
+ public TestContextDateItem getDateValue() {
return dateValue;
}
@@ -82,7 +82,7 @@
*
* @param dateValue the date value
*/
- public void setDateValue(final TestContextItem008 dateValue) {
+ public void setDateValue(final TestContextDateItem dateValue) {
this.dateValue = dateValue;
}
@@ -153,7 +153,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem009 other = (TestContextItem009) obj;
+ final TestContextDateTzItem other = (TestContextDateTzItem) obj;
if (dateValue == null) {
if (other.dateValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem005.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java
similarity index 91%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem005.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java
index d8a3352..ac4f506 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem005.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java
@@ -25,7 +25,7 @@
/**
* The Class TestContextItem005.
*/
-public class TestContextItem005 implements Serializable {
+public class TestContextDoubleItem implements Serializable {
private static final long serialVersionUID = -2958758261076734821L;
private static final int HASH_PRIME_1 = 31;
@@ -36,14 +36,14 @@
/**
* The Constructor.
*/
- public TestContextItem005() {}
+ public TestContextDoubleItem() {}
/**
* The Constructor.
*
* @param doubleValue the double value
*/
- public TestContextItem005(final Double doubleValue) {
+ public TestContextDoubleItem(final Double doubleValue) {
this.doubleValue = doubleValue;
}
@@ -96,7 +96,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem005 other = (TestContextItem005) obj;
+ final TestContextDoubleItem other = (TestContextDoubleItem) obj;
if (Double.doubleToLongBits(doubleValue) != Double.doubleToLongBits(other.doubleValue)) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem004.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java
similarity index 91%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem004.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java
index 1370db1..cd81652 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem004.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java
@@ -25,7 +25,7 @@
/**
* The Class TestContextItem004.
*/
-public class TestContextItem004 implements Serializable {
+public class TestContextFloatItem implements Serializable {
private static final long serialVersionUID = -3359180576903272400L;
private static final int HASH_PRIME_1 = 31;
@@ -35,14 +35,14 @@
/**
* The Constructor.
*/
- public TestContextItem004() {}
+ public TestContextFloatItem() {}
/**
* The Constructor.
*
* @param floatValue the float value
*/
- public TestContextItem004(final Float floatValue) {
+ public TestContextFloatItem(final Float floatValue) {
this.floatValue = floatValue;
}
@@ -93,7 +93,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem004 other = (TestContextItem004) obj;
+ final TestContextFloatItem other = (TestContextFloatItem) obj;
if (Float.floatToIntBits(floatValue) != Float.floatToIntBits(other.floatValue)) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem002.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java
similarity index 90%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem002.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java
index 3b5242f..8983027 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem002.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java
@@ -25,7 +25,7 @@
/**
* The Class TestContextItem002.
*/
-public class TestContextItem002 implements Serializable {
+public class TestContextIntItem implements Serializable {
private static final long serialVersionUID = -8978435658277900984L;
private static final int HASH_PRIME_1 = 31;
@@ -35,14 +35,14 @@
/**
* The Constructor.
*/
- public TestContextItem002() {}
+ public TestContextIntItem() {}
/**
* The Constructor.
*
* @param intValue the int value
*/
- public TestContextItem002(final Integer intValue) {
+ public TestContextIntItem(final Integer intValue) {
this.intValue = intValue;
}
@@ -51,7 +51,7 @@
*
* @param original the original
*/
- public TestContextItem002(final TestContextItem002 original) {
+ public TestContextIntItem(final TestContextIntItem original) {
this.intValue = original.intValue;
}
@@ -102,7 +102,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem002 other = (TestContextItem002) obj;
+ final TestContextIntItem other = (TestContextIntItem) obj;
if (intValue != other.intValue) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem003.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java
similarity index 91%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem003.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java
index e7532ec..be3ee60 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem003.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java
@@ -25,7 +25,7 @@
/**
* The Class TestContextItem003.
*/
-public class TestContextItem003 implements Serializable {
+public class TestContextLongItem implements Serializable {
private static final long serialVersionUID = 3599267534512489386L;
private static final int HASH_PRIME_1 = 31;
@@ -36,14 +36,14 @@
/**
* The Constructor.
*/
- public TestContextItem003() {}
+ public TestContextLongItem() {}
/**
* The Constructor.
*
* @param longValue the long value
*/
- public TestContextItem003(final Long longValue) {
+ public TestContextLongItem(final Long longValue) {
this.longValue = longValue;
}
@@ -94,7 +94,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem003 other = (TestContextItem003) obj;
+ final TestContextLongItem other = (TestContextLongItem) obj;
if (longValue != other.longValue) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem007.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java
similarity index 91%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem007.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java
index 21c6f8c..215868d 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem007.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java
@@ -25,7 +25,7 @@
/**
* The Class TestContextItem007.
*/
-public class TestContextItem007 implements Serializable {
+public class TestContextLongObjectItem implements Serializable {
private static final long serialVersionUID = -1029406737866392421L;
private static final int HASH_PRIME_1 = 31;
@@ -35,14 +35,14 @@
/**
* The Constructor.
*/
- public TestContextItem007() {}
+ public TestContextLongObjectItem() {}
/**
* The Constructor.
*
* @param longValue the long value
*/
- public TestContextItem007(final Long longValue) {
+ public TestContextLongObjectItem(final Long longValue) {
this.longValue = longValue;
}
@@ -93,7 +93,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem007 other = (TestContextItem007) obj;
+ final TestContextLongObjectItem other = (TestContextLongObjectItem) obj;
if (longValue == null) {
if (other.longValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem006.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java
similarity index 91%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem006.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java
index 5fd2f9d..6c9fcb4 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem006.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java
@@ -25,7 +25,7 @@
/**
* The Class TestContextItem006.
*/
-public class TestContextItem006 implements Serializable {
+public class TestContextStringItem implements Serializable {
private static final long serialVersionUID = -1074772190611125121L;
private static final int HASH_PRIME_1 = 31;
@@ -35,14 +35,14 @@
/**
* The Constructor.
*/
- public TestContextItem006() {}
+ public TestContextStringItem() {}
/**
* The Constructor.
*
* @param stringValue the string value
*/
- public TestContextItem006(final String stringValue) {
+ public TestContextStringItem(final String stringValue) {
this.stringValue = stringValue;
}
@@ -93,7 +93,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem006 other = (TestContextItem006) obj;
+ final TestContextStringItem other = (TestContextStringItem) obj;
if (stringValue == null) {
if (other.stringValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00C.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java
similarity index 91%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00C.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java
index 6c91297..eed0c1a 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00C.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java
@@ -27,7 +27,7 @@
/**
* The Class TestContextItem00C.
*/
-public class TestContextItem00C implements Serializable {
+public class TestContextTreeMapItem implements Serializable {
private static final long serialVersionUID = -7497746259264651884L;
private static final int HASH_PRIME_1 = 31;
@@ -37,14 +37,14 @@
/**
* The Constructor.
*/
- public TestContextItem00C() {}
+ public TestContextTreeMapItem() {}
/**
* The Constructor.
*
* @param mapValue the map value
*/
- public TestContextItem00C(final Map<String, String> mapValue) {
+ public TestContextTreeMapItem(final Map<String, String> mapValue) {
this.mapValue = mapValue;
}
@@ -98,7 +98,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem00C other = (TestContextItem00C) obj;
+ final TestContextTreeMapItem other = (TestContextTreeMapItem) obj;
if (mapValue == null) {
if (other.mapValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00B.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java
similarity index 90%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00B.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java
index 4990b1b..fe47c1a 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00B.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java
@@ -27,7 +27,7 @@
/**
* The Class TestContextItem00B.
*/
-public class TestContextItem00B implements Serializable {
+public class TestContextTreeSetItem implements Serializable {
private static final long serialVersionUID = 1254589722957250388L;
private static final int HASH_PRIME_1 = 31;
@@ -37,21 +37,21 @@
/**
* The Constructor.
*/
- public TestContextItem00B() {}
+ public TestContextTreeSetItem() {}
/**
* The Constructor.
*
* @param setArray the set array
*/
- public TestContextItem00B(final String[] setArray) {}
+ public TestContextTreeSetItem(final String[] setArray) {}
/**
* The Constructor.
*
* @param setValue the set value
*/
- public TestContextItem00B(final TreeSet<String> setValue) {
+ public TestContextTreeSetItem(final TreeSet<String> setValue) {
this.setValue = setValue;
}
@@ -105,7 +105,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem00B other = (TestContextItem00B) obj;
+ final TestContextTreeSetItem other = (TestContextTreeSetItem) obj;
if (setValue == null) {
if (other.setValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java
similarity index 81%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java
index 11a1af1..5c63c2e 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java
@@ -30,26 +30,26 @@
private static final int HASH_PRIME_1 = 31;
- private TestContextItem000 testExternalContextItem000;
- private TestContextItem001 testExternalContextItem001;
- private TestContextItem002 testExternalContextItem002;
- private TestContextItem003 testExternalContextItem003;
- private TestContextItem004 testExternalContextItem004;
- private TestContextItem005 testExternalContextItem005;
- private TestContextItem006 testExternalContextItem006;
- private TestContextItem007 testExternalContextItem007;
- private TestContextItem008 testExternalContextItem008;
- private TestContextItem009 testExternalContextItem009;
- private TestContextItem00A testExternalContextItem00A;
- private TestContextItem00B testExternalContextItem00B;
- private TestContextItem00C testExternalContextItem00C;
+ private TestContextBooleanItem testExternalContextItem000;
+ private TestContextByteItem testExternalContextItem001;
+ private TestContextIntItem testExternalContextItem002;
+ private TestContextLongItem testExternalContextItem003;
+ private TestContextFloatItem testExternalContextItem004;
+ private TestContextDoubleItem testExternalContextItem005;
+ private TestContextStringItem testExternalContextItem006;
+ private TestContextLongObjectItem testExternalContextItem007;
+ private TestContextDateItem testExternalContextItem008;
+ private TestContextDateTzItem testExternalContextItem009;
+ private TestContextDateLocaleItem testExternalContextItem00A;
+ private TestContextTreeSetItem testExternalContextItem00B;
+ private TestContextTreeMapItem testExternalContextItem00C;
/**
* Gets the test external context item 000.
*
* @return the test external context item 000
*/
- public TestContextItem000 getTestExternalContextItem000() {
+ public TestContextBooleanItem getTestExternalContextItem000() {
return testExternalContextItem000;
}
@@ -58,7 +58,7 @@
*
* @param testExternalContextItem000 the test external context item 000
*/
- public void setTestExternalContextItem000(final TestContextItem000 testExternalContextItem000) {
+ public void setTestExternalContextItem000(final TestContextBooleanItem testExternalContextItem000) {
this.testExternalContextItem000 = testExternalContextItem000;
}
@@ -67,7 +67,7 @@
*
* @return the test external context item 001
*/
- public TestContextItem001 getTestExternalContextItem001() {
+ public TestContextByteItem getTestExternalContextItem001() {
return testExternalContextItem001;
}
@@ -76,7 +76,7 @@
*
* @param testExternalContextItem001 the test external context item 001
*/
- public void setTestExternalContextItem001(final TestContextItem001 testExternalContextItem001) {
+ public void setTestExternalContextItem001(final TestContextByteItem testExternalContextItem001) {
this.testExternalContextItem001 = testExternalContextItem001;
}
@@ -85,7 +85,7 @@
*
* @return the test external context item 002
*/
- public TestContextItem002 getTestExternalContextItem002() {
+ public TestContextIntItem getTestExternalContextItem002() {
return testExternalContextItem002;
}
@@ -94,7 +94,7 @@
*
* @param testExternalContextItem002 the test external context item 002
*/
- public void setTestExternalContextItem002(final TestContextItem002 testExternalContextItem002) {
+ public void setTestExternalContextItem002(final TestContextIntItem testExternalContextItem002) {
this.testExternalContextItem002 = testExternalContextItem002;
}
@@ -103,7 +103,7 @@
*
* @return the test external context item 003
*/
- public TestContextItem003 getTestExternalContextItem003() {
+ public TestContextLongItem getTestExternalContextItem003() {
return testExternalContextItem003;
}
@@ -112,7 +112,7 @@
*
* @param testExternalContextItem003 the test external context item 003
*/
- public void setTestExternalContextItem003(final TestContextItem003 testExternalContextItem003) {
+ public void setTestExternalContextItem003(final TestContextLongItem testExternalContextItem003) {
this.testExternalContextItem003 = testExternalContextItem003;
}
@@ -121,7 +121,7 @@
*
* @return the test external context item 004
*/
- public TestContextItem004 getTestExternalContextItem004() {
+ public TestContextFloatItem getTestExternalContextItem004() {
return testExternalContextItem004;
}
@@ -130,7 +130,7 @@
*
* @param testExternalContextItem004 the test external context item 004
*/
- public void setTestExternalContextItem004(final TestContextItem004 testExternalContextItem004) {
+ public void setTestExternalContextItem004(final TestContextFloatItem testExternalContextItem004) {
this.testExternalContextItem004 = testExternalContextItem004;
}
@@ -139,7 +139,7 @@
*
* @return the test external context item 005
*/
- public TestContextItem005 getTestExternalContextItem005() {
+ public TestContextDoubleItem getTestExternalContextItem005() {
return testExternalContextItem005;
}
@@ -148,7 +148,7 @@
*
* @param testExternalContextItem005 the test external context item 005
*/
- public void setTestExternalContextItem005(final TestContextItem005 testExternalContextItem005) {
+ public void setTestExternalContextItem005(final TestContextDoubleItem testExternalContextItem005) {
this.testExternalContextItem005 = testExternalContextItem005;
}
@@ -157,7 +157,7 @@
*
* @return the test external context item 006
*/
- public TestContextItem006 getTestExternalContextItem006() {
+ public TestContextStringItem getTestExternalContextItem006() {
return testExternalContextItem006;
}
@@ -166,7 +166,7 @@
*
* @param testExternalContextItem006 the test external context item 006
*/
- public void setTestExternalContextItem006(final TestContextItem006 testExternalContextItem006) {
+ public void setTestExternalContextItem006(final TestContextStringItem testExternalContextItem006) {
this.testExternalContextItem006 = testExternalContextItem006;
}
@@ -175,7 +175,7 @@
*
* @return the test external context item 007
*/
- public TestContextItem007 getTestExternalContextItem007() {
+ public TestContextLongObjectItem getTestExternalContextItem007() {
return testExternalContextItem007;
}
@@ -184,7 +184,7 @@
*
* @param testExternalContextItem007 the test external context item 007
*/
- public void setTestExternalContextItem007(final TestContextItem007 testExternalContextItem007) {
+ public void setTestExternalContextItem007(final TestContextLongObjectItem testExternalContextItem007) {
this.testExternalContextItem007 = testExternalContextItem007;
}
@@ -193,7 +193,7 @@
*
* @return the test external context item 008
*/
- public TestContextItem008 getTestExternalContextItem008() {
+ public TestContextDateItem getTestExternalContextItem008() {
return testExternalContextItem008;
}
@@ -202,7 +202,7 @@
*
* @param testExternalContextItem008 the test external context item 008
*/
- public void setTestExternalContextItem008(final TestContextItem008 testExternalContextItem008) {
+ public void setTestExternalContextItem008(final TestContextDateItem testExternalContextItem008) {
this.testExternalContextItem008 = testExternalContextItem008;
}
@@ -211,7 +211,7 @@
*
* @return the test external context item 009
*/
- public TestContextItem009 getTestExternalContextItem009() {
+ public TestContextDateTzItem getTestExternalContextItem009() {
return testExternalContextItem009;
}
@@ -220,7 +220,7 @@
*
* @param testExternalContextItem009 the test external context item 009
*/
- public void setTestExternalContextItem009(final TestContextItem009 testExternalContextItem009) {
+ public void setTestExternalContextItem009(final TestContextDateTzItem testExternalContextItem009) {
this.testExternalContextItem009 = testExternalContextItem009;
}
@@ -229,7 +229,7 @@
*
* @return the test external context item 00 A
*/
- public TestContextItem00A getTestExternalContextItem00A() {
+ public TestContextDateLocaleItem getTestExternalContextItem00A() {
return testExternalContextItem00A;
}
@@ -238,7 +238,7 @@
*
* @param testExternalContextItem00A the test external context item 00 A
*/
- public void setTestExternalContextItem00A(final TestContextItem00A testExternalContextItem00A) {
+ public void setTestExternalContextItem00A(final TestContextDateLocaleItem testExternalContextItem00A) {
this.testExternalContextItem00A = testExternalContextItem00A;
}
@@ -247,7 +247,7 @@
*
* @return the test external context item 00 B
*/
- public TestContextItem00B getTestExternalContextItem00B() {
+ public TestContextTreeSetItem getTestExternalContextItem00B() {
return testExternalContextItem00B;
}
@@ -256,7 +256,7 @@
*
* @param testExternalContextItem00B the test external context item 00 B
*/
- public void setTestExternalContextItem00B(final TestContextItem00B testExternalContextItem00B) {
+ public void setTestExternalContextItem00B(final TestContextTreeSetItem testExternalContextItem00B) {
this.testExternalContextItem00B = testExternalContextItem00B;
}
@@ -265,7 +265,7 @@
*
* @return the test external context item 00 C
*/
- public TestContextItem00C getTestExternalContextItem00C() {
+ public TestContextTreeMapItem getTestExternalContextItem00C() {
return testExternalContextItem00C;
}
@@ -274,7 +274,7 @@
*
* @param testExternalContextItem00C the test external context item 00 C
*/
- public void setTestExternalContextItem00C(final TestContextItem00C testExternalContextItem00C) {
+ public void setTestExternalContextItem00C(final TestContextTreeMapItem testExternalContextItem00C) {
this.testExternalContextItem00C = testExternalContextItem00C;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java
similarity index 81%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java
index 2e893d9..9953a1a 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java
@@ -30,26 +30,26 @@
private static final int HASH_PRIME_1 = 31;
- private TestContextItem000 testGlobalContextItem000;
- private TestContextItem001 testGlobalContextItem001;
- private TestContextItem002 testGlobalContextItem002;
- private TestContextItem003 testGlobalContextItem003;
- private TestContextItem004 testGlobalContextItem004;
- private TestContextItem005 testGlobalContextItem005;
- private TestContextItem006 testGlobalContextItem006;
- private TestContextItem007 testGlobalContextItem007;
- private TestContextItem008 testGlobalContextItem008;
- private TestContextItem009 testGlobalContextItem009;
- private TestContextItem00A testGlobalContextItem00A;
- private TestContextItem00B testGlobalContextItem00B;
- private TestContextItem00C testGlobalContextItem00C;
+ private TestContextBooleanItem testGlobalContextItem000;
+ private TestContextByteItem testGlobalContextItem001;
+ private TestContextIntItem testGlobalContextItem002;
+ private TestContextLongItem testGlobalContextItem003;
+ private TestContextFloatItem testGlobalContextItem004;
+ private TestContextDoubleItem testGlobalContextItem005;
+ private TestContextStringItem testGlobalContextItem006;
+ private TestContextLongObjectItem testGlobalContextItem007;
+ private TestContextDateItem testGlobalContextItem008;
+ private TestContextDateTzItem testGlobalContextItem009;
+ private TestContextDateLocaleItem testGlobalContextItem00A;
+ private TestContextTreeSetItem testGlobalContextItem00B;
+ private TestContextTreeMapItem testGlobalContextItem00C;
/**
* Gets the test global context item 000.
*
* @return the test global context item 000
*/
- public TestContextItem000 getTestGlobalContextItem000() {
+ public TestContextBooleanItem getTestGlobalContextItem000() {
return testGlobalContextItem000;
}
@@ -58,7 +58,7 @@
*
* @param testGlobalContextItem000 the test global context item 000
*/
- public void setTestGlobalContextItem000(final TestContextItem000 testGlobalContextItem000) {
+ public void setTestGlobalContextItem000(final TestContextBooleanItem testGlobalContextItem000) {
this.testGlobalContextItem000 = testGlobalContextItem000;
}
@@ -67,7 +67,7 @@
*
* @return the test global context item 001
*/
- public TestContextItem001 getTestGlobalContextItem001() {
+ public TestContextByteItem getTestGlobalContextItem001() {
return testGlobalContextItem001;
}
@@ -76,7 +76,7 @@
*
* @param testGlobalContextItem001 the test global context item 001
*/
- public void setTestGlobalContextItem001(final TestContextItem001 testGlobalContextItem001) {
+ public void setTestGlobalContextItem001(final TestContextByteItem testGlobalContextItem001) {
this.testGlobalContextItem001 = testGlobalContextItem001;
}
@@ -85,7 +85,7 @@
*
* @return the test global context item 002
*/
- public TestContextItem002 getTestGlobalContextItem002() {
+ public TestContextIntItem getTestGlobalContextItem002() {
return testGlobalContextItem002;
}
@@ -94,7 +94,7 @@
*
* @param testGlobalContextItem002 the test global context item 002
*/
- public void setTestGlobalContextItem002(final TestContextItem002 testGlobalContextItem002) {
+ public void setTestGlobalContextItem002(final TestContextIntItem testGlobalContextItem002) {
this.testGlobalContextItem002 = testGlobalContextItem002;
}
@@ -103,7 +103,7 @@
*
* @return the test global context item 003
*/
- public TestContextItem003 getTestGlobalContextItem003() {
+ public TestContextLongItem getTestGlobalContextItem003() {
return testGlobalContextItem003;
}
@@ -112,7 +112,7 @@
*
* @param testGlobalContextItem003 the test global context item 003
*/
- public void setTestGlobalContextItem003(final TestContextItem003 testGlobalContextItem003) {
+ public void setTestGlobalContextItem003(final TestContextLongItem testGlobalContextItem003) {
this.testGlobalContextItem003 = testGlobalContextItem003;
}
@@ -121,7 +121,7 @@
*
* @return the test global context item 004
*/
- public TestContextItem004 getTestGlobalContextItem004() {
+ public TestContextFloatItem getTestGlobalContextItem004() {
return testGlobalContextItem004;
}
@@ -130,7 +130,7 @@
*
* @param testGlobalContextItem004 the test global context item 004
*/
- public void setTestGlobalContextItem004(final TestContextItem004 testGlobalContextItem004) {
+ public void setTestGlobalContextItem004(final TestContextFloatItem testGlobalContextItem004) {
this.testGlobalContextItem004 = testGlobalContextItem004;
}
@@ -139,7 +139,7 @@
*
* @return the test global context item 005
*/
- public TestContextItem005 getTestGlobalContextItem005() {
+ public TestContextDoubleItem getTestGlobalContextItem005() {
return testGlobalContextItem005;
}
@@ -148,7 +148,7 @@
*
* @param testGlobalContextItem005 the test global context item 005
*/
- public void setTestGlobalContextItem005(final TestContextItem005 testGlobalContextItem005) {
+ public void setTestGlobalContextItem005(final TestContextDoubleItem testGlobalContextItem005) {
this.testGlobalContextItem005 = testGlobalContextItem005;
}
@@ -157,7 +157,7 @@
*
* @return the test global context item 006
*/
- public TestContextItem006 getTestGlobalContextItem006() {
+ public TestContextStringItem getTestGlobalContextItem006() {
return testGlobalContextItem006;
}
@@ -166,7 +166,7 @@
*
* @param testGlobalContextItem006 the test global context item 006
*/
- public void setTestGlobalContextItem006(final TestContextItem006 testGlobalContextItem006) {
+ public void setTestGlobalContextItem006(final TestContextStringItem testGlobalContextItem006) {
this.testGlobalContextItem006 = testGlobalContextItem006;
}
@@ -175,7 +175,7 @@
*
* @return the test global context item 007
*/
- public TestContextItem007 getTestGlobalContextItem007() {
+ public TestContextLongObjectItem getTestGlobalContextItem007() {
return testGlobalContextItem007;
}
@@ -184,7 +184,7 @@
*
* @param testGlobalContextItem007 the test global context item 007
*/
- public void setTestGlobalContextItem007(final TestContextItem007 testGlobalContextItem007) {
+ public void setTestGlobalContextItem007(final TestContextLongObjectItem testGlobalContextItem007) {
this.testGlobalContextItem007 = testGlobalContextItem007;
}
@@ -193,7 +193,7 @@
*
* @return the test global context item 008
*/
- public TestContextItem008 getTestGlobalContextItem008() {
+ public TestContextDateItem getTestGlobalContextItem008() {
return testGlobalContextItem008;
}
@@ -202,7 +202,7 @@
*
* @param testGlobalContextItem008 the test global context item 008
*/
- public void setTestGlobalContextItem008(final TestContextItem008 testGlobalContextItem008) {
+ public void setTestGlobalContextItem008(final TestContextDateItem testGlobalContextItem008) {
this.testGlobalContextItem008 = testGlobalContextItem008;
}
@@ -211,7 +211,7 @@
*
* @return the test global context item 009
*/
- public TestContextItem009 getTestGlobalContextItem009() {
+ public TestContextDateTzItem getTestGlobalContextItem009() {
return testGlobalContextItem009;
}
@@ -220,7 +220,7 @@
*
* @param testGlobalContextItem009 the test global context item 009
*/
- public void setTestGlobalContextItem009(final TestContextItem009 testGlobalContextItem009) {
+ public void setTestGlobalContextItem009(final TestContextDateTzItem testGlobalContextItem009) {
this.testGlobalContextItem009 = testGlobalContextItem009;
}
@@ -229,7 +229,7 @@
*
* @return the test global context item 00 A
*/
- public TestContextItem00A getTestGlobalContextItem00A() {
+ public TestContextDateLocaleItem getTestGlobalContextItem00A() {
return testGlobalContextItem00A;
}
@@ -238,7 +238,7 @@
*
* @param testGlobalContextItem00A the test global context item 00 A
*/
- public void setTestGlobalContextItem00A(final TestContextItem00A testGlobalContextItem00A) {
+ public void setTestGlobalContextItem00A(final TestContextDateLocaleItem testGlobalContextItem00A) {
this.testGlobalContextItem00A = testGlobalContextItem00A;
}
@@ -247,7 +247,7 @@
*
* @return the test global context item 00 B
*/
- public TestContextItem00B getTestGlobalContextItem00B() {
+ public TestContextTreeSetItem getTestGlobalContextItem00B() {
return testGlobalContextItem00B;
}
@@ -256,7 +256,7 @@
*
* @param testGlobalContextItem00B the test global context item 00 B
*/
- public void setTestGlobalContextItem00B(final TestContextItem00B testGlobalContextItem00B) {
+ public void setTestGlobalContextItem00B(final TestContextTreeSetItem testGlobalContextItem00B) {
this.testGlobalContextItem00B = testGlobalContextItem00B;
}
@@ -265,7 +265,7 @@
*
* @return the test global context item 00 C
*/
- public TestContextItem00C getTestGlobalContextItem00C() {
+ public TestContextTreeMapItem getTestGlobalContextItem00C() {
return testGlobalContextItem00C;
}
@@ -274,7 +274,7 @@
*
* @param testGlobalContextItem00C the test global context item 00 C
*/
- public void setTestGlobalContextItem00C(final TestContextItem00C testGlobalContextItem00C) {
+ public void setTestGlobalContextItem00C(final TestContextTreeMapItem testGlobalContextItem00C) {
this.testGlobalContextItem00C = testGlobalContextItem00C;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java
similarity index 83%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java
index e9381de..fc728a7 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java
@@ -30,19 +30,19 @@
private static final int HASH_PRIME_1 = 31;
- private TestContextItem006 testPolicyContextItem000;
- private TestContextItem003 testPolicyContextItem001;
- private TestContextItem005 testPolicyContextItem002;
- private TestContextItem000 testPolicyContextItem003;
- private TestContextItem003 testPolicyContextItem004;
- private TestContextItem00C testPolicyContextItem005;
+ private TestContextStringItem testPolicyContextItem000;
+ private TestContextLongItem testPolicyContextItem001;
+ private TestContextDoubleItem testPolicyContextItem002;
+ private TestContextBooleanItem testPolicyContextItem003;
+ private TestContextLongItem testPolicyContextItem004;
+ private TestContextTreeMapItem testPolicyContextItem005;
/**
* Gets the test policy context item 000.
*
* @return the test policy context item 000
*/
- public TestContextItem006 getTestPolicyContextItem000() {
+ public TestContextStringItem getTestPolicyContextItem000() {
return testPolicyContextItem000;
}
@@ -51,7 +51,7 @@
*
* @param testPolicyContextItem000 the test policy context item 000
*/
- public void setTestPolicyContextItem000(final TestContextItem006 testPolicyContextItem000) {
+ public void setTestPolicyContextItem000(final TestContextStringItem testPolicyContextItem000) {
this.testPolicyContextItem000 = testPolicyContextItem000;
}
@@ -60,7 +60,7 @@
*
* @return the test policy context item 001
*/
- public TestContextItem003 getTestPolicyContextItem001() {
+ public TestContextLongItem getTestPolicyContextItem001() {
return testPolicyContextItem001;
}
@@ -69,7 +69,7 @@
*
* @param testPolicyContextItem001 the test policy context item 001
*/
- public void setTestPolicyContextItem001(final TestContextItem003 testPolicyContextItem001) {
+ public void setTestPolicyContextItem001(final TestContextLongItem testPolicyContextItem001) {
this.testPolicyContextItem001 = testPolicyContextItem001;
}
@@ -78,7 +78,7 @@
*
* @return the test policy context item 002
*/
- public TestContextItem005 getTestPolicyContextItem002() {
+ public TestContextDoubleItem getTestPolicyContextItem002() {
return testPolicyContextItem002;
}
@@ -87,7 +87,7 @@
*
* @param testPolicyContextItem002 the test policy context item 002
*/
- public void setTestPolicyContextItem002(final TestContextItem005 testPolicyContextItem002) {
+ public void setTestPolicyContextItem002(final TestContextDoubleItem testPolicyContextItem002) {
this.testPolicyContextItem002 = testPolicyContextItem002;
}
@@ -96,7 +96,7 @@
*
* @return the test policy context item 003
*/
- public TestContextItem000 getTestPolicyContextItem003() {
+ public TestContextBooleanItem getTestPolicyContextItem003() {
return testPolicyContextItem003;
}
@@ -105,7 +105,7 @@
*
* @param testPolicyContextItem003 the test policy context item 003
*/
- public void setTestPolicyContextItem003(final TestContextItem000 testPolicyContextItem003) {
+ public void setTestPolicyContextItem003(final TestContextBooleanItem testPolicyContextItem003) {
this.testPolicyContextItem003 = testPolicyContextItem003;
}
@@ -114,7 +114,7 @@
*
* @return the test policy context item 004
*/
- public TestContextItem003 getTestPolicyContextItem004() {
+ public TestContextLongItem getTestPolicyContextItem004() {
return testPolicyContextItem004;
}
@@ -123,7 +123,7 @@
*
* @param testPolicyContextItem004 the test policy context item 004
*/
- public void setTestPolicyContextItem004(final TestContextItem003 testPolicyContextItem004) {
+ public void setTestPolicyContextItem004(final TestContextLongItem testPolicyContextItem004) {
this.testPolicyContextItem004 = testPolicyContextItem004;
}
@@ -132,7 +132,7 @@
*
* @return the test policy context item 005
*/
- public TestContextItem00C getTestPolicyContextItem005() {
+ public TestContextTreeMapItem getTestPolicyContextItem005() {
return testPolicyContextItem005;
}
@@ -141,7 +141,7 @@
*
* @param testPolicyContextItem005 the test policy context item 005
*/
- public void setTestPolicyContextItem005(final TestContextItem00C testPolicyContextItem005) {
+ public void setTestPolicyContextItem005(final TestContextTreeMapItem testPolicyContextItem005) {
this.testPolicyContextItem005 = testPolicyContextItem005;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java
similarity index 100%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java
similarity index 73%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java
index ae0fea7..189208f 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java
@@ -20,6 +20,11 @@
package org.onap.policy.apex.context.test.distribution;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.onap.policy.apex.context.test.utils.Constants.APEX_DISTRIBUTOR;
+import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
+
import java.io.IOException;
import org.onap.policy.apex.context.ContextAlbum;
@@ -40,7 +45,6 @@
* The Class ContextAlbumUpdate is used to test Context Album updates.
*/
public class ContextAlbumUpdate {
- // Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextAlbumUpdate.class);
/**
@@ -53,21 +57,22 @@
public void testContextAlbumUpdate() throws ApexModelException, IOException, ApexException {
LOGGER.debug("Running TestContextAlbumUpdate test . . .");
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1");
+ final AxArtifactKey distributorKey = new AxArtifactKey(APEX_DISTRIBUTOR, VERSION);
final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
final AxContextModel longModel = TestContextAlbumFactory.createLongContextModel();
contextDistributor.registerModel(longModel);
- final AxContextAlbum longAlbum1Def = longModel.getAlbums().get(new AxArtifactKey("LongContextAlbum1", "0.0.1"));
+ final AxContextAlbum longAlbum1Def = longModel.getAlbums().get(new AxArtifactKey("LongContextAlbum1", VERSION));
final ContextAlbum longAlbum1 = contextDistributor.createContextAlbum(longAlbum1Def.getKey());
- assert (longAlbum1 != null);
- final AxContextAlbum longAlbum2Def = longModel.getAlbums().get(new AxArtifactKey("LongContextAlbum2", "0.0.1"));
+ assertNotNull(longAlbum1);
+
+ final AxContextAlbum longAlbum2Def = longModel.getAlbums().get(new AxArtifactKey("LongContextAlbum2", VERSION));
final ContextAlbum longAlbum2 = contextDistributor.createContextAlbum(longAlbum2Def.getKey());
- assert (longAlbum2 != null);
- // CHECKSTYLE:OFF: checkstyle:magicNumber
+ assertNotNull(longAlbum2);
+
longAlbum1.put("0", (long) 0);
longAlbum1.put("1", (long) 1);
longAlbum1.put("2", (long) 2);
@@ -76,20 +81,21 @@
final KeyedMapDifference<String, Object> result0 =
new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
- assert (0 == result0.getDifferentValues().size());
- assert (0 == result0.getIdenticalValues().size());
- assert (0 == result0.getRightOnly().size());
- assert (4 == result0.getLeftOnly().size());
+ assertEquals(0, result0.getDifferentValues().size());
+ assertEquals(0, result0.getIdenticalValues().size());
+ assertEquals(0, result0.getRightOnly().size());
+ assertEquals(4, result0.getLeftOnly().size());
longAlbum2.putAll(longAlbum1);
final KeyedMapDifference<String, Object> result1 =
new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
- assert (0 == result1.getDifferentValues().size());
- assert (4 == result1.getIdenticalValues().size());
- assert (0 == result1.getRightOnly().size());
- assert (0 == result1.getLeftOnly().size());
+
+ assertEquals(0, result1.getDifferentValues().size());
+ assertEquals(4, result1.getIdenticalValues().size());
+ assertEquals(0, result1.getRightOnly().size());
+ assertEquals(0, result1.getLeftOnly().size());
longAlbum1.put("4", (long) 4);
longAlbum2.put("5", (long) 5);
@@ -99,23 +105,21 @@
final KeyedMapDifference<String, Object> result2 =
new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
- assert (1 == result2.getDifferentValues().size());
- assert (4 == result2.getIdenticalValues().size());
- assert (1 == result2.getRightOnly().size());
- assert (1 == result2.getLeftOnly().size());
+ assertEquals(1, result2.getDifferentValues().size());
+ assertEquals(4, result2.getIdenticalValues().size());
+ assertEquals(1, result2.getRightOnly().size());
+ assertEquals(1, result2.getLeftOnly().size());
longAlbum1.remove("0");
longAlbum2.remove("3");
- // CHECKSTYLE:ON: checkstyle:magicNumber
final KeyedMapDifference<String, Object> result3 =
new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
- assert (1 == result3.getDifferentValues().size());
- assert (2 == result3.getIdenticalValues().size());
- assert (2 == result3.getRightOnly().size());
- assert (2 == result3.getLeftOnly().size());
-
+ assertEquals(1, result3.getDifferentValues().size());
+ assertEquals(2, result3.getIdenticalValues().size());
+ assertEquals(2, result3.getRightOnly().size());
+ assertEquals(2, result3.getLeftOnly().size());
contextDistributor.clear();
}
}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
new file mode 100644
index 0000000..03ef650
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
@@ -0,0 +1,552 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.context.test.distribution;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.onap.policy.apex.context.test.factory.TestContextAlbumFactory.createPolicyContextModel;
+import static org.onap.policy.apex.context.test.utils.Constants.BYTE_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.EXCEPTION_MESSAGE;
+import static org.onap.policy.apex.context.test.utils.Constants.EXTERNAL_CONTEXT;
+import static org.onap.policy.apex.context.test.utils.Constants.EXTERNAL_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.FLOAT_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.GLOBAL_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.GLOBAL_CONTEXT_KEY;
+import static org.onap.policy.apex.context.test.utils.Constants.INT_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.INT_VAL_2;
+import static org.onap.policy.apex.context.test.utils.Constants.INT_VAL_3;
+import static org.onap.policy.apex.context.test.utils.Constants.LONG_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.PI_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.POLICY_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.STRING_EXT_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.STRING_GLOBAL_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.STRING_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.TEST_POLICY_CONTEXT_ITEM;
+import static org.onap.policy.apex.context.test.utils.Constants.TIME_ZONE;
+import static org.onap.policy.apex.context.test.utils.Constants.USED_ARTIFACT_STACK_ARRAY;
+import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.ContextRuntimeException;
+import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.test.concepts.TestContextBooleanItem;
+import org.onap.policy.apex.context.test.concepts.TestContextByteItem;
+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.TestContextDateTzItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDoubleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextFloatItem;
+import org.onap.policy.apex.context.test.concepts.TestContextIntItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongObjectItem;
+import org.onap.policy.apex.context.test.concepts.TestContextStringItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeSetItem;
+import org.onap.policy.apex.context.test.concepts.TestExternalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestGlobalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
+import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestContextInstantiation is used to test Apex context insitiation is correct.
+ *
+ * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
+ */
+public class ContextInstantiation {
+
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextInstantiation.class);
+
+ private final static TreeSet<String> TEST_TREE_SET = new TreeSet<>();
+ private final static Map<String, String> TEST_HASH_MAP = new HashMap<>();
+
+ static {
+ TEST_TREE_SET.add("one hundred");
+ TEST_TREE_SET.add("one hundred and one");
+ TEST_TREE_SET.add("one hundred and two");
+ TEST_TREE_SET.add("one hundred and three");
+ TEST_TREE_SET.add("one hundred and four");
+
+ TEST_HASH_MAP.put("0", "zero");
+ TEST_HASH_MAP.put("1", "one");
+ TEST_HASH_MAP.put("2", "two");
+ TEST_HASH_MAP.put("3", "three");
+ TEST_HASH_MAP.put("4", "four");
+
+ }
+
+ /**
+ * Test context instantiation.
+ *
+ * @throws ContextException the context exception
+ */
+ public void testContextInstantiation() throws ContextException {
+ LOGGER.debug("Running TestContextInstantiation test . . .");
+
+ final Distributor contextDistributor = getDistributor();
+
+ try {
+
+ final ContextAlbum policyContextAlbum =
+ contextDistributor.createContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION));
+
+ assertNotNull(policyContextAlbum);
+ policyContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+
+ final Date testDate = new Date();
+
+ final TestContextDateTzItem tci9 = getTestContextDateTzItem(testDate);
+ final TestContextDateLocaleItem tciA = getTestContextDateLocaleItem(testDate);
+
+ final TestPolicyContextItem policyContext = getTestPolicyContextItem(policyContextAlbum, testDate);
+
+ final Map<String, Object> valueMap0 = new HashMap<>();
+ valueMap0.put(TEST_POLICY_CONTEXT_ITEM, policyContext);
+
+ policyContextAlbum.putAll(valueMap0);
+
+ final TestPolicyContextItem contextItem =
+ (TestPolicyContextItem) policyContextAlbum.get(TEST_POLICY_CONTEXT_ITEM);
+ assertEquals(STRING_VAL, contextItem.getTestPolicyContextItem000().getStringValue());
+
+ assertEquals(LONG_VAL, contextItem.getTestPolicyContextItem001().getLongValue());
+ assertDouble(contextItem.getTestPolicyContextItem002().getDoubleValue(), PI_VAL);
+ assertTrue(contextItem.getTestPolicyContextItem003().getFlag());
+ assertEquals(contextItem.getTestPolicyContextItem004().getLongValue(), testDate.getTime());
+ assertEquals(contextItem.getTestPolicyContextItem005().getMapValue(), TEST_HASH_MAP);
+
+ final TestGlobalContextItem globalContext =
+ getTestGlobalContextItem(contextDistributor, testDate, tci9, tciA);
+
+ final Map<String, Object> valueMap1 = new HashMap<>();
+ valueMap1.put(GLOBAL_CONTEXT_KEY, globalContext);
+
+ final ContextAlbum globalContextAlbum = getContextAlbum(contextDistributor);
+
+ globalContextAlbum.putAll(valueMap1);
+
+ final TestGlobalContextItem globalContextItem =
+ (TestGlobalContextItem) globalContextAlbum.get(GLOBAL_CONTEXT_KEY);
+
+ assertFalse(globalContextItem.getTestGlobalContextItem000().getFlag());
+
+ assertEquals(BYTE_VAL, globalContextItem.getTestGlobalContextItem001().getByteValue());
+
+ assertEquals(INT_VAL, globalContextItem.getTestGlobalContextItem002().getIntValue());
+ assertEquals(LONG_VAL, globalContextItem.getTestGlobalContextItem003().getLongValue());
+ assertFloat(FLOAT_VAL, globalContextItem.getTestGlobalContextItem004().getFloatValue());
+
+ assertDouble(PI_VAL, globalContextItem.getTestGlobalContextItem005().getDoubleValue());
+ assertEquals(STRING_GLOBAL_VAL, globalContextItem.getTestGlobalContextItem006().getStringValue());
+
+ assertEquals(new Long(testDate.getTime()), globalContextItem.getTestGlobalContextItem007().getLongValue());
+ assertEquals(testDate, globalContextItem.getTestGlobalContextItem008().getDateValue());
+ assertEquals(tci9.getDateValue().getTime(),
+ globalContextItem.getTestGlobalContextItem009().getDateValue().getTime());
+
+ assertEquals(tciA.getDateValue().getTime(),
+ globalContextItem.getTestGlobalContextItem00A().getDateValue().getTime());
+
+ assertEquals(TEST_TREE_SET, globalContextItem.getTestGlobalContextItem00B().getSetValue());
+ assertEquals(TEST_HASH_MAP, globalContextItem.getTestGlobalContextItem00C().getMapValue());
+
+ final AxContextModel externalContextModel = TestContextAlbumFactory.createExternalContextModel();
+
+ final TestContextDateTzItem tci9A = new TestContextDateTzItem(tci9);
+ final TestContextDateLocaleItem tciAA = new TestContextDateLocaleItem(tciA);
+ final TestExternalContextItem externalContext = getTestExternalContextItem(testDate, tci9A, tciAA);
+
+ final Map<String, Object> valueMap2 = new HashMap<>();
+ valueMap2.put(EXTERNAL_CONTEXT, externalContext);
+
+ contextDistributor.clear();
+ contextDistributor.init(new AxArtifactKey("ClearedandInittedDistributor", VERSION));
+ contextDistributor.registerModel(externalContextModel);
+
+ final AxArtifactKey axContextAlbumKey = new AxArtifactKey(EXTERNAL_CONTEXT_ALBUM, VERSION);
+ final ContextAlbum externalContextAlbum = contextDistributor.createContextAlbum(axContextAlbumKey);
+ assertNotNull(externalContextAlbum);
+ externalContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+
+ externalContextAlbum.putAll(valueMap2);
+ externalContextAlbum.getAlbumDefinition().setWritable(false);
+
+ TestExternalContextItem externalContextItem =
+ (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT);
+
+ assertFalse(externalContextItem.getTestExternalContextItem000().getFlag());
+ assertEquals(BYTE_VAL, externalContextItem.getTestExternalContextItem001().getByteValue());
+ assertEquals(INT_VAL, externalContextItem.getTestExternalContextItem002().getIntValue());
+
+ assertFloat(LONG_VAL, externalContextItem.getTestExternalContextItem003().getLongValue());
+ assertFloat(FLOAT_VAL, externalContextItem.getTestExternalContextItem004().getFloatValue());
+
+ assertDouble(PI_VAL, externalContextItem.getTestExternalContextItem005().getDoubleValue());
+ assertEquals(STRING_EXT_VAL, externalContextItem.getTestExternalContextItem006().getStringValue());
+ assertEquals(new Long(testDate.getTime()),
+ externalContextItem.getTestExternalContextItem007().getLongValue());
+ assertEquals(testDate, externalContextItem.getTestExternalContextItem008().getDateValue());
+ assertEquals(tci9A.getDateValue().getTime(),
+ externalContextItem.getTestExternalContextItem009().getDateValue().getTime());
+
+ assertEquals(tciAA.getDateValue().getTime(),
+ externalContextItem.getTestExternalContextItem00A().getDateValue().getTime());
+ assertEquals(TEST_TREE_SET, externalContextItem.getTestExternalContextItem00B().getSetValue());
+ assertEquals(TEST_HASH_MAP, externalContextItem.getTestExternalContextItem00C().getMapValue());
+
+ final Collection<Object> mapValues = externalContextAlbum.values();
+ assertTrue(externalContextAlbum.values().containsAll(mapValues));
+
+ // Check that clearing does not work
+ try {
+ externalContextAlbum.clear();
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("album \"ExternalContextAlbum:0.0.1\" clear() not allowed on read only albums",
+ e.getMessage());
+ }
+
+ assertEquals(1, externalContextAlbum.size());
+
+ assertContextAlbumContains(externalContext, externalContextAlbum);
+
+ final Set<Entry<String, Object>> entrySet = externalContextAlbum.entrySet();
+ assertEquals(1, entrySet.size());
+
+ try {
+ externalContextAlbum.get(null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for get()",
+ e.getMessage());
+
+ }
+
+ final Object aObject = externalContextAlbum.get(EXTERNAL_CONTEXT);
+ assertEquals(aObject, externalContext);
+
+ // put null keys should fail, throws a runtime exception
+ try {
+ externalContextAlbum.put(null, null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for put()",
+ e.getMessage());
+ }
+
+ try {
+ externalContextAlbum.put("TestExternalContextItem00A", null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(
+ "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItem00A\" for put()",
+ e.getMessage());
+ }
+ assertEquals(tciAA, externalContextItem.getTestExternalContextItem00A());
+
+ // Should return the hash set
+ assertEquals(TEST_TREE_SET, externalContextItem.getTestExternalContextItem00B().getSetValue());
+
+ assertTrue(externalContextAlbum.values().containsAll(mapValues));
+
+ // Set the write flag back as it should be
+ externalContextAlbum.getAlbumDefinition().setWritable(true);
+
+ // Put should return the previous contextItem
+ final TestExternalContextItem externalContextOther = new TestExternalContextItem();
+ externalContextOther.setTestExternalContextItem002(new TestContextIntItem());
+ externalContextOther.getTestExternalContextItem002().setIntValue(INT_VAL_2);
+
+ assertTrue(externalContextAlbum.put(EXTERNAL_CONTEXT, externalContextOther).equals(externalContext));
+ externalContextItem = (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT);
+ assertEquals(INT_VAL_2, externalContextItem.getTestExternalContextItem002().getIntValue());
+ assertTrue(externalContextAlbum.put(EXTERNAL_CONTEXT, externalContext).equals(externalContextOther));
+ externalContextItem = (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT);
+ assertEquals(INT_VAL_3, externalContextItem.getTestExternalContextItem002().getIntValue());
+
+ try {
+ externalContextAlbum.put("TestExternalContextItem00A", null);
+ } catch (final ContextRuntimeException e) {
+ assert (e.getMessage().equals(
+ "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItem00A\" for put()"));
+ }
+ assertTrue(externalContextAlbum.get(EXTERNAL_CONTEXT).equals(externalContext));
+
+ try {
+ externalContextAlbum.put("TestExternalContextItemFFF", null);
+ } catch (final ContextRuntimeException e) {
+ assert (e.getMessage().equals(
+ "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItemFFF\" for put()"));
+ }
+ assertEquals(1, externalContextAlbum.size());
+
+ try {
+ externalContextAlbum.put("TestExternalContextItemFFF", null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(
+ "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItemFFF\" for put()",
+ e.getMessage());
+ }
+ assertEquals(1, externalContextAlbum.size());
+
+ // Should ignore remove
+ externalContextAlbum.remove("TestExternalContextItem017");
+ assertEquals(1, externalContextAlbum.size());
+ assertEquals(1, externalContextAlbum.values().size());
+ assertTrue(externalContextAlbum.values().containsAll(mapValues));
+ } catch (final Exception exception) {
+ LOGGER.error("Unexpected Error:", exception);
+ throw exception;
+ } finally {
+ contextDistributor.clear();
+ }
+
+ }
+
+ private void assertContextAlbumContains(final TestExternalContextItem externalContext,
+ final ContextAlbum externalContextAlbum) {
+ try {
+ externalContextAlbum.containsKey(null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("null values are illegal on method parameter \"key\"", e.getMessage());
+ }
+
+ assertTrue(externalContextAlbum.containsKey(EXTERNAL_CONTEXT));
+ assertTrue(!externalContextAlbum.containsKey(GLOBAL_CONTEXT_KEY));
+
+ try {
+ externalContextAlbum.containsValue(null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("null values are illegal on method parameter \"value\"", e.getMessage());
+ }
+
+ assertTrue(externalContextAlbum.containsValue(externalContext));
+ assertFalse(externalContextAlbum.containsValue("Hello"));
+ }
+
+ private ContextAlbum getContextAlbum(final Distributor contextDistributor) throws ContextException {
+ final ContextAlbum globalContextAlbum =
+ contextDistributor.createContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION));
+ assertNotNull(globalContextAlbum);
+ globalContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+ return globalContextAlbum;
+ }
+
+ private TestGlobalContextItem getTestGlobalContextItem(final Distributor contextDistributor, final Date testDate,
+ final TestContextDateTzItem tci9, final TestContextDateLocaleItem tciA) throws ContextException {
+ final AxContextModel globalContextModel = TestContextAlbumFactory.createGlobalContextModel();
+ final TestGlobalContextItem globalContext = getTestGlobalContextItem(testDate, tci9, tciA);
+ contextDistributor.registerModel(globalContextModel);
+ return globalContext;
+ }
+
+ private TestPolicyContextItem getTestPolicyContextItem(final ContextAlbum policyContextAlbum, final Date testDate) {
+ final TestContextStringItem contextStringItem = new TestContextStringItem(STRING_VAL);
+ final TestContextLongItem contextLongItem = new TestContextLongItem(LONG_VAL);
+ final TestContextDoubleItem contextDoubleItem = new TestContextDoubleItem(PI_VAL);
+ final TestContextBooleanItem contextBooleanItem = new TestContextBooleanItem(true);
+ final TestContextLongItem contextLongItem2 = new TestContextLongItem(testDate.getTime());
+ final TestContextTreeMapItem contextTreeMapItem = new TestContextTreeMapItem(TEST_HASH_MAP);
+
+ final Map<String, Object> valueMapA = new LinkedHashMap<>();
+ valueMapA.put("TestPolicyContextItem001", contextLongItem);
+ valueMapA.put("TestPolicyContextItem002", contextDoubleItem);
+ valueMapA.put("TestPolicyContextItem003", contextBooleanItem);
+ valueMapA.put("TestPolicyContextItem004", contextLongItem2);
+ valueMapA.put("TestPolicyContextItem005", contextTreeMapItem);
+ valueMapA.put("TestPolicyContextItem000", contextStringItem);
+
+ assertPutMethods(policyContextAlbum, contextStringItem, valueMapA);
+
+ final TestPolicyContextItem policyContext = new TestPolicyContextItem();
+
+ LOGGER.debug(policyContextAlbum.toString());
+
+ policyContext.setTestPolicyContextItem000(contextStringItem);
+ policyContext.setTestPolicyContextItem001(contextLongItem);
+ policyContext.setTestPolicyContextItem002(contextDoubleItem);
+ policyContext.setTestPolicyContextItem003(contextBooleanItem);
+ policyContext.setTestPolicyContextItem004(contextLongItem2);
+ policyContext.setTestPolicyContextItem005(contextTreeMapItem);
+ return policyContext;
+ }
+
+ private void assertPutMethods(final ContextAlbum policyContextAlbum, final TestContextStringItem contextStringItem,
+ final Map<String, Object> valueMapA) {
+ try {
+ policyContextAlbum.put("TestPolicyContextItem000", contextStringItem);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(
+ getMessage("TestPolicyContextItem000", "TestContextItem006",
+ TestContextStringItem.class.getCanonicalName(), "stringValue=" + STRING_VAL),
+ e.getMessage());
+ }
+
+ try {
+ policyContextAlbum.putAll(valueMapA);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(getMessage("TestPolicyContextItem001", "TestContextItem003",
+ TestContextLongItem.class.getCanonicalName(), "longValue=" + INT_VAL_3), e.getMessage());
+ }
+ }
+
+ private AxContextModel getAxContextModel() {
+ final AxContextModel policyContextModel = createPolicyContextModel();
+ final AxValidationResult result = new AxValidationResult();
+ policyContextModel.validate(result);
+ LOGGER.debug(result.toString());
+
+ assertTrue(result.isValid());
+ return policyContextModel;
+ }
+
+ private TestContextDateLocaleItem getTestContextDateLocaleItem(final Date testDate) {
+ final TestContextDateLocaleItem tciA = new TestContextDateLocaleItem();
+ tciA.setDateValue(new TestContextDateItem(testDate));
+ tciA.setTZValue(TIME_ZONE.getDisplayName());
+ tciA.setDST(true);
+ tciA.setUTCOffset(-600);
+ tciA.setLocale(Locale.ENGLISH);
+ return tciA;
+ }
+
+ private TestContextDateTzItem getTestContextDateTzItem(final Date testDate) {
+ final TestContextDateTzItem tci9 = new TestContextDateTzItem();
+ tci9.setDateValue(new TestContextDateItem(testDate));
+ tci9.setTZValue(TIME_ZONE.getDisplayName());
+ tci9.setDST(true);
+ return tci9;
+ }
+
+ private TestGlobalContextItem getTestGlobalContextItem(final Date testDate, final TestContextDateTzItem tci9,
+ final TestContextDateLocaleItem tciA) {
+ final TestGlobalContextItem globalContext = new TestGlobalContextItem();
+
+ final TestContextBooleanItem testGlobalContextItem000 = new TestContextBooleanItem(false);
+ final TestContextByteItem testGlobalContextItem001 = new TestContextByteItem(BYTE_VAL);
+ final TestContextIntItem testGlobalContextItem002 = new TestContextIntItem(INT_VAL);
+ final TestContextLongItem testGlobalContextItem003 = new TestContextLongItem(LONG_VAL);
+ final TestContextFloatItem testGlobalContextItem004 = new TestContextFloatItem(new Float(FLOAT_VAL));
+ final TestContextDoubleItem testGlobalContextItem005 = new TestContextDoubleItem(PI_VAL);
+ final TestContextStringItem testGlobalContextItem006 = new TestContextStringItem(STRING_GLOBAL_VAL);
+ final TestContextLongObjectItem testGlobalContextItem007 = new TestContextLongObjectItem(testDate.getTime());
+
+ final TestContextDateItem testGlobalContextItem008 = new TestContextDateItem(testDate);
+ final TestContextTreeSetItem testGlobalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET);
+ final TestContextTreeMapItem testGlobalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP);
+
+
+ globalContext.setTestGlobalContextItem000(testGlobalContextItem000);
+ globalContext.setTestGlobalContextItem001(testGlobalContextItem001);
+ globalContext.setTestGlobalContextItem002(testGlobalContextItem002);
+ globalContext.setTestGlobalContextItem003(testGlobalContextItem003);
+ globalContext.setTestGlobalContextItem004(testGlobalContextItem004);
+ globalContext.setTestGlobalContextItem005(testGlobalContextItem005);
+ globalContext.setTestGlobalContextItem006(testGlobalContextItem006);
+ globalContext.setTestGlobalContextItem007(testGlobalContextItem007);
+ globalContext.setTestGlobalContextItem008(testGlobalContextItem008);
+ globalContext.setTestGlobalContextItem009(tci9);
+ globalContext.setTestGlobalContextItem00A(tciA);
+ globalContext.setTestGlobalContextItem00B(testGlobalContextItem00B);
+ globalContext.setTestGlobalContextItem00C(testGlobalContextItem00C);
+ return globalContext;
+ }
+
+ private TestExternalContextItem getTestExternalContextItem(final Date testDate, final TestContextDateTzItem tci9A,
+ final TestContextDateLocaleItem tciAA) {
+ final TestExternalContextItem externalContext = new TestExternalContextItem();
+
+ final TestContextBooleanItem testExternalContextItem000 = new TestContextBooleanItem(false);
+ final TestContextByteItem testExternalContextItem001 = new TestContextByteItem(BYTE_VAL);
+ final TestContextIntItem testExternalContextItem002 = new TestContextIntItem(INT_VAL);
+ final TestContextLongItem testExternalContextItem003 = new TestContextLongItem(LONG_VAL);
+ final TestContextFloatItem testExternalContextItem004 = new TestContextFloatItem(new Float(3.14159265359));
+ final TestContextDoubleItem testExternalContextItem005 = new TestContextDoubleItem(PI_VAL);
+ final TestContextStringItem testExternalContextItem006 = new TestContextStringItem(STRING_EXT_VAL);
+ final TestContextLongObjectItem testExternalContextItem007 = new TestContextLongObjectItem(testDate.getTime());
+ final TestContextDateItem testExternalContextItem008 = new TestContextDateItem(testDate);
+ final TestContextTreeSetItem testExternalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET);
+ final TestContextTreeMapItem testExternalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP);
+
+
+ externalContext.setTestExternalContextItem000(testExternalContextItem000);
+ externalContext.setTestExternalContextItem001(testExternalContextItem001);
+ externalContext.setTestExternalContextItem002(testExternalContextItem002);
+ externalContext.setTestExternalContextItem003(testExternalContextItem003);
+ externalContext.setTestExternalContextItem004(testExternalContextItem004);
+ externalContext.setTestExternalContextItem005(testExternalContextItem005);
+ externalContext.setTestExternalContextItem006(testExternalContextItem006);
+ externalContext.setTestExternalContextItem007(testExternalContextItem007);
+ externalContext.setTestExternalContextItem008(testExternalContextItem008);
+ externalContext.setTestExternalContextItem009(tci9A);
+ externalContext.setTestExternalContextItem00A(tciAA);
+ externalContext.setTestExternalContextItem00B(testExternalContextItem00B);
+ externalContext.setTestExternalContextItem00C(testExternalContextItem00C);
+ return externalContext;
+ }
+
+ private String getMessage(final String key, final String objName, final String clazzName, final String valString) {
+ return getMessage(key, objName, clazzName, valString, TestPolicyContextItem.class.getCanonicalName());
+ }
+
+ private String getMessage(final String key, final String objName, final String clazzName, final String valString,
+ final String compatibleClazzName) {
+ return "Failed to set context value for key \"" + key + "\" in album \"PolicyContextAlbum:0.0.1\": "
+ + "PolicyContextAlbum:0.0.1: object \"" + objName + " [" + valString + "]\" " + "of class \""
+ + clazzName + "\"" + " not compatible with class \"" + compatibleClazzName + "\"";
+ }
+
+ private void assertFloat(final float actual, final float expected) {
+ assertTrue(Float.compare(actual, expected) == 0);
+ }
+
+ private void assertDouble(final double actual, final double expected) {
+ assertTrue(Double.compare(actual, expected) == 0);
+ }
+
+
+ private Distributor getDistributor() throws ContextException {
+ final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributorInit", VERSION);
+ final Distributor distributor = new DistributorFactory().getDistributor(distributorKey);
+ final AxContextModel policyContextModel = getAxContextModel();
+ distributor.registerModel(policyContextModel);
+ return distributor;
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
new file mode 100644
index 0000000..75d5597
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
@@ -0,0 +1,176 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.context.test.distribution;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.onap.policy.apex.context.test.utils.Constants.APEX_DISTRIBUTOR;
+import static org.onap.policy.apex.context.test.utils.Constants.DATE_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.EXCEPTION_MESSAGE;
+import static org.onap.policy.apex.context.test.utils.Constants.LONG_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.MAP_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.TIME_ZONE;
+import static org.onap.policy.apex.context.test.utils.Constants.USED_ARTIFACT_STACK_ARRAY;
+import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.ContextRuntimeException;
+import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+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.TestContextTreeMapItem;
+import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestContextUpdate checks context updates.
+ *
+ * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
+ */
+public class ContextUpdate {
+ private static final String ZERO = "zero";
+ private static final String _0 = "0";
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextUpdate.class);
+
+ /**
+ * Test context update.
+ *
+ * @throws ApexModelException the apex model exception
+ * @throws IOException the IO exception
+ * @throws ApexException the apex exception
+ */
+ public void testContextUpdate() throws ApexModelException, IOException, ApexException {
+ LOGGER.debug("Running TestContextUpdate test . . .");
+
+ final Distributor contextDistributor = getDistributor();
+
+ final ContextAlbum longContextAlbum = getContextAlbum(LONG_CONTEXT_ALBUM, contextDistributor);
+ final ContextAlbum dateContextAlbum = getContextAlbum(DATE_CONTEXT_ALBUM, contextDistributor);
+ final ContextAlbum mapContextAlbum = getContextAlbum(MAP_CONTEXT_ALBUM, contextDistributor);
+
+ final TestContextDateLocaleItem tciA = getTestContextDateLocaleItem();
+ final TestContextTreeMapItem tciC = getTestContextTreeMapItem();
+
+ longContextAlbum.put(_0, (long) 0);
+ longContextAlbum.put(_0, 0);
+ longContextAlbum.put(_0, _0);
+
+ try {
+ longContextAlbum.put(_0, ZERO);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(
+ "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum:0.0.1: object \"zero\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\"",
+ e.getMessage());
+ }
+
+ try {
+ longContextAlbum.put(_0, "");
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(
+ "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum:0.0.1: object \"\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\"",
+ e.getMessage());
+ }
+
+ try {
+ longContextAlbum.put(_0, null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("album \"LongContextAlbum:0.0.1\" null values are illegal on key \"0\" for put()",
+ e.getMessage());
+ }
+
+ try {
+ longContextAlbum.put(null, null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("album \"LongContextAlbum:0.0.1\" null keys are illegal on keys for put()", e.getMessage());
+ }
+
+ assertNull(dateContextAlbum.put("date0", tciA));
+ assertTrue(dateContextAlbum.put("date0", tciA).equals(tciA));
+
+
+ assertNull(mapContextAlbum.put("map0", tciC));
+ assertTrue(mapContextAlbum.put("map0", tciC).equals(tciC));
+
+ contextDistributor.clear();
+ }
+
+ private TestContextTreeMapItem getTestContextTreeMapItem() {
+ final Map<String, String> testHashMap = new HashMap<>();
+ testHashMap.put(_0, ZERO);
+ testHashMap.put("1", "one");
+ testHashMap.put("2", "two");
+ testHashMap.put("3", "three");
+ testHashMap.put("4", "four");
+
+ final TestContextTreeMapItem tciC = new TestContextTreeMapItem(testHashMap);
+ return tciC;
+ }
+
+ private TestContextDateLocaleItem getTestContextDateLocaleItem() {
+ final TestContextDateLocaleItem tciA = new TestContextDateLocaleItem();
+ tciA.setDateValue(new TestContextDateItem(new Date()));
+ tciA.setTZValue(TIME_ZONE.getDisplayName());
+ tciA.setDST(true);
+ tciA.setUTCOffset(-600);
+ tciA.setLocale(Locale.ENGLISH);
+ return tciA;
+ }
+
+ private ContextAlbum getContextAlbum(final String albumKey, final Distributor contextDistributor)
+ throws ContextException {
+ final ContextAlbum longContextAlbum =
+ contextDistributor.createContextAlbum(new AxArtifactKey(albumKey, VERSION));
+ assertNotNull(longContextAlbum);
+ longContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+ return longContextAlbum;
+ }
+
+ private Distributor getDistributor() throws ContextException {
+ final AxArtifactKey distributorKey = new AxArtifactKey(APEX_DISTRIBUTOR, VERSION);
+ final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
+
+
+ final AxContextModel multiModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
+ contextDistributor.registerModel(multiModel);
+ return contextDistributor;
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
new file mode 100644
index 0000000..e789ae9
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
@@ -0,0 +1,364 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.context.test.distribution;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.onap.policy.apex.context.test.factory.TestContextAlbumFactory.createMultiAlbumsContextModel;
+import static org.onap.policy.apex.context.test.utils.Constants.APEX_DISTRIBUTOR;
+import static org.onap.policy.apex.context.test.utils.Constants.BYTE_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.DATE_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.EXCEPTION_MESSAGE;
+import static org.onap.policy.apex.context.test.utils.Constants.FLOAT_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.INT_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.LONG_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.PI_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.STRING_GLOBAL_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.TIME_ZONE;
+import static org.onap.policy.apex.context.test.utils.Constants.USED_ARTIFACT_STACK_ARRAY;
+import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TimeZone;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.test.concepts.TestContextBooleanItem;
+import org.onap.policy.apex.context.test.concepts.TestContextByteItem;
+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.TestContextDateTzItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDoubleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextFloatItem;
+import org.onap.policy.apex.context.test.concepts.TestContextIntItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongObjectItem;
+import org.onap.policy.apex.context.test.concepts.TestContextStringItem;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+
+
+/**
+ * The Class SequentialContextInstantiation checks sequential initiation of context.
+ *
+ * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
+ */
+public class SequentialContextInstantiation {
+ private static final String DV1 = "dv1";
+ private static final String DV0 = "dv0";
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(SequentialContextInstantiation.class);
+
+ /**
+ * Test sequential context instantiation.
+ *
+ * @throws ContextException the context exception
+ */
+ public void testSequentialContextInstantiation() throws ContextException {
+ LOGGER.debug("Running TestContextInstantiation test . . .");
+
+ final Distributor contextDistributor = getDistributor();
+
+ try {
+ final ContextAlbum dateAlbum = getContextAlbum(DATE_CONTEXT_ALBUM, contextDistributor);
+ final Date testDate = new Date();
+ final TestContextDateLocaleItem tciA00 = getTestContextDateLocaleItem();
+
+ dateAlbum.put(DV0, tciA00);
+ assertEquals(tciA00, dateAlbum.get(DV0));
+
+ dateAlbum.put(DV1, tciA00);
+ assertEquals(tciA00, dateAlbum.get(DV1));
+
+ final TestContextDateTzItem tci9 = getTestContextDateTzItem(testDate);
+
+ try {
+ dateAlbum.put("tci9", tci9);
+ } catch (final Exception e) {
+ final String message = "class \"" + TestContextDateTzItem.class.getCanonicalName()
+ + "\" not compatible with class \"" + TestContextDateLocaleItem.class.getCanonicalName() + "\"";
+ assertTrue(e.getMessage().contains(message));
+ }
+
+ final TestContextDateLocaleItem tciA01 = new TestContextDateLocaleItem(tciA00);
+ final TestContextDateLocaleItem tciA02 = new TestContextDateLocaleItem(tciA00);
+ final TestContextDateLocaleItem tciA03 = new TestContextDateLocaleItem(tciA00);
+
+ final Map<String, Object> valueMap0 = new HashMap<>();
+ valueMap0.put("Item01", tciA01);
+ valueMap0.put("Item02", tciA02);
+ valueMap0.put("Item03", tciA03);
+
+ dateAlbum.putAll(valueMap0);
+ assertEquals(5, dateAlbum.size());
+ assertEquals(tciA01, dateAlbum.get("Item01"));
+ assertEquals(tciA02, dateAlbum.get("Item02"));
+ assertEquals(tciA03, dateAlbum.get("Item03"));
+
+ final Map<String, Object> valueMap1 = getMap(testDate, tciA00, tci9);
+
+ // Get another reference to the album
+ final ContextAlbum dateAlbum1 = getContextAlbum(DATE_CONTEXT_ALBUM, contextDistributor);
+
+ try {
+ dateAlbum1.putAll(valueMap1);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertTrue(e.getMessage().endsWith(
+ "not compatible with class \"" + TestContextDateLocaleItem.class.getCanonicalName() + "\""));
+ }
+ assertEquals(5, dateAlbum1.size());
+
+ valueMap1.clear();
+ valueMap1.put("Item00_2", tciA00);
+ dateAlbum1.putAll(valueMap1);
+ assertEquals(6, dateAlbum1.size());
+
+ assertEquals(tciA00, dateAlbum1.get("Item00_2"));
+ dateAlbum.remove("Item00_2");
+ assertEquals(5, dateAlbum1.size());
+
+ final ContextAlbum dateAlbumCopy = getContextAlbum(DATE_CONTEXT_ALBUM, contextDistributor);
+
+ final Map<String, Object> valueMap2 = new HashMap<>();
+ valueMap2.put("Item04", tciA01);
+ valueMap2.put("Item05", tciA02);
+ valueMap2.put("Item06", tciA03);
+
+ dateAlbumCopy.putAll(valueMap2);
+ assertEquals(8, dateAlbumCopy.size());
+
+ assertEquals(tciA03, dateAlbumCopy.get("Item06"));
+
+ final Collection<Object> mapValues = dateAlbum.values();
+ assertTrue(dateAlbumCopy.values().containsAll(mapValues));
+
+ // Check that clearing works
+ dateAlbum1.clear();
+ assertTrue(dateAlbum1.isEmpty());
+
+
+ dateAlbum.put("Item00", tciA00);
+ final Map<String, Object> valueMap3 = new HashMap<>();
+ valueMap3.put("Item01", tciA01);
+ valueMap3.put("Item02", tciA02);
+ valueMap3.put("Item03", tciA03);
+ dateAlbum.putAll(valueMap3);
+
+ final Map<String, Object> valueMap4 = new HashMap<>();
+ valueMap4.put("Item04", tciA01);
+ valueMap4.put("Item05", tciA02);
+ valueMap4.put("Item06", tciA03);
+
+ dateAlbumCopy.putAll(valueMap4);
+
+ assertContains(dateAlbum, tciA01);
+
+ final Set<Entry<String, Object>> entrySet = dateAlbum.entrySet();
+ assertEquals(7, entrySet.size());
+
+ assertAlbumGetAndPutMethods(dateAlbum, tciA03, tciA00);
+
+ // Should do removes
+ dateAlbum.remove("TestAA");
+ dateAlbum.remove("TestAB");
+ dateAlbum.remove("ItemNull");
+ assertEquals(7, entrySet.size());
+ assertTrue(dateAlbumCopy.values().containsAll(mapValues));
+ // CHECKSTYLE:ON: checkstyle:magicNumber
+ } finally {
+ contextDistributor.clear();
+ }
+ }
+
+ private void assertContains(final ContextAlbum dateAlbum, final TestContextDateLocaleItem tciA01) {
+ try {
+ dateAlbum.containsKey(null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertEquals("null values are illegal on method parameter \"key\"", e.getMessage());
+ }
+
+ assertTrue(dateAlbum.containsKey("Item05"));
+ assertTrue(!dateAlbum.containsKey("Item07"));
+
+ try {
+ dateAlbum.containsValue(null);
+ } catch (final Exception e) {
+ assertEquals("null values are illegal on method parameter \"value\"", e.getMessage());
+
+ }
+
+ assertTrue(dateAlbum.containsValue(tciA01));
+ assertTrue(!dateAlbum.containsValue("Hello"));
+ }
+
+ private void assertAlbumGetAndPutMethods(final ContextAlbum dateAlbum, final TestContextDateLocaleItem tciA03,
+ final TestContextDateLocaleItem tciA00) {
+ try {
+ dateAlbum.get(null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertEquals("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for get()", e.getMessage());
+ }
+
+ final Object aObject = dateAlbum.get("Item03");
+ assertEquals(tciA03, aObject);
+ try {
+ dateAlbum.put(null, null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertEquals("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for put()", e.getMessage());
+ }
+
+ // Put null ContextItem should work (return null)
+ try {
+ dateAlbum.put("ItemNull", null);
+ } catch (final Exception e) {
+ assertEquals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"ItemNull\" for put()",
+ e.getMessage());
+ }
+
+ // Should return null
+ assertNull(dateAlbum.get("ItemNull"));
+ // Put should return the previous contextItem
+ tciA00.setDST(false);
+ final TestContextDateLocaleItem tciA03_clone = new TestContextDateLocaleItem(tciA03);
+ tciA03_clone.setDST(true);
+ TestContextDateLocaleItem retItem = (TestContextDateLocaleItem) dateAlbum.put("Item03", tciA03_clone);
+ assertEquals(tciA03, retItem);
+ retItem = (TestContextDateLocaleItem) dateAlbum.put("Item03", tciA03);
+ assertEquals(tciA03_clone, retItem);
+
+ try {
+ dateAlbum.put("ItemNull", null);
+ fail(EXCEPTION_MESSAGE);
+
+ } catch (final Exception e) {
+ assert (e.getMessage()
+ .equals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"ItemNull\" for put()"));
+ }
+
+ dateAlbum.put("TestAA", tciA00);
+ assertEquals(tciA00, dateAlbum.get("TestAA"));
+
+ // Should print warning
+ try {
+ dateAlbum.put("TestAA", null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertEquals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAA\" for put()",
+ e.getMessage());
+ }
+ assertEquals(8, dateAlbum.size());
+ try {
+ dateAlbum.put("TestAB", null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertEquals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAB\" for put()",
+ e.getMessage());
+ }
+ assertEquals(8, dateAlbum.size());
+ }
+
+ private Map<String, Object> getMap(final Date testDate, final TestContextDateLocaleItem tciA00,
+ final TestContextDateTzItem tci9) {
+ final TestContextBooleanItem testBadItem000 = new TestContextBooleanItem();
+ final TestContextByteItem testBadItem001 = new TestContextByteItem();
+ final TestContextIntItem testBadItem002 = new TestContextIntItem();
+ final TestContextLongItem testBadItem003 = new TestContextLongItem();
+ final TestContextFloatItem testBadItem004 = new TestContextFloatItem();
+ final TestContextDoubleItem testBadItem005 = new TestContextDoubleItem();
+ final TestContextStringItem testBadItem006 = new TestContextStringItem();
+ final TestContextLongObjectItem testBadItem007 = new TestContextLongObjectItem();
+ final TestContextDateItem testBadItem008 = new TestContextDateItem();
+
+ testBadItem000.setFlag(false);
+ testBadItem001.setByteValue(BYTE_VAL);
+ testBadItem002.setIntValue(INT_VAL);
+ testBadItem003.setLongValue(LONG_VAL);
+ testBadItem004.setFloatValue(new Float(FLOAT_VAL));
+ testBadItem005.setDoubleValue(PI_VAL);
+ testBadItem006.setStringValue(STRING_GLOBAL_VAL);
+ testBadItem007.setLongValue(testDate.getTime());
+ testBadItem008.setDateValue(testDate);
+
+ final Map<String, Object> values = new HashMap<>();
+ values.put("TestBadItem000", testBadItem000);
+ values.put("TestBadItem001", testBadItem001);
+ values.put("TestBadItem002", testBadItem002);
+ values.put("TestBadItem003", testBadItem003);
+ values.put("TestBadItem004", testBadItem004);
+ values.put("TestBadItem005", testBadItem005);
+ values.put("TestBadItem006", testBadItem006);
+ values.put("TestBadItem007", testBadItem007);
+ values.put("TestBadItem008", testBadItem008);
+ values.put("TestBadItem009", tci9);
+ values.put("Item00_2", tciA00);
+ return values;
+ }
+
+ private TestContextDateTzItem getTestContextDateTzItem(final Date testDate) {
+ final TestContextDateTzItem tci9 = new TestContextDateTzItem();
+ tci9.setDateValue(new TestContextDateItem(testDate));
+ tci9.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
+ tci9.setDST(true);
+ return tci9;
+ }
+
+ private TestContextDateLocaleItem getTestContextDateLocaleItem() {
+ final TestContextDateLocaleItem tciA00 = new TestContextDateLocaleItem();
+ tciA00.setDateValue(new TestContextDateItem(new Date()));
+ tciA00.setTZValue(TIME_ZONE.getDisplayName());
+ tciA00.setDST(true);
+ tciA00.setUTCOffset(-600);
+ tciA00.setLocale(Locale.ENGLISH);
+ return tciA00;
+ }
+
+ private ContextAlbum getContextAlbum(final String albumName, final Distributor contextDistributor)
+ throws ContextException {
+ final ContextAlbum dateAlbum = contextDistributor.createContextAlbum(new AxArtifactKey(albumName, VERSION));
+ assertNotNull(dateAlbum);
+ dateAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+ return dateAlbum;
+ }
+
+ private Distributor getDistributor() throws ContextException {
+ final AxArtifactKey distributorKey = new AxArtifactKey(APEX_DISTRIBUTOR, VERSION);
+ final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
+ contextDistributor.registerModel(createMultiAlbumsContextModel());
+ return contextDistributor;
+ }
+}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java
similarity index 100%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java
similarity index 63%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java
index 64de009..3003344 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java
@@ -20,6 +20,20 @@
package org.onap.policy.apex.context.test.factory;
+import static org.onap.policy.apex.context.test.utils.Constants.DATE_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.EXTERNAL_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.GLOBAL_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.LONG_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.MAP_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.POLICY_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
+
+import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem;
+import org.onap.policy.apex.context.test.concepts.TestExternalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestGlobalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
@@ -34,6 +48,11 @@
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public final class TestContextAlbumFactory {
+
+ private static final String APPLICATION = "APPLICATION";
+ private static final String JAVA_LONG = Long.class.getCanonicalName();
+ private static final String JAVA_FLAVOUR = "Java";
+
/**
* Default constructor to prevent sub-classing.
*/
@@ -45,19 +64,19 @@
* @return the ax context model
*/
public static AxContextModel createPolicyContextModel() {
- final AxContextSchema policySchema = new AxContextSchema(new AxArtifactKey("PolicySchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestPolicyContextItem");
- final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey("PolicyContextAlbum", "0.0.1"),
- "APPLICATION", true, policySchema.getKey());
+ final AxContextSchema policySchema = new AxContextSchema(new AxArtifactKey("PolicySchema", VERSION),
+ JAVA_FLAVOUR, TestPolicyContextItem.class.getCanonicalName());
+ final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION),
+ APPLICATION, true, policySchema.getKey());
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
+ final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
schemas.getSchemasMap().put(policySchema.getKey(), policySchema);
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("PolicyContextModel", "0.0.1"), schemas, albums, keyInformation);
+ new AxContextModel(new AxArtifactKey("PolicyContextModel", VERSION), schemas, albums, keyInformation);
contextModel.setKeyInformation(keyInformation);
keyInformation.generateKeyInfo(contextModel);
@@ -70,19 +89,19 @@
* @return the ax context model
*/
public static AxContextModel createGlobalContextModel() {
- final AxContextSchema globalSchema = new AxContextSchema(new AxArtifactKey("GlobalSchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestGlobalContextItem");
- final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey("GlobalContextAlbum", "0.0.1"),
+ final AxContextSchema globalSchema = new AxContextSchema(new AxArtifactKey("GlobalSchema", VERSION),
+ JAVA_FLAVOUR, TestGlobalContextItem.class.getCanonicalName());
+ final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION),
"GLOBAL", true, globalSchema.getKey());
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
+ final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
schemas.getSchemasMap().put(globalSchema.getKey(), globalSchema);
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("GlobalContextModel", "0.0.1"), schemas, albums, keyInformation);
+ new AxContextModel(new AxArtifactKey("GlobalContextModel", VERSION), schemas, albums, keyInformation);
contextModel.setKeyInformation(keyInformation);
keyInformation.generateKeyInfo(contextModel);
@@ -95,19 +114,19 @@
* @return the ax context model
*/
public static AxContextModel createExternalContextModel() {
- final AxContextSchema externalSchema = new AxContextSchema(new AxArtifactKey("ExternalSchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestExternalContextItem");
- final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey("ExternalContextAlbum", "0.0.1"),
+ final AxContextSchema externalSchema = new AxContextSchema(new AxArtifactKey("ExternalSchema", VERSION),
+ JAVA_FLAVOUR, TestExternalContextItem.class.getCanonicalName());
+ final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(EXTERNAL_CONTEXT_ALBUM, VERSION),
"EXTERNAL", true, externalSchema.getKey());
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
+ final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
schemas.getSchemasMap().put(externalSchema.getKey(), externalSchema);
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("ExternalContextModel", "0.0.1"), schemas, albums, keyInformation);
+ new AxContextModel(new AxArtifactKey("ExternalContextModel", VERSION), schemas, albums, keyInformation);
contextModel.setKeyInformation(keyInformation);
keyInformation.generateKeyInfo(contextModel);
@@ -120,22 +139,26 @@
* @return the ax context model
*/
public static AxContextModel createLongContextModel() {
- final AxContextSchema longSchema =
- new AxContextSchema(new AxArtifactKey("LongSchema", "0.0.1"), "Java", "java.lang.Long");
- final AxContextAlbum albumDefinition1 = new AxContextAlbum(new AxArtifactKey("LongContextAlbum1", "0.0.1"),
- "APPLICATION", true, longSchema.getKey());
- final AxContextAlbum albumDefinition2 = new AxContextAlbum(new AxArtifactKey("LongContextAlbum2", "0.0.1"),
- "APPLICATION", true, longSchema.getKey());
+ final AxArtifactKey longSchemaKey = new AxArtifactKey("LongSchema", VERSION);
+ final AxContextSchema longSchema = new AxContextSchema(longSchemaKey, JAVA_FLAVOUR, JAVA_LONG);
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
+ final AxArtifactKey longContextAlbumKey = new AxArtifactKey("LongContextAlbum1", VERSION);
+ final AxContextAlbum albumDefinition1 =
+ new AxContextAlbum(longContextAlbumKey, APPLICATION, true, longSchema.getKey());
+
+ final AxArtifactKey longContextAlbumKey2 = new AxArtifactKey("LongContextAlbum2", VERSION);
+ final AxContextAlbum albumDefinition2 =
+ new AxContextAlbum(longContextAlbumKey2, APPLICATION, true, longSchema.getKey());
+
+ final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
albums.getAlbumsMap().put(albumDefinition1.getKey(), albumDefinition1);
albums.getAlbumsMap().put(albumDefinition2.getKey(), albumDefinition2);
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("LongContextModel", "0.0.1"), schemas, albums, keyInformation);
+ new AxContextModel(new AxArtifactKey("LongContextModel", VERSION), schemas, albums, keyInformation);
contextModel.setKeyInformation(keyInformation);
keyInformation.generateKeyInfo(contextModel);
@@ -149,41 +172,42 @@
*/
public static AxContextModel createMultiAlbumsContextModel() {
final AxContextSchema longSchema =
- new AxContextSchema(new AxArtifactKey("LongSchema", "0.0.1"), "Java", "java.lang.Long");
- final AxContextSchema lTypeSchema = new AxContextSchema(new AxArtifactKey("LTypeSchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestContextItem003");
- final AxContextSchema dateSchema = new AxContextSchema(new AxArtifactKey("DateSchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestContextItem00A");
- final AxContextSchema mapSchema = new AxContextSchema(new AxArtifactKey("MapSchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestContextItem00C");
+ new AxContextSchema(new AxArtifactKey("LongSchema", VERSION), JAVA_FLAVOUR, JAVA_LONG);
+ final AxContextSchema lTypeSchema = new AxContextSchema(new AxArtifactKey("LTypeSchema", VERSION), JAVA_FLAVOUR,
+ TestContextLongItem.class.getCanonicalName());
+ final AxContextSchema dateSchema = new AxContextSchema(new AxArtifactKey("DateSchema", VERSION), JAVA_FLAVOUR,
+ TestContextDateLocaleItem.class.getCanonicalName());
+ final AxContextSchema mapSchema = new AxContextSchema(new AxArtifactKey("MapSchema", VERSION), JAVA_FLAVOUR,
+ TestContextTreeMapItem.class.getCanonicalName());
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
+ final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
schemas.getSchemasMap().put(lTypeSchema.getKey(), lTypeSchema);
schemas.getSchemasMap().put(dateSchema.getKey(), dateSchema);
schemas.getSchemasMap().put(mapSchema.getKey(), mapSchema);
- final AxContextAlbum longAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LongContextAlbum", "0.0.1"),
- "APPLICATION", true, longSchema.getKey());
- final AxContextAlbum lTypeAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LTypeContextAlbum", "0.0.1"),
- "APPLICATION", true, lTypeSchema.getKey());
- final AxContextAlbum dateAlbumDefinition = new AxContextAlbum(new AxArtifactKey("DateContextAlbum", "0.0.1"),
- "APPLICATION", true, dateSchema.getKey());
- final AxContextAlbum mapAlbumDefinition = new AxContextAlbum(new AxArtifactKey("MapContextAlbum", "0.0.1"),
- "APPLICATION", true, mapSchema.getKey());
+ final AxContextAlbum longAlbumDefinition = new AxContextAlbum(new AxArtifactKey(LONG_CONTEXT_ALBUM, VERSION),
+ APPLICATION, true, longSchema.getKey());
+ final AxContextAlbum lTypeAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LTypeContextAlbum", VERSION),
+ APPLICATION, true, lTypeSchema.getKey());
+ final AxContextAlbum dateAlbumDefinition = new AxContextAlbum(new AxArtifactKey(DATE_CONTEXT_ALBUM, VERSION),
+ APPLICATION, true, dateSchema.getKey());
+ final AxContextAlbum mapAlbumDefinition = new AxContextAlbum(new AxArtifactKey(MAP_CONTEXT_ALBUM, VERSION),
+ APPLICATION, true, mapSchema.getKey());
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
albums.getAlbumsMap().put(longAlbumDefinition.getKey(), longAlbumDefinition);
albums.getAlbumsMap().put(lTypeAlbumDefinition.getKey(), lTypeAlbumDefinition);
albums.getAlbumsMap().put(dateAlbumDefinition.getKey(), dateAlbumDefinition);
albums.getAlbumsMap().put(mapAlbumDefinition.getKey(), mapAlbumDefinition);
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
- final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("MultiAlbumsContextModel", "0.0.1"),
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
+ final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("MultiAlbumsContextModel", VERSION),
schemas, albums, keyInformation);
contextModel.setKeyInformation(keyInformation);
keyInformation.generateKeyInfo(contextModel);
return contextModel;
}
+
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java
similarity index 100%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
similarity index 79%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
index 35db5dd..2eea957 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
@@ -26,7 +26,7 @@
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -141,28 +141,28 @@
lTypeAlbum.setUserArtifactStack(usedArtifactStackArray);
// CHECKSTYLE:OFF: checkstyle:magicNumber
- lTypeAlbum.put("lTypeValue0", new TestContextItem003(0xFFFFFFFFFFFFFFFFL));
- lTypeAlbum.put("lTypeValue1", new TestContextItem003(0xFFFFFFFFFFFFFFFEL));
- lTypeAlbum.put("lTypeValue2", new TestContextItem003(0xFFFFFFFFFFFFFFFDL));
- lTypeAlbum.put("lTypeValue3", new TestContextItem003(0xFFFFFFFFFFFFFFFCL));
- lTypeAlbum.put("lTypeValue4", new TestContextItem003(0xFFFFFFFFFFFFFFFBL));
- lTypeAlbum.put("lTypeValue5", new TestContextItem003(0xFFFFFFFFFFFFFFFAL));
- lTypeAlbum.put("lTypeValue6", new TestContextItem003(0xFFFFFFFFFFFFFFF9L));
- lTypeAlbum.put("lTypeValue7", new TestContextItem003(0xFFFFFFFFFFFFFFF8L));
- lTypeAlbum.put("lTypeValue8", new TestContextItem003(0xFFFFFFFFFFFFFFF7L));
- lTypeAlbum.put("lTypeValue9", new TestContextItem003(0xFFFFFFFFFFFFFFF6L));
- lTypeAlbum.put("lTypeValueA", new TestContextItem003(0xFFFFFFFFFFFFFFF5L));
- lTypeAlbum.put("lTypeValueB", new TestContextItem003(0xFFFFFFFFFFFFFFF4L));
- lTypeAlbum.put("lTypeValueC", new TestContextItem003(0xFFFFFFFFFFFFFFF3L));
- lTypeAlbum.put("lTypeValueD", new TestContextItem003(0xFFFFFFFFFFFFFFF2L));
- lTypeAlbum.put("lTypeValueE", new TestContextItem003(0xFFFFFFFFFFFFFFF1L));
- lTypeAlbum.put("lTypeValueF", new TestContextItem003(0xFFFFFFFFFFFFFFF0L));
+ lTypeAlbum.put("lTypeValue0", new TestContextLongItem(0xFFFFFFFFFFFFFFFFL));
+ lTypeAlbum.put("lTypeValue1", new TestContextLongItem(0xFFFFFFFFFFFFFFFEL));
+ lTypeAlbum.put("lTypeValue2", new TestContextLongItem(0xFFFFFFFFFFFFFFFDL));
+ lTypeAlbum.put("lTypeValue3", new TestContextLongItem(0xFFFFFFFFFFFFFFFCL));
+ lTypeAlbum.put("lTypeValue4", new TestContextLongItem(0xFFFFFFFFFFFFFFFBL));
+ lTypeAlbum.put("lTypeValue5", new TestContextLongItem(0xFFFFFFFFFFFFFFFAL));
+ lTypeAlbum.put("lTypeValue6", new TestContextLongItem(0xFFFFFFFFFFFFFFF9L));
+ lTypeAlbum.put("lTypeValue7", new TestContextLongItem(0xFFFFFFFFFFFFFFF8L));
+ lTypeAlbum.put("lTypeValue8", new TestContextLongItem(0xFFFFFFFFFFFFFFF7L));
+ lTypeAlbum.put("lTypeValue9", new TestContextLongItem(0xFFFFFFFFFFFFFFF6L));
+ lTypeAlbum.put("lTypeValueA", new TestContextLongItem(0xFFFFFFFFFFFFFFF5L));
+ lTypeAlbum.put("lTypeValueB", new TestContextLongItem(0xFFFFFFFFFFFFFFF4L));
+ lTypeAlbum.put("lTypeValueC", new TestContextLongItem(0xFFFFFFFFFFFFFFF3L));
+ lTypeAlbum.put("lTypeValueD", new TestContextLongItem(0xFFFFFFFFFFFFFFF2L));
+ lTypeAlbum.put("lTypeValueE", new TestContextLongItem(0xFFFFFFFFFFFFFFF1L));
+ lTypeAlbum.put("lTypeValueF", new TestContextLongItem(0xFFFFFFFFFFFFFFF0L));
LOGGER.debug(lTypeAlbum.toString());
assert (lTypeAlbum.size() >= 16);
// CHECKSTYLE:ON: checkstyle:magicNumber
// The initial value for concurrent testing
- final TestContextItem003 item = new TestContextItem003(0L);
+ final TestContextLongItem item = new TestContextLongItem(0L);
lTypeAlbum.put("testValue", item);
}
@@ -180,11 +180,11 @@
throws ContextException {
try {
LOGGER.debug("threads finished, end value is {}",
- ((TestContextItem003) lTypeAlbum.get("testValue")).getLongValue());
+ ((TestContextLongItem) lTypeAlbum.get("testValue")).getLongValue());
} catch (final Exception exception) {
LOGGER.error("Error: ", exception);
}
- final long total = ((TestContextItem003) lTypeAlbum.get("testValue")).getLongValue();
+ final long total = ((TestContextLongItem) lTypeAlbum.get("testValue")).getLongValue();
contextDistributor.clear();
contextDistributor = null;
diff --git a/context/context-test/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
similarity index 100%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
diff --git a/context/context-test/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
similarity index 97%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
index 020eed8..da2741f 100644
--- a/context/context-test/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
@@ -79,7 +79,7 @@
+ System.getProperty("file.separator") + "java");
commandList.add("-cp");
commandList.add(System.getProperty("java.class.path"));
- commandList.add("org.onap.policy.apex.context.test.locking.ConcurrentContextJVM");
+ commandList.add(ConcurrentContextJVM.class.getCanonicalName());
commandList.add(testType);
commandList.add(new Integer(jvm).toString());
commandList.add(new Integer(threadCount).toString());
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
similarity index 94%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
index 42e3e09..554c3d0 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
@@ -25,7 +25,7 @@
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -109,7 +109,7 @@
try {
lTypeAlbum.lockForWriting("testValue");
- final TestContextItem003 item = (TestContextItem003) lTypeAlbum.get("testValue");
+ final TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get("testValue");
final long value = item.getLongValue();
LOGGER.info("completed TestConcurrentContextThread_" + jvm + "_" + instance + ", value=" + value);
} catch (final Exception e) {
@@ -130,12 +130,12 @@
for (int i = 0; i < threadLoops; i++) {
try {
lTypeAlbum.lockForWriting("testValue");
- TestContextItem003 item = (TestContextItem003) lTypeAlbum.get("testValue");
+ TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get("testValue");
if (item != null) {
long value = item.getLongValue();
item.setLongValue(++value);
} else {
- item = new TestContextItem003(0L);
+ item = new TestContextLongItem(0L);
}
lTypeAlbum.put("testValue", item);
} finally {
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java
similarity index 100%
rename from context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java
rename to context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java
new file mode 100644
index 0000000..90e586e
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java
@@ -0,0 +1,59 @@
+/*-
+ * ============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.test.utils;
+
+import java.util.TimeZone;
+
+import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+public class Constants {
+ public static final String MAP_CONTEXT_ALBUM = "MapContextAlbum";
+ public static final String LONG_CONTEXT_ALBUM = "LongContextAlbum";
+ public static final String DATE_CONTEXT_ALBUM = "DateContextAlbum";
+
+ public static final String EXTERNAL_CONTEXT_ALBUM = "ExternalContextAlbum";
+ public static final String GLOBAL_CONTEXT_ALBUM = "GlobalContextAlbum";
+ public static final String POLICY_CONTEXT_ALBUM = "PolicyContextAlbum";
+
+ public static final String APEX_DISTRIBUTOR = "ApexDistributor";
+ public static final String VERSION = "0.0.1";
+ public static final int INT_VAL = 0xFFFFFFFF;
+ public static final int INT_VAL_2 = 2000;
+ public static final int INT_VAL_3 = -1;
+ public static final String EXCEPTION_MESSAGE = "Test should throw an exception";
+ public static final byte BYTE_VAL = (byte) 0xFF;
+ public static final double PI_VAL = Math.PI;
+ public static final float FLOAT_VAL = 3.14159265359f;
+ public static final String EXTERNAL_CONTEXT = "externalContext";
+ public static final String GLOBAL_CONTEXT_KEY = "globalContext";
+ public static final String STRING_GLOBAL_VAL = "This is a global context string";
+ public static final String STRING_VAL = "This is a policy context string";
+ public static final String STRING_EXT_VAL = "This is an external context string";
+ public static final long LONG_VAL = 0xFFFFFFFFFFFFFFFFL;
+ public static final String TEST_POLICY_CONTEXT_ITEM = TestPolicyContextItem.class.getName();
+ public static final TimeZone TIME_ZONE = TimeZone.getTimeZone("Europe/Dublin");
+
+ public static final AxArtifactKey[] USED_ARTIFACT_STACK_ARRAY = {new AxArtifactKey("testC-top", VERSION),
+ new AxArtifactKey("testC-next", VERSION), new AxArtifactKey("testC-bot", VERSION)};
+
+ private Constants() {}
+
+}
diff --git a/context/context-test/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
similarity index 92%
rename from context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
rename to context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
index 7d5693d..105b59e 100644
--- a/context/context-test/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
@@ -25,6 +25,7 @@
import org.junit.After;
import org.junit.Test;
+import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -40,8 +41,7 @@
logger.debug("Running testContextAlbumUpdateJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor");
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextAlbumUpdate().testContextAlbumUpdate();
logger.debug("Ran testContextAlbumUpdateJVMLocalVarSet test");
diff --git a/context/context-test/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
similarity index 92%
rename from context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
rename to context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
index f640b33..565a39f 100644
--- a/context/context-test/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
@@ -26,6 +26,7 @@
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.parameters.ContextParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -55,8 +56,7 @@
logger.debug("Running testContextInstantiationJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor");
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextInstantiation().testContextInstantiation();
logger.debug("Ran testContextInstantiationJVMLocalVarSet test");
diff --git a/context/context-test/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
similarity index 91%
rename from context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
rename to context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
index d140b0d..1a9bc29 100644
--- a/context/context-test/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
@@ -23,6 +23,7 @@
import java.io.IOException;
import org.junit.Test;
+import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -43,8 +44,7 @@
logger.debug("Running testContextUpdateJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor");
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextUpdate().testContextUpdate();
logger.debug("Ran testContextUpdateJVMLocalVarSet test");
diff --git a/context/context-test/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
similarity index 92%
rename from context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
rename to context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
index 2798759..28bd7eb 100644
--- a/context/context-test/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
@@ -26,6 +26,7 @@
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.parameters.ContextParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -53,8 +54,7 @@
logger.debug("Running testSequentialContextInstantiationJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor");
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new SequentialContextInstantiation().testSequentialContextInstantiation();
logger.debug("Ran testSequentialContextInstantiationJVMLocalVarSet test");
diff --git a/context/context-test/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
similarity index 88%
rename from context/context-test/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
rename to context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
index 0f6626f..7788fb4 100644
--- a/context/context-test/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
@@ -26,6 +26,8 @@
import java.io.IOException;
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.parameters.ContextParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -53,8 +55,7 @@
logger.debug("Running testConcurrentContextJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getLockManagerParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager");
+ contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
final long result = new ConcurrentContext().testConcurrentContext("JVMLocalVarSet", TEST_JVM_COUNT_SINGLE_JVM,
TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
@@ -81,10 +82,8 @@
logger.debug("Running testConcurrentContextMultiJVMNoLock test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor");
- contextParameters.getLockManagerParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager");
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
+ contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
final long result = new ConcurrentContext().testConcurrentContext("testConcurrentContextMultiJVMNoLock",
TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
diff --git a/context/context-test/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
similarity index 79%
rename from context/context-test/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
rename to context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
index db1ac47..a059285 100644
--- a/context/context-test/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
@@ -40,10 +40,10 @@
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.context.parameters.PersistorParameters;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
-import org.onap.policy.apex.context.test.concepts.TestContextItem008;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00A;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00C;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+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.TestContextTreeMapItem;
import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -61,7 +61,8 @@
*/
public class TestPersistentContextInstantiation {
// Logger for this class
- // private static final XLogger logger = XLoggerFactory.getXLogger(TestPersistentContextInstantiation.class);
+ // private static final XLogger logger =
+ // XLoggerFactory.getXLogger(TestPersistentContextInstantiation.class);
private Connection connection;
@@ -89,8 +90,8 @@
final AxArtifactKey distributorKey = new AxArtifactKey("AbstractDistributor", "0.0.1");
final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
- final AxArtifactKey[] usedArtifactStackArray = { new AxArtifactKey("testC-top", "0.0.1"),
- new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1") };
+ final AxArtifactKey[] usedArtifactStackArray = {new AxArtifactKey("testC-top", "0.0.1"),
+ new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1")};
final DAOParameters daoParameters = new DAOParameters();
daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
@@ -113,11 +114,11 @@
testMap.put("key", "This is a policy context string");
final Map<String, Object> valueMap0 = new HashMap<String, Object>();
- valueMap0.put("TestPolicyContextItem000", new TestContextItem00C(testMap));
+ valueMap0.put("TestPolicyContextItem000", new TestContextTreeMapItem(testMap));
contextAlbumForMap.putAll(valueMap0);
- assertEquals(((TestContextItem00C) contextAlbumForMap.get("TestPolicyContextItem000")).getMapValue().get("key"),
+ assertEquals(((TestContextTreeMapItem) contextAlbumForMap.get("TestPolicyContextItem000")).getMapValue().get("key"),
"This is a policy context string");
contextAlbumForMap.flush();
@@ -131,8 +132,8 @@
assertNotNull(contextAlbumForDate);
contextAlbumForDate.setUserArtifactStack(usedArtifactStackArray);
- final TestContextItem008 testDate = new TestContextItem008(new Date());
- final TestContextItem00A tci00A = new TestContextItem00A();
+ final TestContextDateItem testDate = new TestContextDateItem(new Date());
+ final TestContextDateLocaleItem tci00A = new TestContextDateLocaleItem();
tci00A.setDateValue(testDate);
tci00A.setTZValue(TimeZone.getTimeZone("Europe/Dublin").toString());
tci00A.setDST(true);
@@ -142,9 +143,9 @@
contextAlbumForDate.putAll(valueMap1);
- assertEquals(((TestContextItem00A) contextAlbumForDate.get("TestPolicyContextItem00A")).getDateValue(),
+ assertEquals(((TestContextDateLocaleItem) contextAlbumForDate.get("TestPolicyContextItem00A")).getDateValue(),
testDate);
- assertEquals(((TestContextItem00A) contextAlbumForDate.get("TestPolicyContextItem00A")).getDST(), true);
+ assertEquals(((TestContextDateLocaleItem) contextAlbumForDate.get("TestPolicyContextItem00A")).getDST(), true);
contextAlbumForDate.flush();
@@ -158,23 +159,23 @@
contextAlbumForLong.setUserArtifactStack(usedArtifactStackArray);
final Map<String, Object> valueMap2 = new HashMap<String, Object>();
- valueMap2.put("TestPolicyContextItem0031", new TestContextItem003(0xFFFFFFFFFFFFFFFFL));
- valueMap2.put("TestPolicyContextItem0032", new TestContextItem003(0xFFFFFFFFFFFFFFFEL));
- valueMap2.put("TestPolicyContextItem0033", new TestContextItem003(0xFFFFFFFFFFFFFFFDL));
- valueMap2.put("TestPolicyContextItem0034", new TestContextItem003(0xFFFFFFFFFFFFFFFCL));
- valueMap2.put("TestPolicyContextItem0035", new TestContextItem003(0xFFFFFFFFFFFFFFFBL));
+ valueMap2.put("TestPolicyContextItem0031", new TestContextLongItem(0xFFFFFFFFFFFFFFFFL));
+ valueMap2.put("TestPolicyContextItem0032", new TestContextLongItem(0xFFFFFFFFFFFFFFFEL));
+ valueMap2.put("TestPolicyContextItem0033", new TestContextLongItem(0xFFFFFFFFFFFFFFFDL));
+ valueMap2.put("TestPolicyContextItem0034", new TestContextLongItem(0xFFFFFFFFFFFFFFFCL));
+ valueMap2.put("TestPolicyContextItem0035", new TestContextLongItem(0xFFFFFFFFFFFFFFFBL));
contextAlbumForLong.putAll(valueMap2);
- assertEquals(((TestContextItem003) contextAlbumForLong.get("TestPolicyContextItem0031")).getLongValue(),
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0031")).getLongValue(),
0xFFFFFFFFFFFFFFFFL);
- assertEquals(((TestContextItem003) contextAlbumForLong.get("TestPolicyContextItem0032")).getLongValue(),
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0032")).getLongValue(),
0xFFFFFFFFFFFFFFFEL);
- assertEquals(((TestContextItem003) contextAlbumForLong.get("TestPolicyContextItem0033")).getLongValue(),
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0033")).getLongValue(),
0xFFFFFFFFFFFFFFFDL);
- assertEquals(((TestContextItem003) contextAlbumForLong.get("TestPolicyContextItem0034")).getLongValue(),
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0034")).getLongValue(),
0xFFFFFFFFFFFFFFFCL);
- assertEquals(((TestContextItem003) contextAlbumForLong.get("TestPolicyContextItem0035")).getLongValue(),
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0035")).getLongValue(),
0xFFFFFFFFFFFFFFFBL);
contextAlbumForLong.flush();
diff --git a/context/context-test/src/test/resources/META-INF/persistence.xml b/context/context-test-utils/src/test/resources/META-INF/persistence.xml
similarity index 100%
rename from context/context-test/src/test/resources/META-INF/persistence.xml
rename to context/context-test-utils/src/test/resources/META-INF/persistence.xml
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java b/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
deleted file mode 100644
index 4b47c63..0000000
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.distribution;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TimeZone;
-import java.util.TreeSet;
-
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.context.ContextRuntimeException;
-import org.onap.policy.apex.context.Distributor;
-import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
-import org.onap.policy.apex.context.test.concepts.TestContextItem000;
-import org.onap.policy.apex.context.test.concepts.TestContextItem001;
-import org.onap.policy.apex.context.test.concepts.TestContextItem002;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
-import org.onap.policy.apex.context.test.concepts.TestContextItem004;
-import org.onap.policy.apex.context.test.concepts.TestContextItem005;
-import org.onap.policy.apex.context.test.concepts.TestContextItem006;
-import org.onap.policy.apex.context.test.concepts.TestContextItem007;
-import org.onap.policy.apex.context.test.concepts.TestContextItem008;
-import org.onap.policy.apex.context.test.concepts.TestContextItem009;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00A;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00B;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00C;
-import org.onap.policy.apex.context.test.concepts.TestExternalContextItem;
-import org.onap.policy.apex.context.test.concepts.TestGlobalContextItem;
-import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
-import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestContextInstantiation is used to test Apex context insitiation is correct.
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class ContextInstantiation {
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextInstantiation.class);
-
- /**
- * Test context instantiation.
- *
- * @throws ContextException the context exception
- */
- // CHECKSTYLE:OFF: checkstyle:MaximumMethodLength
- public void testContextInstantiation() throws ContextException {
- // CHECKSTYLE:ON: checkstyle:MaximumMethodLength
- LOGGER.debug("Running TestContextInstantiation test . . .");
-
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributorInit", "0.0.1");
- Distributor contextDistributor = null;
- try {
- contextDistributor = new DistributorFactory().getDistributor(distributorKey);
- } catch (final Exception exception) {
- LOGGER.error("Error occured while Instantiating Distributor for : {}", distributorKey, exception);
- return;
- }
-
- // @formatter:off
- final AxArtifactKey[] usedArtifactStackArray = {
- new AxArtifactKey("testC-top", "0.0.1"), new AxArtifactKey("testC-next", "0.0.1"),
- new AxArtifactKey("testC-bot", "0.0.1")
- };
- // @formatter:on
-
- try {
- // CHECKSTYLE:OFF: checkstyle:magicNumber
- final AxContextModel policyContextModel = TestContextAlbumFactory.createPolicyContextModel();
- final AxValidationResult result = new AxValidationResult();
- policyContextModel.validate(result);
- LOGGER.debug(result.toString());
- assert (result.isValid());
-
- contextDistributor.registerModel(policyContextModel);
-
- final ContextAlbum policyContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("PolicyContextAlbum", "0.0.1"));
- assert (policyContextAlbum != null);
- policyContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- final Float testFloat = new Float(3.14159265359);
- final Date testDate = new Date();
-
- final TestContextItem009 tci9 = new TestContextItem009();
- tci9.setDateValue(new TestContextItem008(testDate));
- tci9.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
- tci9.setDST(true);
-
- final TestContextItem00A tciA = new TestContextItem00A();
- tciA.setDateValue(new TestContextItem008(testDate));
- tciA.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
- tciA.setDST(true);
- tciA.setUTCOffset(-600);
- tciA.setLocale(Locale.ENGLISH);
-
- final TreeSet<String> testTreeSet = new TreeSet<>();
- testTreeSet.add("one hundred");
- testTreeSet.add("one hundred and one");
- testTreeSet.add("one hundred and two");
- testTreeSet.add("one hundred and three");
- testTreeSet.add("one hundred and four");
-
- final Map<String, String> testHashMap = new HashMap<>();
- testHashMap.put("0", "zero");
- testHashMap.put("1", "one");
- testHashMap.put("2", "two");
- testHashMap.put("3", "three");
- testHashMap.put("4", "four");
-
- final TestContextItem006 testPolicyContextItem000 =
- new TestContextItem006("This is a policy context string");
- final TestContextItem003 testPolicyContextItem001 = new TestContextItem003(0xFFFFFFFFFFFFFFFFL);
- final TestContextItem005 testPolicyContextItem002 = new TestContextItem005(Math.PI);
- final TestContextItem000 testPolicyContextItem003 = new TestContextItem000(true);
- final TestContextItem003 testPolicyContextItem004 = new TestContextItem003(testDate.getTime());
- final TestContextItem00C testPolicyContextItem005 = new TestContextItem00C(testHashMap);
-
- final Map<String, Object> valueMapA = new LinkedHashMap<>();
- valueMapA.put("TestPolicyContextItem001", testPolicyContextItem001);
- valueMapA.put("TestPolicyContextItem002", testPolicyContextItem002);
- valueMapA.put("TestPolicyContextItem003", testPolicyContextItem003);
- valueMapA.put("TestPolicyContextItem004", testPolicyContextItem004);
- valueMapA.put("TestPolicyContextItem005", testPolicyContextItem005);
- valueMapA.put("TestPolicyContextItem000", testPolicyContextItem000);
-
- try {
- policyContextAlbum.put("TestPolicyContextItem000", testPolicyContextItem000);
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("Failed to set context value for key \"TestPolicyContextItem000\" in album \"PolicyContextAlbum:0.0.1\": "
- + "PolicyContextAlbum:0.0.1: object \"TestContextItem006 [stringValue=This is a policy context string]\" "
- + "of class \"org.onap.policy.apex.context.test.concepts.TestContextItem006\""
- + " not compatible with class \"org.onap.policy.apex.context.test.concepts.TestPolicyContextItem\""));
- }
-
- try {
- policyContextAlbum.putAll(valueMapA);
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("Failed to set context value for key \"TestPolicyContextItem001\" in album \"PolicyContextAlbum:0.0.1\": "
- + "PolicyContextAlbum:0.0.1: object \"TestContextItem003 [longValue=-1]\" "
- + "of class \"org.onap.policy.apex.context.test.concepts.TestContextItem003\""
- + " not compatible with class \"org.onap.policy.apex.context.test.concepts.TestPolicyContextItem\""));
- }
-
- final TestPolicyContextItem policyContext = new TestPolicyContextItem();
-
- LOGGER.debug(policyContextAlbum.toString());
-
- policyContext.setTestPolicyContextItem000(testPolicyContextItem000);
- policyContext.setTestPolicyContextItem001(testPolicyContextItem001);
- policyContext.setTestPolicyContextItem002(testPolicyContextItem002);
- policyContext.setTestPolicyContextItem003(testPolicyContextItem003);
- policyContext.setTestPolicyContextItem004(testPolicyContextItem004);
- policyContext.setTestPolicyContextItem005(testPolicyContextItem005);
-
- final Map<String, Object> valueMap0 = new HashMap<>();
- valueMap0.put("TestPolicyContextItem", policyContext);
-
- policyContextAlbum.putAll(valueMap0);
-
- final TestPolicyContextItem contextItem =
- (TestPolicyContextItem) policyContextAlbum.get("TestPolicyContextItem");
- assert (contextItem.getTestPolicyContextItem000().getStringValue()
- .equals("This is a policy context string"));
- assert (contextItem.getTestPolicyContextItem001().getLongValue() == 0xFFFFFFFFFFFFFFFFL);
- assert (Double.compare(contextItem.getTestPolicyContextItem002().getDoubleValue(), Math.PI) == 0);
- assert (contextItem.getTestPolicyContextItem003().getFlag());
- assert (contextItem.getTestPolicyContextItem004().getLongValue() == testDate.getTime());
- assert (contextItem.getTestPolicyContextItem005().getMapValue().equals(testHashMap));
-
- final AxContextModel globalContextModel = TestContextAlbumFactory.createGlobalContextModel();
-
- final TestContextItem000 testGlobalContextItem000 = new TestContextItem000(false);
- final TestContextItem001 testGlobalContextItem001 = new TestContextItem001((byte) 0xFF);
- final TestContextItem002 testGlobalContextItem002 = new TestContextItem002(0xFFFFFFFF);
- final TestContextItem003 testGlobalContextItem003 = new TestContextItem003(0xFFFFFFFFFFFFFFFFL);
- final TestContextItem004 testGlobalContextItem004 = new TestContextItem004(testFloat);
- final TestContextItem005 testGlobalContextItem005 = new TestContextItem005(Math.PI);
- final TestContextItem006 testGlobalContextItem006 =
- new TestContextItem006("This is a global context string");
- final TestContextItem007 testGlobalContextItem007 = new TestContextItem007(testDate.getTime());
- final TestContextItem008 testGlobalContextItem008 = new TestContextItem008(testDate);
- final TestContextItem00B testGlobalContextItem00B = new TestContextItem00B(testTreeSet);
- final TestContextItem00C testGlobalContextItem00C = new TestContextItem00C(testHashMap);
-
- final TestGlobalContextItem globalContext = new TestGlobalContextItem();
-
- globalContext.setTestGlobalContextItem000(testGlobalContextItem000);
- globalContext.setTestGlobalContextItem001(testGlobalContextItem001);
- globalContext.setTestGlobalContextItem002(testGlobalContextItem002);
- globalContext.setTestGlobalContextItem003(testGlobalContextItem003);
- globalContext.setTestGlobalContextItem004(testGlobalContextItem004);
- globalContext.setTestGlobalContextItem005(testGlobalContextItem005);
- globalContext.setTestGlobalContextItem006(testGlobalContextItem006);
- globalContext.setTestGlobalContextItem007(testGlobalContextItem007);
- globalContext.setTestGlobalContextItem008(testGlobalContextItem008);
- globalContext.setTestGlobalContextItem009(tci9);
- globalContext.setTestGlobalContextItem00A(tciA);
- globalContext.setTestGlobalContextItem00B(testGlobalContextItem00B);
- globalContext.setTestGlobalContextItem00C(testGlobalContextItem00C);
- final Map<String, Object> valueMap1 = new HashMap<>();
- valueMap1.put("globalContext", globalContext);
-
- try {
- contextDistributor.registerModel(globalContextModel);
- } catch (final ContextException e) {
- assert (e.getMessage().equals(
- "active context albums found in distributor, clear the distributor before registering models"));
- }
-
- contextDistributor.registerModel(globalContextModel);
-
- final ContextAlbum globalContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("GlobalContextAlbum", "0.0.1"));
- assert (globalContextAlbum != null);
- globalContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- globalContextAlbum.putAll(valueMap1);
-
- final TestGlobalContextItem globalContextItem =
- (TestGlobalContextItem) globalContextAlbum.get("globalContext");
- assert (!globalContextItem.getTestGlobalContextItem000().getFlag());
- assert (globalContextItem.getTestGlobalContextItem001().getByteValue() == (byte) 0xFF);
- assert (globalContextItem.getTestGlobalContextItem002().getIntValue() == 0xFFFFFFFF);
- assert (globalContextItem.getTestGlobalContextItem003().getLongValue() == 0xFFFFFFFFFFFFFFFFL);
- assert (Float.compare(globalContextItem.getTestGlobalContextItem004().getFloatValue(), testFloat) == 0);
- assert (Double.compare(globalContextItem.getTestGlobalContextItem005().getDoubleValue(), Math.PI) == 0);
- assert (globalContextItem.getTestGlobalContextItem006().getStringValue()
- .equals("This is a global context string"));
- assert (globalContextItem.getTestGlobalContextItem007().getLongValue() == testDate.getTime());
- assert (globalContextItem.getTestGlobalContextItem008().getDateValue().equals(testDate));
- assert (globalContextItem.getTestGlobalContextItem009().getDateValue().getTime() == tci9.getDateValue()
- .getTime());
- assert (globalContextItem.getTestGlobalContextItem00A().getDateValue().getTime() == tciA.getDateValue()
- .getTime());
- assert (globalContextItem.getTestGlobalContextItem00B().getSetValue().equals(testTreeSet));
- assert (globalContextItem.getTestGlobalContextItem00C().getMapValue().equals(testHashMap));
-
- final AxContextModel externalContextModel = TestContextAlbumFactory.createExternalContextModel();
-
- final TestExternalContextItem externalContext = new TestExternalContextItem();
-
- final TestContextItem000 testExternalContextItem000 = new TestContextItem000(false);
- final TestContextItem001 testExternalContextItem001 = new TestContextItem001((byte) 0xFF);
- final TestContextItem002 testExternalContextItem002 = new TestContextItem002(0xFFFFFFFF);
- final TestContextItem003 testExternalContextItem003 = new TestContextItem003(0xFFFFFFFFFFFFFFFFL);
- final TestContextItem004 testExternalContextItem004 = new TestContextItem004(testFloat);
- final TestContextItem005 testExternalContextItem005 = new TestContextItem005(Math.PI);
- final TestContextItem006 testExternalContextItem006 =
- new TestContextItem006("This is an external context string");
- final TestContextItem007 testExternalContextItem007 = new TestContextItem007(testDate.getTime());
- final TestContextItem008 testExternalContextItem008 = new TestContextItem008(testDate);
- final TestContextItem00B testExternalContextItem00B = new TestContextItem00B(testTreeSet);
- final TestContextItem00C testExternalContextItem00C = new TestContextItem00C(testHashMap);
-
- final TestContextItem009 tci9A = new TestContextItem009(tci9);
- final TestContextItem00A tciAA = new TestContextItem00A(tciA);
-
- externalContext.setTestExternalContextItem000(testExternalContextItem000);
- externalContext.setTestExternalContextItem001(testExternalContextItem001);
- externalContext.setTestExternalContextItem002(testExternalContextItem002);
- externalContext.setTestExternalContextItem003(testExternalContextItem003);
- externalContext.setTestExternalContextItem004(testExternalContextItem004);
- externalContext.setTestExternalContextItem005(testExternalContextItem005);
- externalContext.setTestExternalContextItem006(testExternalContextItem006);
- externalContext.setTestExternalContextItem007(testExternalContextItem007);
- externalContext.setTestExternalContextItem008(testExternalContextItem008);
- externalContext.setTestExternalContextItem009(tci9A);
- externalContext.setTestExternalContextItem00A(tciAA);
- externalContext.setTestExternalContextItem00B(testExternalContextItem00B);
- externalContext.setTestExternalContextItem00C(testExternalContextItem00C);
-
- final Map<String, Object> valueMap2 = new HashMap<>();
- valueMap2.put("externalContext", externalContext);
-
- contextDistributor.clear();
- contextDistributor.init(new AxArtifactKey("ClearedandInittedDistributor", "0.0.1"));
- contextDistributor.registerModel(externalContextModel);
-
- final ContextAlbum externalContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("ExternalContextAlbum", "0.0.1"));
- assert (externalContextAlbum != null);
- externalContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- externalContextAlbum.putAll(valueMap2);
- externalContextAlbum.getAlbumDefinition().setWritable(false);
-
- final TestExternalContextItem externalContextItem =
- (TestExternalContextItem) externalContextAlbum.get("externalContext");
-
- assert (!externalContextItem.getTestExternalContextItem000().getFlag());
- assert (externalContextItem.getTestExternalContextItem001().getByteValue() == (byte) 0xFF);
- assert (externalContextItem.getTestExternalContextItem002().getIntValue() == 0xFFFFFFFF);
- assert (externalContextItem.getTestExternalContextItem003().getLongValue() == 0xFFFFFFFFFFFFFFFFL);
- assert (Float.compare(externalContextItem.getTestExternalContextItem004().getFloatValue(), testFloat) == 0);
- assert (Double.compare(externalContextItem.getTestExternalContextItem005().getDoubleValue(), Math.PI) == 0);
- assert (externalContextItem.getTestExternalContextItem006().getStringValue()
- .equals("This is an external context string"));
- assert (externalContextItem.getTestExternalContextItem007().getLongValue() == testDate.getTime());
- assert (externalContextItem.getTestExternalContextItem008().getDateValue().equals(testDate));
- assert (externalContextItem.getTestExternalContextItem009().getDateValue().getTime() == tci9A.getDateValue()
- .getTime());
- assert (externalContextItem.getTestExternalContextItem00A().getDateValue().getTime() == tciAA.getDateValue()
- .getTime());
- assert (externalContextItem.getTestExternalContextItem00B().getSetValue().equals(testTreeSet));
- assert (externalContextItem.getTestExternalContextItem00C().getMapValue().equals(testHashMap));
-
- final Collection<Object> mapValues = externalContextAlbum.values();
- assert (externalContextAlbum.values().containsAll(mapValues));
-
- // Check that clearing does not work
- try {
- externalContextAlbum.clear();
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("album \"ExternalContextAlbum:0.0.1\" clear() not allowed on read only albums"));
- }
-
- assert (externalContextAlbum.size() == 1);
-
- try {
- externalContextAlbum.containsKey(null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals("null values are illegal on method parameter \"key\""));
- }
-
- assert (externalContextAlbum.containsKey("externalContext"));
- assert (!externalContextAlbum.containsKey("globalContext"));
-
- try {
- externalContextAlbum.containsValue(null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals("null values are illegal on method parameter \"value\""));
- }
-
- assert (externalContextAlbum.containsValue(externalContext));
- assert (!externalContextAlbum.containsValue(new String("Hello")));
-
- final Set<Entry<String, Object>> entrySet = externalContextAlbum.entrySet();
- assert (entrySet.size() == 1);
-
- try {
- externalContextAlbum.get(null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for get()"));
- }
-
- final Object aObject = externalContextAlbum.get("externalContext");
- assert (aObject.equals(externalContext));
-
- // put null keys should fail, throws a runtime exception
- try {
- externalContextAlbum.put(null, null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for put()"));
- }
-
- try {
- externalContextAlbum.put("TestExternalContextItem00A", null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItem00A\" for put()"));
- }
- assert (externalContextItem.getTestExternalContextItem00A().equals(tciAA));
-
- // Should return the hash set
- assert (externalContextItem.getTestExternalContextItem00B().getSetValue().equals(testTreeSet));
-
- assert (externalContextAlbum.values().containsAll(mapValues));
-
- // Set the write flag back as it should be
- externalContextAlbum.getAlbumDefinition().setWritable(true);
-
- // Put should return the previous contextItem
- final TestExternalContextItem externalContextOther = new TestExternalContextItem();
- externalContextOther.setTestExternalContextItem002(new TestContextItem002());
- externalContextOther.getTestExternalContextItem002().setIntValue(2000);
-
- final Object object = externalContextAlbum.put("externalContext", externalContextOther);
- assert (object.equals(externalContext));
-
- final TestExternalContextItem item = (TestExternalContextItem) externalContextAlbum.get("externalContext");
- assert (item.getTestExternalContextItem002().getIntValue() == 2000);
- final Object actualExternalContext = externalContextAlbum.put("externalContext", externalContext);
- assert (actualExternalContext.equals(externalContextOther));
- assert (externalContextItem.getTestExternalContextItem002().getIntValue() == -1);
-
- try {
- externalContextAlbum.put("TestExternalContextItem00A", null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItem00A\" for put()"));
- }
- assert (externalContextAlbum.get("externalContext").equals(externalContext));
-
- try {
- externalContextAlbum.put("TestExternalContextItemFFF", null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItemFFF\" for put()"));
- }
- assert (externalContextAlbum.size() == 1);
-
- try {
- externalContextAlbum.put("TestExternalContextItemFFF", null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItemFFF\" for put()"));
- }
- assert (externalContextAlbum.size() == 1);
-
- // Should ignore remove
- externalContextAlbum.remove("TestExternalContextItem017");
- assert (externalContextAlbum.size() == 1);
-
- assert (externalContextAlbum.values().size() == 1);
- assert (externalContextAlbum.values().containsAll(mapValues));
- // CHECKSTYLE:ON: checkstyle:magicNumber
- } catch (final Exception exception) {
- LOGGER.error("Error: ", exception);
- contextDistributor.clear();
- assert ("Test has failed".equals(""));
- }
-
- try {
- contextDistributor.clear();
- } catch (final Exception exception) {
- LOGGER.error("Error occured while clearing context distributor: ", exception);
- assert ("Test has failed".equals(""));
- }
- }
-}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java b/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
deleted file mode 100644
index d104900..0000000
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.distribution;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TimeZone;
-
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.ContextRuntimeException;
-import org.onap.policy.apex.context.Distributor;
-import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
-import org.onap.policy.apex.context.test.concepts.TestContextItem008;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00A;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00C;
-import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestContextUpdate checks context updates.
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class ContextUpdate {
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextUpdate.class);
-
- /**
- * Test context update.
- *
- * @throws ApexModelException the apex model exception
- * @throws IOException the IO exception
- * @throws ApexException the apex exception
- */
- public void testContextUpdate() throws ApexModelException, IOException, ApexException {
- LOGGER.debug("Running TestContextUpdate test . . .");
-
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1");
- final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
-
- // @formatter:off
- final AxArtifactKey[] usedArtifactStackArray = {
- new AxArtifactKey("testC-top", "0.0.1"),
- new AxArtifactKey("testC-next", "0.0.1"),
- new AxArtifactKey("testC-bot", "0.0.1")
- };
- // @formatter:on
-
- // CHECKSTYLE:OFF: checkstyle:magicNumber
-
- final AxContextModel multiModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
- contextDistributor.registerModel(multiModel);
-
- final ContextAlbum longContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("LongContextAlbum", "0.0.1"));
- assert (longContextAlbum != null);
- longContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- final ContextAlbum dateContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("DateContextAlbum", "0.0.1"));
- assert (dateContextAlbum != null);
- longContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- final ContextAlbum mapContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("MapContextAlbum", "0.0.1"));
- assert (mapContextAlbum != null);
- mapContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- final TestContextItem00A tciA = new TestContextItem00A();
- tciA.setDateValue(new TestContextItem008(new Date()));
- tciA.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
- tciA.setDST(true);
- tciA.setUTCOffset(-600);
- tciA.setLocale(Locale.ENGLISH);
-
- final Map<String, String> testHashMap = new HashMap<>();
- testHashMap.put("0", "zero");
- testHashMap.put("1", "one");
- testHashMap.put("2", "two");
- testHashMap.put("3", "three");
- testHashMap.put("4", "four");
-
- final TestContextItem00C tciC = new TestContextItem00C(testHashMap);
-
- longContextAlbum.put("0", (long) 0);
- longContextAlbum.put("0", 0);
- longContextAlbum.put("0", "0");
-
- try {
- longContextAlbum.put("0", "zero");
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum:0.0.1: object \"zero\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\""));
- }
-
- try {
- longContextAlbum.put("0", "");
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum:0.0.1: object \"\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\""));
- }
-
- try {
- longContextAlbum.put("0", null);
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("album \"LongContextAlbum:0.0.1\" null values are illegal on key \"0\" for put()"));
- }
-
- try {
- longContextAlbum.put(null, null);
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals("album \"LongContextAlbum:0.0.1\" null keys are illegal on keys for put()"));
- }
-
- Object object = dateContextAlbum.put("date0", tciA);
- assert (object == null);
- object = dateContextAlbum.put("date0", tciA);
- assert (object.equals(tciA));
-
- object = mapContextAlbum.put("map0", tciC);
- assert (object == null);
- object = mapContextAlbum.put("map0", tciC);
- assert (object.equals(tciC));
-
- contextDistributor.clear();
- // CHECKSTYLE:ON: checkstyle:magicNumber
- }
-}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java b/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
deleted file mode 100644
index e22321c..0000000
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.distribution;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TimeZone;
-
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.context.Distributor;
-import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
-import org.onap.policy.apex.context.test.concepts.TestContextItem000;
-import org.onap.policy.apex.context.test.concepts.TestContextItem001;
-import org.onap.policy.apex.context.test.concepts.TestContextItem002;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
-import org.onap.policy.apex.context.test.concepts.TestContextItem004;
-import org.onap.policy.apex.context.test.concepts.TestContextItem005;
-import org.onap.policy.apex.context.test.concepts.TestContextItem006;
-import org.onap.policy.apex.context.test.concepts.TestContextItem007;
-import org.onap.policy.apex.context.test.concepts.TestContextItem008;
-import org.onap.policy.apex.context.test.concepts.TestContextItem009;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00A;
-import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class SequentialContextInstantiation checks sequential initiation of context.
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class SequentialContextInstantiation {
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(SequentialContextInstantiation.class);
-
- /**
- * Test sequential context instantiation.
- *
- * @throws ContextException the context exception
- */
- // CHECKSTYLE:OFF: checkstyle:MaximumMethodLength
- public void testSequentialContextInstantiation() throws ContextException {
- // CHECKSTYLE:ON: MaximumMethodLength
- LOGGER.debug("Running TestContextInstantiation test . . .");
-
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1");
- Distributor contextDistributor = null;
- try {
- contextDistributor = new DistributorFactory().getDistributor(distributorKey);
- } catch (final Exception exception) {
- LOGGER.error("Error occured while Instantiating Distributor for : {}", distributorKey, exception);
- assert ("Test has failed".equals(""));
- return;
- }
-
- // @formatter:off
- final AxArtifactKey[] usedArtifactStackArray = {
- new AxArtifactKey("testC-top", "0.0.1"),
- new AxArtifactKey("testC-next", "0.0.1"),
- new AxArtifactKey("testC-bot", "0.0.1")
- };
- // @formatter:on
-
- try {
- // CHECKSTYLE:OFF: checkstyle:magicNumber
- final AxContextModel multiModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
- contextDistributor.registerModel(multiModel);
-
- final ContextAlbum dateAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("DateContextAlbum", "0.0.1"));
- assert (dateAlbum != null);
- dateAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- final Date testDate = new Date();
-
- final TestContextItem00A tciA00 = new TestContextItem00A();
- tciA00.setDateValue(new TestContextItem008(new Date()));
- tciA00.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
- tciA00.setDST(true);
- tciA00.setUTCOffset(-600);
- tciA00.setLocale(Locale.ENGLISH);
-
- dateAlbum.put("dv0", tciA00);
- assert (tciA00.equals(dateAlbum.get("dv0")));
-
- dateAlbum.put("dv1", tciA00);
- assert (tciA00.equals(dateAlbum.get("dv1")));
-
- final TestContextItem009 tci9 = new TestContextItem009();
- tci9.setDateValue(new TestContextItem008(testDate));
- tci9.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
- tci9.setDST(true);
-
- try {
- dateAlbum.put("tci9", tci9);
- } catch (final Exception e) {
- assert (e.getMessage().contains(
- "class \"org.onap.policy.apex.context.test.concepts.TestContextItem009\" not compatible with class \"org.onap.policy.apex.context.test.concepts.TestContextItem00A\""));
- }
-
- final TestContextItem00A tciA01 = new TestContextItem00A(tciA00);
- final TestContextItem00A tciA02 = new TestContextItem00A(tciA00);
- final TestContextItem00A tciA03 = new TestContextItem00A(tciA00);
-
- final Map<String, Object> valueMap0 = new HashMap<>();
- valueMap0.put("Item01", tciA01);
- valueMap0.put("Item02", tciA02);
- valueMap0.put("Item03", tciA03);
-
- dateAlbum.putAll(valueMap0);
- assert (dateAlbum.size() == 5);
- assert (tciA01.equals(dateAlbum.get("Item01")));
- assert (tciA02.equals(dateAlbum.get("Item02")));
- assert (tciA03.equals(dateAlbum.get("Item03")));
-
- final Float testFloat = new Float(3.14159265359);
-
- final TestContextItem000 testBadItem000 = new TestContextItem000();
- final TestContextItem001 testBadItem001 = new TestContextItem001();
- final TestContextItem002 testBadItem002 = new TestContextItem002();
- final TestContextItem003 testBadItem003 = new TestContextItem003();
- final TestContextItem004 testBadItem004 = new TestContextItem004();
- final TestContextItem005 testBadItem005 = new TestContextItem005();
- final TestContextItem006 testBadItem006 = new TestContextItem006();
- final TestContextItem007 testBadItem007 = new TestContextItem007();
- final TestContextItem008 testBadItem008 = new TestContextItem008();
-
- testBadItem000.setFlag(false);
- testBadItem001.setByteValue((byte) 0xFF);
- testBadItem002.setIntValue(0xFFFFFFFF);
- testBadItem003.setLongValue(0xFFFFFFFFFFFFFFFFL);
- testBadItem004.setFloatValue(testFloat);
- testBadItem005.setDoubleValue(Math.PI);
- testBadItem006.setStringValue("This is a global context string");
- testBadItem007.setLongValue(testDate.getTime());
- testBadItem008.setDateValue(testDate);
-
- final Map<String, Object> valueMap1 = new HashMap<>();
- valueMap1.put("TestBadItem000", testBadItem000);
- valueMap1.put("TestBadItem001", testBadItem001);
- valueMap1.put("TestBadItem002", testBadItem002);
- valueMap1.put("TestBadItem003", testBadItem003);
- valueMap1.put("TestBadItem004", testBadItem004);
- valueMap1.put("TestBadItem005", testBadItem005);
- valueMap1.put("TestBadItem006", testBadItem006);
- valueMap1.put("TestBadItem007", testBadItem007);
- valueMap1.put("TestBadItem008", testBadItem008);
- valueMap1.put("TestBadItem009", tci9);
- valueMap1.put("Item00_2", tciA00);
-
- // Get another reference to the album
- final ContextAlbum dateAlbum1 =
- contextDistributor.createContextAlbum(new AxArtifactKey("DateContextAlbum", "0.0.1"));
- assert (dateAlbum1 != null);
- dateAlbum1.setUserArtifactStack(usedArtifactStackArray);
-
- try {
- dateAlbum1.putAll(valueMap1);
- } catch (final Exception e) {
- assert (e.getMessage().endsWith(
- "not compatible with class \"org.onap.policy.apex.context.test.concepts.TestContextItem00A\""));
- }
- assert (dateAlbum1.size() == 5);
-
- valueMap1.clear();
- valueMap1.put("Item00_2", tciA00);
- dateAlbum1.putAll(valueMap1);
- assert (dateAlbum1.size() == 6);
-
- assert (tciA00.equals(dateAlbum1.get("Item00_2")));
- dateAlbum.remove("Item00_2");
- assert (5 == dateAlbum1.size());
-
- final ContextAlbum dateAlbumCopy =
- contextDistributor.createContextAlbum(new AxArtifactKey("DateContextAlbum", "0.0.1"));
- assert (dateAlbumCopy != null);
- dateAlbumCopy.setUserArtifactStack(usedArtifactStackArray);
-
- final Map<String, Object> valueMap2 = new HashMap<>();
- valueMap2.put("Item04", tciA01);
- valueMap2.put("Item05", tciA02);
- valueMap2.put("Item06", tciA03);
-
- dateAlbumCopy.putAll(valueMap2);
- assert (8 == dateAlbumCopy.size());
- assert (tciA03.equals(dateAlbumCopy.get("Item06")));
-
- final Collection<Object> mapValues = dateAlbum.values();
- assert (dateAlbumCopy.values().containsAll(mapValues));
-
- // Check that clearing works
- dateAlbum1.clear();
- assert (dateAlbum1.size() == 0);
-
- dateAlbum.put("Item00", tciA00);
- final Map<String, Object> valueMap3 = new HashMap<>();
- valueMap3.put("Item01", tciA01);
- valueMap3.put("Item02", tciA02);
- valueMap3.put("Item03", tciA03);
- dateAlbum.putAll(valueMap3);
-
- final Map<String, Object> valueMap4 = new HashMap<>();
- valueMap4.put("Item04", tciA01);
- valueMap4.put("Item05", tciA02);
- valueMap4.put("Item06", tciA03);
-
- dateAlbumCopy.putAll(valueMap4);
-
- try {
- dateAlbum.containsKey(null);
- } catch (final Exception e) {
- assert (e.getMessage().equals("null values are illegal on method parameter \"key\""));
- }
-
- for (final Entry<String, Object> entry : dateAlbum.entrySet()) {
- System.out.println(entry.getKey() + "->" + entry.getValue());
- }
- assert (dateAlbum.containsKey("Item05"));
- assert (!dateAlbum.containsKey("Item07"));
-
- try {
- dateAlbum.containsValue(null);
- } catch (final Exception e) {
- assert (e.getMessage().equals("null values are illegal on method parameter \"value\""));
- }
-
- assert (dateAlbum.containsValue(tciA01));
- assert (!dateAlbum.containsValue(new String("Hello")));
-
- final Set<Entry<String, Object>> entrySet = dateAlbum.entrySet();
- assert (entrySet.size() == 7);
-
- try {
- assert (dateAlbum.get(null) == null);
- } catch (final Exception e) {
- assert (e.getMessage()
- .equals("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for get()"));
- }
-
- final Object aObject = dateAlbum.get("Item03");
- assert (aObject.equals(tciA03));
-
- try {
- final Object object = dateAlbum.put(null, null);
- assert (object == null);
- } catch (final Exception e) {
- assert (e.getMessage()
- .equals("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for put()"));
- }
-
- // Put null ContextItem should work (return null)
- try {
- dateAlbum.put("ItemNull", null);
- } catch (final Exception e) {
- assert (e.getMessage().equals(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"ItemNull\" for put()"));
- }
-
- // Should return null
- assert (dateAlbum.get("ItemNull") == null);
-
- // Put should return the previous contextItem
- tciA00.setDST(false);
- final TestContextItem00A tciA03_clone = new TestContextItem00A(tciA03);
- tciA03_clone.setDST(true);
- TestContextItem00A retItem = (TestContextItem00A) dateAlbum.put("Item03", tciA03_clone);
- assert (retItem.equals(tciA03));
- retItem = (TestContextItem00A) dateAlbum.put("Item03", tciA03);
- assert (retItem.equals(tciA03_clone));
-
- try {
- dateAlbum.put("ItemNull", null);
- assert (dateAlbum.get("ItemNull") == null);
- } catch (final Exception e) {
- assert (e.getMessage().equals(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"ItemNull\" for put()"));
- }
-
- dateAlbum.put("TestAA", tciA00);
- assert (dateAlbum.get("TestAA").equals(tciA00));
-
- // Should print warning
- try {
- dateAlbum.put("TestAA", null);
- } catch (final Exception e) {
- assert (e.getMessage().equals(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAA\" for put()"));
- }
- assert (dateAlbum.size() == 8);
- try {
- dateAlbum.put("TestAB", null);
- } catch (final Exception e) {
- assert (e.getMessage().equals(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAB\" for put()"));
- }
- assert (dateAlbum.size() == 8);
-
- // Should do removes
- dateAlbum.remove("TestAA");
- dateAlbum.remove("TestAB");
- dateAlbum.remove("ItemNull");
- assert (dateAlbum.size() == 7);
- assert (dateAlbumCopy.values().containsAll(mapValues));
- // CHECKSTYLE:ON: checkstyle:magicNumber
- } catch (final Exception exception) {
- LOGGER.error("Error: ", exception);
- contextDistributor.clear();
- assert ("Test has failed".equals(""));
- }
-
- try {
- contextDistributor.clear();
- } catch (final Exception exception) {
- LOGGER.error("Error occured while clearing context distributor", exception);
- assert ("Test has failed".equals(""));
- }
- }
-}
diff --git a/context/pom.xml b/context/pom.xml
index dad8502..9fa599a 100644
--- a/context/pom.xml
+++ b/context/pom.xml
@@ -35,6 +35,6 @@
<modules>
<module>context-management</module>
- <module>context-test</module>
+ <module>context-test-utils</module>
</modules>
</project>
\ No newline at end of file
diff --git a/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml
index ce80a7a..71806c5 100644
--- a/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml
+++ b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/pom.xml
@@ -36,5 +36,11 @@
<artifactId>hazelcast</artifactId>
<version>${version.hazelcast}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.context</groupId>
+ <artifactId>context-test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/plugins/plugins-context/context-distribution/context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
new file mode 100644
index 0000000..c999c95
--- /dev/null
+++ b/plugins/plugins-context/context-distribution/context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.context.distribution.hazelcast;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate;
+import org.onap.policy.apex.context.test.distribution.ContextInstantiation;
+import org.onap.policy.apex.context.test.distribution.ContextUpdate;
+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;
+
+public class HazelcastContextDistributorTest {
+ private static final String HAZEL_CAST_PLUGIN_CLASS = HazelcastContextDistributor.class.getCanonicalName();
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(HazelcastContextDistributorTest.class);
+
+
+ @Test
+ public void testContextAlbumUpdateHazelcast() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testContextAlbumUpdateHazelcast test . . .");
+
+ final ContextParameters contextParameters = new ContextParameters();
+ contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS);
+ new ContextAlbumUpdate().testContextAlbumUpdate();
+
+ logger.debug("Ran testContextAlbumUpdateHazelcast test");
+ }
+
+ @Test
+ public void testContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testContextInstantiationHazelcast test . . .");
+
+ final ContextParameters contextParameters = new ContextParameters();
+ contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS);
+ new ContextInstantiation().testContextInstantiation();
+
+ logger.debug("Ran testContextInstantiationHazelcast test");
+ }
+
+ @Test
+ public void testContextUpdateHazelcast() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testContextUpdateHazelcast test . . .");
+
+ final ContextParameters contextParameters = new ContextParameters();
+ contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS);
+ new ContextUpdate().testContextUpdate();
+
+ logger.debug("Ran testContextUpdateHazelcast test");
+ }
+
+}
diff --git a/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml b/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml
index 7592edd..c6985a9 100644
--- a/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml
+++ b/plugins/plugins-context/context-distribution/context-distribution-infinispan/pom.xml
@@ -42,6 +42,12 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.context</groupId>
+ <artifactId>context-test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/plugins/plugins-context/context-distribution/context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java b/plugins/plugins-context/context-distribution/context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
new file mode 100644
index 0000000..34fa7d4
--- /dev/null
+++ b/plugins/plugins-context/context-distribution/context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.plugins.context.distribution.infinispan;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate;
+import org.onap.policy.apex.context.test.distribution.ContextInstantiation;
+import org.onap.policy.apex.context.test.distribution.ContextUpdate;
+import org.onap.policy.apex.context.test.distribution.SequentialContextInstantiation;
+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;
+
+public class InfinispanContextDistributorTest {
+ private static final XLogger logger = XLoggerFactory.getXLogger(InfinispanContextDistributorTest.class);
+
+ private static final String PLUGIN_CLASS = InfinispanContextDistributor.class.getCanonicalName();
+
+ @Test
+ public void testContextAlbumUpdateInfinispan() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testContextAlbumUpdateInfinispan test . . .");
+
+ final ContextParameters contextParameters = new ContextParameters();
+ contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
+ new InfinispanDistributorParameters();
+
+ new ContextAlbumUpdate().testContextAlbumUpdate();
+
+ logger.debug("Ran testContextAlbumUpdateInfinispan test");
+ }
+
+ @Test
+ public void testContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testContextInstantiationInfinispan test . . .");
+
+ final ContextParameters contextParameters = new ContextParameters();
+ contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
+ new InfinispanDistributorParameters();
+
+ new ContextInstantiation().testContextInstantiation();
+
+ logger.debug("Ran testContextInstantiationInfinispan test");
+ }
+
+ @Test
+ public void testContextUpdateInfinispan() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testContextUpdateInfinispan test . . .");
+
+ final ContextParameters contextParameters = new ContextParameters();
+ contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
+ new InfinispanDistributorParameters();
+
+ new ContextUpdate().testContextUpdate();
+
+ logger.debug("Ran testContextUpdateInfinispan test");
+ }
+
+ @Test
+ public void testSequentialContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testSequentialContextInstantiationInfinispan test . . .");
+
+ final ContextParameters contextParameters = new ContextParameters();
+ contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
+ new InfinispanDistributorParameters();
+
+ new SequentialContextInstantiation().testSequentialContextInstantiation();
+
+ logger.debug("Ran testSequentialContextInstantiationInfinispan test");
+ }
+
+
+}
diff --git a/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/HazelcastContextInjection.java b/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/HazelcastContextInjection.java
deleted file mode 100644
index 4c21103..0000000
--- a/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/HazelcastContextInjection.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.plugins.context.test;
-
-import java.util.Map.Entry;
-import java.util.Random;
-
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.context.Distributor;
-import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public final class HazelcastContextInjection {
- private static final int ONE_SECOND = 1000;
- private static final int SIXTY_SECONDS = 60;
- private static final int MAX_INT_10000 = 10000;
-
- /**
- * Default constructor is private to avoid subclassing.
- */
- private HazelcastContextInjection() {}
-
- /**
- * The main method.
- *
- * @param args the arguments to the method
- * @throws ContextException exceptions thrown on context injection
- */
- public static void main(final String[] args) throws ContextException {
- // For convenience, I created model programmatically, it can of course be read in from a
- // policy model
- final AxContextModel contextModel = createContextModel();
-
- // The model must be registered in the model service.
- ModelService.registerModel(AxContextSchemas.class, contextModel.getSchemas());
- ModelService.registerModel(AxContextAlbums.class, contextModel.getAlbums());
-
- // Configure APex to use Hazelcast distribution and locking
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("com.ericsson.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor");
- contextParameters.getLockManagerParameters()
- .setPluginClass("com.ericsson.apex.plugins.context.locking.hazelcast.HazelcastLockManager");
-
- // Fire up our distribution
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1");
- final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
- contextDistributor.init(distributorKey);
-
- // Now, get a handle on the album
- final ContextAlbum myContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("LongContextAlbum", "0.0.1"));
-
- final int jvmID = new Random().nextInt(MAX_INT_10000);
- final String myLongKey = "MyLong_" + jvmID;
- final String commonLongKey = "CommonLong";
-
- // Put the long value for this JVM into the map
- myContextAlbum.put(myLongKey, new Long(0L));
-
- // Put the common long value to be used across JVMS in the map if its not htere already
- myContextAlbum.lockForWriting(commonLongKey);
- if (myContextAlbum.get(commonLongKey) == null) {
- myContextAlbum.put(commonLongKey, new Long(0L));
- }
- myContextAlbum.unlockForWriting(commonLongKey);
-
- // Run for 60 seconds to show multi JVM
- for (int i = 0; i < SIXTY_SECONDS; i++) {
- System.out.println("JVM " + jvmID + " iteration " + i);
-
- for (final Entry<String, Object> albumEntry : myContextAlbum.entrySet()) {
- myContextAlbum.lockForReading(albumEntry.getKey());
- System.out.println(albumEntry.getKey() + "-->" + albumEntry.getValue());
- myContextAlbum.unlockForReading(albumEntry.getKey());
- }
- System.out.println("old " + myLongKey + ": " + myContextAlbum.get(myLongKey));
-
- myContextAlbum.lockForReading(commonLongKey);
- System.out.println("old CommonLong: " + myContextAlbum.get(commonLongKey));
- myContextAlbum.unlockForReading(commonLongKey);
-
- Long myLong = (Long) myContextAlbum.get(myLongKey);
- myLong++;
- myContextAlbum.put(myLongKey, myLong);
-
- myContextAlbum.lockForWriting(commonLongKey);
- Long commonLong = (Long) myContextAlbum.get(commonLongKey);
- commonLong++;
- myContextAlbum.put(commonLongKey, commonLong);
- myContextAlbum.unlockForWriting(commonLongKey);
-
- System.out.println("new myLong: " + myContextAlbum.get(myLongKey));
- System.out.println("new commonLong: " + myContextAlbum.get(commonLongKey));
-
- try {
- Thread.sleep(ONE_SECOND);
- } catch (final Exception e) {
- e.printStackTrace();
- }
- }
-
- contextDistributor.clear();
- }
-
- /**
- * This method just creates a simple context model programatically.
- *
- * @return a context model
- */
- public static AxContextModel createContextModel() {
- final AxContextSchema longSchema =
- new AxContextSchema(new AxArtifactKey("LongSchema", "0.0.1"), "Java", "java.lang.Long");
-
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
- schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
-
- final AxContextAlbum longAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LongContextAlbum", "0.0.1"),
- "APPLICATION", true, longSchema.getKey());
-
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
- albums.getAlbumsMap().put(longAlbumDefinition.getKey(), longAlbumDefinition);
-
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
- final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("LongContextModel", "0.0.1"), schemas, albums, keyInformation);
- contextModel.setKeyInformation(keyInformation);
- keyInformation.generateKeyInfo(contextModel);
-
- return contextModel;
- }
-}
diff --git a/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/package-info.java b/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/package-info.java
deleted file mode 100644
index eab3618..0000000
--- a/plugins/plugins-context/plugins-context-test/src/main/java/org/onap/policy/apex/plugins/context/test/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-/**
- * Is used to inject context into context maps for test purposes.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-package org.onap.policy.apex.plugins.context.test;
diff --git a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextAlbumUpdate.java b/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextAlbumUpdate.java
deleted file mode 100644
index c24ef40..0000000
--- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextAlbumUpdate.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.plugins.context.test.distribution;
-
-import java.io.IOException;
-
-import org.junit.After;
-import org.junit.Test;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.DistributorParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate;
-
-public class TestContextAlbumUpdate {
- // Logger for this class
- private static final XLogger logger = XLoggerFactory.getXLogger(TestContextAlbumUpdate.class);
-
- @Test
- public void testContextAlbumUpdateJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextAlbumUpdateJVMLocalVarSet test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
- new ContextAlbumUpdate().testContextAlbumUpdate();
-
- logger.debug("Ran testContextAlbumUpdateJVMLocalVarSet test");
- }
-
- @Test
- public void testContextAlbumUpdateHazelcast() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextAlbumUpdateHazelcast test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor");
- new ContextAlbumUpdate().testContextAlbumUpdate();
-
- logger.debug("Ran testContextAlbumUpdateHazelcast test");
- }
-
- @Test
- public void testContextAlbumUpdateInfinispan() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextAlbumUpdateInfinispan test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor");
- new InfinispanDistributorParameters();
-
- new ContextAlbumUpdate().testContextAlbumUpdate();
-
- logger.debug("Ran testContextAlbumUpdateInfinispan test");
- }
-
- @Test
- 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/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextInstantiation.java b/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextInstantiation.java
deleted file mode 100644
index a13b798..0000000
--- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextInstantiation.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.plugins.context.test.distribution;
-
-import java.io.IOException;
-
-import org.junit.Test;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.DistributorParameters;
-import org.onap.policy.apex.context.test.distribution.ContextInstantiation;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-public class TestContextInstantiation {
- // Logger for this class
- private static final XLogger logger = XLoggerFactory.getXLogger(TestContextInstantiation.class);
-
- @Test
- public void testContextInstantiationJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextInstantiationJVMLocalVarSet test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
- new ContextInstantiation().testContextInstantiation();
-
- logger.debug("Ran testContextInstantiationJVMLocalVarSet test");
- }
-
- @Test
- public void testContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextInstantiationHazelcast test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor");
- new ContextInstantiation().testContextInstantiation();
-
- logger.debug("Ran testContextInstantiationHazelcast test");
- }
-
- @Test
- public void testContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextInstantiationInfinispan test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor");
- new InfinispanDistributorParameters();
-
- new ContextInstantiation().testContextInstantiation();
-
- logger.debug("Ran testContextInstantiationInfinispan test");
- }
-
- @Test
- 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/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextUpdate.java b/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextUpdate.java
deleted file mode 100644
index 3abfd18..0000000
--- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestContextUpdate.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.plugins.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.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.DistributorParameters;
-import org.onap.policy.apex.context.test.distribution.ContextUpdate;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-public class TestContextUpdate {
- // Logger for this class
- private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdate.class);
-
- @Before
- public void beforeTest() {}
-
- @After
- public void afterTest() {}
-
- @Test
- public void testContextUpdateJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextUpdateJVMLocalVarSet test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
- new ContextUpdate().testContextUpdate();
-
- logger.debug("Ran testContextUpdateJVMLocalVarSet test");
- }
-
- @Test
- public void testContextUpdateHazelcast() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextUpdateHazelcast test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor");
- new ContextUpdate().testContextUpdate();
-
- logger.debug("Ran testContextUpdateHazelcast test");
- }
-
- @Test
- public void testContextUpdateInfinispan() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextUpdateInfinispan test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor");
- new InfinispanDistributorParameters();
-
- new ContextUpdate().testContextUpdate();
-
- logger.debug("Ran testContextUpdateInfinispan test");
- }
-
- @Test
- 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/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestSequentialContextInstantiation.java b/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestSequentialContextInstantiation.java
deleted file mode 100644
index cc3f520..0000000
--- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/distribution/TestSequentialContextInstantiation.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.plugins.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.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.DistributorParameters;
-import org.onap.policy.apex.context.test.distribution.SequentialContextInstantiation;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestContextInstantiation.
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class TestSequentialContextInstantiation {
- // Logger for this class
- private static final XLogger logger = XLoggerFactory.getXLogger(TestSequentialContextInstantiation.class);
-
- @Before
- public void beforeTest() {}
-
- @After
- public void afterTest() {}
-
- @Test
- public void testSequentialContextInstantiationJVMLocalVarSet()
- throws ApexModelException, IOException, ApexException {
- logger.debug("Running testSequentialContextInstantiationJVMLocalVarSet test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
- new SequentialContextInstantiation().testSequentialContextInstantiation();
-
- logger.debug("Ran testSequentialContextInstantiationJVMLocalVarSet test");
- }
-
- @Test
- public void testSequentialContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testSequentialContextInstantiationHazelcast test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor");
- new SequentialContextInstantiation().testSequentialContextInstantiation();
-
- logger.debug("Ran testSequentialContextInstantiationHazelcast test");
- }
-
- @Test
- public void testSequentialContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testSequentialContextInstantiationInfinispan test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor");
- new InfinispanDistributorParameters();
-
- new SequentialContextInstantiation().testSequentialContextInstantiation();
-
- logger.debug("Ran testSequentialContextInstantiationInfinispan test");
- }
-
- @Test
- public void testSequentialContextInstantiationJVMLocalVarNotSet()
- throws ApexModelException, IOException, ApexException {
- logger.debug("Running testSequentialContextInstantiationJVMLocalVarNotSet test . . .");
-
- new ContextParameters();
- new SequentialContextInstantiation().testSequentialContextInstantiation();
-
- logger.debug("Ran testSequentialContextInstantiationJVMLocalVarNotSet test");
- }
-}
diff --git a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/CuratorManagerTest.java b/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/CuratorManagerTest.java
deleted file mode 100644
index 0b9d606..0000000
--- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/CuratorManagerTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.plugins.context.test.locking;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-
-import org.apache.curator.test.TestingServer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager;
-import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManagerParameters;
-
-public class CuratorManagerTest {
- // Zookeeper test server
- TestingServer zkTestServer;
-
- @Before
- public void beforeTest() throws Exception {
- zkTestServer = new TestingServer(62181);
- }
-
- @After
- public void afterTest() throws IOException {
- zkTestServer.stop();
- }
-
- @Test
- public void testCuratorManagerConfigProperty() {
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.setLockManagerParameters(new CuratorLockManagerParameters());
-
- ((CuratorLockManagerParameters) contextParameters.getLockManagerParameters()).setZookeeperAddress(null);
-
- try {
- final CuratorLockManager curatorManager = new CuratorLockManager();
- curatorManager.init(new AxArtifactKey());
- assertNull(curatorManager);
- } catch (final ContextException e) {
- assertEquals(e.getMessage(),
- "could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
- }
-
- ((CuratorLockManagerParameters) contextParameters.getLockManagerParameters()).setZookeeperAddress("zooby");
-
- try {
- final CuratorLockManager curatorManager = new CuratorLockManager();
- curatorManager.init(new AxArtifactKey());
- fail("Curator manager test should fail");
- } catch (final ContextException e) {
- assertEquals(e.getMessage(),
- "could not connect to Zookeeper server at \"zooby\", see error log for details");
- }
-
- ((CuratorLockManagerParameters) contextParameters.getLockManagerParameters())
- .setZookeeperAddress("localhost:62181");
-
- try {
- final CuratorLockManager curatorManager0 = new CuratorLockManager();
- curatorManager0.init(new AxArtifactKey());
- assertNotNull(curatorManager0);
-
- final CuratorLockManager curatorManager1 = new CuratorLockManager();
- curatorManager1.init(new AxArtifactKey());
- assertNotNull(curatorManager1);
-
- curatorManager0.shutdown();
- curatorManager1.shutdown();
- } catch (final ContextException e) {
- assertNull(e);
- }
- }
-}
diff --git a/plugins/plugins-context/pom.xml b/plugins/plugins-context/pom.xml
index 7be7843..8e3c728 100644
--- a/plugins/plugins-context/pom.xml
+++ b/plugins/plugins-context/pom.xml
@@ -41,64 +41,11 @@
</dependency>
</dependencies>
- <profiles>
- <profile>
- <id>apexDefault</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules>
- <module>context-schema</module>
- <module>context-distribution</module>
- <module>context-locking</module>
- <module>context-persistence</module>
- </modules>
- </profile>
- <profile>
- <id>apexTests</id>
- <activation>
- <property>
- <name>apexTests</name>
- </property>
- </activation>
- <modules>
- <module>context-schema</module>
- <module>context-distribution</module>
- <module>context-locking</module>
- <module>context-persistence</module>
- <module>plugins-context-test</module>
- </modules>
- </profile>
- <profile>
- <id>apexMetrics</id>
- <activation>
- <property>
- <name>apexMetrics</name>
- </property>
- </activation>
- <modules>
- <module>context-schema</module>
- <module>context-distribution</module>
- <module>context-locking</module>
- <module>context-persistence</module>
- <module>context-metrics</module>
- </modules>
- </profile>
- <profile>
- <id>apexAll</id>
- <activation>
- <property>
- <name>apexAll</name>
- </property>
- </activation>
- <modules>
- <module>context-schema</module>
- <module>context-distribution</module>
- <module>context-locking</module>
- <module>context-persistence</module>
- <module>plugins-context-test</module>
- <module>context-metrics</module>
- </modules>
- </profile>
- </profiles>
+ <modules>
+ <module>context-schema</module>
+ <module>context-distribution</module>
+ <module>context-locking</module>
+ <module>context-persistence</module>
+ </modules>
+
</project>
\ No newline at end of file
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
index 59a3560..9ee4311 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
@@ -59,7 +59,7 @@
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test</artifactId>
+ <artifactId>context-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
diff --git a/services/services-engine/pom.xml b/services/services-engine/pom.xml
index cde5d3b..84765da 100644
--- a/services/services-engine/pom.xml
+++ b/services/services-engine/pom.xml
@@ -48,7 +48,7 @@
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test</artifactId>
+ <artifactId>context-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
diff --git a/plugins/plugins-context/context-metrics/pom.xml b/testsuites/integration/integration-context-metrics/pom.xml
similarity index 92%
rename from plugins/plugins-context/context-metrics/pom.xml
rename to testsuites/integration/integration-context-metrics/pom.xml
index 1e5800c..47a1083 100644
--- a/plugins/plugins-context/context-metrics/pom.xml
+++ b/testsuites/integration/integration-context-metrics/pom.xml
@@ -22,15 +22,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context</groupId>
- <artifactId>plugins-context</artifactId>
+ <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
+ <artifactId>integration</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
- <artifactId>context-metrics</artifactId>
+ <artifactId>integration-context-metrics</artifactId>
<name>${project.artifactId}</name>
<description>[${project.parent.artifactId}] module to calculate metrics using various plugins</description>
-
<dependencies>
<dependency>
<groupId>org.onap.policy.apex-pdp.core</groupId>
@@ -39,7 +38,7 @@
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test</artifactId>
+ <artifactId>context-test-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
diff --git a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java b/testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java
similarity index 98%
rename from plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java
rename to testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java
index de719c9..cbe06ed 100644
--- a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java
+++ b/testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetrics.java
@@ -32,7 +32,7 @@
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.context.parameters.DistributorParameters;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
@@ -458,7 +458,7 @@
for (int i = 0; i < longArraySize; i++) {
final String longKey = Integer.toString(i);
- final TestContextItem003 longItem = new TestContextItem003();
+ final TestContextLongItem longItem = new TestContextLongItem();
longItem.setLongValue(0);
lTypeAlbum.put(longKey, longItem);
}
@@ -475,7 +475,7 @@
try {
for (int i = 0; i < longArraySize; i++) {
- total += ((TestContextItem003) lTypeAlbum.get(Integer.toString(i))).getLongValue();
+ total += ((TestContextLongItem) lTypeAlbum.get(Integer.toString(i))).getLongValue();
}
outMetricLine(testName, "Totaled");
diff --git a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVM.java b/testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVM.java
similarity index 100%
rename from plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVM.java
rename to testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVM.java
diff --git a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVMThread.java b/testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVMThread.java
similarity index 100%
rename from plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVMThread.java
rename to testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsJVMThread.java
diff --git a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java b/testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java
similarity index 94%
rename from plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java
rename to testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java
index 2752536..e207832 100644
--- a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java
+++ b/testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/ConcurrentContextMetricsThread.java
@@ -26,7 +26,7 @@
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -109,7 +109,7 @@
final String nextLongKey = Integer.toString(rand.nextInt(longArraySize));
if (lockType == 0) {
- final TestContextItem003 item = (TestContextItem003) lTypeAlbum.get(nextLongKey);
+ final TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get(nextLongKey);
final long value = item.getLongValue();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("lock type=" + lockType + ", value=" + value);
@@ -125,7 +125,7 @@
continue;
}
- final TestContextItem003 item = (TestContextItem003) lTypeAlbum.get(nextLongKey);
+ final TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get(nextLongKey);
final long value = item.getLongValue();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("lock type=" + lockType + ", value=" + value);
@@ -148,7 +148,7 @@
continue;
}
- final TestContextItem003 item = (TestContextItem003) lTypeAlbum.get(nextLongKey);
+ final TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get(nextLongKey);
long value = item.getLongValue();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("lock type=" + lockType + ", value=" + value);
diff --git a/plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/package-info.java b/testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/package-info.java
similarity index 100%
rename from plugins/plugins-context/context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/package-info.java
rename to testsuites/integration/integration-context-metrics/src/main/java/org/onap/policy/apex/plugins/context/metrics/package-info.java
diff --git a/plugins/plugins-context/context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java b/testsuites/integration/integration-context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java
similarity index 100%
rename from plugins/plugins-context/context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java
rename to testsuites/integration/integration-context-metrics/src/test/java/org/onap/policy/apex/plugins/context/metrics/TestMetrics.java
diff --git a/plugins/plugins-context/context-metrics/src/test/resources/hazelcast/hazelcast.xml b/testsuites/integration/integration-context-metrics/src/test/resources/hazelcast/hazelcast.xml
similarity index 100%
rename from plugins/plugins-context/context-metrics/src/test/resources/hazelcast/hazelcast.xml
rename to testsuites/integration/integration-context-metrics/src/test/resources/hazelcast/hazelcast.xml
diff --git a/plugins/plugins-context/context-metrics/src/test/resources/infinispan/infinispan.xml b/testsuites/integration/integration-context-metrics/src/test/resources/infinispan/infinispan.xml
similarity index 100%
rename from plugins/plugins-context/context-metrics/src/test/resources/infinispan/infinispan.xml
rename to testsuites/integration/integration-context-metrics/src/test/resources/infinispan/infinispan.xml
diff --git a/plugins/plugins-context/plugins-context-test/pom.xml b/testsuites/integration/integration-context-test/pom.xml
similarity index 77%
rename from plugins/plugins-context/plugins-context-test/pom.xml
rename to testsuites/integration/integration-context-test/pom.xml
index 7239abe..8c62339 100644
--- a/plugins/plugins-context/plugins-context-test/pom.xml
+++ b/testsuites/integration/integration-context-test/pom.xml
@@ -17,18 +17,20 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context</groupId>
- <artifactId>plugins-context</artifactId>
+ <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
+ <artifactId>integration</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
- <artifactId>plugins-context-test</artifactId>
+ <artifactId>integration-context-test</artifactId>
<name>${project.artifactId}</name>
- <description>[${project.parent.artifactId}] module to run context tests using various plugins</description>
+ <description>[${project.parent.artifactId}] module to run context tests using various plugins, multi-threads and multi-JVMs</description>
+
<dependencies>
<dependency>
@@ -51,6 +53,12 @@
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.context-locking</groupId>
<artifactId>context-locking-curator</artifactId>
<version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.context-locking</groupId>
@@ -59,7 +67,7 @@
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test</artifactId>
+ <artifactId>context-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
@@ -77,23 +85,4 @@
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- <skipDeploy>true</skipDeploy>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <forkMode>always</forkMode>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
\ No newline at end of file
diff --git a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
similarity index 84%
rename from plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
rename to testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
index e02009a..7a3a29c 100644
--- a/plugins/plugins-context/plugins-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
@@ -21,6 +21,7 @@
package org.onap.policy.apex.plugins.context.test.locking;
import static org.junit.Assert.assertEquals;
+import static org.onap.policy.apex.context.parameters.DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS;
import java.io.File;
import java.io.IOException;
@@ -31,12 +32,15 @@
import java.util.Enumeration;
import java.util.TreeSet;
-import org.apache.curator.shaded.com.google.common.io.Files;
import org.apache.zookeeper.server.NIOServerCnxnFactory;
import org.apache.zookeeper.server.ZooKeeperServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+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.parameters.ContextParameters;
import org.onap.policy.apex.context.parameters.DistributorParameters;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
@@ -44,8 +48,12 @@
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor;
+import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor;
import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters;
+import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager;
import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManagerParameters;
+import org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -61,6 +69,7 @@
private static final XLogger logger = XLoggerFactory.getXLogger(TestConcurrentContext.class);
// Test parameters
+ private static final String ZOOKEEPER_ADDRESS = "127.0.0.1";
private static final int ZOOKEEPER_START_PORT = 62181;
private static final int TEST_JVM_COUNT_SINGLE_JVM = 1;
private static final int TEST_JVM_COUNT_MULTI_JVM = 3;
@@ -75,6 +84,9 @@
private static int nextZookeeperPort = ZOOKEEPER_START_PORT;
private int zookeeperPort;
+ @Rule
+ public final TemporaryFolder folder = new TemporaryFolder();
+
@BeforeClass
public static void configure() throws Exception {
System.setProperty("java.net.preferIPv4Stack", "true");
@@ -113,7 +125,7 @@
public static void teardown() throws IOException {}
private void startZookeeperServer() throws IOException, InterruptedException {
- final File zookeeperDirectory = Files.createTempDir();
+ final File zookeeperDirectory = folder.newFolder("zookeeperDirectory");
zookeeperPort = nextZookeeperPort++;
@@ -133,8 +145,7 @@
logger.debug("Running testConcurrentContextJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getLockManagerParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager");
+ contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
final long result = new ConcurrentContext().testConcurrentContext("JVMLocalVarSet", TEST_JVM_COUNT_SINGLE_JVM,
TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
@@ -161,10 +172,8 @@
logger.debug("Running testConcurrentContextMultiJVMNoLock test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor");
- contextParameters.getLockManagerParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager");
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
+ contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
final long result = new ConcurrentContext().testConcurrentContext("testConcurrentContextMultiJVMNoLock",
TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
@@ -180,10 +189,8 @@
logger.debug("Running testConcurrentContextHazelcastLock test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
- contextParameters.getLockManagerParameters()
- .setPluginClass("org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager");
+ contextParameters.getDistributorParameters().setPluginClass(DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
+ contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getCanonicalName());
final long result = new ConcurrentContext().testConcurrentContext("HazelcastLock", TEST_JVM_COUNT_SINGLE_JVM,
TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
@@ -203,8 +210,8 @@
.setPluginClass(DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
- curatorParameters.setPluginClass("org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager");
- curatorParameters.setZookeeperAddress("127.0.0.1:" + zookeeperPort);
+ curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
+ curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
contextParameters.setLockManagerParameters(curatorParameters);
ParameterService.registerParameters(LockManagerParameters.class, curatorParameters);
@@ -223,10 +230,9 @@
logger.debug("Running testConcurrentContextHazelcastMultiJVMHazelcastLock test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor");
- contextParameters.getLockManagerParameters()
- .setPluginClass("org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager");
+ contextParameters.getDistributorParameters()
+ .setPluginClass(HazelcastContextDistributor.class.getCanonicalName());
+ contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getCanonicalName());
final long result = new ConcurrentContext().testConcurrentContext("HazelcastMultiHazelcastlock",
TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
@@ -241,12 +247,10 @@
final ContextParameters contextParameters = new ContextParameters();
final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters();
- infinispanParameters.setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor");
+ infinispanParameters.setPluginClass(InfinispanContextDistributor.class.getCanonicalName());
infinispanParameters.setConfigFile("infinispan/infinispan-context-test.xml");
contextParameters.setDistributorParameters(infinispanParameters);
- contextParameters.getLockManagerParameters()
- .setPluginClass("org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager");
+ contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getCanonicalName());
final long result = new ConcurrentContext().testConcurrentContext("InfinispanMultiHazelcastlock",
TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
@@ -264,14 +268,13 @@
final ContextParameters contextParameters = new ContextParameters();
final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters();
- infinispanParameters.setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor");
+ infinispanParameters.setPluginClass(InfinispanContextDistributor.class.getCanonicalName());
infinispanParameters.setConfigFile("infinispan/infinispan-context-test.xml");
contextParameters.setDistributorParameters(infinispanParameters);
final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
- curatorParameters.setPluginClass("org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager");
- curatorParameters.setZookeeperAddress("127.0.0.1:" + zookeeperPort);
+ curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
+ curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
contextParameters.setLockManagerParameters(curatorParameters);
ParameterService.registerParameters(LockManagerParameters.class, curatorParameters);
@@ -293,12 +296,12 @@
startZookeeperServer();
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(
- "org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor");
+ contextParameters.getDistributorParameters()
+ .setPluginClass(HazelcastContextDistributor.class.getCanonicalName());
final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
- curatorParameters.setPluginClass("org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager");
- curatorParameters.setZookeeperAddress("127.0.0.1:" + zookeeperPort);
+ curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
+ curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
contextParameters.setLockManagerParameters(curatorParameters);
ParameterService.registerParameters(LockManagerParameters.class, curatorParameters);
diff --git a/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml b/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml
new file mode 100644
index 0000000..d69f24b
--- /dev/null
+++ b/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<hazelcast xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <group>
+ <name>ApexHazelcastGroup</name>
+ <password>ApexHazelcastGroupPassword</password>
+ </group>
+ <network>
+ <port auto-increment="true">5706</port>
+ <join>
+ <multicast enabled="false">
+ <multicast-group>224.2.2.10</multicast-group>
+ <multicast-port>54327</multicast-port>
+ </multicast>
+ <tcp-ip enabled="true">
+ <members>127.0.0.1</members>
+ </tcp-ip>
+ </join>
+ <interfaces enabled="false">
+ <!-- This value will allow hazelcast to run locally from the IDE -->
+ <interface>127.0.0.*</interface>
+ </interfaces>
+ </network>
+ <properties>
+ <property name="hazelcast.icmp.enabled">true</property>
+ <property name="hazelcast.logging.type">slf4j</property>
+ <!-- disable the hazelcast shutdown hook - prefer to control the shutdown
+ in code -->
+ <property name="hazelcast.shutdownhook.enabled">false</property>
+ <property name="hazelcast.graceful.shutdown.max.wait">60</property>
+ </properties>
+ <executor-service>
+ <pool-size>16</pool-size>
+ </executor-service>
+</hazelcast>
diff --git a/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-tcp.xml b/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-tcp.xml
new file mode 100644
index 0000000..028cf1d
--- /dev/null
+++ b/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-tcp.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<config xmlns="urn:org:jgroups"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.0.xsd">
+ <TCP bind_addr="${jgroups.tcp.address:127.0.0.1}"
+ bind_port="${jgroups.tcp.port:7800}"
+ enable_diagnostics="false"
+ thread_naming_pattern="pl"
+ send_buf_size="640k"
+ sock_conn_timeout="300"
+ bundler_type="no-bundler"
+
+ thread_pool.min_threads="${jgroups.thread_pool.min_threads:0}"
+ thread_pool.max_threads="${jgroups.thread_pool.max_threads:200}"
+ thread_pool.keep_alive_time="60000"
+ />
+ <MPING bind_addr="${jgroups.tcp.address:127.0.0.1}"
+ mcast_addr="${jgroups.mping.mcast_addr:228.2.4.6}"
+ mcast_port="${jgroups.mping.mcast_port:43366}"
+ ip_ttl="${jgroups.udp.ip_ttl:2}"
+ />
+ <MERGE3 min_interval="10000"
+ max_interval="30000"
+ />
+ <FD_SOCK />
+ <FD_ALL timeout="60000"
+ interval="15000"
+ timeout_check_interval="5000"
+ />
+ <VERIFY_SUSPECT timeout="5000" />
+ <pbcast.NAKACK2 use_mcast_xmit="false"
+ xmit_interval="100"
+ xmit_table_num_rows="50"
+ xmit_table_msgs_per_row="1024"
+ xmit_table_max_compaction_time="30000"
+ resend_last_seqno="true"
+ />
+ <UNICAST3 xmit_interval="100"
+ xmit_table_num_rows="50"
+ xmit_table_msgs_per_row="1024"
+ xmit_table_max_compaction_time="30000"
+ conn_expiry_timeout="0"
+ />
+ <pbcast.STABLE stability_delay="500"
+ desired_avg_gossip="5000"
+ max_bytes="1M"
+ />
+ <pbcast.GMS print_local_addr="false"
+ install_view_locally_first="true"
+ join_timeout="${jgroups.join_timeout:5000}"
+ />
+ <MFC max_credits="2m"
+ min_threshold="0.40"
+ />
+ <FRAG3/>
+</config>
diff --git a/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml b/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml
new file mode 100644
index 0000000..17ba5ea
--- /dev/null
+++ b/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<config xmlns="urn:org:jgroups"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.0.xsd">
+ <UDP mcast_addr="${jgroups.udp.mcast_addr:228.6.7.8}"
+ mcast_port="${jgroups.udp.mcast_port:46655}"
+ ucast_send_buf_size="1m"
+ mcast_send_buf_size="1m"
+ ucast_recv_buf_size="20m"
+ mcast_recv_buf_size="25m"
+ ip_ttl="${jgroups.ip_ttl:2}"
+ thread_naming_pattern="pl"
+ enable_diagnostics="false"
+ bundler_type="no-bundler"
+ max_bundle_size="8500"
+
+ thread_pool.min_threads="${jgroups.thread_pool.min_threads:0}"
+ thread_pool.max_threads="${jgroups.thread_pool.max_threads:200}"
+ thread_pool.keep_alive_time="60000"
+ />
+ <PING />
+ <MERGE3 min_interval="10000"
+ max_interval="30000"
+ />
+ <FD_SOCK />
+ <FD_ALL timeout="60000"
+ interval="15000"
+ timeout_check_interval="5000"
+ />
+ <VERIFY_SUSPECT timeout="5000"
+ />
+ <pbcast.NAKACK2 xmit_interval="100"
+ xmit_table_num_rows="50"
+ xmit_table_msgs_per_row="1024"
+ xmit_table_max_compaction_time="30000"
+ resend_last_seqno="true"
+ />
+ <UNICAST3 xmit_interval="100"
+ xmit_table_num_rows="50"
+ xmit_table_msgs_per_row="1024"
+ xmit_table_max_compaction_time="30000"
+ conn_expiry_timeout="0"
+ />
+ <pbcast.STABLE stability_delay="500"
+ desired_avg_gossip="5000"
+ max_bytes="1M"
+ />
+ <pbcast.GMS print_local_addr="false"
+ install_view_locally_first="true"
+ join_timeout="${jgroups.join_timeout:5000}"
+ />
+ <UFC max_credits="2m"
+ min_threshold="0.40"
+ />
+ <MFC max_credits="2m"
+ min_threshold="0.40"
+ />
+ <FRAG3 frag_size="8000"/>
+</config>
diff --git a/testsuites/integration/integration-context-test/src/test/resources/infinispan/infinispan-context-test.xml b/testsuites/integration/integration-context-test/src/test/resources/infinispan/infinispan-context-test.xml
new file mode 100644
index 0000000..9fa7a2a
--- /dev/null
+++ b/testsuites/integration/integration-context-test/src/test/resources/infinispan/infinispan-context-test.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<infinispan xmlns="urn:infinispan:config:8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:infinispan:config:8.0 http://infinispan.org/schemas/infinispan-config-8.0.xsd">
+ <jgroups>
+ <stack-file name="tcpStack" path="infinispan/default-jgroups-tcp.xml" />
+ </jgroups>
+
+ <cache-container name="ApexCacheContainer" default-cache="LTypeContextAlbum_0.0.1">
+ <transport cluster="apexCluster" stack="tcpStack" />
+ <jmx />
+ <replicated-cache name="LTypeContextAlbum_0.0.1" mode="SYNC" statistics="true">
+ <state-transfer enabled="true" />
+ </replicated-cache>
+ </cache-container>
+</infinispan>
diff --git a/testsuites/integration/integration-context-test/src/test/resources/logback-test.xml b/testsuites/integration/integration-context-test/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..7fd818d
--- /dev/null
+++ b/testsuites/integration/integration-context-test/src/test/resources/logback-test.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<configuration>
+ <contextName>Apex</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ <property name="LOG_DIR" value="${java.io.tmpdir}/apex_logging/" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.apache.zookeeper.ClientCnxn" level="OFF" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <appender name="FILE"
+ class="ch.qos.logback.core.FileAppender">
+ <file>${LOG_DIR}/apex.log</file>
+ <encoder>
+ <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
+ %logger{26} - %msg %n %ex{full}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="CTXT_FILE"
+ class="ch.qos.logback.core.FileAppender">
+ <file>${LOG_DIR}/apex_ctxt.log</file>
+ <encoder>
+ <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
+ %logger{26} - %msg %n %ex{full}</pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.infinispan" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="com.ericsson.apex.context.monitoring" level="TRACE" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="com.ericsson.apex.context.monitoring" level="TRACE" additivity="false">
+ <appender-ref ref="CTXT_FILE" />
+ </logger>
+
+ <logger name="org.jgroups" level="off" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <root level="info">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
diff --git a/testsuites/integration/integration-uservice-test/pom.xml b/testsuites/integration/integration-uservice-test/pom.xml
index 5eeeeff..8fe5164 100644
--- a/testsuites/integration/integration-uservice-test/pom.xml
+++ b/testsuites/integration/integration-uservice-test/pom.xml
@@ -48,7 +48,7 @@
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test</artifactId>
+ <artifactId>context-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
@@ -209,6 +209,12 @@
<artifactId>jersey-container-servlet-core</artifactId>
<version>${version.jersey.core}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.context</groupId>
+ <artifactId>context-test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/testsuites/integration/pom.xml b/testsuites/integration/pom.xml
index 4e6bec7..366556c 100644
--- a/testsuites/integration/pom.xml
+++ b/testsuites/integration/pom.xml
@@ -31,8 +31,43 @@
<artifactId>integration</artifactId>
<packaging>pom</packaging>
- <modules>
- <module>integration-common</module>
- <module>integration-uservice-test</module>
- </modules>
+ <profiles>
+ <profile>
+ <id>apexDefault</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>integration-common</module>
+ <module>integration-uservice-test</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>apexMetrics</id>
+ <activation>
+ <property>
+ <name>apexMetrics</name>
+ </property>
+ </activation>
+ <modules>
+ <module>integration-common</module>
+ <module>integration-uservice-test</module>
+ <module>integration-context-metrics</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>apexAll</id>
+ <activation>
+ <property>
+ <name>apexAll</name>
+ </property>
+ </activation>
+ <modules>
+ <module>integration-common</module>
+ <module>integration-uservice-test</module>
+ <module>integration-context-test</module>
+ <module>integration-context-metrics</module>
+ </modules>
+ </profile>
+ </profiles>
</project>
\ No newline at end of file