summaryrefslogtreecommitdiffstats
path: root/context/context-test-utils/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'context/context-test-utils/src/test')
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/concepts/ConceptUncoveredTest.java715
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdateTest.java100
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextInstantiationTest.java105
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextUpdateTest.java106
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiationTest.java109
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntityTest.java113
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/entities/ReferenceTestEntityTest.java114
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/ConcurrentContextTest.java181
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/PersistentContextInstantiationTest.java224
-rw-r--r--context/context-test-utils/src/test/resources/META-INF/persistence.xml50
10 files changed, 0 insertions, 1817 deletions
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/concepts/ConceptUncoveredTest.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/concepts/ConceptUncoveredTest.java
deleted file mode 100644
index eca9cb72e..000000000
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/concepts/ConceptUncoveredTest.java
+++ /dev/null
@@ -1,715 +0,0 @@
-/*-
- * ============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.concepts;
-
-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 java.time.Instant;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.junit.Test;
-
-/**
- * Cover uncovered code in concepts.
- *
- */
-public class ConceptUncoveredTest {
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testInt() {
- TestContextIntItem intItem = new TestContextIntItem(123);
- assertEquals(123, intItem.getIntValue());
-
- assertFalse(intItem.equals(null));
- assertTrue(intItem.equals(intItem));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(intItem.equals(booleanItem));
-
- TestContextIntItem otherIntItem = new TestContextIntItem(intItem);
- assertTrue(intItem.equals(otherIntItem));
- otherIntItem.setIntValue(321);
- assertFalse(intItem.equals(otherIntItem));
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testByte() {
- TestContextByteItem byteItem = new TestContextByteItem((byte) 123);
- assertEquals(123, byteItem.getByteValue());
-
- assertFalse(byteItem.equals(null));
- assertTrue(byteItem.equals(byteItem));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(byteItem.equals(booleanItem));
-
- TestContextByteItem otherByteItem = new TestContextByteItem((byte) 123);
- assertTrue(byteItem.equals(otherByteItem));
- otherByteItem.setByteValue((byte) 321);
- assertFalse(byteItem.equals(otherByteItem));
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testLong() {
- TestContextLongItem longItem = new TestContextLongItem((long) 123);
- assertEquals(123, longItem.getLongValue());
-
- assertFalse(longItem.equals(null));
- assertTrue(longItem.equals(longItem));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(longItem.equals(booleanItem));
-
- TestContextLongItem otherLongItem = new TestContextLongItem((long) 123);
- assertTrue(longItem.equals(otherLongItem));
- otherLongItem.setLongValue((long) 321);
- assertFalse(longItem.equals(otherLongItem));
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testFloat() {
- TestContextFloatItem floatItem = new TestContextFloatItem((float) 123);
- assertEquals(new Float("123"), (Float) floatItem.getFloatValue());
-
- assertFalse(floatItem.equals(null));
- assertTrue(floatItem.equals(floatItem));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(floatItem.equals(booleanItem));
-
- TestContextFloatItem otherFloatItem = new TestContextFloatItem((float) 123);
- assertTrue(floatItem.equals(otherFloatItem));
- otherFloatItem.setFloatValue((float) 321);
- assertFalse(floatItem.equals(otherFloatItem));
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testDouble() {
- TestContextDoubleItem doubleItem = new TestContextDoubleItem((double) 123);
- assertEquals(new Double("123"), (Double) doubleItem.getDoubleValue());
-
- assertFalse(doubleItem.equals(null));
- assertTrue(doubleItem.equals(doubleItem));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(doubleItem.equals(booleanItem));
-
- TestContextDoubleItem otherDoubleItem = new TestContextDoubleItem((double) 123);
- assertTrue(doubleItem.equals(otherDoubleItem));
- otherDoubleItem.setDoubleValue((double) 321);
- assertFalse(doubleItem.equals(otherDoubleItem));
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testBoolean() {
- TestContextBooleanItem booleanItem = new TestContextBooleanItem(true);
- assertEquals(true, booleanItem.getFlag());
-
- assertFalse(booleanItem.equals(null));
- assertTrue(booleanItem.equals(booleanItem));
-
- TestContextDoubleItem doubleItem = new TestContextDoubleItem();
- assertFalse(booleanItem.equals(doubleItem));
-
- TestContextBooleanItem otherBooleanItem = new TestContextBooleanItem(true);
- assertTrue(booleanItem.equals(otherBooleanItem));
- otherBooleanItem.setFlag(false);
- assertFalse(booleanItem.equals(otherBooleanItem));
-
- assertEquals(1262, booleanItem.hashCode());
- assertEquals(1268, otherBooleanItem.hashCode());
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testString() {
- TestContextStringItem stringItem = new TestContextStringItem("A String");
- assertEquals("A String", stringItem.getStringValue());
-
- assertFalse(stringItem.equals(null));
- assertTrue(stringItem.equals(stringItem));
-
- TestContextDoubleItem doubleItem = new TestContextDoubleItem();
- assertFalse(stringItem.equals(doubleItem));
-
- TestContextStringItem otherStringItem = new TestContextStringItem("A String");
- assertTrue(stringItem.equals(otherStringItem));
- otherStringItem.setStringValue("Some Other String Value");
- assertFalse(stringItem.equals(otherStringItem));
-
- otherStringItem.setStringValue(null);
- assertEquals(-1859249905, stringItem.hashCode());
- assertEquals(31, otherStringItem.hashCode());
-
- assertFalse(otherStringItem.equals(stringItem));
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testLongObject() {
- TestContextLongObjectItem longItem = new TestContextLongObjectItem((long) 123);
- assertEquals((Long) 123L, longItem.getLongValue());
-
- assertFalse(longItem.equals(null));
- assertTrue(longItem.equals(longItem));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(longItem.equals(booleanItem));
-
- TestContextLongObjectItem otherLongItem = new TestContextLongObjectItem((long) 123);
- assertTrue(longItem.equals(otherLongItem));
- otherLongItem.setLongValue((long) 321);
- assertFalse(longItem.equals(otherLongItem));
-
- otherLongItem.setLongValue(null);
- assertEquals(154, longItem.hashCode());
- assertEquals(31, otherLongItem.hashCode());
- assertFalse(otherLongItem.equals(longItem));
- }
-
- @SuppressWarnings(
- { "unlikely-arg-type", "rawtypes", "unchecked" })
- @Test
- public void testTreeMap() {
- TestContextTreeMapItem treeMapItem = new TestContextTreeMapItem();
- assertEquals(new TreeMap(), treeMapItem.getMapValue());
-
- assertFalse(treeMapItem.equals(null));
- assertTrue(treeMapItem.equals(treeMapItem));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(treeMapItem.equals(booleanItem));
-
- TestContextTreeMapItem otherTreeMapItem = new TestContextTreeMapItem();
- assertTrue(treeMapItem.equals(otherTreeMapItem));
- otherTreeMapItem.getMapValue().put("Key", "Value");
- assertFalse(treeMapItem.equals(otherTreeMapItem));
-
- treeMapItem.setMapValue(new TreeMap());
- otherTreeMapItem.setMapValue(null);
- assertNotNull(otherTreeMapItem.getMapValue());
- otherTreeMapItem.setMapValue(null);
- assertEquals(31, treeMapItem.hashCode());
- assertEquals(31, otherTreeMapItem.hashCode());
- assertFalse(otherTreeMapItem.equals(treeMapItem));
- treeMapItem.setMapValue(null);
- assertTrue(otherTreeMapItem.equals(treeMapItem));
- }
-
- @SuppressWarnings(
- { "unlikely-arg-type", "rawtypes", "unchecked" })
- @Test
- public void testTreeSet() {
- TestContextTreeSetItem treeSetItem = new TestContextTreeSetItem();
- assertEquals(new TreeSet(), treeSetItem.getSetValue());
-
- assertFalse(treeSetItem.equals(null));
- assertTrue(treeSetItem.equals(treeSetItem));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(treeSetItem.equals(booleanItem));
-
- TestContextTreeSetItem otherTreeSetItem = new TestContextTreeSetItem();
- assertTrue(treeSetItem.equals(otherTreeSetItem));
- otherTreeSetItem.getSetValue().add("Value");
- assertFalse(treeSetItem.equals(otherTreeSetItem));
-
- treeSetItem.setSetValue(new TreeSet());
- otherTreeSetItem.setSetValue(null);
- assertNotNull(otherTreeSetItem.getSetValue());
- otherTreeSetItem.setSetValue(null);
- assertEquals(31, treeSetItem.hashCode());
- assertEquals(31, otherTreeSetItem.hashCode());
- assertFalse(otherTreeSetItem.equals(treeSetItem));
- treeSetItem.setSetValue(null);
- assertTrue(otherTreeSetItem.equals(treeSetItem));
-
- String[] stringArray =
- { "hello", "goodbye" };
- TestContextTreeSetItem treeSetItemFromArray = new TestContextTreeSetItem(stringArray);
- assertTrue(treeSetItemFromArray.getSetValue().contains("hello"));
- assertTrue(treeSetItemFromArray.getSetValue().contains("goodbye"));
- }
-
- @SuppressWarnings(
- { "unlikely-arg-type" })
- @Test
- public void testDate() {
- TestContextDateItem dateItem = new TestContextDateItem();
- assertTrue(new Date().getTime() >= dateItem.getDateValue().getTime());
-
- assertFalse(dateItem.equals(null));
- assertTrue(dateItem.equals(dateItem));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(dateItem.equals(booleanItem));
-
- TestContextDateItem otherDateItem = new TestContextDateItem(dateItem.getDateValue());
- assertTrue(dateItem.equals(otherDateItem));
- otherDateItem.setDateValue(Date.from(Instant.now()));
- assertFalse(dateItem.equals(otherDateItem));
-
- dateItem.setDateValue(new Date());
- otherDateItem.setDateValue(null);
- assertNotNull(otherDateItem.getDateValue());
- otherDateItem.setDateValue(new Date(12345678));
- assertEquals(939444071, otherDateItem.hashCode());
- assertFalse(otherDateItem.equals(dateItem));
- dateItem = new TestContextDateItem(null);
- otherDateItem = new TestContextDateItem(null);
- assertTrue(otherDateItem.equals(dateItem));
-
- dateItem = new TestContextDateItem(new Date(1538394566123L));
- assertEquals(2018, dateItem.getYear());
- assertEquals(9, dateItem.getMonth());
- assertEquals(1, dateItem.getDay());
- assertEquals(11, dateItem.getHour());
- assertEquals(49, dateItem.getMinute());
- assertEquals(26, dateItem.getSecond());
- assertEquals(123, dateItem.getMilliSecond());
-
- dateItem = new TestContextDateItem(new Date(0L));
- otherDateItem = new TestContextDateItem(new Date(1L));
- assertFalse(dateItem.equals(otherDateItem));
-
- otherDateItem = new TestContextDateItem(new Date(1000L));
- assertFalse(dateItem.equals(otherDateItem));
-
- otherDateItem = new TestContextDateItem(new Date(60000L));
- assertFalse(dateItem.equals(otherDateItem));
-
- otherDateItem = new TestContextDateItem(new Date(3600000L));
- assertFalse(dateItem.equals(otherDateItem));
-
- otherDateItem = new TestContextDateItem(new Date(86400000L));
- assertFalse(dateItem.equals(otherDateItem));
-
- otherDateItem = new TestContextDateItem(new Date(2678400000L));
- assertFalse(dateItem.equals(otherDateItem));
-
- dateItem = new TestContextDateItem(123L);
- assertEquals(123, dateItem.getTime());
-
- assertEquals("TestContextItem008 [time=123, year=1970, month=0, day=1, "
- + "hour=0, minute=0, second=0, milliSecond=123]", dateItem.toString());
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testDateTz() {
- TestContextDateItem dateItem = new TestContextDateItem(new Date(0L));
-
- TestContextDateTzItem dateTzItem = new TestContextDateTzItem(dateItem, "UTC", true);
- assertEquals("Coordinated Universal Time", dateTzItem.getTzValue());
- assertEquals(true, dateTzItem.getDst());
-
- assertFalse(dateTzItem.equals(null));
- assertTrue(dateTzItem.equals(dateTzItem));
-
- TestContextDoubleItem doubleItem = new TestContextDoubleItem();
- assertFalse(dateTzItem.equals(doubleItem));
-
- TestContextDateTzItem otherDateTzItem = new TestContextDateTzItem(dateItem, "UTC", true);
- assertTrue(dateTzItem.equals(otherDateTzItem));
- otherDateTzItem.setDst(false);
- assertFalse(dateTzItem.equals(otherDateTzItem));
- otherDateTzItem.setDst(true);
- otherDateTzItem.setTzValue("IST");
- assertFalse(dateTzItem.equals(otherDateTzItem));
- otherDateTzItem.setTzValue(null);
- assertFalse(dateTzItem.equals(otherDateTzItem));
- otherDateTzItem.setTzValue("UTC");
- assertTrue(otherDateTzItem.equals(dateTzItem));
-
- dateTzItem.setDateValue(null);
- assertFalse(dateTzItem.equals(otherDateTzItem));
- otherDateTzItem.setDateValue(null);
- assertTrue(otherDateTzItem.equals(dateTzItem));
-
- TestContextDateItem otherDateItem = new TestContextDateItem(new Date(1L));
- dateTzItem.setDateValue(dateItem);
- otherDateTzItem.setDateValue(otherDateItem);
- assertFalse(dateTzItem.equals(otherDateTzItem));
- otherDateTzItem.setDateValue(dateItem);
-
- dateTzItem.setTzValue(null);
- assertFalse(dateTzItem.equals(otherDateTzItem));
- otherDateTzItem.setTzValue(null);
- assertTrue(otherDateTzItem.equals(dateTzItem));
-
- dateTzItem.setTzValue("UTC");
- otherDateTzItem.setTzValue("IST");
- assertFalse(dateTzItem.equals(otherDateTzItem));
-
- dateTzItem.setDateValue(null);
- dateTzItem.setTzValue(null);
- dateTzItem.setDst(true);
- assertEquals(67952, dateTzItem.hashCode());
-
- dateTzItem.setDst(false);
- assertEquals(68138, dateTzItem.hashCode());
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testDateLocale() {
- TestContextDateItem dateItem = new TestContextDateItem(new Date(0L));
-
- TestContextDateLocaleItem dateLocaleItem = new TestContextDateLocaleItem(dateItem, "UTC", true, 1, "EN", "IE");
- assertEquals("Coordinated Universal Time", dateLocaleItem.getTzValue());
- assertEquals(true, dateLocaleItem.getDst());
-
- assertFalse(dateLocaleItem.equals(null));
- assertTrue(dateLocaleItem.equals(dateLocaleItem));
-
- TestContextDoubleItem doubleItem = new TestContextDoubleItem();
- assertFalse(dateLocaleItem.equals(doubleItem));
-
- TestContextDateLocaleItem otherDateLocaleItem = new TestContextDateLocaleItem(dateItem, "UTC", true, 1, "EN",
- "IE");
- assertTrue(dateLocaleItem.equals(otherDateLocaleItem));
- otherDateLocaleItem.setDst(false);
- assertFalse(dateLocaleItem.equals(otherDateLocaleItem));
- otherDateLocaleItem.setDst(true);
- otherDateLocaleItem.setTzValue("IST");
- assertFalse(dateLocaleItem.equals(otherDateLocaleItem));
- otherDateLocaleItem.setTzValue(null);
- assertFalse(dateLocaleItem.equals(otherDateLocaleItem));
- otherDateLocaleItem.setTzValue("UTC");
- assertTrue(otherDateLocaleItem.equals(dateLocaleItem));
-
- dateLocaleItem.setDateValue(null);
- assertFalse(dateLocaleItem.equals(otherDateLocaleItem));
- otherDateLocaleItem.setDateValue(null);
- assertTrue(otherDateLocaleItem.equals(dateLocaleItem));
-
- TestContextDateItem otherDateItem = new TestContextDateItem(new Date(1L));
- dateLocaleItem.setDateValue(dateItem);
- otherDateLocaleItem.setDateValue(otherDateItem);
- assertFalse(dateLocaleItem.equals(otherDateLocaleItem));
- otherDateLocaleItem.setDateValue(dateItem);
-
- dateLocaleItem.setTzValue(null);
- assertFalse(dateLocaleItem.equals(otherDateLocaleItem));
- otherDateLocaleItem.setTzValue(null);
- assertTrue(otherDateLocaleItem.equals(dateLocaleItem));
-
- dateLocaleItem.setTzValue("UTC");
- otherDateLocaleItem.setTzValue("IST");
- assertFalse(dateLocaleItem.equals(otherDateLocaleItem));
-
- dateLocaleItem.setDateValue(null);
- dateLocaleItem.setTzValue(null);
- dateLocaleItem.setDst(true);
- dateLocaleItem.setLocale(new Locale("EN", "IE"));
- assertEquals(-1567427636, dateLocaleItem.hashCode());
-
- dateLocaleItem.setDst(false);
- assertEquals(-1567248890, dateLocaleItem.hashCode());
-
- dateLocaleItem.setLocale(null);
- assertEquals(65480619, dateLocaleItem.hashCode());
-
- dateLocaleItem.setLocale(new Locale("EN", "IE"));
- assertEquals(new Locale("EN", "IE"), dateLocaleItem.getLocale());
- assertEquals(1, dateLocaleItem.getUtcOffset());
-
- dateLocaleItem = new TestContextDateLocaleItem(dateItem, "UTC", true, 1, "EN", "IE");
- otherDateLocaleItem = new TestContextDateLocaleItem(dateItem, "UTC", true, 1, "EN", "IE");
- dateLocaleItem.setLocale(null);
- assertFalse(dateLocaleItem.equals(otherDateLocaleItem));
- otherDateLocaleItem.setLocale(null);
- assertTrue(otherDateLocaleItem.equals(dateLocaleItem));
-
- dateLocaleItem.setUtcOffset(0);
- assertFalse(otherDateLocaleItem.equals(dateLocaleItem));
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testPolicyContextItem() {
- TestPolicyContextItem item0 = new TestPolicyContextItem();
- TestPolicyContextItem item1 = new TestPolicyContextItem();
-
- assertTrue(item0.equals(item0));
- assertTrue(item0.equals(item1));
- assertFalse(item0.equals(null));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(item0.equals(booleanItem));
-
- assertEquals(887503681, item0.hashCode());
- item0.setTestPolicyContextItem000(new TestContextStringItem());
- item0.setTestPolicyContextItem001(new TestContextLongItem());
- item0.setTestPolicyContextItem002(new TestContextDoubleItem());
- item0.setTestPolicyContextItem003(new TestContextBooleanItem());
- item0.setTestPolicyContextItem004(new TestContextLongItem());
- item0.setTestPolicyContextItem005(new TestContextTreeMapItem());
- assertEquals(1805779574, item0.hashCode());
-
- assertFalse(item1.equals(item0));
-
- item1.setTestPolicyContextItem000(new TestContextStringItem("Hello"));
- assertFalse(item1.equals(item0));
- item1.setTestPolicyContextItem000(item0.getTestPolicyContextItem000());
- assertFalse(item1.equals(item0));
-
- item1.setTestPolicyContextItem001(new TestContextLongItem(123L));
- assertFalse(item1.equals(item0));
- item1.setTestPolicyContextItem001(item0.getTestPolicyContextItem001());
- assertFalse(item1.equals(item0));
-
- item1.setTestPolicyContextItem002(new TestContextDoubleItem(123.45));
- assertFalse(item1.equals(item0));
- item1.setTestPolicyContextItem002(item0.getTestPolicyContextItem002());
- assertFalse(item1.equals(item0));
-
- item1.setTestPolicyContextItem003(new TestContextBooleanItem(true));
- assertFalse(item1.equals(item0));
- item1.setTestPolicyContextItem003(item0.getTestPolicyContextItem003());
- assertFalse(item1.equals(item0));
-
- item1.setTestPolicyContextItem004(new TestContextLongItem(123L));
- assertFalse(item1.equals(item0));
- item1.setTestPolicyContextItem004(item0.getTestPolicyContextItem004());
- assertFalse(item1.equals(item0));
-
- item1.setTestPolicyContextItem005(new TestContextTreeMapItem());
- item1.getTestPolicyContextItem005().getMapValue().put("Key", "Value");
- assertFalse(item1.equals(item0));
- item1.setTestPolicyContextItem005(item0.getTestPolicyContextItem005());
- assertTrue(item1.equals(item0));
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testExternalContextItem() {
- TestExternalContextItem item0 = new TestExternalContextItem();
- TestExternalContextItem item1 = new TestExternalContextItem();
-
- assertTrue(item0.equals(item0));
- assertTrue(item0.equals(item1));
- assertFalse(item0.equals(null));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(item0.equals(booleanItem));
-
- assertEquals(-505558625, item0.hashCode());
- item0.setTestExternalContextItem000(new TestContextBooleanItem());
- item0.setTestExternalContextItem001(new TestContextByteItem());
- item0.setTestExternalContextItem002(new TestContextIntItem());
- item0.setTestExternalContextItem003(new TestContextLongItem());
- item0.setTestExternalContextItem004(new TestContextFloatItem());
- item0.setTestExternalContextItem005(new TestContextDoubleItem());
- item0.setTestExternalContextItem006(new TestContextStringItem());
- item0.setTestExternalContextItem007(new TestContextLongObjectItem());
- item0.setTestExternalContextItem008(new TestContextDateItem());
- item0.setTestExternalContextItem009(new TestContextDateTzItem());
- item0.setTestExternalContextItem00A(new TestContextDateLocaleItem());
- item0.setTestExternalContextItem00B(new TestContextTreeSetItem());
- item0.setTestExternalContextItem00C(new TestContextTreeMapItem());
- assertTrue(item0.hashCode() != 0);
-
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem000(new TestContextBooleanItem(true));
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem000(item0.getTestExternalContextItem000());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem001(new TestContextByteItem((byte) 123));
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem001(item0.getTestExternalContextItem001());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem002(new TestContextIntItem(123));
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem002(item0.getTestExternalContextItem002());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem003(new TestContextLongItem(123L));
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem003(item0.getTestExternalContextItem003());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem004(new TestContextFloatItem((float) 123.45));
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem004(item0.getTestExternalContextItem004());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem005(new TestContextDoubleItem(123.45));
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem005(item0.getTestExternalContextItem005());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem006(new TestContextStringItem("Hello"));
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem006(item0.getTestExternalContextItem006());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem007(new TestContextLongObjectItem(123L));
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem007(item0.getTestExternalContextItem007());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem008(new TestContextDateItem(new Date(124)));
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem008(item0.getTestExternalContextItem008());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem009(
- new TestContextDateTzItem(new TestContextDateItem(new Date(124)), "UTC", true));
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem009(item0.getTestExternalContextItem009());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem00A(new TestContextDateLocaleItem(new TestContextDateItem(new Date(124)), "UTC",
- true, 1, "EN", "IE"));
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem00A(item0.getTestExternalContextItem00A());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem00B(new TestContextTreeSetItem());
- item1.getTestExternalContextItem00B().getSetValue().add("Hello");
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem00B(item0.getTestExternalContextItem00B());
- assertFalse(item1.equals(item0));
-
- item1.setTestExternalContextItem00C(new TestContextTreeMapItem());
- item1.getTestExternalContextItem00C().getMapValue().put("Key", "Value");
- assertFalse(item1.equals(item0));
- item1.setTestExternalContextItem00C(item0.getTestExternalContextItem00C());
- assertTrue(item1.equals(item0));
- }
-
- @SuppressWarnings("unlikely-arg-type")
- @Test
- public void testGlobalContextItem() {
- TestGlobalContextItem item0 = new TestGlobalContextItem();
- TestGlobalContextItem item1 = new TestGlobalContextItem();
-
- assertTrue(item0.equals(item0));
- assertTrue(item0.equals(item1));
- assertFalse(item0.equals(null));
-
- TestContextBooleanItem booleanItem = new TestContextBooleanItem();
- assertFalse(item0.equals(booleanItem));
-
- assertEquals(-505558625, item0.hashCode());
- item0.setTestGlobalContextItem000(new TestContextBooleanItem());
- item0.setTestGlobalContextItem001(new TestContextByteItem());
- item0.setTestGlobalContextItem002(new TestContextIntItem());
- item0.setTestGlobalContextItem003(new TestContextLongItem());
- item0.setTestGlobalContextItem004(new TestContextFloatItem());
- item0.setTestGlobalContextItem005(new TestContextDoubleItem());
- item0.setTestGlobalContextItem006(new TestContextStringItem());
- item0.setTestGlobalContextItem007(new TestContextLongObjectItem());
- item0.setTestGlobalContextItem008(new TestContextDateItem());
- item0.setTestGlobalContextItem009(new TestContextDateTzItem());
- item0.setTestGlobalContextItem00A(new TestContextDateLocaleItem());
- item0.setTestGlobalContextItem00B(new TestContextTreeSetItem());
- item0.setTestGlobalContextItem00C(new TestContextTreeMapItem());
- assertTrue(item0.hashCode() != 0);
-
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem000(new TestContextBooleanItem(true));
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem000(item0.getTestGlobalContextItem000());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem001(new TestContextByteItem((byte) 123));
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem001(item0.getTestGlobalContextItem001());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem002(new TestContextIntItem(123));
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem002(item0.getTestGlobalContextItem002());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem003(new TestContextLongItem(123L));
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem003(item0.getTestGlobalContextItem003());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem004(new TestContextFloatItem((float) 123.45));
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem004(item0.getTestGlobalContextItem004());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem005(new TestContextDoubleItem(123.45));
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem005(item0.getTestGlobalContextItem005());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem006(new TestContextStringItem("Hello"));
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem006(item0.getTestGlobalContextItem006());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem007(new TestContextLongObjectItem(123L));
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem007(item0.getTestGlobalContextItem007());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem008(new TestContextDateItem(new Date(124)));
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem008(item0.getTestGlobalContextItem008());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem009(
- new TestContextDateTzItem(new TestContextDateItem(new Date(124)), "UTC", true));
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem009(item0.getTestGlobalContextItem009());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem00A(new TestContextDateLocaleItem(new TestContextDateItem(new Date(124)), "UTC",
- true, 1, "EN", "IE"));
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem00A(item0.getTestGlobalContextItem00A());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem00B(new TestContextTreeSetItem());
- item1.getTestGlobalContextItem00B().getSetValue().add("Hello");
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem00B(item0.getTestGlobalContextItem00B());
- assertFalse(item1.equals(item0));
-
- item1.setTestGlobalContextItem00C(new TestContextTreeMapItem());
- item1.getTestGlobalContextItem00C().getMapValue().put("Key", "Value");
- assertFalse(item1.equals(item0));
- item1.setTestGlobalContextItem00C(item0.getTestGlobalContextItem00C());
- assertTrue(item1.equals(item0));
- }
-}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdateTest.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdateTest.java
deleted file mode 100644
index 218a8f9af..000000000
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdateTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.distribution;
-
-import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.context.impl.distribution.jvmlocal.JvmLocalDistributor;
-import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.context.parameters.ContextParameterConstants;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.SchemaParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.common.parameters.ParameterService;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-public class ContextAlbumUpdateTest {
- // Logger for this class
- private static final XLogger logger = XLoggerFactory.getXLogger(ContextAlbumUpdateTest.class);
-
- private SchemaParameters schemaParameters;
- private ContextParameters contextParameters;
-
- /**
- * Set up context data.
- */
- @Before
- public void beforeTest() {
- contextParameters = new ContextParameters();
-
- contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
- contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
- contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
- contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
-
- ParameterService.register(contextParameters);
- ParameterService.register(contextParameters.getDistributorParameters());
- ParameterService.register(contextParameters.getLockManagerParameters());
- ParameterService.register(contextParameters.getPersistorParameters());
-
- schemaParameters = new SchemaParameters();
- schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
- schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
-
- ParameterService.register(schemaParameters);
- }
-
- /**
- * Clear down context data.
- */
- @After
- public void afterTest() {
- ParameterService.deregister(schemaParameters);
-
- ParameterService.deregister(contextParameters.getDistributorParameters());
- ParameterService.deregister(contextParameters.getLockManagerParameters());
- ParameterService.deregister(contextParameters.getPersistorParameters());
- ParameterService.deregister(contextParameters);
- }
-
- @Test
- public void testContextAlbumUpdateJvmLocalVarSet() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextAlbumUpdateJVMLocalVarSet test . . .");
-
- 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 ContextAlbumUpdate().testContextAlbumUpdate();
-
- logger.debug("Ran testContextAlbumUpdateJVMLocalVarNotSet test");
- }
-}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextInstantiationTest.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextInstantiationTest.java
deleted file mode 100644
index d635be441..000000000
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextInstantiationTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.distribution;
-
-import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.context.impl.distribution.jvmlocal.JvmLocalDistributor;
-import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.context.parameters.ContextParameterConstants;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.SchemaParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.common.parameters.ParameterService;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestContextInstantiation.
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class ContextInstantiationTest {
- // Logger for this class
- private static final XLogger logger = XLoggerFactory.getXLogger(ContextInstantiationTest.class);
-
- private SchemaParameters schemaParameters;
- private ContextParameters contextParameters;
-
- /**
- * Set up context for tests.
- */
- @Before
- public void beforeTest() {
- contextParameters = new ContextParameters();
-
- contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
- contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
- contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
- contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
-
- ParameterService.register(contextParameters);
- ParameterService.register(contextParameters.getDistributorParameters());
- ParameterService.register(contextParameters.getLockManagerParameters());
- ParameterService.register(contextParameters.getPersistorParameters());
-
- schemaParameters = new SchemaParameters();
- schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
- schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
-
- ParameterService.register(schemaParameters);
- }
-
- /**
- * Clear down context for tests.
- */
- @After
- public void afterTest() {
- ParameterService.deregister(schemaParameters);
-
- ParameterService.deregister(contextParameters.getDistributorParameters());
- ParameterService.deregister(contextParameters.getLockManagerParameters());
- ParameterService.deregister(contextParameters.getPersistorParameters());
- ParameterService.deregister(contextParameters);
- }
-
- @Test
- public void testContextInstantiationJvmLocalVarSet() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextInstantiationJVMLocalVarSet test . . .");
-
- 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 ContextInstantiation().testContextInstantiation();
-
- logger.debug("Ran testContextInstantiationJVMLocalVarNotSet test");
- }
-}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextUpdateTest.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextUpdateTest.java
deleted file mode 100644
index 0eaf591e3..000000000
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/ContextUpdateTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.distribution;
-
-import java.io.IOException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.context.impl.distribution.jvmlocal.JvmLocalDistributor;
-import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.context.parameters.ContextParameterConstants;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.SchemaParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.common.parameters.ParameterService;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestContextUpdate.
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class ContextUpdateTest {
- // Logger for this class
- private static final XLogger logger = XLoggerFactory.getXLogger(ContextUpdateTest.class);
-
- private SchemaParameters schemaParameters;
- private ContextParameters contextParameters;
-
- /**
- * Set up context for tests.
- */
- @Before
- public void beforeTest() {
- contextParameters = new ContextParameters();
-
- contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
- contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
- contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
- contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
-
- ParameterService.register(contextParameters);
- ParameterService.register(contextParameters.getDistributorParameters());
- ParameterService.register(contextParameters.getLockManagerParameters());
- ParameterService.register(contextParameters.getPersistorParameters());
-
- schemaParameters = new SchemaParameters();
- schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
- schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
-
- ParameterService.register(schemaParameters);
- }
-
- /**
- * Clear down context for tests.
- */
- @After
- public void afterTest() {
- ParameterService.deregister(schemaParameters);
-
- ParameterService.deregister(contextParameters.getDistributorParameters());
- ParameterService.deregister(contextParameters.getLockManagerParameters());
- ParameterService.deregister(contextParameters.getPersistorParameters());
- ParameterService.deregister(contextParameters);
- }
-
- @Test
- public void testContextUpdateJvmLocalVarSet() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextUpdateJVMLocalVarSet test . . .");
-
- 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 ContextUpdate().testContextUpdate();
-
- logger.debug("Ran testContextUpdateJVMLocalVarNotSet test");
- }
-}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiationTest.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiationTest.java
deleted file mode 100644
index 21ab6ef9e..000000000
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiationTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.distribution;
-
-import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.context.impl.distribution.jvmlocal.JvmLocalDistributor;
-import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.context.parameters.ContextParameterConstants;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.SchemaParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.common.parameters.ParameterService;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestContextInstantiation.
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class SequentialContextInstantiationTest {
- // Logger for this class
- private static final XLogger logger = XLoggerFactory.getXLogger(SequentialContextInstantiationTest.class);
-
- private SchemaParameters schemaParameters;
- private ContextParameters contextParameters;
-
- /**
- * Set up context for tests.
- */
- @Before
- public void beforeTest() {
- contextParameters = new ContextParameters();
-
- contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
- contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
- contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
- contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
-
- ParameterService.register(contextParameters);
- ParameterService.register(contextParameters.getDistributorParameters());
- ParameterService.register(contextParameters.getLockManagerParameters());
- ParameterService.register(contextParameters.getPersistorParameters());
-
- schemaParameters = new SchemaParameters();
- schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
- schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
-
- ParameterService.register(schemaParameters);
- }
-
- /**
- * Clear down context for tests.
- */
- @After
- public void afterTest() {
- ParameterService.deregister(schemaParameters);
-
- ParameterService.deregister(contextParameters.getDistributorParameters());
- ParameterService.deregister(contextParameters.getLockManagerParameters());
- ParameterService.deregister(contextParameters.getPersistorParameters());
- ParameterService.deregister(contextParameters);
- }
-
- @Test
- public void testSequentialContextInstantiationJvmLocalVarSet()
- throws ApexModelException, IOException, ApexException {
- logger.debug("Running testSequentialContextInstantiationJVMLocalVarSet test . . .");
-
- 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/entities/ArtifactKeyTestEntityTest.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntityTest.java
deleted file mode 100644
index 486252517..000000000
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntityTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-
- * ============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.entities;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-
-/**
- * Test the AxArtifactKey test entity.
- *
- */
-public class ArtifactKeyTestEntityTest {
-
- @Test
- public void testTestEntity() {
- ArtifactKeyTestEntity testEntity = new ArtifactKeyTestEntity();
-
- ArtifactKeyTestEntity testEntityCopy = new ArtifactKeyTestEntity();
- assertEquals(120390253, testEntityCopy.hashCode());
-
- testEntity.setKey(null);
- testEntity.copyTo(testEntityCopy);
- assertTrue(testEntity.equals((testEntityCopy)));
- assertFalse(testEntity.checkSetKey());
- AxArtifactKey key = new AxArtifactKey("TestKey", "0.0.1");
-
- testEntity.setKey(key);
- testEntity.clean();
- AxValidationResult result = testEntity.validate(new AxValidationResult());
- assertEquals(ValidationResult.VALID, result.getValidationResult());
- assertEquals(key, testEntity.getKey());
- assertEquals(key, testEntity.getKeys().get(0));
- assertEquals(key.getId(), testEntity.getId());
- assertEquals((Double) 0.0, (Double) testEntity.getDoubleValue());
- assertTrue(testEntity.checkSetKey());
- assertEquals((Double) 0.0, (Double) testEntity.getDoubleValue());
- testEntity.setDoubleValue(3.14);
- assertEquals((Double) 3.14, (Double) testEntity.getDoubleValue());
- assertTrue(testEntity.checkSetKey());
- assertEquals("ArtifactKeyTestEntity [key=AxArtifactKey:(name=TestKey,version=0.0.1), doubleValue=3.14]",
- testEntity.toString());
- ArtifactKeyTestEntity testEntityClone = new ArtifactKeyTestEntity();
- testEntity.copyTo(testEntityClone);
- assertTrue(testEntity.equals(testEntity));
- assertTrue(testEntity.equals(testEntityClone));
- ArtifactKeyTestEntity testEntityNew = null;
- testEntityNew = (ArtifactKeyTestEntity) testEntity.copyTo(testEntityNew);
- assertTrue(testEntityNew.equals(testEntityNew));
- assertTrue(testEntity.equals(testEntityNew));
- ReferenceKeyTestEntity testEntityBad = new ReferenceKeyTestEntity();
- testEntityBad = (ReferenceKeyTestEntity) testEntity.copyTo(testEntityBad);
- assertNull(testEntityBad);
-
- testEntityBad = new ReferenceKeyTestEntity();
- assertEquals(-1036664728, testEntity.hashCode());
- assertFalse(testEntity.equals(null));
- assertEquals(-1, testEntity.compareTo(null));
- assertTrue(testEntity.equals(testEntity));
- assertEquals(0, testEntity.compareTo(testEntity));
- assertFalse(testEntity.equals(testEntityBad));
- assertEquals(-1, testEntity.compareTo(testEntityBad));
- assertFalse(testEntityCopy.equals(testEntity));
- assertEquals(1, testEntityCopy.compareTo(testEntity));
- testEntityClone.setKey(key);
- testEntityNew.setKey(AxArtifactKey.getNullKey());
- assertFalse(testEntityNew.equals(testEntityClone));
- assertEquals(-6, testEntityNew.compareTo(testEntityClone));
- testEntityClone.setKey(null);
- testEntityNew.setKey(null);
- assertTrue(testEntityNew.equals(testEntityClone));
- assertEquals(0, testEntityNew.compareTo(testEntityClone));
- testEntityCopy.setKey(AxArtifactKey.getNullKey());
- assertFalse(testEntityCopy.equals(testEntity));
- assertEquals(-6, testEntityCopy.compareTo(testEntity));
- testEntityClone.setKey(key);
- testEntityClone.setDoubleValue(1.23);
- assertFalse(testEntity.equals(testEntityClone));
- assertEquals(1, testEntity.compareTo(testEntityClone));
-
- ArtifactKeyTestEntity entity2 = new ArtifactKeyTestEntity(3.14);
- assertEquals((Double)3.14, (Double)entity2.getDoubleValue());
- ArtifactKeyTestEntity entity3 = new ArtifactKeyTestEntity(key, 3.14);
- assertEquals(key, entity3.getKey());
-
- entity3.setKey(null);
- assertEquals(31, entity3.hashCode());
- }
-}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/entities/ReferenceTestEntityTest.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/entities/ReferenceTestEntityTest.java
deleted file mode 100644
index ce9073431..000000000
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/entities/ReferenceTestEntityTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*-
- * ============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.entities;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-
-/**
- * Test the AxArtifactKey test entity.
- *
- */
-public class ReferenceTestEntityTest {
-
- @Test
- public void testTestEntity() {
- ReferenceKeyTestEntity testEntity = new ReferenceKeyTestEntity();
-
- ReferenceKeyTestEntity testEntityCopy = new ReferenceKeyTestEntity();
- assertEquals(-192063539, testEntityCopy.hashCode());
-
- testEntity.setKey(null);
- testEntity.copyTo(testEntityCopy);
- assertTrue(testEntity.equals((testEntityCopy)));
- assertFalse(testEntity.checkSetKey());
- AxReferenceKey key = new AxReferenceKey("TestKey", "0.0.1", "ParentLocalName", "LocalName");
-
- testEntity.setKey(key);
- testEntity.clean();
- AxValidationResult result = testEntity.validate(new AxValidationResult());
- assertEquals(ValidationResult.VALID, result.getValidationResult());
- assertEquals(key, testEntity.getKey());
- assertEquals(key, testEntity.getKeys().get(0));
- assertEquals(key.getId(), testEntity.getId());
- assertEquals((Double) 0.0, (Double) testEntity.getDoubleValue());
- assertTrue(testEntity.checkSetKey());
- assertEquals((Double) 0.0, (Double) testEntity.getDoubleValue());
- testEntity.setDoubleValue(3.14);
- assertEquals((Double) 3.14, (Double) testEntity.getDoubleValue());
- assertTrue(testEntity.checkSetKey());
- assertEquals("ReferenceKeyTestEntity [key=AxReferenceKey:(parentKeyName=TestKey,parentKeyVersion=0.0.1,"
- + "parentLocalName=ParentLocalName,localName=LocalName), doubleValue=3.14]",
- testEntity.toString());
- ReferenceKeyTestEntity testEntityClone = new ReferenceKeyTestEntity();
- testEntity.copyTo(testEntityClone);
- assertTrue(testEntity.equals(testEntity));
- assertTrue(testEntity.equals(testEntityClone));
- ReferenceKeyTestEntity testEntityNew = null;
- testEntityNew = (ReferenceKeyTestEntity) testEntity.copyTo(testEntityNew);
- assertTrue(testEntityNew.equals(testEntityNew));
- assertTrue(testEntity.equals(testEntityNew));
- ArtifactKeyTestEntity testEntityBad = new ArtifactKeyTestEntity();
- testEntityBad = (ArtifactKeyTestEntity) testEntity.copyTo(testEntityBad);
- assertNull(testEntityBad);
-
- testEntityBad = new ArtifactKeyTestEntity();
- assertEquals(-49094350, testEntity.hashCode());
- assertFalse(testEntity.equals(null));
- assertEquals(-1, testEntity.compareTo(null));
- assertTrue(testEntity.equals(testEntity));
- assertEquals(0, testEntity.compareTo(testEntity));
- assertFalse(testEntity.equals(testEntityBad));
- assertEquals(-1, testEntity.compareTo(testEntityBad));
- assertFalse(testEntityCopy.equals(testEntity));
- assertEquals(1, testEntityCopy.compareTo(testEntity));
- testEntityClone.setKey(key);
- testEntityNew.setKey(AxReferenceKey.getNullKey());
- assertFalse(testEntityNew.equals(testEntityClone));
- assertEquals(-6, testEntityNew.compareTo(testEntityClone));
- testEntityClone.setKey(null);
- testEntityNew.setKey(null);
- assertTrue(testEntityNew.equals(testEntityClone));
- assertEquals(0, testEntityNew.compareTo(testEntityClone));
- testEntityCopy.setKey(AxReferenceKey.getNullKey());
- assertFalse(testEntityCopy.equals(testEntity));
- assertEquals(-6, testEntityCopy.compareTo(testEntity));
- testEntityClone.setKey(key);
- testEntityClone.setDoubleValue(1.23);
- assertFalse(testEntity.equals(testEntityClone));
- assertEquals(1, testEntity.compareTo(testEntityClone));
-
- ReferenceKeyTestEntity entity2 = new ReferenceKeyTestEntity(3.14);
- assertEquals((Double) 3.14, (Double) entity2.getDoubleValue());
- ReferenceKeyTestEntity entity3 = new ReferenceKeyTestEntity(key, 3.14);
- assertEquals(key, entity3.getKey());
-
- entity3.setKey(null);
- assertEquals(31, entity3.hashCode());
- }
-}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/ConcurrentContextTest.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/ConcurrentContextTest.java
deleted file mode 100644
index 7274f0d57..000000000
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/ConcurrentContextTest.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.locking;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.onap.policy.apex.context.test.lock.modifier.LockType.WRITE_LOCK_SINGLE_VALUE_UPDATE;
-import static org.onap.policy.apex.context.test.utils.Constants.TEST_VALUE;
-
-import java.util.Map;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.context.impl.distribution.jvmlocal.JvmLocalDistributor;
-import org.onap.policy.apex.context.impl.locking.jvmlocal.JvmLocalLockManager;
-import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.context.parameters.ContextParameterConstants;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.SchemaParameters;
-import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
-import org.onap.policy.apex.context.test.utils.ConfigrationProvider;
-import org.onap.policy.apex.context.test.utils.ConfigrationProviderImpl;
-import org.onap.policy.apex.context.test.utils.Constants;
-import org.onap.policy.common.parameters.ParameterService;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestConcurrentContext tests concurrent use of context.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ConcurrentContextTest {
-
- // Logger for this class
- private static final XLogger logger = XLoggerFactory.getXLogger(ConcurrentContextTest.class);
-
- // Test parameters
- private static final int ALBUM_SIZE = 16;
- 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;
-
- private SchemaParameters schemaParameters;
- private ContextParameters contextParameters;
-
- /**
- * Set up context for tests.
- */
- @Before
- public void beforeTest() {
- contextParameters = new ContextParameters();
-
- contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
- contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
- contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
- contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
-
- ParameterService.register(contextParameters);
- ParameterService.register(contextParameters.getDistributorParameters());
- ParameterService.register(contextParameters.getLockManagerParameters());
- ParameterService.register(contextParameters.getPersistorParameters());
-
- schemaParameters = new SchemaParameters();
- schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
- schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
-
- ParameterService.register(schemaParameters);
- }
-
- /**
- * Clear down context for tests.
- */
- @After
- public void afterTest() {
- ParameterService.deregister(schemaParameters);
-
- ParameterService.deregister(contextParameters.getDistributorParameters());
- ParameterService.deregister(contextParameters.getLockManagerParameters());
- ParameterService.deregister(contextParameters.getPersistorParameters());
- ParameterService.deregister(contextParameters);
- }
-
- @Test
- public void testConcurrentContextJvmLocalVarSet() throws Exception {
- logger.debug("Running testConcurrentContextJVMLocalVarSet test . . .");
-
- contextParameters.getLockManagerParameters().setPluginClass(JvmLocalLockManager.class.getCanonicalName());
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalVarSet",
- TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
-
- final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
-
- assertFalse(result.isEmpty());
- final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
- final TestContextLongItem actual = result.get(TEST_VALUE);
- assertNotNull(actual);
- assertEquals(expected, actual.getLongValue());
-
-
- logger.debug("Ran testConcurrentContextJVMLocalVarSet test");
- }
-
- @Test
- public void testConcurrentContextJvmLocalNoVarSet() throws Exception {
- logger.debug("Running testConcurrentContextJVMLocalNoVarSet test . . .");
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalNoVarSet",
- TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
-
- final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
-
- assertFalse(result.isEmpty());
- final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
- final TestContextLongItem actual = result.get(TEST_VALUE);
- assertNotNull(actual);
- assertEquals(expected, actual.getLongValue());
-
- logger.debug("Ran testConcurrentContextJVMLocalNoVarSet test");
- }
-
- @Test
- public void testConcurrentContextMultiJvmNoLock() throws Exception {
- logger.debug("Running testConcurrentContextMultiJVMNoLock test . . .");
-
- contextParameters.getDistributorParameters().setPluginClass(JvmLocalDistributor.class.getCanonicalName());
- contextParameters.getLockManagerParameters().setPluginClass(JvmLocalLockManager.class.getCanonicalName());
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("testConcurrentContextMultiJVMNoLock",
- TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
-
- final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
-
- // No concurrent map so result will be zero
- assertFalse(result.isEmpty());
- final TestContextLongItem actual = result.get(TEST_VALUE);
- assertNotNull(actual);
- assertEquals(0, actual.getLongValue());
-
- logger.debug("Ran testConcurrentContextMultiJVMNoLock test");
- }
-
- private ConfigrationProvider getConfigrationProvider(final String testType, final int jvmCount,
- final int threadCount, final int threadLoops) {
- return new ConfigrationProviderImpl(testType, jvmCount, threadCount, threadLoops, ALBUM_SIZE,
- WRITE_LOCK_SINGLE_VALUE_UPDATE.getValue()) {
- @Override
- public Map<String, Object> getContextAlbumInitValues() {
- final Map<String, Object> initValues = super.getContextAlbumInitValues();
- initValues.put(Constants.TEST_VALUE, new TestContextLongItem(0L));
- return initValues;
- }
- };
- }
-}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/PersistentContextInstantiationTest.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/PersistentContextInstantiationTest.java
deleted file mode 100644
index 6bd4a4d41..000000000
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/PersistentContextInstantiationTest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.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.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.context.parameters.ContextParameterConstants;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.SchemaParameters;
-import org.onap.policy.apex.context.test.concepts.TestContextDateItem;
-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.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;
-import org.onap.policy.common.parameters.ParameterService;
-
-/**
- * The Class TestContextInstantiation.
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class PersistentContextInstantiationTest {
- // Logger for this class
- // private static final XLogger logger =
- // XLoggerFactory.getXLogger(TestPersistentContextInstantiation.class);
-
- private Connection connection;
- private SchemaParameters schemaParameters;
- private ContextParameters contextParameters;
-
- @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();
- }
-
- /**
- * Set up context for tests.
- */
- @Before
- public void beforeTest() {
- contextParameters = new ContextParameters();
-
- contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
- contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
- contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
- contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
-
- ParameterService.register(contextParameters);
- ParameterService.register(contextParameters.getDistributorParameters());
- ParameterService.register(contextParameters.getLockManagerParameters());
- ParameterService.register(contextParameters.getPersistorParameters());
-
- schemaParameters = new SchemaParameters();
- schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
- schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
-
- ParameterService.register(schemaParameters);
- }
-
- /**
- * Clear down context for tests.
- */
- @After
- public void afterTest() {
- ParameterService.deregister(schemaParameters);
-
- ParameterService.deregister(contextParameters.getDistributorParameters());
- ParameterService.deregister(contextParameters.getLockManagerParameters());
- ParameterService.deregister(contextParameters.getPersistorParameters());
- ParameterService.deregister(contextParameters);
- }
-
- @Test
- public void testContextPersistentInstantiation() throws ApexModelException, IOException, ApexException {
-
- 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("This is a policy context string",
- ((TestContextTreeMapItem) contextAlbumForMap.get("TestPolicyContextItem000")).getMapValue()
- .get("key"));
-
- 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(testDate, ((TestContextDateLocaleItem) contextAlbumForDate.get("TestPolicyContextItem00A"))
- .getDateValue());
- assertEquals(true, ((TestContextDateLocaleItem) contextAlbumForDate.get("TestPolicyContextItem00A")).getDst());
-
- 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(0xFFFFFFFFFFFFFFFFL,
- ((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0031")).getLongValue());
- assertEquals(0xFFFFFFFFFFFFFFFEL,
- ((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0032")).getLongValue());
- assertEquals(0xFFFFFFFFFFFFFFFDL,
- ((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0033")).getLongValue());
- assertEquals(0xFFFFFFFFFFFFFFFCL,
- ((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0034")).getLongValue());
- assertEquals(0xFFFFFFFFFFFFFFFBL,
- ((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0035")).getLongValue());
-
- 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
deleted file mode 100644
index b7911caa2..000000000
--- a/context/context-test-utils/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?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>