summaryrefslogtreecommitdiffstats
path: root/context/context-test-utils/src
diff options
context:
space:
mode:
Diffstat (limited to 'context/context-test-utils/src')
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java114
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java112
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java258
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java261
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java186
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java115
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java112
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java121
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java113
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java116
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java116
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java122
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java128
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java434
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java434
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java241
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java27
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java125
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java552
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java176
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java364
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java27
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java213
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java27
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java194
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java219
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java124
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java146
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java27
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java59
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java65
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java75
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java62
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java73
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java96
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java185
-rw-r--r--context/context-test-utils/src/test/resources/META-INF/persistence.xml50
37 files changed, 5869 insertions, 0 deletions
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java
new file mode 100644
index 000000000..7f019f57c
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java
@@ -0,0 +1,114 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+
+/**
+ * The Class TestContextItem000.
+ */
+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;
+
+ private static final long serialVersionUID = 7241008665286367796L;
+
+ private boolean flag = false;;
+
+ /**
+ * The Constructor.
+ */
+ public TestContextBooleanItem() {}
+
+ /**
+ * The Constructor.
+ *
+ * @param flag the flag
+ */
+ public TestContextBooleanItem(final Boolean flag) {
+ this.flag = flag;
+ }
+
+ /**
+ * Gets the flag.
+ *
+ * @return the flag
+ */
+ public boolean getFlag() {
+ return flag;
+ }
+
+ /**
+ * Sets the flag.
+ *
+ * @param flag the flag
+ */
+ public void setFlag(final boolean flag) {
+ this.flag = flag;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + (flag ? HASH_PRIME_2 : HASH_PRIME_3);
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextBooleanItem other = (TestContextBooleanItem) obj;
+ if (flag != other.flag) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem000 [flag=" + flag + "]";
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java
new file mode 100644
index 000000000..2b107b492
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java
@@ -0,0 +1,112 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+
+/**
+ * The Class TestContextItem001.
+ */
+public class TestContextByteItem implements Serializable {
+ private static final long serialVersionUID = 1361938145823720386L;
+
+ private static final int HASH_PRIME_1 = 31;
+
+ private byte byteValue = 0;
+
+ /**
+ * The Constructor.
+ */
+ public TestContextByteItem() {}
+
+ /**
+ * The Constructor.
+ *
+ * @param byteValue the byte value
+ */
+ public TestContextByteItem(final Byte byteValue) {
+ this.byteValue = byteValue;
+ }
+
+ /**
+ * Gets the byte value.
+ *
+ * @return the byte value
+ */
+ public byte getByteValue() {
+ return byteValue;
+ }
+
+ /**
+ * Sets the byte value.
+ *
+ * @param byteValue the byte value
+ */
+ public void setByteValue(final byte byteValue) {
+ this.byteValue = byteValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + byteValue;
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextByteItem other = (TestContextByteItem) obj;
+ if (byteValue != other.byteValue) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem001 [byteValue=" + byteValue + "]";
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java
new file mode 100644
index 000000000..f7c849023
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java
@@ -0,0 +1,258 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * The Class TestContextItem008.
+ */
+public class TestContextDateItem implements Serializable {
+ private static final long serialVersionUID = -6984963129968805460L;
+
+ private static final int HASH_PRIME_1 = 31;
+ private static final int FOUR_BYTES = 32;
+
+ private long time;
+
+ private int year;
+ private int month;
+ private int day;
+ private int hour;
+ private int minute;
+ private int second;
+ private int milliSecond;
+
+ /**
+ * The Constructor.
+ */
+ public TestContextDateItem() {
+ this(new Date(System.currentTimeMillis()));
+ }
+
+ /**
+ * The Constructor.
+ *
+ * @param dateValue the date value
+ */
+ public TestContextDateItem(final Date dateValue) {
+ setDateValue(dateValue.getTime());
+ }
+
+ /**
+ * The Constructor.
+ *
+ * @param time the time
+ */
+ public TestContextDateItem(final long time) {
+ setDateValue(time);
+ }
+
+ /**
+ * Gets the time.
+ *
+ * @return the time
+ */
+ public long getTime() {
+ return time;
+ }
+
+ /**
+ * Gets the year.
+ *
+ * @return the year
+ */
+ public int getYear() {
+ return year;
+ }
+
+ /**
+ * Gets the month.
+ *
+ * @return the month
+ */
+ public int getMonth() {
+ return month;
+ }
+
+ /**
+ * Gets the day.
+ *
+ * @return the day
+ */
+ public int getDay() {
+ return day;
+ }
+
+ /**
+ * Gets the hour.
+ *
+ * @return the hour
+ */
+ public int getHour() {
+ return hour;
+ }
+
+ /**
+ * Gets the minute.
+ *
+ * @return the minute
+ */
+ public int getMinute() {
+ return minute;
+ }
+
+ /**
+ * Gets the second.
+ *
+ * @return the second
+ */
+ public int getSecond() {
+ return second;
+ }
+
+ /**
+ * Gets the milli second.
+ *
+ * @return the milli second
+ */
+ public int getMilliSecond() {
+ return milliSecond;
+ }
+
+ /**
+ * Gets the date value.
+ *
+ * @return the date value
+ */
+ public Date getDateValue() {
+ return new Date(time);
+ }
+
+ /**
+ * Sets the date value.
+ *
+ * @param dateValue the date value
+ */
+ public void setDateValue(final Date dateValue) {
+ setDateValue(dateValue.getTime());
+ }
+
+ /**
+ * Sets the date value.
+ *
+ * @param dateValue the date value
+ */
+ public void setDateValue(final long dateValue) {
+ this.time = dateValue;
+
+ final Calendar calendar = Calendar.getInstance();
+ calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
+ calendar.setTimeInMillis(time);
+
+ year = calendar.get(Calendar.YEAR);
+ month = calendar.get(Calendar.MONTH);
+ day = calendar.get(Calendar.DAY_OF_MONTH);
+ hour = calendar.get(Calendar.HOUR);
+ minute = calendar.get(Calendar.MINUTE);
+ second = calendar.get(Calendar.SECOND);
+ milliSecond = calendar.get(Calendar.MILLISECOND);
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + day;
+ result = prime * result + hour;
+ result = prime * result + milliSecond;
+ result = prime * result + minute;
+ result = prime * result + month;
+ result = prime * result + second;
+ result = prime * result + (int) (time ^ (time >>> FOUR_BYTES));
+ result = prime * result + year;
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextDateItem other = (TestContextDateItem) obj;
+ if (day != other.day) {
+ return false;
+ }
+ if (hour != other.hour) {
+ return false;
+ }
+ if (milliSecond != other.milliSecond) {
+ return false;
+ }
+ if (minute != other.minute) {
+ return false;
+ }
+ if (month != other.month) {
+ return false;
+ }
+ if (second != other.second) {
+ return false;
+ }
+ if (time != other.time) {
+ return false;
+ }
+ if (year != other.year) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem008 [time=" + time + ", year=" + year + ", month=" + month + ", day=" + day + ", hour="
+ + hour + ", minute=" + minute + ", second=" + second + ", milliSecond=" + milliSecond + "]";
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java
new file mode 100644
index 000000000..0c94bcb1d
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java
@@ -0,0 +1,261 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/**
+ * The Class TestContextItem00A.
+ */
+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 TestContextDateItem dateValue = new TestContextDateItem(System.currentTimeMillis());
+ private String timeZoneString = TimeZone.getTimeZone("Europe/Dublin").getDisplayName();
+ private boolean dst = false;
+ private int utcOffset = 0;
+ private String localeLanguage = Locale.ENGLISH.getLanguage();
+ private String localeCountry = Locale.ENGLISH.getCountry();
+
+ /**
+ * The Constructor.
+ */
+ public TestContextDateLocaleItem() {}
+
+ /**
+ * The Constructor.
+ *
+ * @param dateValue the date value
+ * @param tzValue the tz value
+ * @param dst the dst
+ * @param utcOffset the utc offset
+ * @param language the language
+ * @param country the country
+ */
+ 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();
+ this.dst = dst;
+ this.utcOffset = utcOffset;
+
+ final Locale locale = new Locale(language, country);
+ this.localeLanguage = locale.getLanguage();
+ this.localeCountry = locale.getCountry();
+ }
+
+ /**
+ * The Constructor.
+ *
+ * @param original the original
+ */
+ public TestContextDateLocaleItem(final TestContextDateLocaleItem original) {
+ this.dateValue = original.dateValue;
+ this.timeZoneString = TimeZone.getTimeZone(original.timeZoneString).getDisplayName();
+ this.dst = original.dst;
+ this.utcOffset = original.utcOffset;
+
+ final Locale locale = new Locale(original.localeLanguage, original.localeCountry);
+ this.localeLanguage = locale.getLanguage();
+ this.localeCountry = locale.getCountry();
+ }
+
+ /**
+ * Gets the date value.
+ *
+ * @return the date value
+ */
+ public TestContextDateItem getDateValue() {
+ return dateValue;
+ }
+
+ /**
+ * Sets the date value.
+ *
+ * @param dateValue the date value
+ */
+ public void setDateValue(final TestContextDateItem dateValue) {
+ this.dateValue = dateValue;
+ }
+
+ /**
+ * Gets the TZ value.
+ *
+ * @return the TZ value
+ */
+ public String getTZValue() {
+ return timeZoneString;
+ }
+
+ /**
+ * Sets the TZ value.
+ *
+ * @param tzValue the TZ value
+ */
+ public void setTZValue(final String tzValue) {
+ this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName();
+ }
+
+ /**
+ * Gets the DST.
+ *
+ * @return the dst
+ */
+ public boolean getDST() {
+ return dst;
+ }
+
+ /**
+ * Sets the DST.
+ *
+ * @param newDst the dst
+ */
+ public void setDST(final boolean newDst) {
+ this.dst = newDst;
+ }
+
+ /**
+ * Gets the UTC offset.
+ *
+ * @return the UTC offset
+ */
+ public int getUTCOffset() {
+ return utcOffset;
+ }
+
+ /**
+ * Sets the UTC offset.
+ *
+ * @param newUtcOffset the UTC offset
+ */
+ public void setUTCOffset(final int newUtcOffset) {
+ this.utcOffset = newUtcOffset;
+ }
+
+ /**
+ * Gets the locale.
+ *
+ * @return the locale
+ */
+ public Locale getLocale() {
+ return new Locale(localeLanguage, localeCountry);
+ }
+
+ /**
+ * Sets the locale.
+ *
+ * @param locale the locale
+ */
+ public void setLocale(final Locale locale) {
+ this.localeLanguage = locale.getLanguage();
+ this.localeCountry = locale.getCountry();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + ((dateValue == null) ? 0 : dateValue.hashCode());
+ result = prime * result + (dst ? HASH_PRIME_2 : HASH_PRIME_3);
+ result = prime * result + ((localeCountry == null) ? 0 : localeCountry.hashCode());
+ result = prime * result + ((localeLanguage == null) ? 0 : localeLanguage.hashCode());
+ result = prime * result + ((timeZoneString == null) ? 0 : timeZoneString.hashCode());
+ result = prime * result + utcOffset;
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextDateLocaleItem other = (TestContextDateLocaleItem) obj;
+ if (dateValue == null) {
+ if (other.dateValue != null) {
+ return false;
+ }
+ } else if (!dateValue.equals(other.dateValue)) {
+ return false;
+ }
+ if (dst != other.dst) {
+ return false;
+ }
+ if (localeCountry == null) {
+ if (other.localeCountry != null) {
+ return false;
+ }
+ } else if (!localeCountry.equals(other.localeCountry)) {
+ return false;
+ }
+ if (localeLanguage == null) {
+ if (other.localeLanguage != null) {
+ return false;
+ }
+ } else if (!localeLanguage.equals(other.localeLanguage)) {
+ return false;
+ }
+ if (timeZoneString == null) {
+ if (other.timeZoneString != null) {
+ return false;
+ }
+ } else if (!timeZoneString.equals(other.timeZoneString)) {
+ return false;
+ }
+ if (utcOffset != other.utcOffset) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem00A [dateValue=" + dateValue + ", timeZoneString=" + timeZoneString + ", dst=" + dst
+ + ", utcOffset=" + utcOffset + ", localeLanguage=" + localeLanguage + ", localeCountry=" + localeCountry
+ + "]";
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java
new file mode 100644
index 000000000..7d3ed80d5
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java
@@ -0,0 +1,186 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+import java.util.TimeZone;
+
+/**
+ * The Class TestContextItem009.
+ */
+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 TestContextDateItem dateValue = new TestContextDateItem(System.currentTimeMillis());
+ private String timeZoneString = TimeZone.getTimeZone("Europe/Dublin").getDisplayName();
+ private boolean dst = false;
+
+ /**
+ * The Constructor.
+ */
+ public TestContextDateTzItem() {
+ dst = true;
+ }
+
+ /**
+ * The Constructor.
+ *
+ * @param dateValue the date value
+ * @param tzValue the tz value
+ * @param dst the dst
+ */
+ public TestContextDateTzItem(final TestContextDateItem dateValue, final String tzValue, final boolean dst) {
+ this.dateValue = dateValue;
+ this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName();
+ this.dst = dst;
+ }
+
+ /**
+ * The Constructor.
+ *
+ * @param original the original
+ */
+ public TestContextDateTzItem(final TestContextDateTzItem original) {
+ this.dateValue = original.dateValue;
+ this.timeZoneString = original.timeZoneString;
+ this.dst = original.dst;
+ }
+
+ /**
+ * Gets the date value.
+ *
+ * @return the date value
+ */
+ public TestContextDateItem getDateValue() {
+ return dateValue;
+ }
+
+ /**
+ * Sets the date value.
+ *
+ * @param dateValue the date value
+ */
+ public void setDateValue(final TestContextDateItem dateValue) {
+ this.dateValue = dateValue;
+ }
+
+ /**
+ * Gets the TZ value.
+ *
+ * @return the TZ value
+ */
+ public String getTZValue() {
+ return timeZoneString;
+ }
+
+ /**
+ * Sets the TZ value.
+ *
+ * @param tzValue the TZ value
+ */
+ public void setTZValue(final String tzValue) {
+ this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName();
+ }
+
+ /**
+ * Gets the DST.
+ *
+ * @return the dst
+ */
+ public boolean getDST() {
+ return dst;
+ }
+
+ /**
+ * Sets the DST.
+ *
+ * @param newDst the dst
+ */
+ public void setDST(final boolean newDst) {
+ this.dst = newDst;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + ((dateValue == null) ? 0 : dateValue.hashCode());
+ result = prime * result + (dst ? HASH_PRIME_2 : HASH_PRIME_3);
+ result = prime * result + ((timeZoneString == null) ? 0 : timeZoneString.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextDateTzItem other = (TestContextDateTzItem) obj;
+ if (dateValue == null) {
+ if (other.dateValue != null) {
+ return false;
+ }
+ } else if (!dateValue.equals(other.dateValue)) {
+ return false;
+ }
+ if (dst != other.dst) {
+ return false;
+ }
+ if (timeZoneString == null) {
+ if (other.timeZoneString != null) {
+ return false;
+ }
+ } else if (!timeZoneString.equals(other.timeZoneString)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem009 [dateValue=" + dateValue + ", tzValue=" + timeZoneString + ", dst=" + dst + "]";
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java
new file mode 100644
index 000000000..ac4f5069f
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java
@@ -0,0 +1,115 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+
+/**
+ * The Class TestContextItem005.
+ */
+public class TestContextDoubleItem implements Serializable {
+ private static final long serialVersionUID = -2958758261076734821L;
+
+ private static final int HASH_PRIME_1 = 31;
+ private static final int FOUR_BYTES = 32;
+
+ private double doubleValue = 0;
+
+ /**
+ * The Constructor.
+ */
+ public TestContextDoubleItem() {}
+
+ /**
+ * The Constructor.
+ *
+ * @param doubleValue the double value
+ */
+ public TestContextDoubleItem(final Double doubleValue) {
+ this.doubleValue = doubleValue;
+ }
+
+ /**
+ * Gets the double value.
+ *
+ * @return the double value
+ */
+ public double getDoubleValue() {
+ return doubleValue;
+ }
+
+ /**
+ * Sets the double value.
+ *
+ * @param doubleValue the double value
+ */
+ public void setDoubleValue(final double doubleValue) {
+ this.doubleValue = doubleValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ long temp;
+ temp = Double.doubleToLongBits(doubleValue);
+ result = prime * result + (int) (temp ^ (temp >>> FOUR_BYTES));
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextDoubleItem other = (TestContextDoubleItem) obj;
+ if (Double.doubleToLongBits(doubleValue) != Double.doubleToLongBits(other.doubleValue)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem005 [doubleValue=" + doubleValue + "]";
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java
new file mode 100644
index 000000000..cd8165251
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java
@@ -0,0 +1,112 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+
+/**
+ * The Class TestContextItem004.
+ */
+public class TestContextFloatItem implements Serializable {
+ private static final long serialVersionUID = -3359180576903272400L;
+
+ private static final int HASH_PRIME_1 = 31;
+
+ private float floatValue = 0;
+
+ /**
+ * The Constructor.
+ */
+ public TestContextFloatItem() {}
+
+ /**
+ * The Constructor.
+ *
+ * @param floatValue the float value
+ */
+ public TestContextFloatItem(final Float floatValue) {
+ this.floatValue = floatValue;
+ }
+
+ /**
+ * Gets the float value.
+ *
+ * @return the float value
+ */
+ public float getFloatValue() {
+ return floatValue;
+ }
+
+ /**
+ * Sets the float value.
+ *
+ * @param floatValue the float value
+ */
+ public void setFloatValue(final float floatValue) {
+ this.floatValue = floatValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + Float.floatToIntBits(floatValue);
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextFloatItem other = (TestContextFloatItem) obj;
+ if (Float.floatToIntBits(floatValue) != Float.floatToIntBits(other.floatValue)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem004 [floatValue=" + floatValue + "]";
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java
new file mode 100644
index 000000000..898302716
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java
@@ -0,0 +1,121 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+
+/**
+ * The Class TestContextItem002.
+ */
+public class TestContextIntItem implements Serializable {
+ private static final long serialVersionUID = -8978435658277900984L;
+
+ private static final int HASH_PRIME_1 = 31;
+
+ private int intValue = 0;
+
+ /**
+ * The Constructor.
+ */
+ public TestContextIntItem() {}
+
+ /**
+ * The Constructor.
+ *
+ * @param intValue the int value
+ */
+ public TestContextIntItem(final Integer intValue) {
+ this.intValue = intValue;
+ }
+
+ /**
+ * The Constructor.
+ *
+ * @param original the original
+ */
+ public TestContextIntItem(final TestContextIntItem original) {
+ this.intValue = original.intValue;
+ }
+
+ /**
+ * Gets the int value.
+ *
+ * @return the int value
+ */
+ public int getIntValue() {
+ return intValue;
+ }
+
+ /**
+ * Sets the int value.
+ *
+ * @param intValue the int value
+ */
+ public void setIntValue(final int intValue) {
+ this.intValue = intValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + intValue;
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextIntItem other = (TestContextIntItem) obj;
+ if (intValue != other.intValue) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem002 [intValue=" + intValue + "]";
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java
new file mode 100644
index 000000000..be3ee60f8
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java
@@ -0,0 +1,113 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+
+/**
+ * The Class TestContextItem003.
+ */
+public class TestContextLongItem implements Serializable {
+ private static final long serialVersionUID = 3599267534512489386L;
+
+ private static final int HASH_PRIME_1 = 31;
+ private static final int FOUR_BYTES = 33;
+
+ private long longValue = 0;
+
+ /**
+ * The Constructor.
+ */
+ public TestContextLongItem() {}
+
+ /**
+ * The Constructor.
+ *
+ * @param longValue the long value
+ */
+ public TestContextLongItem(final Long longValue) {
+ this.longValue = longValue;
+ }
+
+ /**
+ * Gets the long value.
+ *
+ * @return the long value
+ */
+ public long getLongValue() {
+ return longValue;
+ }
+
+ /**
+ * Sets the long value.
+ *
+ * @param longValue the long value
+ */
+ public void setLongValue(final long longValue) {
+ this.longValue = longValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + (int) (longValue ^ (longValue >>> FOUR_BYTES));
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextLongItem other = (TestContextLongItem) obj;
+ if (longValue != other.longValue) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem003 [longValue=" + longValue + "]";
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java
new file mode 100644
index 000000000..215868d11
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java
@@ -0,0 +1,116 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+
+/**
+ * The Class TestContextItem007.
+ */
+public class TestContextLongObjectItem implements Serializable {
+ private static final long serialVersionUID = -1029406737866392421L;
+
+ private static final int HASH_PRIME_1 = 31;
+
+ private Long longValue = new Long(0);
+
+ /**
+ * The Constructor.
+ */
+ public TestContextLongObjectItem() {}
+
+ /**
+ * The Constructor.
+ *
+ * @param longValue the long value
+ */
+ public TestContextLongObjectItem(final Long longValue) {
+ this.longValue = longValue;
+ }
+
+ /**
+ * Gets the long value.
+ *
+ * @return the long value
+ */
+ public Long getLongValue() {
+ return longValue;
+ }
+
+ /**
+ * Sets the long value.
+ *
+ * @param longValue the long value
+ */
+ public void setLongValue(final Long longValue) {
+ this.longValue = longValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + ((longValue == null) ? 0 : longValue.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextLongObjectItem other = (TestContextLongObjectItem) obj;
+ if (longValue == null) {
+ if (other.longValue != null) {
+ return false;
+ }
+ } else if (!longValue.equals(other.longValue)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem007 [longValue=" + longValue + "]";
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java
new file mode 100644
index 000000000..6c9fcb412
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java
@@ -0,0 +1,116 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+
+/**
+ * The Class TestContextItem006.
+ */
+public class TestContextStringItem implements Serializable {
+ private static final long serialVersionUID = -1074772190611125121L;
+
+ private static final int HASH_PRIME_1 = 31;
+
+ private String stringValue = "";
+
+ /**
+ * The Constructor.
+ */
+ public TestContextStringItem() {}
+
+ /**
+ * The Constructor.
+ *
+ * @param stringValue the string value
+ */
+ public TestContextStringItem(final String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+ /**
+ * Gets the string value.
+ *
+ * @return the string value
+ */
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ /**
+ * Sets the string value.
+ *
+ * @param stringValue the string value
+ */
+ public void setStringValue(final String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + ((stringValue == null) ? 0 : stringValue.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextStringItem other = (TestContextStringItem) obj;
+ if (stringValue == null) {
+ if (other.stringValue != null) {
+ return false;
+ }
+ } else if (!stringValue.equals(other.stringValue)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem006 [stringValue=" + stringValue + "]";
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java
new file mode 100644
index 000000000..eed0c1a2f
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java
@@ -0,0 +1,122 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * The Class TestContextItem00C.
+ */
+public class TestContextTreeMapItem implements Serializable {
+ private static final long serialVersionUID = -7497746259264651884L;
+
+ private static final int HASH_PRIME_1 = 31;
+
+ private Map<String, String> mapValue = new TreeMap<String, String>();
+
+ /**
+ * The Constructor.
+ */
+ public TestContextTreeMapItem() {}
+
+ /**
+ * The Constructor.
+ *
+ * @param mapValue the map value
+ */
+ public TestContextTreeMapItem(final Map<String, String> mapValue) {
+ this.mapValue = mapValue;
+ }
+
+ /**
+ * Gets the map value.
+ *
+ * @return the map value
+ */
+ public Map<String, String> getMapValue() {
+ if (mapValue == null) {
+ mapValue = new TreeMap<String, String>();
+ }
+ return mapValue;
+ }
+
+ /**
+ * Sets the map value.
+ *
+ * @param mapValue the map value
+ */
+ public void setMapValue(final Map<String, String> mapValue) {
+ this.mapValue = mapValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + ((mapValue == null) ? 0 : mapValue.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextTreeMapItem other = (TestContextTreeMapItem) obj;
+ if (mapValue == null) {
+ if (other.mapValue != null) {
+ return false;
+ }
+ } else if (!mapValue.equals(other.mapValue)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem00C [mapValue=" + mapValue + "]";
+ }
+
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java
new file mode 100644
index 000000000..fe47c1af0
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java
@@ -0,0 +1,128 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * The Class TestContextItem00B.
+ */
+public class TestContextTreeSetItem implements Serializable {
+ private static final long serialVersionUID = 1254589722957250388L;
+
+ private static final int HASH_PRIME_1 = 31;
+
+ private TreeSet<String> setValue = new TreeSet<String>();
+
+ /**
+ * The Constructor.
+ */
+ public TestContextTreeSetItem() {}
+
+ /**
+ * The Constructor.
+ *
+ * @param setArray the set array
+ */
+ public TestContextTreeSetItem(final String[] setArray) {}
+
+ /**
+ * The Constructor.
+ *
+ * @param setValue the set value
+ */
+ public TestContextTreeSetItem(final TreeSet<String> setValue) {
+ this.setValue = setValue;
+ }
+
+ /**
+ * Gets the set value.
+ *
+ * @return the sets the value
+ */
+ public Set<String> getSetValue() {
+ if (setValue == null) {
+ setValue = new TreeSet<String>();
+ }
+ return setValue;
+ }
+
+ /**
+ * Sets the set value.
+ *
+ * @param setValue the sets the value
+ */
+ public void setSetValue(final TreeSet<String> setValue) {
+ this.setValue = setValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + ((setValue == null) ? 0 : setValue.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestContextTreeSetItem other = (TestContextTreeSetItem) obj;
+ if (setValue == null) {
+ if (other.setValue != null) {
+ return false;
+ }
+ } else if (!setValue.equals(other.setValue)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestContextItem00B [setValue=" + setValue + "]";
+ }
+}
diff --git a/context/context-test-utils/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
new file mode 100644
index 000000000..5c63c2ecb
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java
@@ -0,0 +1,434 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+
+/**
+ * The Class TestExternalContextItem.
+ */
+public class TestExternalContextItem implements Serializable {
+ private static final long serialVersionUID = 3512435733818672173L;
+
+ private static final int HASH_PRIME_1 = 31;
+
+ 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 TestContextBooleanItem getTestExternalContextItem000() {
+ return testExternalContextItem000;
+ }
+
+ /**
+ * Sets the test external context item 000.
+ *
+ * @param testExternalContextItem000 the test external context item 000
+ */
+ public void setTestExternalContextItem000(final TestContextBooleanItem testExternalContextItem000) {
+ this.testExternalContextItem000 = testExternalContextItem000;
+ }
+
+ /**
+ * Gets the test external context item 001.
+ *
+ * @return the test external context item 001
+ */
+ public TestContextByteItem getTestExternalContextItem001() {
+ return testExternalContextItem001;
+ }
+
+ /**
+ * Sets the test external context item 001.
+ *
+ * @param testExternalContextItem001 the test external context item 001
+ */
+ public void setTestExternalContextItem001(final TestContextByteItem testExternalContextItem001) {
+ this.testExternalContextItem001 = testExternalContextItem001;
+ }
+
+ /**
+ * Gets the test external context item 002.
+ *
+ * @return the test external context item 002
+ */
+ public TestContextIntItem getTestExternalContextItem002() {
+ return testExternalContextItem002;
+ }
+
+ /**
+ * Sets the test external context item 002.
+ *
+ * @param testExternalContextItem002 the test external context item 002
+ */
+ public void setTestExternalContextItem002(final TestContextIntItem testExternalContextItem002) {
+ this.testExternalContextItem002 = testExternalContextItem002;
+ }
+
+ /**
+ * Gets the test external context item 003.
+ *
+ * @return the test external context item 003
+ */
+ public TestContextLongItem getTestExternalContextItem003() {
+ return testExternalContextItem003;
+ }
+
+ /**
+ * Sets the test external context item 003.
+ *
+ * @param testExternalContextItem003 the test external context item 003
+ */
+ public void setTestExternalContextItem003(final TestContextLongItem testExternalContextItem003) {
+ this.testExternalContextItem003 = testExternalContextItem003;
+ }
+
+ /**
+ * Gets the test external context item 004.
+ *
+ * @return the test external context item 004
+ */
+ public TestContextFloatItem getTestExternalContextItem004() {
+ return testExternalContextItem004;
+ }
+
+ /**
+ * Sets the test external context item 004.
+ *
+ * @param testExternalContextItem004 the test external context item 004
+ */
+ public void setTestExternalContextItem004(final TestContextFloatItem testExternalContextItem004) {
+ this.testExternalContextItem004 = testExternalContextItem004;
+ }
+
+ /**
+ * Gets the test external context item 005.
+ *
+ * @return the test external context item 005
+ */
+ public TestContextDoubleItem getTestExternalContextItem005() {
+ return testExternalContextItem005;
+ }
+
+ /**
+ * Sets the test external context item 005.
+ *
+ * @param testExternalContextItem005 the test external context item 005
+ */
+ public void setTestExternalContextItem005(final TestContextDoubleItem testExternalContextItem005) {
+ this.testExternalContextItem005 = testExternalContextItem005;
+ }
+
+ /**
+ * Gets the test external context item 006.
+ *
+ * @return the test external context item 006
+ */
+ public TestContextStringItem getTestExternalContextItem006() {
+ return testExternalContextItem006;
+ }
+
+ /**
+ * Sets the test external context item 006.
+ *
+ * @param testExternalContextItem006 the test external context item 006
+ */
+ public void setTestExternalContextItem006(final TestContextStringItem testExternalContextItem006) {
+ this.testExternalContextItem006 = testExternalContextItem006;
+ }
+
+ /**
+ * Gets the test external context item 007.
+ *
+ * @return the test external context item 007
+ */
+ public TestContextLongObjectItem getTestExternalContextItem007() {
+ return testExternalContextItem007;
+ }
+
+ /**
+ * Sets the test external context item 007.
+ *
+ * @param testExternalContextItem007 the test external context item 007
+ */
+ public void setTestExternalContextItem007(final TestContextLongObjectItem testExternalContextItem007) {
+ this.testExternalContextItem007 = testExternalContextItem007;
+ }
+
+ /**
+ * Gets the test external context item 008.
+ *
+ * @return the test external context item 008
+ */
+ public TestContextDateItem getTestExternalContextItem008() {
+ return testExternalContextItem008;
+ }
+
+ /**
+ * Sets the test external context item 008.
+ *
+ * @param testExternalContextItem008 the test external context item 008
+ */
+ public void setTestExternalContextItem008(final TestContextDateItem testExternalContextItem008) {
+ this.testExternalContextItem008 = testExternalContextItem008;
+ }
+
+ /**
+ * Gets the test external context item 009.
+ *
+ * @return the test external context item 009
+ */
+ public TestContextDateTzItem getTestExternalContextItem009() {
+ return testExternalContextItem009;
+ }
+
+ /**
+ * Sets the test external context item 009.
+ *
+ * @param testExternalContextItem009 the test external context item 009
+ */
+ public void setTestExternalContextItem009(final TestContextDateTzItem testExternalContextItem009) {
+ this.testExternalContextItem009 = testExternalContextItem009;
+ }
+
+ /**
+ * Gets the test external context item 00 A.
+ *
+ * @return the test external context item 00 A
+ */
+ public TestContextDateLocaleItem getTestExternalContextItem00A() {
+ return testExternalContextItem00A;
+ }
+
+ /**
+ * Sets the test external context item 00 A.
+ *
+ * @param testExternalContextItem00A the test external context item 00 A
+ */
+ public void setTestExternalContextItem00A(final TestContextDateLocaleItem testExternalContextItem00A) {
+ this.testExternalContextItem00A = testExternalContextItem00A;
+ }
+
+ /**
+ * Gets the test external context item 00 B.
+ *
+ * @return the test external context item 00 B
+ */
+ public TestContextTreeSetItem getTestExternalContextItem00B() {
+ return testExternalContextItem00B;
+ }
+
+ /**
+ * Sets the test external context item 00 B.
+ *
+ * @param testExternalContextItem00B the test external context item 00 B
+ */
+ public void setTestExternalContextItem00B(final TestContextTreeSetItem testExternalContextItem00B) {
+ this.testExternalContextItem00B = testExternalContextItem00B;
+ }
+
+ /**
+ * Gets the test external context item 00 C.
+ *
+ * @return the test external context item 00 C
+ */
+ public TestContextTreeMapItem getTestExternalContextItem00C() {
+ return testExternalContextItem00C;
+ }
+
+ /**
+ * Sets the test external context item 00 C.
+ *
+ * @param testExternalContextItem00C the test external context item 00 C
+ */
+ public void setTestExternalContextItem00C(final TestContextTreeMapItem testExternalContextItem00C) {
+ this.testExternalContextItem00C = testExternalContextItem00C;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + ((testExternalContextItem000 == null) ? 0 : testExternalContextItem000.hashCode());
+ result = prime * result + ((testExternalContextItem001 == null) ? 0 : testExternalContextItem001.hashCode());
+ result = prime * result + ((testExternalContextItem002 == null) ? 0 : testExternalContextItem002.hashCode());
+ result = prime * result + ((testExternalContextItem003 == null) ? 0 : testExternalContextItem003.hashCode());
+ result = prime * result + ((testExternalContextItem004 == null) ? 0 : testExternalContextItem004.hashCode());
+ result = prime * result + ((testExternalContextItem005 == null) ? 0 : testExternalContextItem005.hashCode());
+ result = prime * result + ((testExternalContextItem006 == null) ? 0 : testExternalContextItem006.hashCode());
+ result = prime * result + ((testExternalContextItem007 == null) ? 0 : testExternalContextItem007.hashCode());
+ result = prime * result + ((testExternalContextItem008 == null) ? 0 : testExternalContextItem008.hashCode());
+ result = prime * result + ((testExternalContextItem009 == null) ? 0 : testExternalContextItem009.hashCode());
+ result = prime * result + ((testExternalContextItem00A == null) ? 0 : testExternalContextItem00A.hashCode());
+ result = prime * result + ((testExternalContextItem00B == null) ? 0 : testExternalContextItem00B.hashCode());
+ result = prime * result + ((testExternalContextItem00C == null) ? 0 : testExternalContextItem00C.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestExternalContextItem other = (TestExternalContextItem) obj;
+ if (testExternalContextItem000 == null) {
+ if (other.testExternalContextItem000 != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem000.equals(other.testExternalContextItem000)) {
+ return false;
+ }
+ if (testExternalContextItem001 == null) {
+ if (other.testExternalContextItem001 != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem001.equals(other.testExternalContextItem001)) {
+ return false;
+ }
+ if (testExternalContextItem002 == null) {
+ if (other.testExternalContextItem002 != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem002.equals(other.testExternalContextItem002)) {
+ return false;
+ }
+ if (testExternalContextItem003 == null) {
+ if (other.testExternalContextItem003 != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem003.equals(other.testExternalContextItem003)) {
+ return false;
+ }
+ if (testExternalContextItem004 == null) {
+ if (other.testExternalContextItem004 != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem004.equals(other.testExternalContextItem004)) {
+ return false;
+ }
+ if (testExternalContextItem005 == null) {
+ if (other.testExternalContextItem005 != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem005.equals(other.testExternalContextItem005)) {
+ return false;
+ }
+ if (testExternalContextItem006 == null) {
+ if (other.testExternalContextItem006 != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem006.equals(other.testExternalContextItem006)) {
+ return false;
+ }
+ if (testExternalContextItem007 == null) {
+ if (other.testExternalContextItem007 != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem007.equals(other.testExternalContextItem007)) {
+ return false;
+ }
+ if (testExternalContextItem008 == null) {
+ if (other.testExternalContextItem008 != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem008.equals(other.testExternalContextItem008)) {
+ return false;
+ }
+ if (testExternalContextItem009 == null) {
+ if (other.testExternalContextItem009 != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem009.equals(other.testExternalContextItem009)) {
+ return false;
+ }
+ if (testExternalContextItem00A == null) {
+ if (other.testExternalContextItem00A != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem00A.equals(other.testExternalContextItem00A)) {
+ return false;
+ }
+ if (testExternalContextItem00B == null) {
+ if (other.testExternalContextItem00B != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem00B.equals(other.testExternalContextItem00B)) {
+ return false;
+ }
+ if (testExternalContextItem00C == null) {
+ if (other.testExternalContextItem00C != null) {
+ return false;
+ }
+ } else if (!testExternalContextItem00C.equals(other.testExternalContextItem00C)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestExternalContextItem [testExternalContextItem000=" + testExternalContextItem000
+ + ", testExternalContextItem001=" + testExternalContextItem001 + ", testExternalContextItem002="
+ + testExternalContextItem002 + ", testExternalContextItem003=" + testExternalContextItem003
+ + ", testExternalContextItem004=" + testExternalContextItem004 + ", testExternalContextItem005="
+ + testExternalContextItem005 + ", testExternalContextItem006=" + testExternalContextItem006
+ + ", testExternalContextItem007=" + testExternalContextItem007 + ", testExternalContextItem008="
+ + testExternalContextItem008 + ", testExternalContextItem009=" + testExternalContextItem009
+ + ", testExternalContextItem00A=" + testExternalContextItem00A + ", testExternalContextItem00B="
+ + testExternalContextItem00B + ", testExternalContextItem00C=" + testExternalContextItem00C + "]";
+ }
+}
diff --git a/context/context-test-utils/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
new file mode 100644
index 000000000..9953a1a95
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java
@@ -0,0 +1,434 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+
+/**
+ * The Class TestGlobalContextItem.
+ */
+public class TestGlobalContextItem implements Serializable {
+ private static final long serialVersionUID = 3348445332683174361L;
+
+ private static final int HASH_PRIME_1 = 31;
+
+ 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 TestContextBooleanItem getTestGlobalContextItem000() {
+ return testGlobalContextItem000;
+ }
+
+ /**
+ * Sets the test global context item 000.
+ *
+ * @param testGlobalContextItem000 the test global context item 000
+ */
+ public void setTestGlobalContextItem000(final TestContextBooleanItem testGlobalContextItem000) {
+ this.testGlobalContextItem000 = testGlobalContextItem000;
+ }
+
+ /**
+ * Gets the test global context item 001.
+ *
+ * @return the test global context item 001
+ */
+ public TestContextByteItem getTestGlobalContextItem001() {
+ return testGlobalContextItem001;
+ }
+
+ /**
+ * Sets the test global context item 001.
+ *
+ * @param testGlobalContextItem001 the test global context item 001
+ */
+ public void setTestGlobalContextItem001(final TestContextByteItem testGlobalContextItem001) {
+ this.testGlobalContextItem001 = testGlobalContextItem001;
+ }
+
+ /**
+ * Gets the test global context item 002.
+ *
+ * @return the test global context item 002
+ */
+ public TestContextIntItem getTestGlobalContextItem002() {
+ return testGlobalContextItem002;
+ }
+
+ /**
+ * Sets the test global context item 002.
+ *
+ * @param testGlobalContextItem002 the test global context item 002
+ */
+ public void setTestGlobalContextItem002(final TestContextIntItem testGlobalContextItem002) {
+ this.testGlobalContextItem002 = testGlobalContextItem002;
+ }
+
+ /**
+ * Gets the test global context item 003.
+ *
+ * @return the test global context item 003
+ */
+ public TestContextLongItem getTestGlobalContextItem003() {
+ return testGlobalContextItem003;
+ }
+
+ /**
+ * Sets the test global context item 003.
+ *
+ * @param testGlobalContextItem003 the test global context item 003
+ */
+ public void setTestGlobalContextItem003(final TestContextLongItem testGlobalContextItem003) {
+ this.testGlobalContextItem003 = testGlobalContextItem003;
+ }
+
+ /**
+ * Gets the test global context item 004.
+ *
+ * @return the test global context item 004
+ */
+ public TestContextFloatItem getTestGlobalContextItem004() {
+ return testGlobalContextItem004;
+ }
+
+ /**
+ * Sets the test global context item 004.
+ *
+ * @param testGlobalContextItem004 the test global context item 004
+ */
+ public void setTestGlobalContextItem004(final TestContextFloatItem testGlobalContextItem004) {
+ this.testGlobalContextItem004 = testGlobalContextItem004;
+ }
+
+ /**
+ * Gets the test global context item 005.
+ *
+ * @return the test global context item 005
+ */
+ public TestContextDoubleItem getTestGlobalContextItem005() {
+ return testGlobalContextItem005;
+ }
+
+ /**
+ * Sets the test global context item 005.
+ *
+ * @param testGlobalContextItem005 the test global context item 005
+ */
+ public void setTestGlobalContextItem005(final TestContextDoubleItem testGlobalContextItem005) {
+ this.testGlobalContextItem005 = testGlobalContextItem005;
+ }
+
+ /**
+ * Gets the test global context item 006.
+ *
+ * @return the test global context item 006
+ */
+ public TestContextStringItem getTestGlobalContextItem006() {
+ return testGlobalContextItem006;
+ }
+
+ /**
+ * Sets the test global context item 006.
+ *
+ * @param testGlobalContextItem006 the test global context item 006
+ */
+ public void setTestGlobalContextItem006(final TestContextStringItem testGlobalContextItem006) {
+ this.testGlobalContextItem006 = testGlobalContextItem006;
+ }
+
+ /**
+ * Gets the test global context item 007.
+ *
+ * @return the test global context item 007
+ */
+ public TestContextLongObjectItem getTestGlobalContextItem007() {
+ return testGlobalContextItem007;
+ }
+
+ /**
+ * Sets the test global context item 007.
+ *
+ * @param testGlobalContextItem007 the test global context item 007
+ */
+ public void setTestGlobalContextItem007(final TestContextLongObjectItem testGlobalContextItem007) {
+ this.testGlobalContextItem007 = testGlobalContextItem007;
+ }
+
+ /**
+ * Gets the test global context item 008.
+ *
+ * @return the test global context item 008
+ */
+ public TestContextDateItem getTestGlobalContextItem008() {
+ return testGlobalContextItem008;
+ }
+
+ /**
+ * Sets the test global context item 008.
+ *
+ * @param testGlobalContextItem008 the test global context item 008
+ */
+ public void setTestGlobalContextItem008(final TestContextDateItem testGlobalContextItem008) {
+ this.testGlobalContextItem008 = testGlobalContextItem008;
+ }
+
+ /**
+ * Gets the test global context item 009.
+ *
+ * @return the test global context item 009
+ */
+ public TestContextDateTzItem getTestGlobalContextItem009() {
+ return testGlobalContextItem009;
+ }
+
+ /**
+ * Sets the test global context item 009.
+ *
+ * @param testGlobalContextItem009 the test global context item 009
+ */
+ public void setTestGlobalContextItem009(final TestContextDateTzItem testGlobalContextItem009) {
+ this.testGlobalContextItem009 = testGlobalContextItem009;
+ }
+
+ /**
+ * Gets the test global context item 00 A.
+ *
+ * @return the test global context item 00 A
+ */
+ public TestContextDateLocaleItem getTestGlobalContextItem00A() {
+ return testGlobalContextItem00A;
+ }
+
+ /**
+ * Sets the test global context item 00 A.
+ *
+ * @param testGlobalContextItem00A the test global context item 00 A
+ */
+ public void setTestGlobalContextItem00A(final TestContextDateLocaleItem testGlobalContextItem00A) {
+ this.testGlobalContextItem00A = testGlobalContextItem00A;
+ }
+
+ /**
+ * Gets the test global context item 00 B.
+ *
+ * @return the test global context item 00 B
+ */
+ public TestContextTreeSetItem getTestGlobalContextItem00B() {
+ return testGlobalContextItem00B;
+ }
+
+ /**
+ * Sets the test global context item 00 B.
+ *
+ * @param testGlobalContextItem00B the test global context item 00 B
+ */
+ public void setTestGlobalContextItem00B(final TestContextTreeSetItem testGlobalContextItem00B) {
+ this.testGlobalContextItem00B = testGlobalContextItem00B;
+ }
+
+ /**
+ * Gets the test global context item 00 C.
+ *
+ * @return the test global context item 00 C
+ */
+ public TestContextTreeMapItem getTestGlobalContextItem00C() {
+ return testGlobalContextItem00C;
+ }
+
+ /**
+ * Sets the test global context item 00 C.
+ *
+ * @param testGlobalContextItem00C the test global context item 00 C
+ */
+ public void setTestGlobalContextItem00C(final TestContextTreeMapItem testGlobalContextItem00C) {
+ this.testGlobalContextItem00C = testGlobalContextItem00C;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + ((testGlobalContextItem000 == null) ? 0 : testGlobalContextItem000.hashCode());
+ result = prime * result + ((testGlobalContextItem001 == null) ? 0 : testGlobalContextItem001.hashCode());
+ result = prime * result + ((testGlobalContextItem002 == null) ? 0 : testGlobalContextItem002.hashCode());
+ result = prime * result + ((testGlobalContextItem003 == null) ? 0 : testGlobalContextItem003.hashCode());
+ result = prime * result + ((testGlobalContextItem004 == null) ? 0 : testGlobalContextItem004.hashCode());
+ result = prime * result + ((testGlobalContextItem005 == null) ? 0 : testGlobalContextItem005.hashCode());
+ result = prime * result + ((testGlobalContextItem006 == null) ? 0 : testGlobalContextItem006.hashCode());
+ result = prime * result + ((testGlobalContextItem007 == null) ? 0 : testGlobalContextItem007.hashCode());
+ result = prime * result + ((testGlobalContextItem008 == null) ? 0 : testGlobalContextItem008.hashCode());
+ result = prime * result + ((testGlobalContextItem009 == null) ? 0 : testGlobalContextItem009.hashCode());
+ result = prime * result + ((testGlobalContextItem00A == null) ? 0 : testGlobalContextItem00A.hashCode());
+ result = prime * result + ((testGlobalContextItem00B == null) ? 0 : testGlobalContextItem00B.hashCode());
+ result = prime * result + ((testGlobalContextItem00C == null) ? 0 : testGlobalContextItem00C.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestGlobalContextItem other = (TestGlobalContextItem) obj;
+ if (testGlobalContextItem000 == null) {
+ if (other.testGlobalContextItem000 != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem000.equals(other.testGlobalContextItem000)) {
+ return false;
+ }
+ if (testGlobalContextItem001 == null) {
+ if (other.testGlobalContextItem001 != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem001.equals(other.testGlobalContextItem001)) {
+ return false;
+ }
+ if (testGlobalContextItem002 == null) {
+ if (other.testGlobalContextItem002 != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem002.equals(other.testGlobalContextItem002)) {
+ return false;
+ }
+ if (testGlobalContextItem003 == null) {
+ if (other.testGlobalContextItem003 != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem003.equals(other.testGlobalContextItem003)) {
+ return false;
+ }
+ if (testGlobalContextItem004 == null) {
+ if (other.testGlobalContextItem004 != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem004.equals(other.testGlobalContextItem004)) {
+ return false;
+ }
+ if (testGlobalContextItem005 == null) {
+ if (other.testGlobalContextItem005 != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem005.equals(other.testGlobalContextItem005)) {
+ return false;
+ }
+ if (testGlobalContextItem006 == null) {
+ if (other.testGlobalContextItem006 != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem006.equals(other.testGlobalContextItem006)) {
+ return false;
+ }
+ if (testGlobalContextItem007 == null) {
+ if (other.testGlobalContextItem007 != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem007.equals(other.testGlobalContextItem007)) {
+ return false;
+ }
+ if (testGlobalContextItem008 == null) {
+ if (other.testGlobalContextItem008 != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem008.equals(other.testGlobalContextItem008)) {
+ return false;
+ }
+ if (testGlobalContextItem009 == null) {
+ if (other.testGlobalContextItem009 != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem009.equals(other.testGlobalContextItem009)) {
+ return false;
+ }
+ if (testGlobalContextItem00A == null) {
+ if (other.testGlobalContextItem00A != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem00A.equals(other.testGlobalContextItem00A)) {
+ return false;
+ }
+ if (testGlobalContextItem00B == null) {
+ if (other.testGlobalContextItem00B != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem00B.equals(other.testGlobalContextItem00B)) {
+ return false;
+ }
+ if (testGlobalContextItem00C == null) {
+ if (other.testGlobalContextItem00C != null) {
+ return false;
+ }
+ } else if (!testGlobalContextItem00C.equals(other.testGlobalContextItem00C)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestGlobalContextItem [testGlobalContextItem000=" + testGlobalContextItem000
+ + ", testGlobalContextItem001=" + testGlobalContextItem001 + ", testGlobalContextItem002="
+ + testGlobalContextItem002 + ", testGlobalContextItem003=" + testGlobalContextItem003
+ + ", testGlobalContextItem004=" + testGlobalContextItem004 + ", testGlobalContextItem005="
+ + testGlobalContextItem005 + ", testGlobalContextItem006=" + testGlobalContextItem006
+ + ", testGlobalContextItem007=" + testGlobalContextItem007 + ", testGlobalContextItem008="
+ + testGlobalContextItem008 + ", testGlobalContextItem009=" + testGlobalContextItem009
+ + ", testGlobalContextItem00A=" + testGlobalContextItem00A + ", testGlobalContextItem00B="
+ + testGlobalContextItem00B + ", testGlobalContextItem00C=" + testGlobalContextItem00C + "]";
+ }
+}
diff --git a/context/context-test-utils/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
new file mode 100644
index 000000000..fc728a7ae
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java
@@ -0,0 +1,241 @@
+/*-
+ * ============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.concepts;
+
+import java.io.Serializable;
+
+/**
+ * The Class TestPolicyContextItem.
+ */
+public class TestPolicyContextItem implements Serializable {
+ private static final long serialVersionUID = 6336372857646152910L;
+
+ private static final int HASH_PRIME_1 = 31;
+
+ 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 TestContextStringItem getTestPolicyContextItem000() {
+ return testPolicyContextItem000;
+ }
+
+ /**
+ * Sets the test policy context item 000.
+ *
+ * @param testPolicyContextItem000 the test policy context item 000
+ */
+ public void setTestPolicyContextItem000(final TestContextStringItem testPolicyContextItem000) {
+ this.testPolicyContextItem000 = testPolicyContextItem000;
+ }
+
+ /**
+ * Gets the test policy context item 001.
+ *
+ * @return the test policy context item 001
+ */
+ public TestContextLongItem getTestPolicyContextItem001() {
+ return testPolicyContextItem001;
+ }
+
+ /**
+ * Sets the test policy context item 001.
+ *
+ * @param testPolicyContextItem001 the test policy context item 001
+ */
+ public void setTestPolicyContextItem001(final TestContextLongItem testPolicyContextItem001) {
+ this.testPolicyContextItem001 = testPolicyContextItem001;
+ }
+
+ /**
+ * Gets the test policy context item 002.
+ *
+ * @return the test policy context item 002
+ */
+ public TestContextDoubleItem getTestPolicyContextItem002() {
+ return testPolicyContextItem002;
+ }
+
+ /**
+ * Sets the test policy context item 002.
+ *
+ * @param testPolicyContextItem002 the test policy context item 002
+ */
+ public void setTestPolicyContextItem002(final TestContextDoubleItem testPolicyContextItem002) {
+ this.testPolicyContextItem002 = testPolicyContextItem002;
+ }
+
+ /**
+ * Gets the test policy context item 003.
+ *
+ * @return the test policy context item 003
+ */
+ public TestContextBooleanItem getTestPolicyContextItem003() {
+ return testPolicyContextItem003;
+ }
+
+ /**
+ * Sets the test policy context item 003.
+ *
+ * @param testPolicyContextItem003 the test policy context item 003
+ */
+ public void setTestPolicyContextItem003(final TestContextBooleanItem testPolicyContextItem003) {
+ this.testPolicyContextItem003 = testPolicyContextItem003;
+ }
+
+ /**
+ * Gets the test policy context item 004.
+ *
+ * @return the test policy context item 004
+ */
+ public TestContextLongItem getTestPolicyContextItem004() {
+ return testPolicyContextItem004;
+ }
+
+ /**
+ * Sets the test policy context item 004.
+ *
+ * @param testPolicyContextItem004 the test policy context item 004
+ */
+ public void setTestPolicyContextItem004(final TestContextLongItem testPolicyContextItem004) {
+ this.testPolicyContextItem004 = testPolicyContextItem004;
+ }
+
+ /**
+ * Gets the test policy context item 005.
+ *
+ * @return the test policy context item 005
+ */
+ public TestContextTreeMapItem getTestPolicyContextItem005() {
+ return testPolicyContextItem005;
+ }
+
+ /**
+ * Sets the test policy context item 005.
+ *
+ * @param testPolicyContextItem005 the test policy context item 005
+ */
+ public void setTestPolicyContextItem005(final TestContextTreeMapItem testPolicyContextItem005) {
+ this.testPolicyContextItem005 = testPolicyContextItem005;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = HASH_PRIME_1;
+ int result = 1;
+ result = prime * result + ((testPolicyContextItem000 == null) ? 0 : testPolicyContextItem000.hashCode());
+ result = prime * result + ((testPolicyContextItem001 == null) ? 0 : testPolicyContextItem001.hashCode());
+ result = prime * result + ((testPolicyContextItem002 == null) ? 0 : testPolicyContextItem002.hashCode());
+ result = prime * result + ((testPolicyContextItem003 == null) ? 0 : testPolicyContextItem003.hashCode());
+ result = prime * result + ((testPolicyContextItem004 == null) ? 0 : testPolicyContextItem004.hashCode());
+ result = prime * result + ((testPolicyContextItem005 == null) ? 0 : testPolicyContextItem005.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestPolicyContextItem other = (TestPolicyContextItem) obj;
+ if (testPolicyContextItem000 == null) {
+ if (other.testPolicyContextItem000 != null) {
+ return false;
+ }
+ } else if (!testPolicyContextItem000.equals(other.testPolicyContextItem000)) {
+ return false;
+ }
+ if (testPolicyContextItem001 == null) {
+ if (other.testPolicyContextItem001 != null) {
+ return false;
+ }
+ } else if (!testPolicyContextItem001.equals(other.testPolicyContextItem001)) {
+ return false;
+ }
+ if (testPolicyContextItem002 == null) {
+ if (other.testPolicyContextItem002 != null) {
+ return false;
+ }
+ } else if (!testPolicyContextItem002.equals(other.testPolicyContextItem002)) {
+ return false;
+ }
+ if (testPolicyContextItem003 == null) {
+ if (other.testPolicyContextItem003 != null) {
+ return false;
+ }
+ } else if (!testPolicyContextItem003.equals(other.testPolicyContextItem003)) {
+ return false;
+ }
+ if (testPolicyContextItem004 == null) {
+ if (other.testPolicyContextItem004 != null) {
+ return false;
+ }
+ } else if (!testPolicyContextItem004.equals(other.testPolicyContextItem004)) {
+ return false;
+ }
+ if (testPolicyContextItem005 == null) {
+ if (other.testPolicyContextItem005 != null) {
+ return false;
+ }
+ } else if (!testPolicyContextItem005.equals(other.testPolicyContextItem005)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "TestPolicyContextItem [testPolicyContextItem000=" + testPolicyContextItem000
+ + ", testPolicyContextItem001=" + testPolicyContextItem001 + ", testPolicyContextItem002="
+ + testPolicyContextItem002 + ", testPolicyContextItem003=" + testPolicyContextItem003
+ + ", testPolicyContextItem004=" + testPolicyContextItem004 + ", testPolicyContextItem005="
+ + testPolicyContextItem005 + "]";
+ }
+}
diff --git a/context/context-test-utils/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
new file mode 100644
index 000000000..d57b3fda3
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ * Defines test Java context classes.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+
+package org.onap.policy.apex.context.test.concepts;
diff --git a/context/context-test-utils/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
new file mode 100644
index 000000000..189208fd5
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java
@@ -0,0 +1,125 @@
+/*-
+ * ============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.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;
+import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+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.AxContextAlbum;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.onap.policy.apex.model.utilities.comparison.KeyedMapComparer;
+import org.onap.policy.apex.model.utilities.comparison.KeyedMapDifference;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class ContextAlbumUpdate is used to test Context Album updates.
+ */
+public class ContextAlbumUpdate {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextAlbumUpdate.class);
+
+ /**
+ * Test context album update.
+ *
+ * @throws ApexModelException the apex model exception
+ * @throws IOException the IO exception
+ * @throws ApexException the apex exception
+ */
+ public void testContextAlbumUpdate() throws ApexModelException, IOException, ApexException {
+ LOGGER.debug("Running TestContextAlbumUpdate test . . .");
+
+ 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", VERSION));
+ final ContextAlbum longAlbum1 = contextDistributor.createContextAlbum(longAlbum1Def.getKey());
+
+ assertNotNull(longAlbum1);
+
+ final AxContextAlbum longAlbum2Def = longModel.getAlbums().get(new AxArtifactKey("LongContextAlbum2", VERSION));
+ final ContextAlbum longAlbum2 = contextDistributor.createContextAlbum(longAlbum2Def.getKey());
+
+ assertNotNull(longAlbum2);
+
+ longAlbum1.put("0", (long) 0);
+ longAlbum1.put("1", (long) 1);
+ longAlbum1.put("2", (long) 2);
+ longAlbum1.put("3", (long) 3);
+
+ final KeyedMapDifference<String, Object> result0 =
+ new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
+
+ 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);
+
+
+ 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);
+ longAlbum1.put("67", (long) 6);
+ longAlbum2.put("67", (long) 7);
+
+ final KeyedMapDifference<String, Object> result2 =
+ new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
+
+ 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");
+
+ final KeyedMapDifference<String, Object> result3 =
+ new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
+
+ 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 000000000..03ef650da
--- /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 000000000..75d559724
--- /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 000000000..e789ae90c
--- /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-utils/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
new file mode 100644
index 000000000..148c8cac4
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ * Runs context distribution tests in APEX.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+
+package org.onap.policy.apex.context.test.distribution;
diff --git a/context/context-test-utils/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
new file mode 100644
index 000000000..3003344b3
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java
@@ -0,0 +1,213 @@
+/*-
+ * ============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.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;
+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;
+
+/**
+ * The Class TestContextAlbumFactory creates test context albums.
+ *
+ * @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.
+ */
+ private TestContextAlbumFactory() {}
+
+ /**
+ * Creates the policy context model.
+ *
+ * @return the ax context model
+ */
+ public static AxContextModel createPolicyContextModel() {
+ 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", VERSION));
+ schemas.getSchemasMap().put(policySchema.getKey(), policySchema);
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
+ albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
+
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
+ final AxContextModel contextModel =
+ new AxContextModel(new AxArtifactKey("PolicyContextModel", VERSION), schemas, albums, keyInformation);
+ contextModel.setKeyInformation(keyInformation);
+ keyInformation.generateKeyInfo(contextModel);
+
+ return contextModel;
+ }
+
+ /**
+ * Creates the global context model.
+ *
+ * @return the ax context model
+ */
+ public static AxContextModel createGlobalContextModel() {
+ 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", VERSION));
+ schemas.getSchemasMap().put(globalSchema.getKey(), globalSchema);
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
+ albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
+
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
+ final AxContextModel contextModel =
+ new AxContextModel(new AxArtifactKey("GlobalContextModel", VERSION), schemas, albums, keyInformation);
+ contextModel.setKeyInformation(keyInformation);
+ keyInformation.generateKeyInfo(contextModel);
+
+ return contextModel;
+ }
+
+ /**
+ * Creates the external context model.
+ *
+ * @return the ax context model
+ */
+ public static AxContextModel createExternalContextModel() {
+ 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", VERSION));
+ schemas.getSchemasMap().put(externalSchema.getKey(), externalSchema);
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
+ albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
+
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
+ final AxContextModel contextModel =
+ new AxContextModel(new AxArtifactKey("ExternalContextModel", VERSION), schemas, albums, keyInformation);
+ contextModel.setKeyInformation(keyInformation);
+ keyInformation.generateKeyInfo(contextModel);
+
+ return contextModel;
+ }
+
+ /**
+ * Creates the long context model.
+ *
+ * @return the ax context model
+ */
+ public static AxContextModel createLongContextModel() {
+ final AxArtifactKey longSchemaKey = new AxArtifactKey("LongSchema", VERSION);
+ final AxContextSchema longSchema = new AxContextSchema(longSchemaKey, JAVA_FLAVOUR, JAVA_LONG);
+
+ 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", VERSION));
+ albums.getAlbumsMap().put(albumDefinition1.getKey(), albumDefinition1);
+ albums.getAlbumsMap().put(albumDefinition2.getKey(), albumDefinition2);
+
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
+ final AxContextModel contextModel =
+ new AxContextModel(new AxArtifactKey("LongContextModel", VERSION), schemas, albums, keyInformation);
+ contextModel.setKeyInformation(keyInformation);
+ keyInformation.generateKeyInfo(contextModel);
+
+ return contextModel;
+ }
+
+ /**
+ * Creates the multi albums context model.
+ *
+ * @return the ax context model
+ */
+ public static AxContextModel createMultiAlbumsContextModel() {
+ final AxContextSchema longSchema =
+ 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", 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(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", 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", 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-utils/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
new file mode 100644
index 000000000..ea70ce2a8
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ * Contains factories for creating test context albums.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+
+package org.onap.policy.apex.context.test.factory;
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
new file mode 100644
index 000000000..2eea957c6
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
@@ -0,0 +1,194 @@
+/*-
+ * ============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.locking;
+
+import java.io.IOException;
+
+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.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;
+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 TestConcurrentContext tests concurrent use of context.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class ConcurrentContext {
+ private static final int TEN_MILLISECONDS = 10;
+
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContext.class);
+
+ // The context distributor and map used by each test
+ private Distributor contextDistributor = null;
+ private ContextAlbum lTypeAlbum = null;
+
+ /**
+ * Test concurrent context.
+ *
+ * @param testType the test type
+ * @param jvmCount the jvm count
+ * @param threadCount the thread count
+ * @param threadLoops the thread loops
+ * @return the long
+ * @throws ApexModelException the apex model exception
+ * @throws IOException the IO exception
+ * @throws ApexException the apex exception
+ */
+ public long testConcurrentContext(final String testType, final int jvmCount, final int threadCount,
+ final int threadLoops) throws ApexModelException, IOException, ApexException {
+ final ConcurrentContext concurrentContext = new ConcurrentContext();
+
+ try {
+ concurrentContext.setupAndVerifyContext();
+ } catch (final Exception exception) {
+ LOGGER.error("Error occured while setting up and verifying concurrent context", exception);
+ throw exception;
+ }
+
+ LOGGER.debug("starting JVMs and threads . . .");
+
+ final Thread[] threadArray = new Thread[threadCount];
+
+ // Check if we have a single JVM or multiple JVMs
+ int runningThreadCount = -1;
+ if (jvmCount == 1) {
+ // Run everything in this JVM
+ for (int t = 0; t < threadCount; t++) {
+ threadArray[t] = new Thread(new ConcurrentContextThread(0, t, threadLoops));
+ threadArray[t].setName(testType + ":TestConcurrentContextThread_0_" + t);
+ threadArray[t].start();
+ }
+
+ runningThreadCount = threadCount;
+ } else {
+ // Spawn JVMs to run the tests
+ for (int j = 0; j < jvmCount; j++) {
+ threadArray[j] = new Thread(new ConcurrentContextJVMThread(testType, j, threadCount, threadLoops));
+ threadArray[j].setName(testType + ":TestConcurrentContextJVMThread_" + j);
+ threadArray[j].start();
+ }
+ runningThreadCount = jvmCount;
+ }
+
+ boolean allFinished;
+ do {
+ allFinished = true;
+ for (int i = 0; i < runningThreadCount; i++) {
+ if (threadArray[i].isAlive()) {
+ allFinished = false;
+ try {
+ Thread.sleep(TEN_MILLISECONDS);
+ } catch (final Exception e) {
+ }
+ break;
+ }
+ }
+ } while (!allFinished);
+
+ return concurrentContext.verifyAndClearContext(jvmCount, threadCount, threadLoops);
+ }
+
+ /**
+ * Setup and verify context.
+ *
+ * @throws ContextException the context exception
+ */
+ private void setupAndVerifyContext() throws ContextException {
+ final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1");
+ 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
+
+ final AxContextModel albumsModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
+ contextDistributor.registerModel(albumsModel);
+
+ lTypeAlbum = contextDistributor.createContextAlbum(new AxArtifactKey("LTypeContextAlbum", "0.0.1"));
+ assert (lTypeAlbum != null);
+ lTypeAlbum.setUserArtifactStack(usedArtifactStackArray);
+
+ // CHECKSTYLE:OFF: checkstyle:magicNumber
+ 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 TestContextLongItem item = new TestContextLongItem(0L);
+ lTypeAlbum.put("testValue", item);
+
+ }
+
+ /**
+ * Verify and clear context.
+ *
+ * @param jvmCount the jvm count
+ * @param threadCount the thread count
+ * @param threadLoops the thread loops
+ * @return the long
+ * @throws ContextException the context exception
+ */
+ private long verifyAndClearContext(final int jvmCount, final int threadCount, final int threadLoops)
+ throws ContextException {
+ try {
+ LOGGER.debug("threads finished, end value is {}",
+ ((TestContextLongItem) lTypeAlbum.get("testValue")).getLongValue());
+ } catch (final Exception exception) {
+ LOGGER.error("Error: ", exception);
+ }
+ final long total = ((TestContextLongItem) lTypeAlbum.get("testValue")).getLongValue();
+
+ contextDistributor.clear();
+ contextDistributor = null;
+
+ return total;
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
new file mode 100644
index 000000000..0145bd161
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
@@ -0,0 +1,219 @@
+/*-
+ * ============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.locking;
+
+import com.google.gson.Gson;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Map.Entry;
+import java.util.TreeSet;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.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.service.AbstractParameters;
+import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class ConcurrentContextJVM tests concurrent use of context in a single JVM.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public final class ConcurrentContextJVM {
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextJVM.class);
+
+ private static final int TEN_MILLISECONDS = 10;
+ private static final int IPV4_ADDRESS_LENGTH = 4;
+
+ /**
+ * The Constructor.
+ *
+ * @param testType the test type
+ * @param jvmNo the jvm no
+ * @param threadCount the thread count
+ * @param threadLoops the thread loops
+ * @throws ApexException the apex exception
+ */
+ private ConcurrentContextJVM(final String testType, final int jvmNo, final int threadCount, final int threadLoops)
+ throws ApexException {
+ super();
+ LOGGER.debug("starting JVMs and threads . . .");
+
+ final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor" + jvmNo, "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
+
+ final AxContextModel albumsModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
+ contextDistributor.registerModel(albumsModel);
+
+ final ContextAlbum lTypeAlbum =
+ contextDistributor.createContextAlbum(new AxArtifactKey("LTypeContextAlbum", "0.0.1"));
+ assert (lTypeAlbum != null);
+ lTypeAlbum.setUserArtifactStack(usedArtifactStackArray);
+
+ final Thread[] threadArray = new Thread[threadCount];
+
+ for (int t = 0; t < threadCount; t++) {
+ threadArray[t] = new Thread(new ConcurrentContextThread(jvmNo, t, threadLoops));
+ threadArray[t].setName(testType + ":ConcurrentContextThread_" + jvmNo + "_" + t);
+ threadArray[t].start();
+ LOGGER.debug("started thread " + threadArray[t].getName());
+ }
+
+ boolean allFinished;
+ do {
+ allFinished = true;
+ for (int t = 0; t < threadCount; t++) {
+ if (threadArray[t].isAlive()) {
+ allFinished = false;
+ try {
+ Thread.sleep(TEN_MILLISECONDS);
+ } catch (final Exception e) {
+ }
+ break;
+ }
+ }
+ } while (!allFinished);
+
+ LOGGER.debug("threads finished, end value is {}", lTypeAlbum.get("testValue"));
+ contextDistributor.clear();
+ }
+
+ /**
+ * The main method.
+ *
+ * @param args the args
+ * @throws Exception Any exception thrown by the test code
+ */
+ @SuppressWarnings("unchecked")
+ public static void main(final String[] args) throws Exception {
+ configure();
+
+ System.out.println("JVM Arguments: " + Arrays.toString(args));
+ // CHECKSTYLE:OFF: checkstyle:magicNumber
+
+ // An even number of arguments greater than 3
+ if (args.length < 4 || (args.length % 2 != 0)) {
+ LOGGER.error("invalid arguments: " + Arrays.toString(args));
+ LOGGER.error(
+ "usage: TestConcurrentContextJVM testType jvmNo threadCount threadLoops [parameterKey parameterJson].... ");
+ return;
+ }
+
+ int jvmNo = -1;
+ int threadCount = -1;
+ int threadLoops = -1;
+
+ try {
+ jvmNo = Integer.parseInt(args[1]);
+ } catch (final Exception e) {
+ LOGGER.error("invalid argument jvmNo", e);
+ return;
+ }
+
+ try {
+ threadCount = Integer.parseInt(args[2]);
+ } catch (final Exception e) {
+ LOGGER.error("invalid argument threadCount", e);
+ return;
+ }
+
+ try {
+ threadLoops = Integer.parseInt(args[3]);
+ } catch (final Exception e) {
+ LOGGER.error("invalid argument threadLoops", e);
+ return;
+ }
+
+ for (int p = 4; p < args.length - 1; p += 2) {
+ @SuppressWarnings("rawtypes")
+ final Class parametersClass = Class.forName(args[p]);
+ final AbstractParameters parameters =
+ (AbstractParameters) new Gson().fromJson(args[p + 1], parametersClass);
+ ParameterService.registerParameters(parametersClass, parameters);
+ }
+
+ for (final Entry<Class<?>, AbstractParameters> parameterEntry : ParameterService.getAll()) {
+ LOGGER.info("Parameter class " + parameterEntry.getKey().getCanonicalName() + "="
+ + parameterEntry.getValue().toString());
+ }
+
+ try {
+ new ConcurrentContextJVM(args[0], jvmNo, threadCount, threadLoops);
+ } catch (final Exception e) {
+ LOGGER.error("error running test in JVM", e);
+ return;
+ }
+ // CHECKSTYLE:ON: checkstyle:magicNumber
+ }
+
+ /**
+ * This method setus up any static configuration required by the JVM.
+ *
+ * @throws Exception on configuration errors
+ */
+ public static void configure() throws Exception {
+ System.setProperty("java.net.preferIPv4Stack", "true");
+ System.setProperty("hazelcast.config", "src/test/resources/hazelcast/hazelcast.xml");
+
+ // The JGroups IP address must be set to a real (not loopback) IP address for Infinispan to work. IN order to
+ // ensure that all
+ // the JVMs in a test pick up the same IP address, this function sets te address to be the first non-loopback
+ // IPv4 address
+ // on a host
+ final TreeSet<String> ipAddressSet = new TreeSet<String>();
+
+ final Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
+ for (final NetworkInterface netint : Collections.list(nets)) {
+ final Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
+ for (final InetAddress inetAddress : Collections.list(inetAddresses)) {
+ // Look for real IPv4 Internet addresses
+ if (!inetAddress.isLoopbackAddress() && inetAddress.getAddress().length == IPV4_ADDRESS_LENGTH) {
+ ipAddressSet.add(inetAddress.getHostAddress());
+ }
+ }
+ }
+
+ if (ipAddressSet.size() == 0) {
+ throw new Exception("cound not find real IP address for test");
+ }
+ System.out.println("Setting jgroups.tcp.address to: " + ipAddressSet.first());
+ System.setProperty("jgroups.tcp.address", ipAddressSet.first());
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
new file mode 100644
index 000000000..da2741f7b
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
@@ -0,0 +1,124 @@
+/*-
+ * ============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.locking;
+
+import com.google.gson.Gson;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
+import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestConcurrentContextThread tests concurrent use of context.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class ConcurrentContextJVMThread implements Runnable {
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextJVMThread.class);
+
+ private final String testType;
+ private final int jvm;
+ private final int threadCount;
+ private final int target;
+
+ /**
+ * The Constructor.
+ *
+ * @param testType the test type
+ * @param jvm the jvm
+ * @param threadCount the thread count
+ * @param target the target
+ * @throws ApexException the apex exception
+ */
+ public ConcurrentContextJVMThread(final String testType, final int jvm, final int threadCount, final int target)
+ throws ApexException {
+ this.testType = testType;
+ this.jvm = jvm;
+ this.threadCount = threadCount;
+ this.target = target;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ final List<String> commandList = new ArrayList<>();
+ commandList.add(System.getProperty("java.home") + System.getProperty("file.separator") + "bin"
+ + System.getProperty("file.separator") + "java");
+ commandList.add("-cp");
+ commandList.add(System.getProperty("java.class.path"));
+ commandList.add(ConcurrentContextJVM.class.getCanonicalName());
+ commandList.add(testType);
+ commandList.add(new Integer(jvm).toString());
+ commandList.add(new Integer(threadCount).toString());
+ commandList.add(new Integer(target).toString());
+
+ for (final Entry<Class<?>, AbstractParameters> parameterServiceEntry : ParameterService.getAll()) {
+ commandList.add(parameterServiceEntry.getKey().getCanonicalName());
+ commandList.add(new Gson().toJson(parameterServiceEntry.getValue()));
+ }
+
+ LOGGER.info("starting JVM " + jvm);
+
+ // Run the JVM
+ final ProcessBuilder processBuilder = new ProcessBuilder(commandList);
+ processBuilder.redirectErrorStream(true);
+ Process process;
+
+ try {
+ process = processBuilder.start();
+
+ final InputStream is = process.getInputStream();
+ final InputStreamReader isr = new InputStreamReader(is);
+ final BufferedReader br = new BufferedReader(isr);
+ String line;
+ LOGGER.info("JVM Output for command " + commandList + "\n");
+ while ((line = br.readLine()) != null) {
+ LOGGER.info(line);
+ }
+
+ // Wait to get exit value
+ try {
+ final int exitValue = process.waitFor();
+ LOGGER.info("\n\nJVM " + jvm + " finished, exit value is " + exitValue);
+ } catch (final InterruptedException e) {
+ LOGGER.warn("Thread was interrupted");
+ Thread.currentThread().interrupt();
+ }
+ } catch (final IOException ioException) {
+ LOGGER.error("Error occured while writing JVM Output for command ", ioException);
+ }
+ }
+}
diff --git a/context/context-test-utils/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
new file mode 100644
index 000000000..554c3d005
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
@@ -0,0 +1,146 @@
+/*-
+ * ============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.locking;
+
+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.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;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestConcurrentContextThread tests concurrent use of context.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class ConcurrentContextThread implements Runnable {
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextThread.class);
+ private final Distributor distributor;
+ private final int jvm;
+ private final int instance;
+ private final int threadLoops;
+
+ /**
+ * The Constructor.
+ *
+ * @param jvm the jvm
+ * @param instance the instance
+ * @param threadLoops the thread loops
+ * @throws ApexException the apex exception
+ */
+ public ConcurrentContextThread(final int jvm, final int instance, final int threadLoops) throws ApexException {
+ this.jvm = jvm;
+ this.instance = instance;
+ this.threadLoops = threadLoops;
+
+ final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor_" + jvm + "_" + instance, "0.0.1");
+
+ new ContextParameters();
+ distributor = new DistributorFactory().getDistributor(distributorKey);
+ final AxContextModel albumsModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
+ distributor.registerModel(albumsModel);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ LOGGER.info("running TestConcurrentContextThread_" + jvm + "_" + instance + " . . .");
+
+ ContextAlbum lTypeAlbum = null;
+
+ try {
+ lTypeAlbum = distributor.createContextAlbum(new AxArtifactKey("LTypeContextAlbum", "0.0.1"));
+ } catch (final Exception e) {
+ LOGGER.error("could not get the test context album", e);
+ LOGGER.error("failed TestConcurrentContextThread_" + jvm + "_" + instance);
+ return;
+ }
+
+ if (lTypeAlbum == null) {
+ LOGGER.error("could not find the test context album");
+ LOGGER.error("failed TestConcurrentContextThread_" + jvm + "_" + instance);
+ 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
+
+ lTypeAlbum.setUserArtifactStack(usedArtifactStackArray);
+
+ try {
+ updateAlbum(lTypeAlbum);
+ } catch (final Exception exception) {
+ LOGGER.error("could not set the value in the test context album", exception);
+ LOGGER.error("failed TestConcurrentContextThread_" + jvm + "_" + instance);
+ return;
+ }
+
+ try {
+ lTypeAlbum.lockForWriting("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) {
+ LOGGER.error("could not read the value in the test context album", e);
+ LOGGER.error("failed TestConcurrentContextThread_" + jvm + "_" + instance);
+ } finally {
+ try {
+ lTypeAlbum.unlockForWriting("testValue");
+ distributor.shutdown();
+ } catch (final ContextException e) {
+ LOGGER.error("could not unlock test context album item", e);
+ LOGGER.error("failed TestConcurrentContextThread_" + jvm + "_" + instance);
+ }
+ }
+ }
+
+ private void updateAlbum(final ContextAlbum lTypeAlbum) throws Exception {
+ for (int i = 0; i < threadLoops; i++) {
+ try {
+ lTypeAlbum.lockForWriting("testValue");
+ TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get("testValue");
+ if (item != null) {
+ long value = item.getLongValue();
+ item.setLongValue(++value);
+ } else {
+ item = new TestContextLongItem(0L);
+ }
+ lTypeAlbum.put("testValue", item);
+ } finally {
+ lTypeAlbum.unlockForWriting("testValue");
+ }
+ }
+ }
+}
diff --git a/context/context-test-utils/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
new file mode 100644
index 000000000..0e80e611d
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ * Contains tests to check APEX context album distributed locking.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+
+package org.onap.policy.apex.context.test.locking;
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 000000000..90e586e72
--- /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-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
new file mode 100644
index 000000000..105b59e8e
--- /dev/null
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
@@ -0,0 +1,65 @@
+/*-
+ * ============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 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;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+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(JVMLocalDistributor.class.getCanonicalName());
+ new ContextAlbumUpdate().testContextAlbumUpdate();
+
+ logger.debug("Ran testContextAlbumUpdateJVMLocalVarSet 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/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
new file mode 100644
index 000000000..565a39f97
--- /dev/null
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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 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;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestContextInstantiation.
+ *
+ * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
+ */
+public class TestContextInstantiation {
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(TestContextInstantiation.class);
+
+ @Before
+ public void beforeTest() {}
+
+ /**
+ * Test context instantiation clear down.
+ */
+ @After
+ public void afterTest() {}
+
+ @Test
+ public void testContextInstantiationJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testContextInstantiationJVMLocalVarSet test . . .");
+
+ final ContextParameters contextParameters = new ContextParameters();
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
+ new ContextInstantiation().testContextInstantiation();
+
+ logger.debug("Ran testContextInstantiationJVMLocalVarSet 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/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
new file mode 100644
index 000000000..1a9bc29f1
--- /dev/null
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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 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;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestContextUpdate.
+ *
+ * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
+ */
+public class TestContextUpdate {
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdate.class);
+
+ @Test
+ public void testContextUpdateJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testContextUpdateJVMLocalVarSet test . . .");
+
+ final ContextParameters contextParameters = new ContextParameters();
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
+ new ContextUpdate().testContextUpdate();
+
+ logger.debug("Ran testContextUpdateJVMLocalVarSet 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/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
new file mode 100644
index 000000000..28bd7eb01
--- /dev/null
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
@@ -0,0 +1,73 @@
+/*-
+ * ============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 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;
+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(JVMLocalDistributor.class.getCanonicalName());
+ new SequentialContextInstantiation().testSequentialContextInstantiation();
+
+ logger.debug("Ran testSequentialContextInstantiationJVMLocalVarSet 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/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
new file mode 100644
index 000000000..7788fb411
--- /dev/null
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
@@ -0,0 +1,96 @@
+/*-
+ * ============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.locking;
+
+
+import static org.junit.Assert.assertEquals;
+
+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;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestConcurrentContext tests concurrent use of context.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class TestConcurrentContext {
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(TestConcurrentContext.class);
+
+ // Test parameters
+ private static final int TEST_JVM_COUNT_SINGLE_JVM = 1;
+ private static final int TEST_JVM_COUNT_MULTI_JVM = 3;
+ private static final int TEST_THREAD_COUNT_SINGLE_JVM = 64;
+ private static final int TEST_THREAD_COUNT_MULTI_JVM = 20;
+ private static final int TEST_THREAD_LOOPS = 100;
+
+ @Test
+ public void testConcurrentContextJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testConcurrentContextJVMLocalVarSet test . . .");
+
+ final ContextParameters contextParameters = new ContextParameters();
+ 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);
+
+ assertEquals(TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS, result);
+
+ logger.debug("Ran testConcurrentContextJVMLocalVarSet test");
+ }
+
+ @Test
+ public void testConcurrentContextJVMLocalNoVarSet() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testConcurrentContextJVMLocalNoVarSet test . . .");
+
+ new ContextParameters();
+ final long result = new ConcurrentContext().testConcurrentContext("JVMLocalNoVarSet", TEST_JVM_COUNT_SINGLE_JVM,
+ TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
+
+ assertEquals(TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS, result);
+
+ logger.debug("Ran testConcurrentContextJVMLocalNoVarSet test");
+ }
+
+ @Test
+ public void testConcurrentContextMultiJVMNoLock() throws ApexModelException, IOException, ApexException {
+ logger.debug("Running testConcurrentContextMultiJVMNoLock test . . .");
+
+ final ContextParameters contextParameters = new ContextParameters();
+ 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);
+
+ // No concurrent map so result will be zero
+ assertEquals(0, result);
+
+ logger.debug("Ran testConcurrentContextMultiJVMNoLock test");
+ }
+}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
new file mode 100644
index 000000000..a05928591
--- /dev/null
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
@@ -0,0 +1,185 @@
+/*-
+ * ============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.persistence;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.PersistorParameters;
+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;
+import org.onap.policy.apex.model.basicmodel.dao.ApexDao;
+import org.onap.policy.apex.model.basicmodel.dao.ApexDaoFactory;
+import org.onap.policy.apex.model.basicmodel.dao.DAOParameters;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+
+/**
+ * The Class TestContextInstantiation.
+ *
+ * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
+ */
+public class TestPersistentContextInstantiation {
+ // Logger for this class
+ // private static final XLogger logger =
+ // XLoggerFactory.getXLogger(TestPersistentContextInstantiation.class);
+
+ private Connection connection;
+
+ @Before
+ public void setup() throws Exception {
+ Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
+ connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
+ }
+
+ @After
+ public void teardown() throws Exception {
+ connection.close();
+ new File("derby.log").delete();
+ }
+
+ @After
+ public void afterTest() throws IOException {}
+
+ @Test
+ public void testContextPersistentInstantiation() throws ApexModelException, IOException, ApexException {
+
+ final ContextParameters contextParameters = new ContextParameters();
+ contextParameters.setPersistorParameters(new PersistorParameters());
+
+ final AxArtifactKey distributorKey = new AxArtifactKey("AbstractDistributor", "0.0.1");
+ final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
+
+ 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");
+ daoParameters.setPersistenceUnit("DAOTest");
+ final ApexDao apexDao = new ApexDaoFactory().createApexDao(daoParameters);
+ apexDao.init(daoParameters);
+
+ final AxContextModel someContextModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
+
+ // Context for Storing Map values
+ final AxContextAlbum axContextAlbumForMap =
+ someContextModel.getAlbums().getAlbumsMap().get(new AxArtifactKey("MapContextAlbum", "0.0.1"));
+ apexDao.create(axContextAlbumForMap);
+ contextDistributor.registerModel(someContextModel);
+ final ContextAlbum contextAlbumForMap = contextDistributor.createContextAlbum(axContextAlbumForMap.getKey());
+ assertNotNull(contextAlbumForMap);
+ contextAlbumForMap.setUserArtifactStack(usedArtifactStackArray);
+
+ final Map<String, String> testMap = new HashMap<String, String>();
+ testMap.put("key", "This is a policy context string");
+
+ final Map<String, Object> valueMap0 = new HashMap<String, Object>();
+ valueMap0.put("TestPolicyContextItem000", new TestContextTreeMapItem(testMap));
+
+ contextAlbumForMap.putAll(valueMap0);
+
+ assertEquals(((TestContextTreeMapItem) contextAlbumForMap.get("TestPolicyContextItem000")).getMapValue().get("key"),
+ "This is a policy context string");
+
+ contextAlbumForMap.flush();
+
+ // Context for Storing Date values
+ final AxContextAlbum axContextAlbumForDate =
+ someContextModel.getAlbums().getAlbumsMap().get(new AxArtifactKey("DateContextAlbum", "0.0.1"));
+ apexDao.create(axContextAlbumForDate);
+ contextDistributor.registerModel(someContextModel);
+ final ContextAlbum contextAlbumForDate = contextDistributor.createContextAlbum(axContextAlbumForDate.getKey());
+ assertNotNull(contextAlbumForDate);
+ contextAlbumForDate.setUserArtifactStack(usedArtifactStackArray);
+
+ 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);
+
+ final Map<String, Object> valueMap1 = new HashMap<String, Object>();
+ valueMap1.put("TestPolicyContextItem00A", tci00A);
+
+ contextAlbumForDate.putAll(valueMap1);
+
+ assertEquals(((TestContextDateLocaleItem) contextAlbumForDate.get("TestPolicyContextItem00A")).getDateValue(),
+ testDate);
+ assertEquals(((TestContextDateLocaleItem) contextAlbumForDate.get("TestPolicyContextItem00A")).getDST(), true);
+
+ contextAlbumForDate.flush();
+
+ // Context for Storing Long values
+ final AxContextAlbum axContextAlbumForLong =
+ someContextModel.getAlbums().getAlbumsMap().get(new AxArtifactKey("LTypeContextAlbum", "0.0.1"));
+ apexDao.create(axContextAlbumForLong);
+ contextDistributor.registerModel(someContextModel);
+ final ContextAlbum contextAlbumForLong = contextDistributor.createContextAlbum(axContextAlbumForLong.getKey());
+ assertNotNull(contextAlbumForLong);
+ contextAlbumForLong.setUserArtifactStack(usedArtifactStackArray);
+
+ final Map<String, Object> valueMap2 = new HashMap<String, Object>();
+ 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(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0031")).getLongValue(),
+ 0xFFFFFFFFFFFFFFFFL);
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0032")).getLongValue(),
+ 0xFFFFFFFFFFFFFFFEL);
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0033")).getLongValue(),
+ 0xFFFFFFFFFFFFFFFDL);
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0034")).getLongValue(),
+ 0xFFFFFFFFFFFFFFFCL);
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0035")).getLongValue(),
+ 0xFFFFFFFFFFFFFFFBL);
+
+ contextAlbumForLong.flush();
+ contextDistributor.clear();
+
+ }
+}
diff --git a/context/context-test-utils/src/test/resources/META-INF/persistence.xml b/context/context-test-utils/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 000000000..ec9357851
--- /dev/null
+++ b/context/context-test-utils/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,50 @@
+<?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=========================================================
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+ <persistence-unit name="DAOTest" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.apex.model.basicmodel.dao.converters.CDATAConditioner</class>
+ <class>org.onap.policy.apex.model.basicmodel.dao.converters.UUID2String</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxConcept</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxModel</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.TestEntity</class>
+ <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema</class>
+ <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas</class>
+ <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum</class>
+ <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums</class>
+ <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextModel</class>
+
+ <properties>
+ <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
+ <property name="javax.persistence.target-database" value="Derby" />
+ <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
+
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+ </properties>
+ </persistence-unit>
+</persistence>