summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-02-19 16:40:30 -0500
committerPamela Dragosh <pdragosh@research.att.com>2017-02-19 16:40:51 -0500
commitf6016415a09828385e3fb5603597cc9b238f150c (patch)
tree155ebad515ad8032a548931f4a4be1379f822c94
parent9944937b56f62af260d10c0ef965bebd5a783dba (diff)
adding back in unit tests with ignore
Change-Id: Ib81e9a63869b8a97b858d204e38637acd5483083 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
-rw-r--r--integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/AuditPeriodTest.java475
-rw-r--r--integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbAuditCompareEntriesTest.java615
-rw-r--r--integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbAuditTest.java749
-rw-r--r--integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbDAOTest.java725
-rw-r--r--integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/IntegrityAuditDesignationTest.java1101
-rw-r--r--integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/jpa/IaTestEntity.java163
-rw-r--r--integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/jpa/PersonTest.java64
-rw-r--r--integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/IntegrityMonitorTest.java734
-rw-r--r--integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementEntityTest.java197
-rw-r--r--integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementTest.java338
-rw-r--r--integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateTransitionTest.java2188
11 files changed, 7349 insertions, 0 deletions
diff --git a/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/AuditPeriodTest.java b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/AuditPeriodTest.java
new file mode 100644
index 00000000..649b71f2
--- /dev/null
+++ b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/AuditPeriodTest.java
@@ -0,0 +1,475 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Audit
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.common.ia.test;
+
+
+import static org.junit.Assert.*;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+
+//import org.apache.commons.logging.Log;
+//import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.openecomp.policy.common.ia.AuditThread;
+import org.openecomp.policy.common.ia.IntegrityAudit;
+import org.openecomp.policy.common.ia.IntegrityAuditProperties;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+
+public class AuditPeriodTest {
+
+ private static Logger logger = FlexLogger.getLogger(AuditPeriodTest.class);
+
+ private static final String AUDIT_PERIOD_TEST_LOG = "./testingLogs/common-modules/integrity-audit/debug.log";
+
+ private static String persistenceUnit;
+ private static Properties properties;
+ private static String resourceName;
+
+ @Before
+ public void setUp() throws Exception {
+
+
+ System.out.println("setUp: Clearing " + AUDIT_PERIOD_TEST_LOG);
+ FileOutputStream fstream = new FileOutputStream(AUDIT_PERIOD_TEST_LOG);
+ fstream.close();
+
+ logger.info("setUp: Entering");
+
+ IntegrityAudit.isUnitTesting = true;
+
+ properties = new Properties();
+ properties.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+
+ persistenceUnit = "testPU";
+ resourceName = "pdp1";
+
+ //Clean up the DB
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+
+ EntityManager em = emf.createEntityManager();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
+ em.createQuery("Delete from IntegrityAuditEntity").executeUpdate();
+
+ // commit transaction
+ et.commit();
+ em.close();
+
+ logger.info("setUp: Exiting");
+
+ }
+
+
+ @After
+ public void tearDown() throws Exception {
+
+ logger.info("tearDown: Entering");
+
+ logger.info("tearDown: Exiting");
+
+ }
+
+ /*
+ * Verifies (via log parsing) that when a negative audit period is
+ * specified, the audit is suppressed.
+ */
+ @Ignore
+ @Test
+ public void testNegativeAuditPeriod() throws Exception {
+
+ logger.info("testNegativeAuditPeriod: Entering");
+
+ properties.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "-1");
+
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName, persistenceUnit, properties);
+ integrityAudit.startAuditThread();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) audit to immediately terminate.
+ */
+ Thread.sleep(1000);
+
+ logger.info("testNegativeAuditPeriod: Stopping audit thread (should be a no-op!)");
+ integrityAudit.stopAuditThread();
+
+ FileInputStream fstream = new FileInputStream(AUDIT_PERIOD_TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ ArrayList<String> expectedResult = new ArrayList<String>(Arrays.asList("-1"));
+ ArrayList<String> delegates = new ArrayList<String>();
+ while ((strLine = br.readLine()) != null) {
+ /* parse strLine to obtain what you want */
+ if (strLine.contains("Suppressing integrity audit, integrityAuditPeriodSeconds=")) {
+ startIndex = strLine.indexOf("integrityAuditPeriodSeconds=") + 28;
+
+ String integrityAuditPeriodSeconds = strLine.substring(startIndex);
+
+ delegates.add(integrityAuditPeriodSeconds);
+ }
+ }
+
+ for (String delegate: delegates) {
+ logger.info("testNegativeAuditPeriod: delegate: " + delegate);
+ }
+
+ fstream.close();
+
+ assertTrue(expectedResult.equals(delegates));
+
+ logger.info("testNegativeAuditPeriod: Exiting");
+
+ }
+
+ /*
+ * Verifies (via log parsing) that when an audit period of zero is
+ * specified, the audit runs continuously, generating a number of
+ * sleep/wake sequences in a short period of time (e.g. 100ms).
+ */
+ @Ignore
+ @Test
+ public void testZeroAuditPeriod() throws Exception {
+
+ logger.info("testZeroAuditPeriod: Entering");
+
+ properties.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "0");
+
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName,
+ persistenceUnit, properties);
+ integrityAudit.startAuditThread();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) audit to generate a bunch of sleep wake sequences.
+ *
+ * Note:
+ *
+ * (AuditThread.AUDIT_SIMULATION_SLEEP_INTERVAL *
+ * AuditThread.AUDIT_SIMULATION_ITERATIONS) is the time it takes for the
+ * audit simulation to run.
+ *
+ * (integrityAudit.getIntegrityAuditPeriodSeconds() should return a
+ * value of zero; i.e. audit should not sleep at all between iterations
+ *
+ * "100"ms is the time we allow the audit to cycle continuously
+ */
+ long sleepMillis = (AuditThread.AUDIT_SIMULATION_SLEEP_INTERVAL * AuditThread.AUDIT_SIMULATION_ITERATIONS)
+ + (integrityAudit.getIntegrityAuditPeriodSeconds() * 1000)
+ + 100;
+ logger.info("testZeroAuditPeriod: Sleeping " + sleepMillis + "ms before stopping auditThread");
+ Thread.sleep(sleepMillis);
+
+ logger.info("testZeroAuditPeriod: Stopping audit thread");
+ integrityAudit.stopAuditThread();
+
+ /*
+ * Before audit completion message upon awaking from sleep is upper case "Awaking". After audit
+ * completion, all awakings are lower case "awaking".
+ */
+ logger.info("testZeroAuditPeriod: Parsing " + AUDIT_PERIOD_TEST_LOG + " for 'awaking'");
+ FileInputStream fstream = new FileInputStream(AUDIT_PERIOD_TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine = "";
+ int awakings = 0;
+ int lines = 0;
+ while ((strLine = br.readLine()) != null) {
+ if (strLine.contains("Awaking from 0ms sleep")) {
+ fail("Audit appears not to have run!? Got '" + strLine + "'");
+ } else {
+ if (strLine.contains("awaking from 0ms sleep")) {
+ awakings++;
+ }
+ }
+ lines++;
+ }
+ logger.info("testZeroAuditPeriod: Done parsing "
+ + AUDIT_PERIOD_TEST_LOG + " for 'awaking'; lines parsed="
+ + lines + ", closing stream");
+ fstream.close();
+
+ /*
+ * We should get at least 10 sleep/wake sequences.
+ */
+ assertTrue("Only " + awakings + " awakings", awakings > 10);
+ assertTrue(integrityAudit.getIntegrityAuditPeriodSeconds() == 0);
+
+ logger.info("testZeroAuditPeriod: Exiting, awakings="
+ + awakings + ", integrityAuditPeriodSeconds="
+ + integrityAudit.getIntegrityAuditPeriodSeconds());
+
+ }
+
+ /*
+ * Verifies (via log parsing) that when an audit period of five minutes is
+ * specified, there is a five minute interval between the audits run
+ * on each of three different entities.
+ */
+ @Ignore
+ @Test
+ public void testFiveMinuteAuditPeriod() throws Exception {
+
+ logger.info("testFiveMinuteAuditPeriod: Entering");
+
+ properties.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "300");
+
+ /*
+ * Start audit for pdp1.
+ */
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName,
+ persistenceUnit, properties);
+ integrityAudit.startAuditThread();
+
+ /*
+ * Start audit for pdp2.
+ */
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties2.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "300");
+ String persistenceUnit2 = "testPU";
+ String resourceName2 = "pdp2";
+ IntegrityAudit integrityAudit2 = new IntegrityAudit(resourceName2, persistenceUnit2, properties2);
+ integrityAudit2.startAuditThread();
+
+ /*
+ * Start audit for pdp3.
+ */
+ Properties properties3 = new Properties();
+ properties3.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties3.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties3.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties3.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties3.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties3.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties3.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "300");
+ String persistenceUnit3 = "testPU";
+ String resourceName3 = "pdp3";
+ IntegrityAudit integrityAudit3 = new IntegrityAudit(resourceName3, persistenceUnit3, properties3);
+ integrityAudit3.startAuditThread();
+
+
+ /*
+ * 1) All three audit run once. This should take approximately 105 seconds, as follows:
+ *
+ * T0: pdp1 runs audit (15 seconds), then sleeps for five minutes (300 seconds)
+ * pdp2 recognizes that pdp1 is stale (30 seconds) and runs its audit (15 seconds)
+ * pdp3 recognizes that pdp2 is stale (30 seconds) and runs its audit (15 seconds)
+ *
+ * 2) Five minutes after T0, at T1, pdp1 wakes up and the above sequence begins again,
+ * which should take another 115 seconds:
+ *
+ * T1: pdp1 runs audit (15 seconds), then sleeps for two minutes (300 seconds)
+ * pdp2 wakes up, resets auditCompleted and sleeps (5 seconds), recognizes that pdp1 is stale (30 seconds) and runs its audit (15 seconds)
+ * pdp3 wakes up, resets auditCompleted and sleeps (5 seconds), recognizes that pdp2 is stale (30 seconds) and runs its audit (15 seconds)
+ *
+ * So, the entire sequence should take 15 + 300 + 115 = 430 seconds
+ * Adding a fudge factor, we sleep for 450 seconds
+ */
+ Thread.sleep(450000);
+
+
+ logger.info("testFiveMinuteAuditPeriod: Stopping all three audit threads");
+ integrityAudit.stopAuditThread();
+
+ integrityAudit.stopAuditThread();
+ integrityAudit2.stopAuditThread();
+ integrityAudit3.stopAuditThread();
+
+ FileInputStream fstream = new FileInputStream(AUDIT_PERIOD_TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ int endIndex;
+ ArrayList<String> expectedResult = new ArrayList<String>(Arrays.asList("pdp1", "pdp2", "pdp3", "pdp1", "pdp2", "pdp3"));
+ ArrayList<String> delegates = new ArrayList<String>();
+ while ((strLine = br.readLine()) != null) {
+ /* parse strLine to obtain what you want */
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+
+ String rName = strLine.substring(startIndex, endIndex);
+
+ delegates.add(rName);
+ }
+ }
+
+ for (String delegate: delegates) {
+ logger.info("testFiveMinuteAuditPeriod: delegate: " + delegate);
+ }
+
+ fstream.close();
+
+ assertTrue("delegate count only " + delegates.size(), delegates.size() >= 6);
+ assertTrue("delegate 0 is " + expectedResult.get(0), expectedResult.get(0).equals(delegates.get(0)));
+ assertTrue("delegate 1 is " + expectedResult.get(1), expectedResult.get(1).equals(delegates.get(1)));
+ assertTrue("delegate 2 is " + expectedResult.get(2), expectedResult.get(2).equals(delegates.get(2)));
+ assertTrue("delegate 3 is " + expectedResult.get(3), expectedResult.get(3).equals(delegates.get(3)));
+ assertTrue("delegate 4 is " + expectedResult.get(4), expectedResult.get(4).equals(delegates.get(4)));
+ assertTrue("delegate 5 is " + expectedResult.get(5), expectedResult.get(5).equals(delegates.get(5)));
+
+ logger.info("testFiveMinuteAuditPeriod: Exiting");
+ }
+
+ /*
+ * Verifies (via log parsing) that when an audit period of 20 seconds is
+ * specified, there is a 20 second interval between the audits run
+ * on each of three different entities.
+ */
+ @Ignore
+ @Test
+ public void testTwentySecondAuditPeriod() throws Exception {
+
+ logger.info("testTwentySecondAuditPeriod: Entering");
+
+ properties.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "20");
+
+ /*
+ * Start audit for pdp1.
+ */
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName,
+ persistenceUnit, properties);
+ integrityAudit.startAuditThread();
+
+ /*
+ * Start audit for pdp2.
+ */
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties2.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "20");
+ String persistenceUnit2 = "testPU";
+ String resourceName2 = "pdp2";
+ IntegrityAudit integrityAudit2 = new IntegrityAudit(resourceName2, persistenceUnit2, properties2);
+ integrityAudit2.startAuditThread();
+
+ /*
+ * Start audit for pdp3.
+ */
+ Properties properties3 = new Properties();
+ properties3.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties3.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties3.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties3.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties3.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties3.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties3.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "20");
+ String persistenceUnit3 = "testPU";
+ String resourceName3 = "pdp3";
+ IntegrityAudit integrityAudit3 = new IntegrityAudit(resourceName3, persistenceUnit3, properties3);
+ integrityAudit3.startAuditThread();
+
+
+ /*
+ * 1) All three audit run once.
+ *
+ * pdp1 runs audit (15 seconds), then goes into 20 second sleep cycles
+ * pdp2 recognizes that pdp1 is stale (30 seconds), runs its audit (15 seconds), then goes into 20 second sleep cycles
+ * pdp3 recognizes that pdp2 is stale (30 seconds), runs its audit (15 seconds), then goes into 20 second sleep cycles
+ *
+ * 2) Eventually pdp2 gets stale, pdp1 recognizes this and cycle begins again.
+ *
+ * So, we allow 15 + (5 * 45) = 240 seconds plus a fudge factor.
+ *
+ */
+ Thread.sleep(250000);
+
+
+ logger.info("testTwentySecondAuditPeriod: Stopping all three audit threads");
+ integrityAudit.stopAuditThread();
+
+ integrityAudit.stopAuditThread();
+ integrityAudit2.stopAuditThread();
+ integrityAudit3.stopAuditThread();
+
+ FileInputStream fstream = new FileInputStream(AUDIT_PERIOD_TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ int endIndex;
+ ArrayList<String> expectedResult = new ArrayList<String>(Arrays.asList("pdp1", "pdp2", "pdp3", "pdp1", "pdp2", "pdp3"));
+ ArrayList<String> delegates = new ArrayList<String>();
+ while ((strLine = br.readLine()) != null) {
+ /* parse strLine to obtain what you want */
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+
+ String rName = strLine.substring(startIndex, endIndex);
+
+ delegates.add(rName);
+ }
+ }
+
+ for (String delegate: delegates) {
+ logger.info("testTwentySecondAuditPeriod: delegate: " + delegate);
+ }
+
+ fstream.close();
+
+ assertTrue("delegate count only " + delegates.size(), delegates.size() >= 6);
+ assertTrue("delegate 0 is " + expectedResult.get(0), expectedResult.get(0).equals(delegates.get(0)));
+ assertTrue("delegate 1 is " + expectedResult.get(1), expectedResult.get(1).equals(delegates.get(1)));
+ assertTrue("delegate 2 is " + expectedResult.get(2), expectedResult.get(2).equals(delegates.get(2)));
+ assertTrue("delegate 3 is " + expectedResult.get(3), expectedResult.get(3).equals(delegates.get(3)));
+ assertTrue("delegate 4 is " + expectedResult.get(4), expectedResult.get(4).equals(delegates.get(4)));
+ assertTrue("delegate 5 is " + expectedResult.get(5), expectedResult.get(5).equals(delegates.get(5)));
+
+ logger.info("testTwentySecondAuditPeriod: Exiting");
+ }
+
+}
diff --git a/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbAuditCompareEntriesTest.java b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbAuditCompareEntriesTest.java
new file mode 100644
index 00000000..f109689d
--- /dev/null
+++ b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbAuditCompareEntriesTest.java
@@ -0,0 +1,615 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Audit
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.common.ia.test;
+
+import static org.junit.Assert.*;
+
+import java.io.FileOutputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+
+
+//import org.apache.commons.logging.Log;
+//import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.openecomp.policy.common.ia.DbAudit;
+import org.openecomp.policy.common.ia.DbDAO;
+import org.openecomp.policy.common.ia.IntegrityAudit;
+import org.openecomp.policy.common.ia.IntegrityAuditProperties;
+import org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity;
+import org.openecomp.policy.common.ia.test.jpa.IaTestEntity;
+import org.openecomp.policy.common.ia.test.jpa.PersonTest;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+
+public class DbAuditCompareEntriesTest {
+
+ private static Logger logger = FlexLogger.getLogger(DbAuditCompareEntriesTest.class);
+ private DbDAO dbDAO;
+ private static String persistenceUnit;
+ private static Properties properties;
+ private static String resourceName;
+ private String dbDriver;
+ private String dbUrl;
+ private String dbUser;
+ private String dbPwd;
+ private String siteName;
+ private String nodeType;
+ private static final String TEST_LOG = "./testingLogs/common-modules/integrity-audit/debug.log";
+
+ @Before
+ public void setUp() throws Exception {
+ System.out.println("setUp: Clearing IntegrityAudit.log");
+ //FileOutputStream fstream = new FileOutputStream("IntegrityAudit.log");
+ FileOutputStream fstream = new FileOutputStream(TEST_LOG);
+ fstream.close();
+
+ logger.info("setUp: Entering");
+
+ IntegrityAudit.isUnitTesting = true;
+
+ properties = new Properties();
+ properties.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+
+ dbDriver = IntegrityAuditProperties.DEFAULT_DB_DRIVER;
+ dbUrl = IntegrityAuditProperties.DEFAULT_DB_URL;
+ dbUser = IntegrityAuditProperties.DEFAULT_DB_USER;
+ dbPwd = IntegrityAuditProperties.DEFAULT_DB_PWD;
+ siteName = "SiteA";
+ nodeType = "pdp_xacml";
+ persistenceUnit = "testPU";
+ resourceName = "pdp1";
+
+ logger.info("setUp: Exiting");
+ }
+
+ /*
+ * Clean up DB after each test.
+ */
+ @After
+ public void tearDown() throws Exception {
+ logger.info("tearDown: Entering");
+
+ logger.info("tearDown: Exiting");
+ }
+
+ /*
+ * Tests that a comparison between hashsets is successful if
+ * the entries match
+ */
+ @Ignore
+ @Test
+ public void testSuccessfulComparison() throws Exception {
+ logger.info("testSuccessfulComparison: Entering");
+
+ dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ DbAudit dbAudit = new DbAudit(dbDAO);
+
+ String className = null;
+ //There is only one entry IntegrityAuditEntity, but we will check anyway
+ HashSet<String> classNameSet = dbDAO.getPersistenceClassNames();
+ for(String c : classNameSet){
+ if (c.equals("org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity")){
+ className = c;
+ }
+ }
+ String resourceName1 = resourceName;
+ String resourceName2 = resourceName;
+
+ IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
+ IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
+ Date date = new Date();
+
+ /*
+ * Two entries with the same field values
+ */
+ entry1.setDesignated(false);
+ entry1.setJdbcDriver(dbDriver);
+ entry1.setJdbcPassword(dbPwd);
+ entry1.setJdbcUrl(dbUrl);
+ entry1.setJdbcUser(dbUser);
+ entry1.setLastUpdated(date);
+ entry1.setNodeType(nodeType);
+ entry1.setPersistenceUnit(persistenceUnit);
+ entry1.setResourceName(resourceName1);
+ entry1.setSite(siteName);
+
+ entry2.setDesignated(false);
+ entry2.setJdbcDriver(dbDriver);
+ entry2.setJdbcPassword(dbPwd);
+ entry2.setJdbcUrl(dbUrl);
+ entry2.setJdbcUser(dbUser);
+ entry2.setLastUpdated(date);
+ entry2.setNodeType(nodeType);
+ entry2.setPersistenceUnit(persistenceUnit);
+ entry2.setResourceName(resourceName2);
+ entry2.setSite(siteName);
+
+ dbAudit.writeAuditDebugLog(className, resourceName1, resourceName2, entry1, entry2);
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("pdp1", entry1);
+ theirEntries.put("pdp1", entry2);
+
+ HashSet<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert that there are no mismatches returned
+ */
+ assertTrue(result.isEmpty());
+
+ logger.info("testSuccessfulComparison: Exit");
+ }
+
+ /*
+ * Tests that an error is detected if an entry in one hashset doesn't
+ * match the other
+ */
+ @Ignore
+ @Test
+ public void testComparisonError() throws Exception {
+ logger.info("testComparisonError: Entering");
+
+ dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ DbAudit dbAudit = new DbAudit(dbDAO);
+
+ String resourceName1 = resourceName;
+ String resourceName2 = resourceName;
+
+ IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
+ IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
+ Date date = new Date();
+
+ /*
+ * Create two entries with different designated values
+ */
+ entry1.setDesignated(false);
+ entry1.setJdbcDriver(dbDriver);
+ entry1.setJdbcPassword(dbPwd);
+ entry1.setJdbcUrl(dbUrl);
+ entry1.setJdbcUser(dbUser);
+ entry1.setLastUpdated(date);
+ entry1.setNodeType(nodeType);
+ entry1.setPersistenceUnit(persistenceUnit);
+ entry1.setResourceName(resourceName1);
+ entry1.setSite(siteName);
+
+ entry2.setDesignated(true);
+ entry2.setJdbcDriver(dbDriver);
+ entry2.setJdbcPassword(dbPwd);
+ entry2.setJdbcUrl(dbUrl);
+ entry2.setJdbcUser(dbUser);
+ entry2.setLastUpdated(date);
+ entry2.setNodeType(nodeType);
+ entry2.setPersistenceUnit(persistenceUnit);
+ entry2.setResourceName(resourceName2);
+ entry2.setSite(siteName);
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("pdp1", entry1);
+ theirEntries.put("pdp1", entry2);
+
+ HashSet<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert that there was one mismatch
+ */
+ assertEquals(1, result.size());
+
+ logger.info("testComparisonError: Exit");
+ }
+
+ /*
+ * Tests that a mismatch/miss entry is detected if there are missing entries in
+ * one or both of the hashsets
+ */
+ @Ignore
+ @Test
+ public void testCompareMissingEntries() throws Exception {
+ logger.info("testCompareMissingEntries: Entering");
+
+ dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ DbAudit dbAudit = new DbAudit(dbDAO);
+
+ String resourceName1 = resourceName;
+ String resourceName2 = resourceName;
+
+ IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
+ IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
+ IntegrityAuditEntity entry3 = new IntegrityAuditEntity();
+ IntegrityAuditEntity entry4 = new IntegrityAuditEntity();
+
+ Date date = new Date();
+
+ /*
+ * 4 entries, one mismatch, two miss entries
+ */
+ entry1.setDesignated(false);
+ entry1.setJdbcDriver(dbDriver);
+ entry1.setJdbcPassword(dbPwd);
+ entry1.setJdbcUrl(dbUrl);
+ entry1.setJdbcUser(dbUser);
+ entry1.setLastUpdated(date);
+ entry1.setNodeType(nodeType);
+ entry1.setPersistenceUnit(persistenceUnit);
+ entry1.setResourceName(resourceName1);
+ entry1.setSite(siteName);
+
+ entry2.setDesignated(true);
+ entry2.setJdbcDriver(dbDriver);
+ entry2.setJdbcPassword(dbPwd);
+ entry2.setJdbcUrl(dbUrl);
+ entry2.setJdbcUser(dbUser);
+ entry2.setLastUpdated(date);
+ entry2.setNodeType(nodeType);
+ entry2.setPersistenceUnit(persistenceUnit);
+ entry2.setResourceName(resourceName2);
+ entry2.setSite(siteName);
+
+ entry3.setDesignated(false);
+ entry3.setJdbcDriver(dbDriver);
+ entry3.setJdbcPassword(dbPwd);
+ entry3.setJdbcUrl(dbUrl);
+ entry3.setJdbcUser(dbUser);
+ entry3.setLastUpdated(date);
+ entry3.setNodeType(nodeType);
+ entry3.setPersistenceUnit(persistenceUnit);
+ entry3.setResourceName(resourceName2);
+ entry3.setSite("SiteB");
+
+ entry4.setDesignated(false);
+ entry4.setJdbcDriver(dbDriver);
+ entry4.setJdbcPassword(dbPwd);
+ entry4.setJdbcUrl(dbUrl);
+ entry4.setJdbcUser(dbUser);
+ entry4.setLastUpdated(date);
+ entry4.setNodeType(nodeType);
+ entry4.setPersistenceUnit(persistenceUnit);
+ entry4.setResourceName(resourceName2);
+ entry4.setSite("SiteB");
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("0", entry1);
+ myEntries.put("1", entry3);
+ theirEntries.put("0", entry2);
+ theirEntries.put("2", entry4);
+
+ HashSet<Object> mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert 3 mismatches/missing entries were found
+ */
+ assertEquals(3, mismatchResult.size());
+
+ logger.info("testCompareMissingEntries: Exit");
+ }
+
+ /*
+ * Tests that comparison algorithm works for each entity in the hashsets
+ */
+ @Ignore
+ @Test
+ public void testCompareAllHashEntities() throws Exception {
+ logger.info("testCompareAllHashEntities: Entering");
+
+ dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ DbAudit dbAudit = new DbAudit(dbDAO);
+
+ @SuppressWarnings("unused")
+ String className = null;
+ HashSet<String> classNameSet = dbDAO.getPersistenceClassNames();
+ HashSet<Object> mismatchResult = new HashSet<Object>();
+ for(String c : classNameSet) {
+ className = c;
+ if (c.equals("org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity")){
+ String resourceName1 = resourceName;
+ String resourceName2 = resourceName;
+
+ IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
+ IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
+ Date date = new Date();
+
+ /*
+ * Two entries with the same field values
+ */
+ entry1.setDesignated(false);
+ entry1.setJdbcDriver(dbDriver);
+ entry1.setJdbcPassword(dbPwd);
+ entry1.setJdbcUrl(dbUrl);
+ entry1.setJdbcUser(dbUser);
+ entry1.setLastUpdated(date);
+ entry1.setNodeType(nodeType);
+ entry1.setPersistenceUnit(persistenceUnit);
+ entry1.setResourceName(resourceName1);
+ entry1.setSite(siteName);
+
+ entry2.setDesignated(false);
+ entry2.setJdbcDriver(dbDriver);
+ entry2.setJdbcPassword(dbPwd);
+ entry2.setJdbcUrl(dbUrl);
+ entry2.setJdbcUser(dbUser);
+ entry2.setLastUpdated(date);
+ entry2.setNodeType(nodeType);
+ entry2.setPersistenceUnit(persistenceUnit);
+ entry2.setResourceName(resourceName2);
+ entry2.setSite(siteName);
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("pdp1", entry1);
+ theirEntries.put("pdp1", entry2);
+
+ mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert there was no mismatches
+ */
+ assertTrue(mismatchResult.isEmpty());
+ }
+ else if (c.equals("org.openecomp.policy.common.ia.test.jpa.IaTestEntity")) {
+ IaTestEntity iate = new IaTestEntity();
+ IaTestEntity iate2 = new IaTestEntity();
+ IaTestEntity iate3 = new IaTestEntity();
+ IaTestEntity iate4 = new IaTestEntity();
+
+ Date date = new Date();
+
+ /*
+ * Four entries, 2 mismatches
+ */
+ iate.setCreatedBy("Ford");
+ iate.setModifiedBy("Ford");
+ iate.setModifiedDate(date);
+
+ iate2.setCreatedBy("Ford");
+ iate2.setModifiedBy("Zaphod");
+ iate2.setModifiedDate(date);
+
+ iate3.setCreatedBy("Zaphod");
+ iate3.setModifiedBy("Ford");
+ iate3.setModifiedDate(date);
+
+ iate4.setCreatedBy("Ford");
+ iate4.setModifiedBy("Ford");
+ iate4.setModifiedDate(date);
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("0", iate);
+ myEntries.put("1", iate2);
+ theirEntries.put("0", iate3);
+ theirEntries.put("1", iate4);
+
+ mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert that there is 2 mismatches
+ */
+ assertEquals(2, mismatchResult.size());
+ }
+ }
+
+ logger.info("testCompareAllHashEntities: Exit");
+ }
+
+ /*
+ * Tests that comparison algorithm works for each entity in the database
+ */
+ @Ignore
+ @Test
+ public void testCompareAllDbEntities() throws Exception {
+ logger.info("testCompareAllDbEntities: Entering");
+
+ logger.info("Setting up DB");
+
+ IntegrityAudit.isUnitTesting = true;
+
+ properties = new Properties();
+ properties.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, "jdbc:h2:file:./sql/iaTest2");
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+
+ dbDriver = IntegrityAuditProperties.DEFAULT_DB_DRIVER;
+ dbUrl = IntegrityAuditProperties.DEFAULT_DB_URL;
+ dbUser = IntegrityAuditProperties.DEFAULT_DB_USER;
+ dbPwd = IntegrityAuditProperties.DEFAULT_DB_PWD;
+ siteName = "SiteA";
+ nodeType = "pdp_xacml";
+ persistenceUnit = "testPU";
+ resourceName = "pdp1";
+
+ //Clean up the two DBs
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManagerFactory emf2 = Persistence.createEntityManagerFactory(persistenceUnit, properties2);
+
+ EntityManager em = emf.createEntityManager();
+ EntityManager em2 = emf2.createEntityManager();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+ EntityTransaction et2 = em2.getTransaction();
+
+ /*
+ * Delete entries in first DB
+ */
+ et.begin();
+
+ // Clean the IntegrityAuditEntity table
+ em.createQuery("Delete from IntegrityAuditEntity").executeUpdate();
+
+ // commit transaction
+ et.commit();
+
+ et.begin();
+
+ // Clean the IaTestEntity table
+ em.createQuery("Delete from IaTestEntity").executeUpdate();
+
+ // commit transaction
+ et.commit();
+ em.close();
+
+ /*
+ * Delete entries in second DB
+ */
+ et2.begin();
+
+ // Clean the IntegrityAuditEntity table
+ em2.createQuery("Delete from IntegrityAuditEntity").executeUpdate();
+
+ // commit transaction
+ et2.commit();
+
+ et2.begin();
+
+ // Clean the IaTestEntity table
+ em2.createQuery("Delete from IaTestEntity").executeUpdate();
+
+ // commit transaction
+ et2.commit();
+ em2.close();
+ logger.info("Exiting set up");
+
+ // Add entries into DB1
+ dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ DbDAO dbDAO2 = new DbDAO("pdp2", persistenceUnit, properties);
+ DbAudit dbAudit = new DbAudit(dbDAO);
+
+ // Add entries into DB2
+ DbDAO dbDAO3 = new DbDAO(resourceName, persistenceUnit, properties2);
+ DbDAO dbDAO4 = new DbDAO("pdp2", persistenceUnit, properties2);
+
+ // Pull all entries and compare
+ HashSet<String> classNameSet = dbDAO.getPersistenceClassNames();
+ HashMap<Object, Object> myEntries;
+ HashMap<Object, Object> theirEntries;
+ HashSet<Object> mismatchResult = new HashSet<Object>();
+ String className;
+ for(String c : classNameSet) {
+ className = c;
+ logger.info("classNameSet entry = " + c);
+ myEntries = dbDAO.getAllEntries(persistenceUnit, properties, className);
+ theirEntries = dbDAO3.getAllEntries(persistenceUnit, properties2, className);
+ mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
+ if(className.contains("IntegrityAuditEntity")){
+ break;
+ }
+ }
+
+ // Assert that there is 2 mismatches between IntegrityAuditEntity tables
+ assertEquals(2, mismatchResult.size());
+
+ logger.info("testCompareAllDbEntities: Exit");
+ }
+
+ /*
+ * Tests that differences in embedded classes are still caught
+ */
+ @Ignore
+ @Test
+ public void testEmbeddedClass() throws Exception {
+ logger.info("testEmbeddedClasses: Entering");
+
+ dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ DbAudit dbAudit = new DbAudit(dbDAO);
+
+ String className = null;
+ //There is only one entry IntegrityAuditEntity, but we will check anyway
+ HashSet<String> classNameSet = dbDAO.getPersistenceClassNames();
+ for(String c : classNameSet){
+ if (c.equals("org.openecomp.policy.common.ia.test.jpa.IaTestEntity")){
+ className = c;
+ }
+ }
+
+ IaTestEntity iate = new IaTestEntity();
+ IaTestEntity iate2 = new IaTestEntity();
+
+ Date date = new Date();
+
+ PersonTest person = new PersonTest("Ford", "Prefect", 21);
+ PersonTest person2 = new PersonTest("Zaphod", "Beeblebrox", 25);
+
+ /*
+ * Two entries, 1 mismatch
+ */
+ iate.setCreatedBy("Ford");
+ iate.setModifiedBy("Zaphod");
+ iate.setModifiedDate(date);
+ iate.setPersonTest(person);
+
+ iate2.setCreatedBy("Ford");
+ iate2.setModifiedBy("Zaphod");
+ iate2.setModifiedDate(date);
+ iate2.setPersonTest(person2);
+
+ dbAudit.writeAuditDebugLog(className, "resource1", "resource2", iate, iate2);
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("0", iate);
+ theirEntries.put("0", iate2);
+
+ HashSet<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert that there are no mismatches returned
+ */
+ assertTrue(!result.isEmpty());
+
+ logger.info("testEmbeddedClasses: Exit");
+ }
+}
diff --git a/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbAuditTest.java b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbAuditTest.java
new file mode 100644
index 00000000..a84281dd
--- /dev/null
+++ b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbAuditTest.java
@@ -0,0 +1,749 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Audit
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.common.ia.test;
+
+import static org.junit.Assert.*;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+
+//import org.apache.commons.logging.Log;
+//import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.openecomp.policy.common.ia.DbAudit;
+import org.openecomp.policy.common.ia.DbAuditException;
+import org.openecomp.policy.common.ia.DbDAO;
+import org.openecomp.policy.common.ia.DbDaoTransactionException;
+import org.openecomp.policy.common.ia.IntegrityAudit;
+import org.openecomp.policy.common.ia.IntegrityAuditProperties;
+import org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+
+public class DbAuditTest {
+
+ private static Logger logger = FlexLogger.getLogger(DbAuditTest.class);
+
+ private DbDAO dbDAO;
+ private static String persistenceUnit;
+ private static Properties properties;
+ private static String resourceName;
+ private String dbDriver;
+ private String dbUrl;
+ private String dbUser;
+ private String dbPwd;
+ private String siteName;
+ private String nodeType;
+ private static final String TEST_LOG = "./testingLogs/common-modules/integrity-audit/debug.log";
+ private static final String ERROR_LOG = "./testingLogs/common-modules/integrity-audit/error.log";
+
+ public void cleanLog() throws Exception{
+
+ logger.debug("cleanLog: enter");
+ //FileOutputStream fstream = new FileOutputStream("IntegrityAudit.log");
+ FileOutputStream fstream = new FileOutputStream(TEST_LOG);
+ fstream.close();
+ fstream = new FileOutputStream(ERROR_LOG);
+ fstream.close();
+ logger.debug("cleanLog: exit");
+ }
+
+ public void cleanDb(String persistenceUnit, Properties properties){
+ logger.debug("cleanDb: enter");
+
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+
+ EntityManager em = emf.createEntityManager();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // Clean up the DB
+ em.createQuery("Delete from IntegrityAuditEntity").executeUpdate();
+
+ // commit transaction
+ et.commit();
+ em.close();
+ logger.debug("cleanDb: exit");
+ }
+
+
+ @Before
+ public void setUp() throws Exception {
+
+ logger.info("setUp: Entering");
+
+ IntegrityAudit.isUnitTesting = true;
+ IntegrityAuditEntity.isUnitTesting = true;
+
+ properties = new Properties();
+ properties.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+
+ dbDriver = IntegrityAuditProperties.DEFAULT_DB_DRIVER;
+ dbUrl = IntegrityAuditProperties.DEFAULT_DB_URL;
+ dbUser = IntegrityAuditProperties.DEFAULT_DB_USER;
+ dbPwd = IntegrityAuditProperties.DEFAULT_DB_PWD;
+ siteName = "SiteA";
+ nodeType = "pdp_xacml";
+ persistenceUnit = "testPU";
+ resourceName = "pdp1";
+
+ logger.info("setUp: Exiting");
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ logger.info("tearDown: Entering");
+
+ //cleanDb(persistenceUnit, properties);
+
+ logger.info("tearDown: Exiting");
+ }
+
+ @Ignore
+ @Test
+ public void runAllTests() throws Exception{
+ //The order is important - I haven't figured out why, but it is.
+ mismatchTest();
+ noEntitiesTest();
+ oneEntityTest();
+ }
+
+
+ /*
+ * Tests printing an error to the log in the event where
+ * there are no entities saved in the database
+ */
+ public void noEntitiesTest() throws Exception {
+ cleanLog();
+ cleanDb(persistenceUnit, properties);
+
+ logger.info("noEntitiesTest: Entering");
+
+ // Boolean to assert there are no entries found
+ Boolean noEntities = false;
+
+ dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ dbDAO.deleteAllIntegrityAuditEntities();
+ try {
+ DbAudit dbAudit = new DbAudit(dbDAO);
+ dbAudit.dbAudit(resourceName, persistenceUnit, nodeType);
+ }
+ catch (DbAuditException e) {
+ noEntities = true;
+ }
+
+ dbDAO.deleteAllIntegrityAuditEntities();
+
+ logger.info("noEntitiesTest: No entities are persisted in the database");
+
+ // Assert there are no entities retrieved
+ assertTrue(noEntities);
+
+ logger.info("noEntitiesTest: Exit");
+ }
+
+ /*
+ * Tests the detection of only one entry in the database
+ */
+ public void oneEntityTest() throws Exception{
+ cleanLog();
+ cleanDb(persistenceUnit, properties);
+
+ logger.info("oneEntityTest: Entering");
+
+ // Add one entry in the database
+ dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ DbAudit dbAudit = new DbAudit(dbDAO);
+ dbAudit.dbAudit(resourceName, persistenceUnit, nodeType);
+
+ List<IntegrityAuditEntity> iaeList = dbDAO.getIntegrityAuditEntities(persistenceUnit, nodeType);
+ logger.info("List size: " + iaeList.size());
+
+ //FileInputStream fstream = new FileInputStream("IntegrityAudit.log");
+ FileInputStream fstream = new FileInputStream(TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ Boolean oneEntity = false;
+ while ((strLine = br.readLine()) != null) {
+ //parse strLine to obtain what you want
+
+ if (strLine.contains("DbAudit: Found only one IntegrityAuditEntity entry:")) {
+ oneEntity = true;
+ }
+
+ }
+ if(oneEntity){
+ logger.info("oneEntityTest: One entity is persisted in the database");
+ }else{
+ logger.info("oneEntityTest: No entities are persisted in the database");
+ }
+
+
+ // Assert there is only one entry
+ assertTrue(oneEntity);
+
+ br.close();
+
+ logger.info("oneEntityTest: Exit");
+ }
+
+ /*
+ * Tests reporting mismatches and misentries using the error log
+ */
+ @SuppressWarnings("unused")
+ public void mismatchTest() throws Exception{
+ cleanLog();
+ logger.info("mismatchTest: Entering");
+
+ // Properties for DB2
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, "jdbc:h2:file:./sql/iaTest2");
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+
+ //Clean the DBs before we begin
+ cleanDb(persistenceUnit, properties);
+ cleanDb(persistenceUnit, properties2);
+
+ // Entries in DB1
+ dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ DbDAO dbDAO2 = new DbDAO("pdp2", persistenceUnit, properties);
+
+ /*
+ * dbDAO3 is a mismatch entry, dbDAO7 is a misentry
+ */
+ DbDAO dbDAO3 = new DbDAO("pdp3", persistenceUnit, properties);
+ DbDAO dbDAO7 = new DbDAO("pdp4", persistenceUnit, properties);
+ Date date = new Date();
+
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+
+ /*
+ * Update DB url's in DB1 to point to DB2
+ */
+ try{
+ EntityManager em = emf.createEntityManager();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
+ Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", "pdp2");
+ iaequery.setParameter("pu", persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+
+ //If it already exists, we just want to update the properties and lastUpdated date
+ if(!iaeList.isEmpty()){
+ //ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + "pdp2" + " with PersistenceUnit: " + persistenceUnit
+ + " exists and entry be updated");
+ }else{
+ // If it does not exist, we also must add teh resourceName, persistenceUnit and designated values
+ logger.info("Adding resource " + "pdp2" + " with PersistenceUnit: " + persistenceUnit
+ + " to IntegrityAuditEntity table");
+ iae = new IntegrityAuditEntity();
+ iae.setResourceName("pdp2");
+ iae.setPersistenceUnit(persistenceUnit);
+ iae.setDesignated(false);
+ }
+
+ //update/set properties in entry
+ iae.setSite(siteName);
+ iae.setNodeType(nodeType);
+ iae.setLastUpdated(date);
+ iae.setCreatedDate(date);
+ iae.setJdbcDriver(dbDriver);
+ iae.setJdbcPassword(dbPwd);
+ iae.setJdbcUrl("jdbc:h2:file:./sql/iaTest2");
+ iae.setJdbcUser(dbUser);
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
+ iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", "pdp1");
+ iaequery.setParameter("pu", persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList2 = iaequery.getResultList();
+ iae = null;
+
+ //If it already exists, we just want to update the properties and lastUpdated date
+ if(!iaeList2.isEmpty()){
+ //ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList2.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + "pdp1" + " with PersistenceUnit: " + persistenceUnit
+ + " exists and entry be updated");
+ }else{
+ // If it does not exist, we also must add teh resourceName, persistenceUnit and designated values
+ logger.info("Adding resource " + "pdp1" + " with PersistenceUnit: " + persistenceUnit
+ + " to IntegrityAuditEntity table");
+ iae = new IntegrityAuditEntity();
+ iae.setResourceName("pdp1");
+ iae.setPersistenceUnit(persistenceUnit);
+ iae.setDesignated(false);
+ }
+
+ //update/set properties in entry
+ iae.setSite(siteName);
+ iae.setNodeType(nodeType);
+ iae.setLastUpdated(date);
+ iae.setCreatedDate(date);
+ iae.setJdbcDriver(dbDriver);
+ iae.setJdbcPassword(dbPwd);
+ iae.setJdbcUrl("jdbc:h2:file:./sql/iaTest2");
+ iae.setJdbcUser(dbUser);
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
+ iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", "pdp3");
+ iaequery.setParameter("pu", persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList3 = iaequery.getResultList();
+ iae = null;
+
+ //If it already exists, we just want to update the properties and lastUpdated date
+ if(!iaeList3.isEmpty()){
+ //ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList3.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + "pdp3" + " with PersistenceUnit: " + persistenceUnit
+ + " exists and entry be updated");
+ }else{
+ // If it does not exist, we also must add the resourceName, persistenceUnit and designated values
+ logger.info("Adding resource " + "pdp3" + " with PersistenceUnit: " + persistenceUnit
+ + " to IntegrityAuditEntity table");
+ iae = new IntegrityAuditEntity();
+ iae.setResourceName("pdp3");
+ iae.setPersistenceUnit(persistenceUnit);
+ iae.setDesignated(false);
+ }
+
+ //update/set properties in entry
+ iae.setSite(siteName);
+ iae.setNodeType(nodeType);
+ iae.setLastUpdated(date);
+ iae.setCreatedDate(date);
+ iae.setJdbcDriver(dbDriver);
+ iae.setJdbcPassword(dbPwd);
+ iae.setJdbcUrl(dbUrl);
+ iae.setJdbcUser(dbUser);
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
+ iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", "pdp4");
+ iaequery.setParameter("pu", persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList4 = iaequery.getResultList();
+ iae = null;
+
+ //If it already exists, we just want to update the properties and lastUpdated date
+ if(!iaeList4.isEmpty()){
+ //ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList4.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + "pdp4" + " with PersistenceUnit: " + persistenceUnit
+ + " exists and entry be updated");
+ }else{
+ // If it does not exist, we also must add the resourceName, persistenceUnit and designated values
+ logger.info("Adding resource " + "pdp4" + " with PersistenceUnit: " + persistenceUnit
+ + " to IntegrityAuditEntity table");
+ iae = new IntegrityAuditEntity();
+ iae.setResourceName("pdp4");
+ iae.setPersistenceUnit(persistenceUnit);
+ iae.setDesignated(false);
+ }
+
+ //update/set properties in entry
+ iae.setSite(siteName);
+ iae.setNodeType(nodeType);
+ iae.setLastUpdated(date);
+ iae.setCreatedDate(date);
+ iae.setJdbcDriver(dbDriver);
+ iae.setJdbcPassword(dbPwd);
+ iae.setJdbcUrl("jdbc:h2:file:./sql/iaTest2");
+ iae.setJdbcUser(dbUser);
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ em.close();
+ }catch (Exception e){
+ String msg = "DbDAO: " + "register() " + "ecountered a problem in execution: ";
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(e);
+ }
+
+ /*
+ * Identical entries in from DB1 in DB2 except for dbDAO6
+ */
+ emf = Persistence.createEntityManagerFactory(persistenceUnit, properties2);
+ DbDAO dbDAO4 = new DbDAO(resourceName, persistenceUnit, properties2);
+
+ DbDAO dbDAO5 = new DbDAO("pdp2", persistenceUnit, properties2);
+
+ /*
+ * This is the mismatch entry
+ */
+ DbDAO dbDAO6 = new DbDAO("pdp3", persistenceUnit, properties2);
+ try{
+ EntityManager em = emf.createEntityManager();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
+ Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", "pdp2");
+ iaequery.setParameter("pu", persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+
+ //If it already exists, we just want to update the properties and lastUpdated date
+ if(!iaeList.isEmpty()){
+ //ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + "pdp2" + " with PersistenceUnit: " + persistenceUnit
+ + " exists and entry be updated");
+ }else{
+ // If it does not exist, we also must add teh resourceName, persistenceUnit and designated values
+ logger.info("Adding resource " + "pdp2" + " with PersistenceUnit: " + persistenceUnit
+ + " to IntegrityAuditEntity table");
+ iae = new IntegrityAuditEntity();
+ iae.setResourceName("pdp2");
+ iae.setPersistenceUnit(persistenceUnit);
+ iae.setDesignated(false);
+ }
+
+ //update/set properties in entry
+ iae.setSite(siteName);
+ iae.setNodeType(nodeType);
+ iae.setLastUpdated(date);
+ iae.setCreatedDate(date);
+ iae.setJdbcDriver(dbDriver);
+ iae.setJdbcPassword(dbPwd);
+ iae.setJdbcUrl("jdbc:h2:file:./sql/iaTest2");
+ iae.setJdbcUser(dbUser);
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
+ iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", "pdp1");
+ iaequery.setParameter("pu", persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList2 = iaequery.getResultList();
+ iae = null;
+
+ //If it already exists, we just want to update the properties and lastUpdated date
+ if(!iaeList2.isEmpty()){
+ //ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList2.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + "pdp1" + " with PersistenceUnit: " + persistenceUnit
+ + " exists and entry be updated");
+ }else{
+ // If it does not exist, we also must add teh resourceName, persistenceUnit and designated values
+ logger.info("Adding resource " + "pdp1" + " with PersistenceUnit: " + persistenceUnit
+ + " to IntegrityAuditEntity table");
+ iae = new IntegrityAuditEntity();
+ iae.setResourceName("pdp1");
+ iae.setPersistenceUnit(persistenceUnit);
+ iae.setDesignated(false);
+ }
+
+ //update/set properties in entry
+ iae.setSite(siteName);
+ iae.setNodeType(nodeType);
+ iae.setLastUpdated(date);
+ iae.setCreatedDate(date);
+ iae.setJdbcDriver(dbDriver);
+ iae.setJdbcPassword(dbPwd);
+ iae.setJdbcUrl("jdbc:h2:file:./sql/iaTest2");
+ iae.setJdbcUser(dbUser);
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
+ iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", "pdp3");
+ iaequery.setParameter("pu", persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList3 = iaequery.getResultList();
+ iae = null;
+
+ //If it already exists, we just want to update the properties and lastUpdated date
+ if(!iaeList3.isEmpty()){
+ //ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList3.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + "pdp3" + " with PersistenceUnit: " + persistenceUnit
+ + " exists and entry be updated");
+ }else{
+ // If it does not exist, we also must add teh resourceName, persistenceUnit and designated values
+ logger.info("Adding resource " + "pdp3" + " with PersistenceUnit: " + persistenceUnit
+ + " to IntegrityAuditEntity table");
+ iae = new IntegrityAuditEntity();
+ iae.setResourceName("pdp3");
+ iae.setPersistenceUnit(persistenceUnit);
+ iae.setDesignated(false);
+ }
+
+ //update/set properties in entry
+ iae.setSite(siteName);
+ iae.setNodeType(nodeType);
+ iae.setLastUpdated(date);
+ iae.setCreatedDate(date);
+ iae.setJdbcDriver(dbDriver);
+ iae.setJdbcPassword(dbPwd);
+ iae.setJdbcUrl("jdbc:h2:file:./sql/iaTest2");
+ iae.setJdbcUser(dbUser);
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ em.close();
+ }catch (Exception e){
+ String msg = "DbDAO: " + "register() " + "ecountered a problem in execution: ";
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(e);
+
+ }
+
+ /*
+ * Run the DB Audit, once it finds a mismatch and sleeps, update DB1
+ * to have the same entry as DB2 it can be confirmed that the mismatch
+ * is resolved
+ */
+ DbAudit dbAudit = new DbAudit(dbDAO);
+ dbAudit.dbAudit(resourceName, persistenceUnit, nodeType);
+ emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ try{
+ EntityManager em = emf.createEntityManager();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
+ Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", "pdp3");
+ iaequery.setParameter("pu", persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+
+ //If it already exists, we just want to update the properties and lastUpdated date
+ if(!iaeList.isEmpty()){
+ //ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + "pdp3" + " with PersistenceUnit: " + persistenceUnit
+ + " exists and entry be updated");
+ }else{
+ // If it does not exist, we also must add the resourceName, persistenceUnit and designated values
+ logger.info("Adding resource " + "pdp3" + " with PersistenceUnit: " + persistenceUnit
+ + " to IntegrityAuditEntity table");
+ iae = new IntegrityAuditEntity();
+ iae.setResourceName("pdp3");
+ iae.setPersistenceUnit(persistenceUnit);
+ iae.setDesignated(false);
+ }
+
+ //update/set properties in entry
+ iae.setSite(siteName);
+ iae.setNodeType(nodeType);
+ iae.setLastUpdated(date);
+ iae.setCreatedDate(date);
+ iae.setJdbcDriver(dbDriver);
+ iae.setJdbcPassword(dbPwd);
+ iae.setJdbcUrl("jdbc:h2:file:./sql/iaTest2");
+ iae.setJdbcUser(dbUser);
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+ em.close();
+ }catch (Exception e){
+ String msg = "DbDAO: " + "register() " + "ecountered a problem in execution: ";
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(e);
+ }
+
+ /*
+ * Run the audit again and correct the mismatch, the result should be one
+ * entry in the mismatchKeySet because of the misentry from the beginning
+ * of the test
+ */
+ dbAudit.dbAudit(resourceName, persistenceUnit, nodeType);
+
+ //Cleanup DB2
+ cleanDb(persistenceUnit, properties2);
+
+ FileInputStream fstream = new FileInputStream(TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ String mismatchIndex = "";
+ while ((strLine = br.readLine()) != null) {
+ //parse strLine to obtain what you want...retrieve the last entry
+
+ if (strLine.contains("Mismatched entries (keys):")) {
+ startIndex = strLine.indexOf("(keys):") + 8;
+ mismatchIndex = strLine.substring(startIndex);
+ }
+ }
+ int mismatchEntries = mismatchIndex.trim().split(",").length;
+ logger.info("mismatchTest: mismatchIndex found: '" + mismatchIndex + "'"
+ + " mismatachEntries = " + mismatchEntries);
+
+ // Assert there is only one entry index
+ assertEquals(1, mismatchEntries);
+
+ br.close();
+
+ //Now check the entry in the error.log
+ fstream = new FileInputStream(ERROR_LOG);
+ br = new BufferedReader(new InputStreamReader(fstream));
+ String mismatchNum = "";
+ while ((strLine = br.readLine()) != null) {
+ //parse strLine to obtain what you want...retrieve the last entry
+
+ if (strLine.contains("DB Audit:")) {
+ startIndex = strLine.indexOf("DB Audit:") + 10;
+ mismatchNum = strLine.substring(startIndex, startIndex+1);
+ }
+ }
+ logger.info("mismatchTest: mismatchNum found: '" + mismatchNum + "'");
+
+ // Assert that there are a total of 3 mismatches - 1 between each comparison node.
+ assertEquals("3", mismatchNum);
+
+ br.close();
+
+ logger.info("mismatchTest: Exit");
+ }
+
+}
diff --git a/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbDAOTest.java b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbDAOTest.java
new file mode 100644
index 00000000..31fd0be6
--- /dev/null
+++ b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/DbDAOTest.java
@@ -0,0 +1,725 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Audit
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.common.ia.test;
+
+import static org.junit.Assert.*;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+import javax.persistence.PersistenceUnitUtil;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Root;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.openecomp.policy.common.ia.DbDAO;
+import org.openecomp.policy.common.ia.DbDaoTransactionException;
+import org.openecomp.policy.common.ia.IntegrityAuditProperties;
+import org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity;
+
+public class DbDAOTest {
+ private static String persistenceUnit;
+ private static Properties properties;
+ private static String resourceName;
+
+ DbDAO d;
+
+ @Before
+ public void setUp() throws Exception {
+ properties = new Properties();
+ properties.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+
+ persistenceUnit = "integrityAuditPU";
+ resourceName = "pdp0";
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /* Tests registering a new IntegrityAuditEntity object in the DB */
+ @Ignore
+ @Test
+ public void testNewRegistration() {
+ try {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ // Begin Transaction
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+
+ et.begin();
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+
+ // Find the proper entry in the database
+ Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", DbDAOTest.resourceName);
+ iaequery.setParameter("pu", DbDAOTest.persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+
+ // Assert that the IntegrityAuditEntity object was found
+ assertNotNull(iaeList);
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+ em.close();
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /* Tests updating an IntegrityAuditEntity if it has already been registered */
+ @Ignore
+ @Test
+ public void testUpdateRegistration() {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ // Begin transaction
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+
+ // close the EntityManager
+ em.close();
+
+ try {
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+
+ // Change site_name in properties to test that an update was made to an existing entry in the table
+ properties.put(IntegrityAuditProperties.SITE_NAME, "SiteB");
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+
+ em = emf.createEntityManager();
+
+ // Start a transaction
+ et = em.getTransaction();
+
+ // Begin Transaction
+ et.begin();
+
+ // Find the proper entry in the database
+ Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", DbDAOTest.resourceName);
+ iaequery.setParameter("pu", DbDAOTest.persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+ if(!iaeList.isEmpty()) {
+ //ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+
+ em.refresh(iae);
+ em.persist(iae);
+
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ // close the EntityManager
+ em.close();
+
+ // Assert that the site_name for the existing entry was updated
+ assertEquals("SiteB", iae.getSite());
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /* Tests obtaining all Integrity Audit Entities from a table */
+ @Ignore
+ @Test
+ public void testGetIntegrityAuditEntities() {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+
+ // close the transaction
+ et.commit();
+
+ // close the EntityManager
+ em.close();
+
+ try {
+ // Add some entries to the DB
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+ DbDAO d2 = new DbDAO("pdp1", persistenceUnit, properties);
+ properties.put(IntegrityAuditProperties.NODE_TYPE, "pdp_drools");
+ DbDAO d3 = new DbDAO("pdp2", persistenceUnit, properties);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ List<IntegrityAuditEntity> entities;
+ try {
+ // Obtain entries based on persistenceUnit and nodeType
+ entities = d.getIntegrityAuditEntities(persistenceUnit, "pdp_xacml");
+ assertEquals(2, entities.size());
+ } catch (DbDaoTransactionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /* Tests retrieving a DbDAO instance's IntegrityAuditEntity */
+ @Ignore
+ @Test
+ public void testGetMyIntegrityAuditEntity() {
+ try {
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+ IntegrityAuditEntity iae = d.getMyIntegrityAuditEntity();
+ assertEquals("integrityAuditPU", iae.getPersistenceUnit());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /* Tests obtaining an IntegrityAuditEntity by ID */
+ @Ignore
+ @Test
+ public void testGetIntegrityAuditEntity() {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ // Begin transaction
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+
+ // close the transaction
+ et.commit();
+
+ try {
+ // Obtain an entry from the database based on ID
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+
+ et.begin();
+
+ // Find the proper database entry
+ Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", DbDAOTest.resourceName);
+ iaequery.setParameter("pu", DbDAOTest.persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+ if(!iaeList.isEmpty()){
+ //ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+
+ // Obtain ID for an IntegrityAuditEntity
+ PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
+ Object iaeId = util.getIdentifier(iae);
+
+ // Obtain the same IntegrityAuditEntity based on ID
+ IntegrityAuditEntity iaeDuplicate = d.getIntegrityAuditEntity((long) iaeId);
+ Object duplicateId = util.getIdentifier(iaeDuplicate);
+
+ // Assert that the proper entry was retrieved based on ID
+ assertEquals((long) iaeId, (long) duplicateId);
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ // close the EntityManager
+ em.close();
+ }
+
+ /* Tests setting an IntegrityAuditEntity as the designated node */
+ @Ignore
+ @Test
+ public void testSetDesignated() {
+ try {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ // Begin transaction
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+
+ et.begin();
+
+ // Create an entry and set it's designated field to true
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+ d.setDesignated(resourceName, persistenceUnit, true);
+
+ // Find the proper entry in the database
+ Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", resourceName);
+ iaequery.setParameter("pu", persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+
+ if(!iaeList.isEmpty()){
+ //ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+ em.refresh(iae);
+
+ // Check if the node is designated
+ boolean result = iae.isDesignated();
+
+ // Assert that it is designated
+ assertTrue(result);
+ }
+
+ // flush to the DB
+ em.flush();
+
+ // close the transaction
+ et.commit();
+
+ // close the EntityManager
+ em.close();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /* Tests that the lastUpdated column in the database is updated properly */
+ @Ignore
+ @Test
+ public void testSetLastUpdated() {
+ try {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ // Begin transaction
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+
+ et.begin();
+
+ // Create an entry
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+
+ // Find the proper entry in the database
+ Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", resourceName);
+ iaequery.setParameter("pu", persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+
+ if(!iaeList.isEmpty()){
+ // ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+
+ // Obtain old update value and set new update value
+ Date oldDate = iae.getLastUpdated();
+ iae.setSite("SiteB");
+ iae.setLastUpdated(new Date());
+ Date newDate = iae.getLastUpdated();
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+ // close the transaction
+ et.commit();
+ // close the EntityManager
+ em.close();
+
+ // Assert that the old and new update times are different
+ assertNotEquals(oldDate, newDate);
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /* Tests that all the entries from a class can be retrieved */
+ @Ignore
+ @Test
+ public void testGetAllMyEntriesString() {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ // Begin transaction
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+
+ // close the EntityManager
+ em.close();
+
+ try {
+ // create entries for the IntegrityAuditEntity table
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+ DbDAO d2 = new DbDAO("pdp1", persistenceUnit, properties);
+ DbDAO d3 = new DbDAO("pdp2", persistenceUnit, properties);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ // Obtain a hash with the persisted objects
+ HashMap<Object, Object> entries = d.getAllMyEntries("org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity");
+
+ // Assert there were 3 entries for that class
+ assertEquals(3, entries.size());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /* Tests retrieving all entities in a Persistence Unit using the class name and a hashset of IDs */
+ @Ignore
+ @Test
+ public void testGetAllMyEntriesStringHashSet() {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ // Begin transaction
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+
+ try {
+ // create entries for the IntegrityAuditEntity table
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+ DbDAO d2 = new DbDAO("pdp1", persistenceUnit, properties);
+ DbDAO d3 = new DbDAO("pdp2", persistenceUnit, properties);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ // Obtain all entity keys
+ CriteriaBuilder cb = em.getCriteriaBuilder();
+ CriteriaQuery<Object> cq = cb.createQuery();
+ Root<?> rootEntry = cq.from(Class.forName("org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity"));
+ CriteriaQuery<Object> all = cq.select(rootEntry);
+ TypedQuery<Object> allQuery = em.createQuery(all);
+ List<Object> objectList = allQuery.getResultList();
+ HashSet<Object> resultSet = new HashSet<Object>();
+ PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
+ for (Object o: objectList){
+ Object key = util.getIdentifier(o);
+ resultSet.add(key);
+ }
+
+ // Obtain a hash with the persisted objects
+ HashMap<Object, Object> entries = d.getAllMyEntries("org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity", resultSet);
+
+ // Assert there were 3 entries for that class
+ assertEquals(3, entries.size());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // close the EntityManager
+ em.close();
+ }
+
+ /* Tests retrieving all entities in a Persistence Unit using the persistence unit, properties, and class name */
+ @Ignore
+ @Test
+ public void testGetAllEntriesStringPropertiesString() {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ // Begin transaction
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+
+ // close the EntityManager
+ em.close();
+
+ try {
+ // create entries for the IntegrityAuditEntity table
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+ DbDAO d2 = new DbDAO("pdp1", persistenceUnit, properties);
+ DbDAO d3 = new DbDAO("pdp2", persistenceUnit, properties);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ // Obtain a hash with the persisted objects
+ HashMap<Object, Object> entries = d.getAllEntries("integrityAuditPU", properties, "org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity");
+
+ // Assert there were 3 entries for that class
+ assertEquals(3, entries.size());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /* Tests retrieving all entities in a Persistence Unit using the persistence unit, properties, class name, and a hashset of IDs */
+ @Ignore
+ @Test
+ public void testGetAllEntriesStringPropertiesStringHashSet() {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ // Begin transaction
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+
+ try {
+ // create entries for the IntegrityAuditEntity table
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+ DbDAO d2 = new DbDAO("pdp1", persistenceUnit, properties);
+ DbDAO d3 = new DbDAO("pdp2", persistenceUnit, properties);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ // Obtain all entity keys
+ CriteriaBuilder cb = em.getCriteriaBuilder();
+ CriteriaQuery<Object> cq = cb.createQuery();
+ Root<?> rootEntry = cq.from(Class.forName("org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity"));
+ CriteriaQuery<Object> all = cq.select(rootEntry);
+ TypedQuery<Object> allQuery = em.createQuery(all);
+ List<Object> objectList = allQuery.getResultList();
+ HashSet<Object> resultSet = new HashSet<Object>();
+ PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
+ for (Object o: objectList){
+ Object key = util.getIdentifier(o);
+ resultSet.add(key);
+ }
+
+ // Obtain a hash with the persisted objects
+ HashMap<Object, Object> entries = d.getAllEntries("integrityAuditPU", properties, "org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity", resultSet);
+
+ // Assert there were 3 entries for that class
+ assertEquals(3, entries.size());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // close the EntityManager
+ em.close();
+ }
+
+ /* Tests getting all the entries from a class based on persistenceUnit, properties, and className */
+ @Ignore
+ @Test
+ public void testGetAllEntries() {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ // Begin transaction
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+
+ // close the EntityManager
+ em.close();
+
+ try {
+ // create entries for the IntegrityAuditEntity table
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+ DbDAO d2 = new DbDAO("pdp1", persistenceUnit, properties);
+ DbDAO d3 = new DbDAO("pdp2", persistenceUnit, properties);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ // Obtain a hash with the persisted objects
+ HashMap<Object, Object> entries = d.getAllEntries(persistenceUnit, properties, "org.openecomp.policy.common.ia.jpa.IntegrityAuditEntity");
+
+ // Assert there were 3 entries for that class
+ assertEquals(3, entries.size());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /* Tests obtaining all class names of persisted classes */
+ public void testGetPersistenceClassNames() {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ // Begin transaction
+ et.begin();
+
+ // Clean the DB
+ em.createQuery("DELETE FROM IntegrityAuditEntity").executeUpdate();
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+
+ // close the EntityManager
+ em.close();
+
+ try {
+ d = new DbDAO(resourceName, persistenceUnit, properties);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ // Retrieve persistence class names
+ HashSet<String> result = d.getPersistenceClassNames();
+ assertEquals(1, result.size());
+ }
+}
diff --git a/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/IntegrityAuditDesignationTest.java b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/IntegrityAuditDesignationTest.java
new file mode 100644
index 00000000..6eb5fa4e
--- /dev/null
+++ b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/IntegrityAuditDesignationTest.java
@@ -0,0 +1,1101 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Audit
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.common.ia.test;
+
+import static org.junit.Assert.*;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+
+
+
+//import org.apache.commons.logging.Log;
+//import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.openecomp.policy.common.ia.AuditThread;
+import org.openecomp.policy.common.ia.DbDAO;
+import org.openecomp.policy.common.ia.IntegrityAudit;
+import org.openecomp.policy.common.ia.IntegrityAuditProperties;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+
+public class IntegrityAuditDesignationTest {
+
+ private static Logger logger = FlexLogger.getLogger(IntegrityAuditDesignationTest.class);
+
+ /*
+ * Provides a little cushion for timing events.
+ */
+ private static int FUDGE_FACTOR = 5000;
+
+ private static String persistenceUnit;
+ private static Properties properties;
+ private static String resourceName;
+ private static final String TEST_LOG = "./testingLogs/common-modules/integrity-audit/debug.log";
+ @Before
+ public void setUp() throws Exception {
+
+
+ System.out.println("setUp: Clearing debug.log");
+ FileOutputStream fstream = new FileOutputStream(TEST_LOG);
+ fstream.close();
+
+ logger.info("setUp: Entering");
+
+ IntegrityAudit.isUnitTesting = true;
+
+ properties = new Properties();
+ properties.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+
+ /*
+ * AuditThread.AUDIT_THREAD_SLEEP_INTERVAL is also five seconds, so
+ * setting AUDIT_PERIOD_SECONDS to 5 ensures that whether or not audit
+ * has already been run on a node, it will sleep the same amount of
+ * time.
+ */
+ properties.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+
+ persistenceUnit = "testPU";
+ resourceName = "pdp1";
+
+
+ //Clean up the DB
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+
+ EntityManager em = emf.createEntityManager();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
+ em.createQuery("Delete from IntegrityAuditEntity").executeUpdate();
+
+ // commit transaction
+ et.commit();
+ em.close();
+ logger.info("setUp: Exiting");
+
+ }
+
+
+ @After
+ public void tearDown() throws Exception {
+
+ logger.info("tearDown: Entering");
+
+ logger.info("tearDown: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when only one functioning resource is in play. Designation
+ * should stay with single resource.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test was successful.
+ */
+ @Ignore
+ @Test
+ public void testOneResource() throws Exception {
+
+ logger.info("testOneResource: Entering");
+
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName, persistenceUnit, properties);
+ integrityAudit.startAuditThread();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 to run audit (15 seconds)
+ *
+ * 2) Logic to detect that no other node is available for designation (60 seconds)
+ *
+ * 3) pdp1 to run audit again (15 seconds)
+ */
+ logger.info("testOneResource: Sleeping 100 seconds");
+ Thread.sleep(100000);
+
+ logger.info("testOneResource: Stopping audit thread");
+ integrityAudit.stopAuditThread();
+
+ FileInputStream fstream = new FileInputStream(TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ int endIndex;
+
+ String rName = "";
+ while ((strLine = br.readLine()) != null) {
+ // parse strLine to obtain what you want
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+ rName = strLine.substring(startIndex, endIndex);
+ logger.info("testOneResource: rName: " + rName);
+ assertEquals("pdp1", rName);
+ }
+ }
+ fstream.close();
+
+ /*
+ * Test fix for ECOMPD2TD-783: Audit fails to run when application is restarted.
+ */
+ integrityAudit.startAuditThread();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 to run audit (15 seconds)
+ *
+ * 2) Logic to detect that no other node is available for designation (60 seconds)
+ *
+ * 3) pdp1 to run audit again (15 seconds)
+ */
+ logger.info("testOneResource: Sleeping 100 seconds for second time");
+ Thread.sleep(100000);
+
+ logger.info("testOneResource: Stopping audit thread for second time");
+ integrityAudit.stopAuditThread();
+
+ fstream = new FileInputStream(TEST_LOG);
+ br = new BufferedReader(new InputStreamReader(fstream));
+
+ rName = "";
+ while ((strLine = br.readLine()) != null) {
+ // parse strLine to obtain what you want
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+ rName = strLine.substring(startIndex, endIndex);
+ logger.info("testOneResource: rName: " + rName);
+ assertEquals("pdp1", rName);
+ }
+ }
+ fstream.close();
+
+ logger.info("testOneResource: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when two functioning resources are in play.
+ * Designation should alternate between resources.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test
+ * was successful. A quick way of examining the log is to search for the
+ * string "audit simulation":
+ *
+ * As you can see from the "dbAuditSimulate" method, when it executes, it
+ * logs the "Starting audit simulation..." message and when it finishes, it
+ * logs the "Finished audit simulation..." message. By looking for these
+ * messages, you can verify that the audits are run by the proper resource.
+ * For example, when testFourResourcesOneDead is run, you should see a
+ * Starting.../Finished... sequence for pdp1, followed by a
+ * Starting.../Finished... sequence for pdp2, followed by a
+ * Starting.../Finished... sequence for pdp4 (pdp3 is skipped as it's
+ * dead/hung), followed by a Starting.../Finished... sequence for pdp1, etc.
+ */
+ @Ignore
+ @Test
+ public void testTwoResources() throws Exception {
+
+ logger.info("testTwoResources: Entering");
+
+ /*
+ * Start audit for pdp1.
+ */
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName, persistenceUnit, properties);
+ integrityAudit.startAuditThread();
+
+ /*
+ * Start audit for pdp2.
+ */
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties2.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit2 = "testPU";
+ String resourceName2 = "pdp2";
+ IntegrityAudit integrityAudit2 = new IntegrityAudit(resourceName2, persistenceUnit2, properties2);
+ integrityAudit2.startAuditThread();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 to run audit (15 seconds)
+ *
+ * 2) Logic to detect that pdp1 is stale and designate pdp2 (30 seconds)
+ *
+ * 3) pdp2 to run audit (15 seconds)
+ *
+ * 4) Logic to detect that pdp2 is stale and designate pdp1 (30 seconds)
+ *
+ * 5) pdp1 to run audit (15 seconds)
+ */
+ Thread.sleep(120000);
+
+ logger.info("testTwoResources: Stopping audit threads");
+ integrityAudit.stopAuditThread();
+ integrityAudit2.stopAuditThread();
+
+ FileInputStream fstream = new FileInputStream(TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ int endIndex;
+ ArrayList<String> expectedResult = new ArrayList<String>(Arrays.asList("pdp1", "pdp2", "pdp1"));
+ ArrayList<String> delegates = new ArrayList<String>();
+ while ((strLine = br.readLine()) != null) {
+ /* parse strLine to obtain what you want */
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+
+ String rName = strLine.substring(startIndex, endIndex);
+
+ delegates.add(rName);
+ }
+ }
+
+ for (String delegate: delegates) {
+ logger.info("testTwoResources: delegate: " + delegate);
+ }
+
+ fstream.close();
+
+ assertTrue(expectedResult.equals(delegates));
+
+ assertTrue("delegate count only " + delegates.size(), delegates.size() >= 3);
+ assertTrue("delegate 0 is " + expectedResult.get(0), expectedResult.get(0).equals(delegates.get(0)));
+ assertTrue("delegate 1 is " + expectedResult.get(1), expectedResult.get(1).equals(delegates.get(1)));
+ assertTrue("delegate 2 is " + expectedResult.get(2), expectedResult.get(2).equals(delegates.get(2)));
+
+ logger.info("testTwoResources: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when two functioning resources are in play, each
+ * with different PUs. Audits for "testPU" and "integrityAuditPU" should run
+ * simultaneously. Designation should not alternate.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test
+ * was successful.
+ */
+ @Ignore
+ @Test
+ public void testTwoResourcesDifferentPus() throws Exception {
+
+ logger.info("testTwoResourcesDifferentPus: Entering");
+
+ /*
+ * Start audit for pdp1.
+ */
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName, persistenceUnit, properties);
+ integrityAudit.startAuditThread();
+
+ /*
+ * Start audit for pdp2.
+ */
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties2.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit2 = "integrityAuditPU";
+ String resourceName2 = "pdp2";
+ IntegrityAudit integrityAudit2 = new IntegrityAudit(resourceName2, persistenceUnit2, properties2);
+ integrityAudit2.startAuditThread();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 and pdp2 to run audit simultaneously (15 seconds)
+ *
+ * 2) Logic to detect that no other node is available for designation for either pdp1 or pdp2 (60 seconds)
+ *
+ * 3) pdp1 and pdp2 to again run audit simultaneously (15 seconds)
+ *
+ * NOTE: Based on the above, you would think a 100000ms sleep would be appropriate,
+ * but for some reason, when all tests are run this test errors.
+ */
+ logger.info("testTwoResourcesDifferentPus: Sleeping 80 seconds");
+ Thread.sleep(100000);
+
+ logger.info("testTwoResourcesDifferentPus: Stopping audit threads");
+ integrityAudit.stopAuditThread();
+ integrityAudit2.stopAuditThread();
+
+ FileInputStream fstream = new FileInputStream(TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ int endIndex;
+ ArrayList<String> expectedResult = new ArrayList<String>(Arrays.asList("pdp1", "pdp2", "pdp1", "pdp2"));
+ ArrayList<String> delegates = new ArrayList<String>();
+ while ((strLine = br.readLine()) != null) {
+ /* parse strLine to obtain what you want */
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+
+ String rName = strLine.substring(startIndex, endIndex);
+
+ delegates.add(rName);
+ }
+ }
+
+ for (String delegate: delegates) {
+ logger.info("testTwoResourcesDifferentPus: delegate: " + delegate);
+ }
+
+ fstream.close();
+
+ assertTrue("delegate count only " + delegates.size(), delegates.size() >= 4);
+ assertTrue("delegate 0 is " + expectedResult.get(0), expectedResult.get(0).equals(delegates.get(0)));
+ assertTrue("delegate 1 is " + expectedResult.get(1), expectedResult.get(1).equals(delegates.get(1)));
+ assertTrue("delegate 2 is " + expectedResult.get(2), expectedResult.get(2).equals(delegates.get(2)));
+ assertTrue("delegate 3 is " + expectedResult.get(3), expectedResult.get(3).equals(delegates.get(3)));
+
+ assertTrue(expectedResult.equals(delegates));
+
+ logger.info("testTwoResourcesDifferentPus: Exiting");
+
+ }
+
+
+ /*
+ * Tests designation logic when two resources are in play but one of them is
+ * dead/hung. Designation should move to second resource but then get
+ * restored back to original resource when it's discovered that second
+ * resource is dead.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test
+ * was successful.
+ */
+ @Ignore
+ @Test
+ public void testTwoResourcesOneDead() throws Exception {
+
+ logger.info("testTwoResourcesOneDead: Entering");
+
+ /*
+ * Start audit for pdp1.
+ */
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName, persistenceUnit, properties);
+ integrityAudit.startAuditThread();
+
+ /*
+ * Populate DB for pdp2, which will simulate it having registered but then having died.
+ */
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties2.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit2 = "testPU";
+ String resourceName2 = "pdp2";
+ new DbDAO(resourceName2, persistenceUnit2, properties2);
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 to run audit (15 seconds)
+ *
+ * 2) Logic to detect that other node, pdp2, is not available for designation (60 seconds)
+ *
+ * 3) pdp1 to run audit again (15 seconds)
+ */
+ logger.info("testTwoResourcesOneDead: Sleeping 100 seconds");
+ Thread.sleep(100000);
+
+ logger.info("testTwoResourcesOneDead: Stopping audit thread");
+ integrityAudit.stopAuditThread();
+
+ FileInputStream fstream = new FileInputStream(TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ int endIndex;
+ ArrayList<String> expectedResult = new ArrayList<String>(Arrays.asList("pdp1", "pdp1"));
+ ArrayList<String> delegates = new ArrayList<String>();
+ while ((strLine = br.readLine()) != null) {
+ /* parse strLine to obtain what you want */
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+
+ String rName = strLine.substring(startIndex, endIndex);
+
+ delegates.add(rName);
+ }
+ }
+
+ for (String delegate: delegates) {
+ logger.info("testTwoResourcesOneDead: delegate: " + delegate);
+ }
+
+ fstream.close();
+
+ assertTrue("delegate count only " + delegates.size(), delegates.size() >= 2);
+ assertTrue("delegate 0 is " + expectedResult.get(0), expectedResult.get(0).equals(delegates.get(0)));
+ assertTrue("delegate 1 is " + expectedResult.get(1), expectedResult.get(1).equals(delegates.get(1)));
+
+ logger.info("testTwoResourcesOneDead: Exiting");
+
+ }
+
+
+ /*
+ * Tests designation logic when three functioning resources are in play. Designation should
+ * round robin among resources.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test was successful.
+ */
+ @Ignore
+ @Test
+ public void testThreeResources() throws Exception {
+
+ logger.info("testThreeResources: Entering");
+
+ /*
+ * Start audit for pdp1.
+ */
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName, persistenceUnit, properties);
+ integrityAudit.startAuditThread();
+
+ /*
+ * Start audit for pdp2.
+ */
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties2.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit2 = "testPU";
+ String resourceName2 = "pdp2";
+ IntegrityAudit integrityAudit2 = new IntegrityAudit(resourceName2, persistenceUnit2, properties2);
+ integrityAudit2.startAuditThread();
+
+ /*
+ * Start audit for pdp3.
+ */
+ Properties properties3 = new Properties();
+ properties3.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties3.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties3.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties3.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties3.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties3.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties3.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit3 = "testPU";
+ String resourceName3 = "pdp3";
+ IntegrityAudit integrityAudit3 = new IntegrityAudit(resourceName3, persistenceUnit3, properties3);
+ integrityAudit3.startAuditThread();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 to run audit (15 seconds)
+ *
+ * 2) Logic to detect that pdp1 is stale and designate pdp2 (30 seconds)
+ *
+ * 3) pdp2 to run audit (15 seconds)
+ *
+ * 4) Logic to detect that pdp2 is stale and designate pdp3 (30 seconds)
+ *
+ * 5) pdp3 to run audit (15 seconds)
+ *
+ * 6) Logic to detect that pdp3 is stale and designate pdp1 (30 seconds)
+ *
+ * 7) pdp1 to run audit (15 seconds)
+ */
+ logger.info("testThreeResources: Sleeping 160 seconds");
+ Thread.sleep(160000);
+
+ logger.info("testThreeResources: Stopping threads");
+ integrityAudit.stopAuditThread();
+ integrityAudit2.stopAuditThread();
+ integrityAudit3.stopAuditThread();
+
+ FileInputStream fstream = new FileInputStream(TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ int endIndex;
+ ArrayList<String> expectedResult = new ArrayList<String>(Arrays.asList("pdp1", "pdp2", "pdp3", "pdp1"));
+ ArrayList<String> delegates = new ArrayList<String>();
+ while ((strLine = br.readLine()) != null) {
+ /* parse strLine to obtain what you want */
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+
+ String rName = strLine.substring(startIndex, endIndex);
+
+ delegates.add(rName);
+ }
+ }
+
+ for (String delegate: delegates) {
+ logger.info("testThreeResources: delegate: " + delegate);
+ }
+
+ fstream.close();
+
+ assertTrue("delegate count only " + delegates.size(), delegates.size() >= 3);
+ assertTrue("delegate 0 is " + expectedResult.get(0), expectedResult.get(0).equals(delegates.get(0)));
+ assertTrue("delegate 1 is " + expectedResult.get(1), expectedResult.get(1).equals(delegates.get(1)));
+ assertTrue("delegate 2 is " + expectedResult.get(2), expectedResult.get(2).equals(delegates.get(2)));
+ assertTrue("delegate 3 is " + expectedResult.get(3), expectedResult.get(3).equals(delegates.get(3)));
+
+ logger.info("testThreeResources: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when four functioning resources are in play, two
+ * with one PU, two with another. Audits for "testPU" and "integrityAuditPU" should run
+ * simultaneously. Designation should alternate between resources for each of the two
+ * persistence units.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test
+ * was successful.
+ */
+ @Ignore
+ @Test
+ public void testFourResourcesDifferentPus() throws Exception {
+
+ logger.info("testFourResourcesDifferentPus: Entering");
+
+ /*
+ * Start audit for pdp1, testPU.
+ */
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName, persistenceUnit, properties);
+ integrityAudit.startAuditThread();
+
+ /*
+ * Start audit for pdp2, integrityAuditPU.
+ */
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties2.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit2 = "integrityAuditPU";
+ String resourceName2 = "pdp2";
+ IntegrityAudit integrityAudit2 = new IntegrityAudit(resourceName2, persistenceUnit2, properties2);
+ integrityAudit2.startAuditThread();
+
+ /*
+ * Start audit for pdp3, testPU.
+ */
+ Properties properties3 = new Properties();
+ properties3.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties3.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties3.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties3.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties3.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties3.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties3.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit3 = "testPU";
+ String resourceName3 = "pdp3";
+ IntegrityAudit integrityAudit3 = new IntegrityAudit(resourceName3, persistenceUnit3, properties3);
+ integrityAudit3.startAuditThread();
+
+ /*
+ * Start audit for pdp4, integrityAuditPU.
+ */
+ Properties properties4 = new Properties();
+ properties4.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties4.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties4.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties4.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties4.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties4.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties4.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit4 = "integrityAuditPU";
+ String resourceName4 = "pdp4";
+ IntegrityAudit integrityAudit4 = new IntegrityAudit(resourceName4, persistenceUnit4, properties4);
+ integrityAudit4.startAuditThread();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 and pdp2 to run audit simultaneously (15 seconds)
+ *
+ * 2) Logic to detect that pdp1 and pdp2 are stale and designate pdp3 (one's counterpart) and pdp4 (two's counterpart) (30 seconds)
+ *
+ * 3) pdp3 and pdp4 to run audit simultaneously (15 seconds)
+ *
+ * 4) Logic to detect that pdp3 and pdp4 are stale and designate pdp1 (three's counterpart) and pdp2 (four's counterpart) (30 seconds)
+ *
+ * 5) pdp1 and pdp2 to run audit simultaneously (15 seconds)
+ */
+ logger.info("testFourResourcesDifferentPus: Sleeping 120 seconds");
+ Thread.sleep(120000);
+
+ logger.info("testFourResourcesDifferentPus: Stopping threads");
+ integrityAudit.stopAuditThread();
+ integrityAudit2.stopAuditThread();
+ integrityAudit3.stopAuditThread();
+ integrityAudit4.stopAuditThread();
+
+ FileInputStream fstream = new FileInputStream(TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ int endIndex;
+ ArrayList<String> expectedResult = new ArrayList<String>(Arrays.asList("pdp1", "pdp2", "pdp3", "pdp4", "pdp1", "pdp2"));
+ ArrayList<String> delegates = new ArrayList<String>();
+ while ((strLine = br.readLine()) != null) {
+ /* parse strLine to obtain what you want */
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+
+ String rName = strLine.substring(startIndex, endIndex);
+
+ delegates.add(rName);
+ }
+ }
+
+ for (String delegate: delegates) {
+ logger.info("testFourResourcesDifferentPus: delegate: " + delegate);
+ }
+
+ fstream.close();
+
+ assertTrue("delegate count only " + delegates.size(), delegates.size() >= 6);
+ assertTrue("delegate 0 is " + expectedResult.get(0), expectedResult.get(0).equals(delegates.get(0)));
+ assertTrue("delegate 1 is " + expectedResult.get(1), expectedResult.get(1).equals(delegates.get(1)));
+ assertTrue("delegate 2 is " + expectedResult.get(2), expectedResult.get(2).equals(delegates.get(2)));
+ assertTrue("delegate 3 is " + expectedResult.get(3), expectedResult.get(3).equals(delegates.get(3)));
+ assertTrue("delegate 4 is " + expectedResult.get(4), expectedResult.get(4).equals(delegates.get(4)));
+ assertTrue("delegate 5 is " + expectedResult.get(5), expectedResult.get(5).equals(delegates.get(5)));
+
+ logger.info("testFourResourcesDifferentPus: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when four resources are in play but one is not
+ * functioning. Designation should round robin among functioning resources
+ * only.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test
+ * was successful.
+ */
+ @Ignore
+ @Test
+ public void testFourResourcesOneDead() throws Exception {
+
+ logger.info("testFourResourcesOneDead: Entering");
+
+ /*
+ * Start audit for pdp1.
+ */
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName, persistenceUnit, properties);
+ integrityAudit.startAuditThread();
+
+ /*
+ * Start audit for pdp2.
+ */
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties2.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit2 = "testPU";
+ String resourceName2 = "pdp2";
+ IntegrityAudit integrityAudit2 = new IntegrityAudit(resourceName2, persistenceUnit2, properties2);
+ integrityAudit2.startAuditThread();
+
+ /*
+ * Populate DB for pdp3, which will simulate it having registered but then having died.
+ */
+ Properties properties3 = new Properties();
+ properties3.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties3.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties3.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties3.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties3.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties3.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties3.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit3 = "testPU";
+ String resourceName3 = "pdp3";
+ new DbDAO(resourceName3, persistenceUnit3, properties3);
+
+ /*
+ * Start audit for pdp4.
+ */
+ Properties properties4 = new Properties();
+ properties4.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties4.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties4.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties4.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties4.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties4.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties4.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit4 = "testPU";
+ String resourceName4 = "pdp4";
+ IntegrityAudit integrityAudit4 = new IntegrityAudit(resourceName4, persistenceUnit4, properties4);
+ integrityAudit4.startAuditThread();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 to run audit (15 seconds)
+ *
+ * 2) Logic to detect that pdp1 is stale and designate pdp2 (30 seconds)
+ *
+ * 3) pdp2 to run audit (15 seconds)
+ *
+ * 4) Logic to detect that pdp2 is stale and designate pdp4 (30 seconds)
+ *
+ * 5) pdp4 to run audit (15 seconds)
+ *
+ * 6) Logic to detect that pdp4 is stale and designate pdp1 (30 seconds)
+ *
+ * 7) pdp1 to run audit (15 seconds)
+ *
+ * 8) Logic to detect that pdp1 is stale and designate pdp2 (30 seconds)
+ *
+ * 7) pdp2 to run audit (15 seconds)
+ */
+ logger.info("testFourResourcesOneDead: Sleeping 210 seconds");
+ Thread.sleep(210000);
+
+ logger.info("testFourResourcesOneDead: Stopping threads");
+ integrityAudit.stopAuditThread();
+ integrityAudit2.stopAuditThread();
+ integrityAudit4.stopAuditThread();
+
+ FileInputStream fstream = new FileInputStream(TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ int endIndex;
+ ArrayList<String> expectedResult = new ArrayList<String>(Arrays.asList("pdp1", "pdp2", "pdp4", "pdp1", "pdp2", "pdp4"));
+ ArrayList<String> delegates = new ArrayList<String>();
+ while ((strLine = br.readLine()) != null) {
+ /* parse strLine to obtain what you want */
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+
+ String rName = strLine.substring(startIndex, endIndex);
+
+ delegates.add(rName);
+ }
+ }
+
+ for (String delegate : delegates) {
+ logger.info("testFourResourcesOneDead: delegate: " + delegate);
+ }
+
+ fstream.close();
+
+ assertTrue("delegate count only " + delegates.size(), delegates.size() >= 6);
+ assertTrue("delegate 0 is " + expectedResult.get(0), expectedResult.get(0).equals(delegates.get(0)));
+ assertTrue("delegate 1 is " + expectedResult.get(1), expectedResult.get(1).equals(delegates.get(1)));
+ assertTrue("delegate 2 is " + expectedResult.get(2), expectedResult.get(2).equals(delegates.get(2)));
+ assertTrue("delegate 3 is " + expectedResult.get(3), expectedResult.get(3).equals(delegates.get(3)));
+ assertTrue("delegate 4 is " + expectedResult.get(4), expectedResult.get(4).equals(delegates.get(4)));
+ assertTrue("delegate 5 is " + expectedResult.get(5), expectedResult.get(5).equals(delegates.get(5)));
+
+ logger.info("testFourResourcesOneDead: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when four resources are in play but only one is
+ * functioning. Designation should remain with sole functioning resource.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test
+ * was successful.
+ */
+ @Ignore
+ @Test
+ public void testFourResourcesThreeDead() throws Exception {
+
+ logger.info("testFourResourcesThreeDead: Entering");
+
+ /*
+ * Populate DB for pdp1, which will simulate it having registered but then having died.
+ */
+ new DbDAO(resourceName, persistenceUnit, properties);
+
+
+ /*
+ * Populate DB for pdp2, which will simulate it having registered but then having died.
+ */
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties2.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit2 = "testPU";
+ String resourceName2 = "pdp2";
+ new DbDAO(resourceName2, persistenceUnit2, properties2);
+
+ /*
+ * Start audit for pdp3.
+ */
+ Properties properties3 = new Properties();
+ properties3.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties3.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties3.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties3.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties3.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties3.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties3.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit3 = "testPU";
+ String resourceName3 = "pdp3";
+ IntegrityAudit integrityAudit3 = new IntegrityAudit(resourceName3, persistenceUnit3, properties3);
+ integrityAudit3.startAuditThread();
+
+ /*
+ * Populate DB for pdp4, which will simulate it having registered but then having died.
+ */
+ Properties properties4 = new Properties();
+ properties4.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties4.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties4.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties4.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties4.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties4.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties4.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit4 = "testPU";
+ String resourceName4 = "pdp4";
+ new DbDAO(resourceName4, persistenceUnit4, properties4);
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp3 to discover that all other designation candidates are stale (30 seconds)
+ *
+ * 1) pdp3 to run audit (15 seconds)
+ *
+ * 2) Logic to detect that no other nodes are available for designation (60 seconds)
+ *
+ * 3) pdp3 to run audit again (15 seconds)
+ */
+ logger.info("testFourResourcesThreeDead: Sleeping 130 seconds");
+ Thread.sleep(130000);
+
+ logger.info("testFourResourcesThreeDead: Stopping thread");
+ integrityAudit3.stopAuditThread();
+
+ FileInputStream fstream = new FileInputStream(TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ int endIndex;
+ ArrayList<String> expectedResult = new ArrayList<String>(Arrays.asList("pdp3", "pdp3"));
+ ArrayList<String> delegates = new ArrayList<String>();
+ while ((strLine = br.readLine()) != null) {
+ /* parse strLine to obtain what you want */
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+
+ String rName = strLine.substring(startIndex, endIndex);
+
+ delegates.add(rName);
+ }
+ }
+
+ for (String delegate : delegates) {
+ logger.info("testFourResourcesThreeDead: delegate: " + delegate);
+ }
+
+ fstream.close();
+
+ assertTrue("delegate count only " + delegates.size(), delegates.size() >= 2);
+ assertTrue("delegate 0 is " + expectedResult.get(0), expectedResult.get(0).equals(delegates.get(0)));
+ assertTrue("delegate 1 is " + expectedResult.get(1), expectedResult.get(1).equals(delegates.get(1)));
+
+ logger.info("testFourResourcesThreeDead: Exiting");
+
+ }
+
+
+ /*
+ * Tests designation logic when the designated node dies and is no longer
+ * current
+ *
+ * Note: console.log must be examined to ascertain whether or not this test
+ * was successful.
+ */
+ @Ignore
+ @Test
+ public void testDesignatedNodeDead() throws Exception {
+ logger.info("testDesignatedNodeDead: Entering");
+
+ /*
+ * Instantiate audit object for pdp1.
+ */
+ IntegrityAudit integrityAudit = new IntegrityAudit(resourceName, persistenceUnit, properties);
+
+ /*
+ * Start audit for pdp2.
+ */
+ Properties properties2 = new Properties();
+ properties2.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties2.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties2.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties2.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties2.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties2.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties2.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit2 = "testPU";
+ String resourceName2 = "pdp2";
+ IntegrityAudit integrityAudit2 = new IntegrityAudit(resourceName2, persistenceUnit2, properties2);
+
+ /*
+ * Instantiate audit object for pdp3.
+ */
+ Properties properties3 = new Properties();
+ properties3.put(IntegrityAuditProperties.DB_DRIVER, IntegrityAuditProperties.DEFAULT_DB_DRIVER);
+ properties3.put(IntegrityAuditProperties.DB_URL, IntegrityAuditProperties.DEFAULT_DB_URL);
+ properties3.put(IntegrityAuditProperties.DB_USER, IntegrityAuditProperties.DEFAULT_DB_USER);
+ properties3.put(IntegrityAuditProperties.DB_PWD, IntegrityAuditProperties.DEFAULT_DB_PWD);
+ properties3.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties3.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
+ properties3.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "5");
+ String persistenceUnit3 = "testPU";
+ String resourceName3 = "pdp3";
+ IntegrityAudit integrityAudit3 = new IntegrityAudit(resourceName3, persistenceUnit3, properties3);
+
+ // Start audit on pdp1
+ integrityAudit.startAuditThread();
+
+ // Sleep long enough for pdp1 figure out that it should be auditing and start the audit.
+ Thread.sleep(500);
+
+ // Start the auditing threads on other nodes.
+ integrityAudit2.startAuditThread();
+ integrityAudit3.startAuditThread();
+
+ // Sleep long enough to ensure the other two audits have registered.
+ Thread.sleep(500);
+
+ // Kill audit on pdp1
+ integrityAudit.stopAuditThread();
+
+ // Sleep long enough for pdp1 to get stale and pdp2 to take over
+ Thread.sleep(AuditThread.AUDIT_COMPLETION_INTERVAL + FUDGE_FACTOR);
+
+ // Start audit thread on pdp1 again.
+ integrityAudit.startAuditThread();
+
+ // Sleep long enough for pdp2 to complete its audit and get stale, at
+ // which point pdp3 should take over
+ Thread.sleep((AuditThread.AUDIT_SIMULATION_SLEEP_INTERVAL * AuditThread.AUDIT_SIMULATION_ITERATIONS)
+ + AuditThread.AUDIT_COMPLETION_INTERVAL + FUDGE_FACTOR);
+
+ // Kill audit on pdp3
+ logger.info("testDesignatedNodeDead: Killing audit on pdp3");
+ integrityAudit3.stopAuditThread();
+
+ // Sleep long enough for pdp3 to get stale and pdp1 to take over
+ Thread.sleep(AuditThread.AUDIT_COMPLETION_INTERVAL + FUDGE_FACTOR);
+
+ FileInputStream fstream = new FileInputStream(TEST_LOG);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
+ String strLine;
+ int startIndex;
+ int endIndex;
+ ArrayList<String> expectedResult = new ArrayList<String>(Arrays.asList("pdp1", "pdp2", "pdp3", "pdp1"));
+ ArrayList<String> delegates = new ArrayList<String>();
+ while ((strLine = br.readLine()) != null) {
+ /* parse strLine to obtain what you want */
+ if (strLine.contains("Starting audit simulation for resourceName=")) {
+ startIndex = strLine.indexOf("resourceName=") + 13;
+ endIndex = strLine.indexOf(",");
+
+ String rName = strLine.substring(startIndex, endIndex);
+
+ delegates.add(rName);
+ }
+ }
+ fstream.close();
+
+ // Stop remaining threads.
+ logger.info("testDesignatedNodeDead: Stopping remaining threads");
+ integrityAudit.stopAuditThread();
+ integrityAudit2.stopAuditThread();
+
+ for (String delegate: delegates) {
+ logger.info("testDesignatedNodeDead: delegate: " + delegate);
+ }
+
+ assertTrue("delegate count only " + delegates.size(), delegates.size() >= 4);
+ assertTrue("delegate 0 is " + expectedResult.get(0), expectedResult.get(0).equals(delegates.get(0)));
+ assertTrue("delegate 1 is " + expectedResult.get(1), expectedResult.get(1).equals(delegates.get(1)));
+ assertTrue("delegate 2 is " + expectedResult.get(2), expectedResult.get(2).equals(delegates.get(2)));
+ assertTrue("delegate 3 is " + expectedResult.get(3), expectedResult.get(3).equals(delegates.get(3)));
+
+ logger.info("testDesignatedNodeDead: Exiting");
+ }
+}
diff --git a/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/jpa/IaTestEntity.java b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/jpa/IaTestEntity.java
new file mode 100644
index 00000000..e875fa3d
--- /dev/null
+++ b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/jpa/IaTestEntity.java
@@ -0,0 +1,163 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Audit
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.common.ia.test.jpa;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Version;
+/*
+ * The Entity class to persist a policy object Action Body
+ */
+
+@Entity
+@Table(name="IaTestEntity")
+@NamedQueries({
+ @NamedQuery(name=" IaTestEntity.findAll", query="SELECT e FROM IaTestEntity e "),
+ @NamedQuery(name="IaTestEntity.deleteAll", query="DELETE FROM IaTestEntity WHERE 1=1")
+})
+//@SequenceGenerator(name="seqImTest", initialValue=1, allocationSize=1)
+
+public class IaTestEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqImTest")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name="ImTestId")
+ private long imTestId;
+
+ @Column(name="created_by", nullable=false, length=255)
+ private String createdBy = "guest";
+
+ @Column(name="person", nullable=false, length=255)
+ private PersonTest person;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="created_date", updatable=false)
+ private Date createdDate;
+
+ @Column(name="modified_by", nullable=false, length=255)
+ private String modifiedBy = "guest";
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="modified_date", nullable=false)
+ private Date modifiedDate;
+
+ public IaTestEntity() {
+ }
+
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.modifiedDate = date;
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.modifiedDate = new Date();
+ }
+
+ /**
+ * @return the Id
+ */
+ public long getImTestId() {
+ return imTestId;
+ }
+
+ /**
+ * @return the createdBy
+ */
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ /**
+ * @param createdBy the createdBy to set
+ */
+ public void setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ /**
+ * @return the modifiedBy
+ */
+ public String getModifiedBy() {
+ return modifiedBy;
+ }
+
+ /**
+ * @param modifiedBy the modifiedBy to set
+ */
+ public void setModifiedBy(String modifiedBy) {
+ this.modifiedBy = modifiedBy;
+ }
+
+ /**
+ * @return the modifiedDate
+ */
+ public Date getModifiedDate() {
+ return modifiedDate;
+ }
+
+ /**
+ * @param modifiedDate the modifiedDate to set
+ */
+ public void setModifiedDate(Date modifiedDate) {
+ this.modifiedDate = modifiedDate;
+ }
+
+ /**
+ * @return the createdDate
+ */
+ public Date getCreatedDate() {
+ return createdDate;
+ }
+
+ /**
+ * @param the person to set
+ */
+ public void setPersonTest(PersonTest p) {
+ this.person = p;
+ }
+
+ /**
+ * @return the person
+ */
+ public PersonTest getPersonTest() {
+ return person;
+ }
+}
diff --git a/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/jpa/PersonTest.java b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/jpa/PersonTest.java
new file mode 100644
index 00000000..7ec5e294
--- /dev/null
+++ b/integrity-audit/src/test/java/org/openecomp/policy/common/ia/test/jpa/PersonTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Audit
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.common.ia.test.jpa;
+
+import java.io.Serializable;
+
+public class PersonTest implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String firstName;
+ private String lastName;
+ private int age;
+
+ public PersonTest(String first, String last, int age) {
+ this.firstName = first;
+ this.lastName = last;
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return this.firstName;
+ }
+
+ public void setFirstName(String name) {
+ this.firstName = name;
+ }
+
+ public String getLasttName() {
+ return this.lastName;
+ }
+
+ public void setLastName(String name) {
+ this.lastName = name;
+ }
+
+ public int getAge() {
+ return this.age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+}
diff --git a/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/IntegrityMonitorTest.java b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/IntegrityMonitorTest.java
new file mode 100644
index 00000000..68a6cf2f
--- /dev/null
+++ b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/IntegrityMonitorTest.java
@@ -0,0 +1,734 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Monitor
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.common.im.test;
+
+import static org.junit.Assert.*;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+//import org.apache.commons.logging.Log;
+//import org.apache.commons.logging.LogFactory;
+
+
+
+import org.openecomp.policy.common.im.IntegrityMonitor;
+import org.openecomp.policy.common.im.IntegrityMonitorProperties;
+import org.openecomp.policy.common.im.StateManagement;
+import org.openecomp.policy.common.im.jpa.ForwardProgressEntity;
+import org.openecomp.policy.common.im.jpa.ImTestEntity;
+import org.openecomp.policy.common.im.jpa.ResourceRegistrationEntity;
+import org.openecomp.policy.common.im.jpa.StateManagementEntity;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+
+public class IntegrityMonitorTest {
+ private static Logger logger = FlexLogger.getLogger(IntegrityMonitorTest.class);
+ private static Properties myProp;
+ private static EntityManagerFactory emf;
+ private static EntityManager em;
+ private static EntityTransaction et;
+ private static String resourceName;
+ private static Properties systemProps;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ IntegrityMonitor.isUnitTesting = true;
+
+ myProp = new Properties();
+ myProp.put(IntegrityMonitorProperties.DB_DRIVER, IntegrityMonitorProperties.DEFAULT_DB_DRIVER);
+ myProp.put(IntegrityMonitorProperties.DB_URL, IntegrityMonitorProperties.DEFAULT_DB_URL);
+ myProp.put(IntegrityMonitorProperties.DB_USER, IntegrityMonitorProperties.DEFAULT_DB_USER);
+ myProp.put(IntegrityMonitorProperties.DB_PWD, IntegrityMonitorProperties.DEFAULT_DB_PWD);
+ myProp.put(IntegrityMonitorProperties.SITE_NAME, "SiteA");
+ myProp.put(IntegrityMonitorProperties.NODE_TYPE, "pap");
+
+ // set JMX remote port in system properties
+ systemProps = System.getProperties();
+ systemProps.put("com.sun.management.jmxremote.port", "9797");
+
+ resourceName = "siteA.pap1";
+
+ //Create the data schema and entity manager factory
+ emf = Persistence.createEntityManagerFactory("schemaPU", myProp);
+
+ // Create an entity manager to use the DB
+ em = emf.createEntityManager();
+
+ }
+
+
+ @After
+ public void tearDown() throws Exception {
+ // clear jmx remote port setting
+ systemProps.remove("com.sun.management.jmxremote.port");
+ }
+
+ /*
+ * The following test verifies the following test cases:
+ * New Install
+ * New Install - Bad Dependency data
+ * Recovery from bad dependency data
+ * Lock
+ * Lock restart
+ * Unlock
+ * Unlock restart
+ */
+ @Ignore // Test passed 10/18/16
+ @Test
+ public void testSanityJmx() throws Exception {
+ System.out.println("\nIntegrityMonitorTest: Entering testSanityJmx\n\n");
+
+ String dependent = "group1_logparser";
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, dependent);
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "true");
+ IntegrityMonitor.updateProperties(myProp);
+
+ IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
+ System.out.println("\n\ntestSanityJmx starting im state"
+ + "\nAdminState = " + im.getStateManager().getAdminState()
+ + "\nOpState() = " + im.getStateManager().getOpState()
+ + "\nAvailStatus = " + im.getStateManager().getAvailStatus()
+ + "\nStandbyStatus = " + im.getStateManager().getStandbyStatus()
+ + "\n");
+ // add an entry to Resource registration table in the DB for the dependent resource
+
+
+ et = em.getTransaction();
+ et.begin();
+ Query rquery = em.createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
+ rquery.setParameter("rn", dependent);
+
+ @SuppressWarnings("rawtypes")
+ List rrList = rquery.getResultList();
+ ResourceRegistrationEntity rrx = null;
+ if(rrList.isEmpty()){
+ // register resource by adding entry to table in DB
+ System.out.println("Adding resource " + dependent + " to ResourceRegistration table");
+ rrx = new ResourceRegistrationEntity();
+ // set columns in entry
+ rrx.setResourceName(dependent);
+ rrx.setResourceUrl("service:jmx:somewhere:9999");
+ rrx.setNodeType("logparser");
+ rrx.setSite("siteA");
+ }
+ em.persist(rrx);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ Thread.sleep(15000); //sleep 15 sec so the FPManager has time to call evaluateSanty()
+
+ boolean sanityPass = true;
+ try {
+ im.evaluateSanity();
+ } catch (Exception e) {
+ System.out.println("evaluateSanity exception: " + e);
+ sanityPass = false;
+ }
+ assertFalse(sanityPass); // expect sanity test to fail
+
+ // undo dependency groups and jmx test properties settings
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ IntegrityMonitor.updateProperties(myProp);
+
+ System.out.println("\ntestSantityJmx ending properties: " + myProp);
+
+ //We know at this point that the IM is disable-dependency. We want to be
+ //sure it will recover from this condition since the properties were
+ //updated.
+
+
+ System.out.println("\n\ntestSanityJmx ending im state"
+ + "\nAdminState = " + im.getStateManager().getAdminState()
+ + "\nOpState() = " + im.getStateManager().getOpState()
+ + "\nAvailStatus = " + im.getStateManager().getAvailStatus()
+ + "\nStandbyStatus = " + im.getStateManager().getStandbyStatus()
+ + "\n");
+
+ //Destroy the instance
+ System.out.println("\ntestSanityJmx restarting the IntegrityMonitor");
+ IntegrityMonitor.deleteInstance();
+ //Create a new instance. It should recover from the disabled-dependency condition
+ im = IntegrityMonitor.getInstance(resourceName, myProp);
+
+ System.out.println("\n\ntestSanityJmx state after creating new im"
+ + "\nAdminState = " + im.getStateManager().getAdminState()
+ + "\nOpState() = " + im.getStateManager().getOpState()
+ + "\nAvailStatus = " + im.getStateManager().getAvailStatus()
+ + "\nStandbyStatus = " + im.getStateManager().getStandbyStatus()
+ + "\n");
+
+ //Verify the state
+ assertEquals(im.getStateManager().getAdminState(), StateManagement.UNLOCKED);
+ assertEquals(im.getStateManager().getOpState(), StateManagement.ENABLED);
+ assertEquals(im.getStateManager().getAvailStatus(), StateManagement.NULL_VALUE);
+ assertEquals(im.getStateManager().getStandbyStatus(), StateManagement.NULL_VALUE);
+
+ //Test state manager via the IntegrityMonitor
+ StateManagement sm = im.getStateManager();
+
+ // Verify lock state
+ sm.lock();
+ System.out.println("\n\nsm.lock()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getAdminState().equals(StateManagement.LOCKED));
+
+ //Verify lock persists across a restart
+ //Destroy the instance
+ System.out.println("\ntestSanityJmx restarting the IntegrityMonitor");
+ IntegrityMonitor.deleteInstance();
+ //Create a new instance. It should come up with the admin state locked
+ im = IntegrityMonitor.getInstance(resourceName, myProp);
+ sm = im.getStateManager();
+ System.out.println("\n\ntestSanityJmx restart with AdminState=locked"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getAdminState().equals(StateManagement.LOCKED));
+
+ // Verify unlock
+ sm.unlock();
+ System.out.println("\n\ntestSanityJmx sm.unlock"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getAdminState().equals(StateManagement.UNLOCKED));
+
+ // Verify unlock restart
+ //Destroy the instance
+ System.out.println("\ntestSanityJmx restarting the IntegrityMonitor");
+ IntegrityMonitor.deleteInstance();
+ //Create a new instance. It should come up with the admin state locked
+ im = IntegrityMonitor.getInstance(resourceName, myProp);
+ sm = im.getStateManager();
+ System.out.println("\n\ntestSanityJmx restart with AdminState=unlocked"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getAdminState().equals(StateManagement.UNLOCKED));
+
+ System.out.println("\n\ntestSanityJmx: Exit\n\n");
+ }
+
+
+ @Ignore // Test passed 10/18/16
+ @Test
+ public void testIM() throws Exception {
+ System.out.println("\nIntegrityMonitorTest: Entering testIM\n\n");
+
+ // parameters are passed via a properties file
+
+ /*
+ * Create an IntegrityMonitor
+ * NOTE: This uses the database that was created above. So, this MUST follow the creation
+ * of the DB
+ */
+ IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
+
+ System.out.println("\n\nim before sleep"
+ + "\nAdminState = " + im.getStateManager().getAdminState()
+ + "\nOpState() = " + im.getStateManager().getOpState()
+ + "\nAvailStatus = " + im.getStateManager().getAvailStatus()
+ + "\nStandbyStatus = " + im.getStateManager().getStandbyStatus()
+ + "\n");
+
+ // wait for test transactions to fire and increment fpc
+ Thread.sleep(20000);
+
+ System.out.println("\n\nim after sleep"
+ + "\nAdminState = " + im.getStateManager().getAdminState()
+ + "\nOpState() = " + im.getStateManager().getOpState()
+ + "\nAvailStatus = " + im.getStateManager().getAvailStatus()
+ + "\nStandbyStatus = " + im.getStateManager().getStandbyStatus()
+ + "\n");
+
+ // test evaluate sanity
+ boolean sanityPass = true;
+ try {
+ im.evaluateSanity();
+ } catch (Exception e) {
+ System.out.println("evaluateSanity exception: " + e);
+ sanityPass = false;
+ }
+ assertTrue(sanityPass); // expect sanity test to pass
+
+ //Test startTransaction - should works since it is unlocked
+ boolean transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(transPass);
+
+ //Test state manager via the IntegrityMonitor
+ StateManagement sm = im.getStateManager();
+
+ sm.lock();
+ System.out.println("\n\nsm.lock()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getAdminState().equals(StateManagement.LOCKED));
+
+ //test startTransaction. It should fail since it is locked
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(!transPass); //expect it to fail
+
+ sm.unlock();
+ System.out.println("\n\nsm.unlock()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getAdminState().equals(StateManagement.UNLOCKED));
+
+ //test startTransaction. It should succeed
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(transPass); //expect it to succeed
+
+ sm.disableDependency();
+ System.out.println("\n\nsm.disableDependency()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getOpState().equals(StateManagement.DISABLED));
+ assert(sm.getAvailStatus().equals(StateManagement.DEPENDENCY));
+
+ //test startTransaction. It should succeed since standby status is null and unlocked
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(transPass); //expect it to succeed
+
+ sm.enableNoDependency();
+ System.out.println("\n\nsm.enableNoDependency()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getOpState().equals(StateManagement.ENABLED));
+ //test startTransaction. It should succeed since standby status is null and unlocked
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(transPass); //expect it to succeed
+
+
+ sm.disableFailed();
+ System.out.println("\n\nsm.disableFailed()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getOpState().equals(StateManagement.DISABLED));
+ assert(sm.getAvailStatus().equals(StateManagement.FAILED));
+ //test startTransaction. It should succeed since standby status is null and unlocked
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(transPass); //expect it to succeed
+
+ sm.enableNotFailed();
+ System.out.println("\n\nsm.enabledNotFailed()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getOpState().equals(StateManagement.ENABLED));
+ //test startTransaction. It should succeed since standby status is null and unlocked
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(transPass); //expect it to succeed
+
+ sm.demote();
+ System.out.println("\n\nsm.demote()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
+
+ //test startTransaction. It should fail since it is standby
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(!transPass); //expect it to fail
+
+ sm.promote();
+ System.out.println("\n\nsm.promote()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+
+ //test startTransaction. It should succeed since it is providing service
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(transPass); //expect it to succeed
+
+
+ //Test the multi-valued availability status
+ sm.disableDependency();
+ sm.disableFailed();
+ System.out.println("\n\nsm.disableDependency(), sm.disableFailed"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getAvailStatus().equals(StateManagement.DEPENDENCY_FAILED));
+
+ //Test startTransaction. Should fail since standby status is cold standby
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(!transPass); //expect it to fail
+
+ sm.enableNoDependency();
+ System.out.println("\n\nsm.enableNoDependency()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getAvailStatus().equals(StateManagement.FAILED));
+ //Test startTransaction. Should fail since standby status is cold standby
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(!transPass); //expect it to fail
+
+ sm.disableDependency();
+ sm.enableNotFailed();
+ System.out.println("\n\nsm.disableDependency(),sm.enableNotFailed()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getAvailStatus().equals(StateManagement.DEPENDENCY));
+ //Test startTransaction. Should fail since standby status is cold standby
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(!transPass); //expect it to fail
+
+ sm.enableNoDependency();
+ System.out.println("\n\nsm.enableNoDependency()"
+ + "\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ assert(sm.getOpState().equals(StateManagement.ENABLED));
+ //test startTransaction. It should fail since standby status is hot standby
+ transPass = true;
+ try{
+ im.startTransaction();
+ } catch (Exception e){
+ System.out.println("startTransaction exception: " + e);
+ transPass = false;
+ }
+ assertTrue(!transPass); //expect it to fail
+
+ System.out.println("\n\ntestIM: Exit\n\n");
+ }
+
+
+ @Ignore // Test passed 10/18/16
+ @Test
+ public void testSanityState() throws Exception {
+ System.out.println("\nIntegrityMonitorTest: Entering testSanityState\n\n");
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "group1_dep1,group1_dep2; group2_dep1");
+ IntegrityMonitor.updateProperties(myProp);
+
+ IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
+
+ // Add a group1 dependent resources to put an entry in the forward progress table
+ ForwardProgressEntity fpe = new ForwardProgressEntity();
+ ForwardProgressEntity fpe2 = new ForwardProgressEntity();
+ fpe.setFpcCount(0);
+ fpe.setResourceName("group1_dep1");
+ fpe2.setFpcCount(0);
+ fpe2.setResourceName("group1_dep2");
+ et = em.getTransaction();
+ et.begin();
+ em.persist(fpe);
+ em.persist(fpe2);
+ em.flush();
+ et.commit();
+
+
+ // Add a group2 dependent resource to the StateManagementEntity DB table and set its admin state to locked
+ // Expect sanity test to fail.
+ StateManagement stateManager = new StateManagement(emf, "group2_dep1");
+ stateManager.lock();
+
+ //Now add new group1 stateManager instances
+ StateManagement sm2 = new StateManagement(emf, "group1_dep1");
+ StateManagement sm3 = new StateManagement(emf, "group1_dep2");
+
+ boolean sanityPass = true;
+ Thread.sleep(15000);
+ try {
+ im.evaluateSanity();
+ } catch (Exception e) {
+ System.out.println("evaluateSanity exception: " + e);
+ sanityPass = false;
+ }
+ assertFalse(sanityPass); // expect sanity test to fail
+
+ // undo dependency groups and jmx test properties settings
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ IntegrityMonitor.updateProperties(myProp);
+
+ et = em.getTransaction();
+
+ et.begin();
+ // Make sure we leave the DB clean
+ em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
+ em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
+ em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
+
+ em.flush();
+ et.commit();
+
+ System.out.println("\n\ntestSanityState: Exit\n\n");
+ }
+
+ @Ignore // Test passed 10/18/16
+ @Test
+ public void testRefreshStateAudit() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Enter\n\n");
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ IntegrityMonitor.updateProperties(myProp);
+
+ et = em.getTransaction();
+ et.begin();
+
+ // Make sure we leave the DB clean
+ em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
+ em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
+ em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
+
+ em.flush();
+ et.commit();
+
+ IntegrityMonitor.deleteInstance();
+
+ IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
+
+ //the state here is unlocked, enabled, null, null
+ StateManagementEntity sme = null;
+
+ Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+
+ query.setParameter("resource", resourceName);
+
+ //Just test that we are retrieving the right object
+ @SuppressWarnings("rawtypes")
+ List resourceList = query.getResultList();
+ if (!resourceList.isEmpty()) {
+ // exist
+ sme = (StateManagementEntity) resourceList.get(0);
+ em.refresh(sme);
+
+ logger.debug("??? -- Retrieve StateManagementEntity from database --"
+ + "\nsme.getResourceName() = " + sme.getResourceName()
+ + "\nsme.getAdminState() = " + sme.getAdminState()
+ + "\nsme.getOpState() = " + sme.getOpState()
+ + "\nsme.getAvailStatus() = " + sme.getAvailStatus()
+ + "\nsme.getStandbyStatus() = " + sme.getStandbyStatus());
+
+ assertTrue(sme.getAdminState().equals(StateManagement.UNLOCKED));
+ assertTrue(sme.getOpState().equals(StateManagement.ENABLED));
+ assertTrue(sme.getAvailStatus().equals(StateManagement.NULL_VALUE));
+ assertTrue(sme.getStandbyStatus().equals(StateManagement.NULL_VALUE));
+ logger.debug("--");
+ } else {
+ logger.debug("Record not found, resourceName: " + resourceName);
+ assertTrue(false);
+ }
+
+ et = em.getTransaction();
+ et.begin();
+
+ sme.setStandbyStatus(StateManagement.COLD_STANDBY);
+ em.persist(sme);
+ em.flush();
+ et.commit();
+
+ Thread.sleep(65000);
+
+ //The refreshStateAudit should run and change the state to unlocked,enabled,null,hotstandby
+ StateManagementEntity sme1 = null;
+
+ Query query1 = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+
+ query1.setParameter("resource", resourceName);
+
+ //Just test that we are retrieving the right object
+ @SuppressWarnings("rawtypes")
+ List resourceList1 = query1.getResultList();
+ if (!resourceList1.isEmpty()) {
+ // exist
+ sme1 = (StateManagementEntity) resourceList1.get(0);
+ em.refresh(sme1);
+ logger.debug("??? -- Retrieve StateManagementEntity from database --"
+ + "\nsme1.getResourceName() = " + sme1.getResourceName()
+ + "\nsme1.getAdminState() = " + sme1.getAdminState()
+ + "\nsme1.getOpState() = " + sme1.getOpState()
+ + "\nsme1.getAvailStatus() = " + sme1.getAvailStatus()
+ + "\nsme1.getStandbyStatus() = " + sme1.getStandbyStatus());
+
+ assertTrue(sme1.getAdminState().equals(StateManagement.UNLOCKED));
+ assertTrue(sme1.getOpState().equals(StateManagement.ENABLED));
+ assertTrue(sme1.getAvailStatus().equals(StateManagement.NULL_VALUE));
+ assertTrue(sme1.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
+ logger.debug("--");
+ } else {
+ logger.debug("Record not found, resourceName: " + resourceName);
+ assertTrue(false);
+ }
+
+ et = em.getTransaction();
+ et.begin();
+
+ // Make sure we leave the DB clean
+ em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
+ em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
+ em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
+
+ em.flush();
+ et.commit();
+
+ IntegrityMonitor.deleteInstance();
+
+ logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Exit\n\n");
+ }
+}
diff --git a/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementEntityTest.java b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementEntityTest.java
new file mode 100644
index 00000000..b4222568
--- /dev/null
+++ b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementEntityTest.java
@@ -0,0 +1,197 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Monitor
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.common.im.test;
+
+import static org.junit.Assert.*;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+//import org.apache.commons.logging.Log;
+//import org.apache.commons.logging.LogFactory;
+
+import org.openecomp.policy.common.im.StateManagement;
+import org.openecomp.policy.common.im.jpa.StateManagementEntity;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+
+public class StateManagementEntityTest {
+ private static Logger logger = FlexLogger.getLogger(StateManagementEntityTest.class);
+
+ private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
+ private static final String DEFAULT_DB_URL = "jdbc:h2:file:./sql/smTest";
+ //private static final String DEFAULT_DB_URL = "jdbc:h2:file:./sql/xacml";
+ private static final String DEFAULT_DB_USER = "sa";
+ private static final String DEFAULT_DB_PWD = "";
+
+ /*
+ private static final String DEFAULT_DB_DRIVER = "org.mariadb.jdbc.Driver";
+ private static final String DEFAULT_DB_URL = "jdbc:mariadb://localhost:3306/xacml";
+ private static final String DEFAULT_DB_USER = "policy_user";
+ private static final String DEFAULT_DB_PWD = "policy_user";
+ */
+
+ private static final String DB_DRIVER = "javax.persistence.jdbc.driver";
+ private static final String DB_URL = "javax.persistence.jdbc.url";
+ private static final String DB_USER = "javax.persistence.jdbc.user";
+ private static final String DB_PWD = "javax.persistence.jdbc.password";
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Ignore
+ @Test
+ public void testJPA() throws Exception {
+ System.out.println("\n??? logger.infor StateManagementEntityTest: Entering\n\n");
+
+ Properties myProp = new Properties();
+ myProp.put(DB_DRIVER, DEFAULT_DB_DRIVER);
+ myProp.put(DB_URL, DEFAULT_DB_URL);
+ myProp.put(DB_USER, DEFAULT_DB_USER);
+ myProp.put(DB_PWD, DEFAULT_DB_PWD);
+
+ System.out.println("??? " + DB_DRIVER + "=" + DEFAULT_DB_DRIVER);
+ System.out.println("??? " + DB_URL + "=" + DEFAULT_DB_URL);
+ System.out.println("??? " + DB_USER + "=" + DEFAULT_DB_USER);
+ System.out.println("??? " + DB_PWD + "=" + DEFAULT_DB_PWD);
+
+ //Create the data schema and entity manager factory
+ System.out.println("??? createEntityManagerFactory for schemaPU");
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory("schemaPU", myProp);
+
+ // Create an entity manager to use the DB
+ System.out.println("??? createEntityManager");
+ EntityManager em = emf.createEntityManager();
+ System.out.println("??? getTransaction");
+ EntityTransaction et = em.getTransaction();
+ et.begin();
+ // Make sure the DB is clean
+ System.out.println("??? clean StateManagementEntity");
+ em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
+
+ //Define the resourceName for the StateManagement constructor
+ String resourceName = "test_resource1";
+
+ //
+ System.out.println("Create StateManagementEntity, resourceName: " + resourceName);
+ System.out.println("??? instantiate StateManagementEntity object");
+ StateManagementEntity sme = new StateManagementEntity();
+
+ System.out.println("??? setResourceName : " + resourceName);
+ sme.setResourceName(resourceName);
+ System.out.println("??? getResourceName : " + sme.getResourceName());
+
+ System.out.println("??? setAdminState : " + StateManagement.UNLOCKED);
+ sme.setAdminState(StateManagement.UNLOCKED);
+ System.out.println("??? getAdminState : " + sme.getAdminState());
+
+ System.out.println("??? setOpState : " + StateManagement.ENABLED);
+ sme.setOpState(StateManagement.ENABLED);
+ System.out.println("??? getOpState : " + sme.getOpState());
+
+ System.out.println("??? setAvailStatus : " + StateManagement.NULL_VALUE);
+ sme.setAvailStatus(StateManagement.NULL_VALUE);
+ System.out.println("??? getAvailStatus : " + sme.getAvailStatus());
+
+ System.out.println("??? setStandbyStatus: " + StateManagement.COLD_STANDBY);
+ sme.setStandbyStatus(StateManagement.COLD_STANDBY);
+ System.out.println("??? getStandbyStatus: " + sme.getStandbyStatus());
+
+ System.out.println("??? before persist");
+ em.persist(sme);
+ System.out.println("??? after persist");
+
+ em.flush();
+ System.out.println("??? after flush");
+
+ et.commit();
+ System.out.println("??? after commit");
+
+ try {
+ Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+
+ query.setParameter("resource", resourceName);
+
+ //Just test that we are retrieving the right object
+ @SuppressWarnings("rawtypes")
+ List resourceList = query.getResultList();
+ String resource = null;
+ if (!resourceList.isEmpty()) {
+ // exist
+ StateManagementEntity sme2 = (StateManagementEntity) resourceList.get(0);
+ System.out.println("??? -- Retrieve StateManagementEntity from database --"
+ + "\n\nsme.getResourceName() = " + sme.getResourceName()
+ + "\nsme2getResourceName() = " + sme2.getResourceName()
+ + "\n\nsme.getAdminState() = " + sme.getAdminState()
+ + "\nsme2.getAdminState() = " + sme2.getAdminState()
+ + "\n\nsme.getOpState() = " + sme.getOpState()
+ + "\nsme2.getOpState() = " + sme2.getOpState()
+ + "\n\nsme.getAvailStatus() = " + sme.getAvailStatus()
+ + "\nsme2.getAvailStatus() = " + sme.getAvailStatus()
+ + "\n\nsme.getStandbyStatus() = " + sme.getStandbyStatus()
+ + "\nsme2.getStandbyStatus() = " + sme2.getStandbyStatus());
+
+
+ assert(sme2.getResourceName().equals(sme.getResourceName()));
+ assert(sme2.getAdminState().equals(sme.getAdminState()));
+ assert(sme2.getOpState().equals(sme.getOpState()));
+ assert(sme2.getAvailStatus().equals(sme.getAvailStatus()));
+ assert(sme2.getStandbyStatus().equals(sme.getStandbyStatus()));
+ System.out.println("--");
+ } else {
+ System.out.println("Record not found, resourceName: " + resourceName);
+ }
+ } catch(Exception ex) {
+ logger.error("Exception on select query: " + ex.toString());
+ }
+
+ em.close();
+ System.out.println("\n??? after close");
+ System.out.println("\n\nJpaTest: Exit\n\n");
+ }
+}
diff --git a/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementTest.java b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementTest.java
new file mode 100644
index 00000000..3247d781
--- /dev/null
+++ b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementTest.java
@@ -0,0 +1,338 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Monitor
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.common.im.test;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.LockModeType;
+import javax.persistence.PersistenceException;
+import javax.persistence.Query;
+
+
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.openecomp.policy.common.im.StateManagement;
+import org.openecomp.policy.common.im.StateTransition;
+import org.openecomp.policy.common.im.StandbyStatusException;
+import org.openecomp.policy.common.im.StateChangeNotifier;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+
+public class StateManagementTest {
+ private static Logger logger = FlexLogger.getLogger(StateManagementTest.class);
+
+ private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
+ private static final String DEFAULT_DB_URL = "jdbc:h2:file:./sql/smTest";
+ private static final String DEFAULT_DB_USER = "sa";
+ private static final String DEFAULT_DB_PWD = "";
+
+ private static final String DB_DRIVER = "javax.persistence.jdbc.driver";
+ private static final String DB_URL = "javax.persistence.jdbc.url";
+ private static final String DB_USER = "javax.persistence.jdbc.user";
+ private static final String DB_PWD = "javax.persistence.jdbc.password";
+ //
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Ignore
+ @Test
+ public void testJPA() throws Exception {
+ logger.info("\n\nlogger.infor StateManagementTest: Entering\n\n");
+ String resourceName = "test_resource1";
+ boolean standbyExceptionThrown = false;
+
+ //These parameters are in a properties file
+ EntityManagerFactory emf = null;
+ try {
+ Properties myProp = new Properties();
+ myProp.put(DB_DRIVER, DEFAULT_DB_DRIVER);
+ myProp.put(DB_URL, DEFAULT_DB_URL);
+ myProp.put(DB_USER, DEFAULT_DB_USER);
+ myProp.put(DB_PWD, DEFAULT_DB_PWD);
+
+ //Create the data schema and entity manager factory
+ emf = Persistence.createEntityManagerFactory("schemaPU", myProp);
+
+ StateManagement sm = new StateManagement(emf, resourceName);
+ System.out.println("\n\ntest lock()");
+ displayState(resourceName, sm);
+ logger.info("\n??? test lock()");
+ logger.info(resourceName + " before adminState = " + sm.getAdminState());
+ logger.info(resourceName + " before opState = " + sm.getOpState());
+ logger.info(resourceName + " before availStatus = " + sm.getAvailStatus());
+ logger.info(resourceName + " before standbyStatus= " + sm.getStandbyStatus());
+ sm.lock();
+ System.out.println("\n\nafter lock()");
+ displayState(resourceName, sm);
+ logger.info(resourceName + " after adminState = " + sm.getAdminState());
+ logger.info(resourceName + " after opState = " + sm.getOpState());
+ logger.info(resourceName + " after availStatus = " + sm.getAvailStatus());
+ logger.info(resourceName + " after standbyStatus= " + sm.getStandbyStatus());
+
+ logger.info("\n??? test unlock()");
+ sm.unlock();
+ System.out.println("\n\nafter unlock()");
+ displayState(resourceName, sm);
+ logger.info(resourceName + " adminState = " + sm.getAdminState());
+ logger.info(resourceName + " opState = " + sm.getOpState());
+ logger.info(resourceName + " availStatus = " + sm.getAvailStatus());
+ logger.info(resourceName + " standbyStatus= " + sm.getStandbyStatus());
+
+ logger.info("\n??? test enableNotFailed()");
+ sm.enableNotFailed();
+ System.out.println("\n\nafter enableNotFailed()");
+ displayState(resourceName, sm);
+ logger.info(resourceName + " adminState = " + sm.getAdminState());
+ logger.info(resourceName + " opState = " + sm.getOpState());
+ logger.info(resourceName + " availStatus = " + sm.getAvailStatus());
+ logger.info(resourceName + " standbyStatus= " + sm.getStandbyStatus());
+
+ logger.info("\n??? test disableFailed()");
+ sm.disableFailed();
+ System.out.println("\n\nafter disableFailed()");
+ displayState(resourceName, sm);
+ logger.info(resourceName + " adminState = " + sm.getAdminState());
+ logger.info(resourceName + " opState = " + sm.getOpState());
+ logger.info(resourceName + " availStatus = " + sm.getAvailStatus());
+ logger.info(resourceName + " standbyStatus= " + sm.getStandbyStatus());
+
+ // P4 If promote() is called while either the opState is disabled or the adminState is locked,
+ // the standbystatus shall transition to coldstandby and a StandbyStatusException shall be thrown
+ logger.info("\n??? promote() test case P4");
+ try {
+ sm.disableFailed();
+ sm.lock();
+ System.out.println("\n\nafter lock() and disableFailed");
+ displayState(resourceName, sm);
+ logger.info(resourceName + " adminState = " + sm.getAdminState());
+ logger.info(resourceName + " opState = " + sm.getOpState());
+ logger.info(resourceName + " standbyStatus= " + sm.getStandbyStatus());
+ sm.promote();
+ System.out.println("\n\nafter promote");
+ displayState(resourceName, sm);
+ } catch(StandbyStatusException ex) {
+ standbyExceptionThrown = true;
+ logger.info("StandbyStatusException thrown and catched");
+ } catch(Exception ex) {
+ logger.info("??? Exception: " + ex.toString());
+ }
+ assert(standbyExceptionThrown);
+ assert(sm.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
+ standbyExceptionThrown = false;
+
+ // P3 If promote() is called while standbyStatus is coldstandby, the state shall not transition
+ // and a StandbyStatusException shall be thrown
+ logger.info("\n??? promote() test case P3");
+ try {
+ logger.info(resourceName + " standbyStatus= " + sm.getStandbyStatus());
+ sm.promote();
+ } catch(StandbyStatusException ex) {
+ standbyExceptionThrown = true;
+ logger.info("StandbyStatusException thrown and catched");
+ } catch(Exception ex) {
+ logger.info("??? Exception: " + ex.toString());
+ }
+ assert(standbyExceptionThrown);
+ assert(sm.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
+ System.out.println("\n\nP3 after promote()");
+ displayState(resourceName, sm);
+ standbyExceptionThrown = false;
+
+ // P2 If promote() is called while the standbyStatus is null and the opState is enabled and adminState is unlocked,
+ // the state shall transition to providingservice
+ logger.info("\n??? promote() test case P2");
+ resourceName = "test_resource2";
+ StateManagement sm2 = new StateManagement(emf, resourceName);
+ sm2.enableNotFailed();
+ sm2.unlock();
+ System.out.println("\n\nafter sm2.enableNotFailed() and sm2.unlock()");
+ displayState(resourceName, sm2);
+ logger.info(resourceName + " adminState = " + sm2.getAdminState());
+ logger.info(resourceName + " opState = " + sm2.getOpState());
+ logger.info(resourceName + " standbyStatus= " + sm2.getStandbyStatus());
+ sm2.promote();
+ System.out.println("\n\nP2 after sm2.promote");
+ displayState(resourceName, sm2);
+ assert(sm2.getAdminState().equals(StateManagement.UNLOCKED));
+ assert(sm2.getOpState().equals(StateManagement.ENABLED));
+ assert(sm2.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+
+ // P5 If promote() is called while standbyStatus is providingservice, no action is taken
+ logger.info("\n??? promote() test case P5");
+ logger.info(resourceName + " standbyStatus= " + sm2.getStandbyStatus());
+ sm2.promote();
+ System.out.println("\n\nP5 after sm2.promote()");
+ displayState(resourceName, sm2);
+ assert(sm2.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+
+ // D1 If demote() is called while standbyStatus is providingservice, the state shall transition to hotstandby
+ logger.info("\n??? demote() test case D1");
+ logger.info(resourceName + " standbyStatus= " + sm2.getStandbyStatus());
+ sm2.demote();
+ System.out.println("\n\nD1 after sm2.demote()");
+ displayState(resourceName, sm2);
+ assert(sm2.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
+
+ // D4 If demote() is called while standbyStatus is hotstandby, no action is taken
+ logger.info("\n??? demote() test case D4");
+ logger.info(resourceName + " standbyStatus= " + sm2.getStandbyStatus());
+ sm2.demote();
+ System.out.println("\n\nD4 after sm2.demote()");
+ displayState(resourceName, sm2);
+ assert(sm2.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
+
+ // D3 If demote() is called while standbyStatus is null and adminState is locked or opState is disabled,
+ // the state shall transition to coldstandby
+ logger.info("\n??? demote() test case D3");
+ resourceName = "test_resource3";
+ StateManagement sm3 = new StateManagement(emf, resourceName);
+ sm3.lock();
+ sm3.disableFailed();
+ System.out.println("\n\nD3 after sm3.lock() and sm3.disableFailed()");
+ displayState(resourceName, sm3);
+ logger.info(resourceName + " adminState = " + sm3.getAdminState());
+ logger.info(resourceName + " opState = " + sm3.getOpState());
+ logger.info(resourceName + " standbyStatus= " + sm3.getStandbyStatus());
+ sm3.demote();
+ System.out.println("\n\nD3 after sm3.demote()");
+ displayState(resourceName, sm3);
+ assert(sm3.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
+
+ // D5 If demote() is called while standbyStatus is coldstandby, no action is taken
+ logger.info("\n??? demote() test case D5");
+ logger.info(resourceName + " standbyStatus= " + sm3.getStandbyStatus());
+ sm3.demote();
+ System.out.println("\n\nD5 after sm3.demote()");
+ displayState(resourceName, sm3);
+ assert(sm3.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
+
+ // D2 If demote() is called while standbyStatus is null and adminState is unlocked and opState is enabled,
+ // the state shall transition to hotstandby
+ logger.info("\n??? demote() test case D2");
+ resourceName = "test_resource4";
+ StateManagement sm4 = new StateManagement(emf, resourceName);
+ sm4.unlock();
+ sm4.enableNotFailed();
+ System.out.println("\n\nD2 after sm4.unlock() and sm4.enableNotFailed()");
+ displayState(resourceName, sm4);
+ logger.info(resourceName + " adminState = " + sm4.getAdminState());
+ logger.info(resourceName + " opState = " + sm4.getOpState());
+ logger.info(resourceName + " standbyStatus= " + sm4.getStandbyStatus());
+ sm4.demote();
+ assert(sm4.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
+
+ // P1 If promote() is called while standbyStatus is hotstandby, the state shall transition to providingservice.
+ logger.info("\n??? promote() test case P1");
+ logger.info(resourceName + " standbyStatus= " + sm4.getStandbyStatus());
+ sm4.promote();
+ System.out.println("\n\nP1 after sm4.promote()");
+ displayState(resourceName, sm4);
+ assert(sm4.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+
+ // State change notification
+ logger.info("\n??? State change notification test case 1 - lock()");
+ StateChangeNotifier stateChangeNotifier = new StateChangeNotifier();
+ sm.addObserver(stateChangeNotifier);
+ sm.lock();
+
+ logger.info("\n??? State change notification test case 2 - unlock()");
+ sm.unlock();
+
+ logger.info("\n??? State change notification test case 3 - enabled()");
+ sm.enableNotFailed();
+
+ logger.info("\n??? State change notification test case 4 - disableFailed()");
+ sm.disableFailed();
+
+ logger.info("\n??? State change notification test case 5 - demote()");
+ sm.demote();
+
+ logger.info("\n??? State change notification test case 6 - promote()");
+ try {
+ sm.promote();
+ } catch(Exception ex) {
+ logger.info("Exception from promote(): " + ex.toString());
+ }
+
+ if (emf.isOpen()) {
+ emf.close();
+ }
+ } catch(Exception ex) {
+ logger.error("Exception: " + ex.toString());
+ } finally {
+ if (emf.isOpen()) {
+ emf.close();
+ }
+ }
+
+ logger.info("\n\nStateManagementTest: Exit\n\n");
+ }
+
+ private void displayState(String resourceName, StateManagement sm)
+ {
+ System.out.println("\nAdminState = " + sm.getAdminState()
+ + "\nOpState() = " + sm.getOpState()
+ + "\nAvailStatus = " + sm.getAvailStatus()
+ + "\nStandbyStatus = " + sm.getStandbyStatus()
+ + "\n");
+ logger.info(resourceName + " adminState = " + sm.getAdminState());
+ logger.info(resourceName + " opState = " + sm.getOpState());
+ logger.info(resourceName + " availStatus = " + sm.getAvailStatus());
+ logger.info(resourceName + " standbyStatus= " + sm.getStandbyStatus());
+ }
+}
+
diff --git a/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateTransitionTest.java b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateTransitionTest.java
new file mode 100644
index 00000000..b0e6e18e
--- /dev/null
+++ b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateTransitionTest.java
@@ -0,0 +1,2188 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Monitor
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.common.im.test;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+//import org.apache.commons.logging.Log;
+//import org.apache.commons.logging.LogFactory;
+
+import org.openecomp.policy.common.im.StateTransition;
+import org.openecomp.policy.common.im.StateElement;
+import org.openecomp.policy.common.im.StandbyStatusException;
+import org.openecomp.policy.common.im.StateChangeNotifier;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+
+public class StateTransitionTest {
+ private static Logger logger = FlexLogger.getLogger(StateTransitionTest.class);
+
+ private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
+ private static final String DEFAULT_DB_URL = "jdbc:h2:file:./sql/smTest";
+ private static final String DEFAULT_DB_USER = "sa";
+ private static final String DEFAULT_DB_PWD = "";
+
+ private static final String DB_DRIVER = "javax.persistence.jdbc.driver";
+ private static final String DB_URL = "javax.persistence.jdbc.url";
+ private static final String DB_USER = "javax.persistence.jdbc.user";
+ private static final String DB_PWD = "javax.persistence.jdbc.password";
+ //
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Ignore
+ @Test
+ public void testJPA() throws Exception {
+ logger.info("\n\nlogger.infor StateTransitionTest: Entering\n\n");
+ boolean standbyExceptionThrown = false;
+
+ //These parameters are in a properties file
+ EntityManagerFactory emf = null;
+ try {
+ Properties myProp = new Properties();
+ myProp.put(DB_DRIVER, DEFAULT_DB_DRIVER);
+ myProp.put(DB_URL, DEFAULT_DB_URL);
+ myProp.put(DB_USER, DEFAULT_DB_USER);
+ myProp.put(DB_PWD, DEFAULT_DB_PWD);
+
+ logger.info("??? create a new StateTransition");
+ StateTransition st = new StateTransition();
+
+ StateElement se = null;
+ try {
+ // bad test case
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "lock");
+ //
+ logger.info("??? StateTransition testcase 1");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "lock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 2");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 3");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 4");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 5");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 6");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 7");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 8");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 9");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 10");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 11");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 12");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 13");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 14");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 15");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 16");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 17");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 18");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 19");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 20");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 21");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 22");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 23");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 24");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 25");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 26");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 27");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 28");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 29");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 30");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 31");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 32");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 33");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 34");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 35");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 36");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 37");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 38");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 39");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 40");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 41");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 42");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 43");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 44");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 45");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 46");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 47");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 48");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 49");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 50");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 51");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 52");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 53");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 54");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 55");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 56");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 57");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 58");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 59");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 60");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 61");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 62");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 63");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 64");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 65");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 66");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 67");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 68");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 69");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 70");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 71");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 72");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 73");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 74");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 75");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 76");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 77");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 78");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 79");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 80");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 81");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 82");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 83");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 84");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 85");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 86");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 87");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 88");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 89");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 90");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 91");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 92");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 93");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 94");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 95");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 96");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 97");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 98");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 99");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 100");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 101");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 102");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 103");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 104");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 105");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 106");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 107");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 108");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 109");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 110");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 111");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 112");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 113");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 114");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 115");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 116");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 117");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 118");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 119");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 120");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 121");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 122");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 123");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 124");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 125");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 126");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 127");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 128");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 129");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 130");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 131");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 132");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 133");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 134");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 135");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 136");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 137");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 138");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 139");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 140");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 141");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 142");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 143");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 144");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 145");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 146");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 147");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 148");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 149");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 150");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 151");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 152");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 153");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 154");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 155");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 156");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 157");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 158");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 159");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 160");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 161");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 162");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 163");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 164");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 165");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 166");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 167");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 168");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 169");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 170");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 171");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 172");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 173");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 174");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 175");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 176");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 177");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 178");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 179");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 180");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 181");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 182");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 183");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 184");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 185");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 186");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 187");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 188");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 189");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 190");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 191");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 192");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 193");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 194");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 195");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 196");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 197");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 198");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 199");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 200");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 201");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 202");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 203");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 204");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 205");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 206");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 207");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 208");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 209");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 210");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 211");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 212");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 213");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 214");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 215");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 216");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 217");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 218");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 219");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 220");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 221");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 222");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 223");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 224");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 225");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 226");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 227");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 228");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 229");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 230");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 231");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 232");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 233");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 234");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 235");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 236");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 237");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 238");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 239");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 240");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 241");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 242");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 243");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 244");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 245");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 246");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 247");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 248");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 249");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 250");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 251");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 252");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 253");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 254");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 255");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 256");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 257");
+ se = st.getEndingState("locked", "enabled", "null", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 258");
+ se = st.getEndingState("locked", "enabled", "null", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 259");
+ se = st.getEndingState("locked", "enabled", "null", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 260");
+ se = st.getEndingState("locked", "enabled", "null", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 261");
+ se = st.getEndingState("locked", "enabled", "null", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 262");
+ se = st.getEndingState("locked", "enabled", "null", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 263");
+ se = st.getEndingState("locked", "enabled", "null", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 264");
+ se = st.getEndingState("locked", "enabled", "null", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 265");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 266");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 267");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 268");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 269");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 270");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 271");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 272");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 273");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 274");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 275");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 276");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 277");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 278");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 279");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 280");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 281");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 282");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 283");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 284");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 285");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 286");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 287");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 288");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 289");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 290");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 291");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 292");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 293");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 294");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 295");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 296");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 297");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 298");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 299");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 300");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 301");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 302");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 303");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 304");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 305");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 306");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 307");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 308");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 309");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 310");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 311");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 312");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 313");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 314");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 315");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 316");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 317");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 318");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 319");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 320");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 321");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 322");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 323");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 324");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 325");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 326");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 327");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 328");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 329");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 330");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 331");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 332");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 333");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 334");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 335");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 336");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 337");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 338");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 339");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 340");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 341");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 342");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 343");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 344");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 345");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 346");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 347");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 348");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 349");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 350");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 351");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 352");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 353");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 354");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 355");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 356");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 357");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 358");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 359");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 360");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 361");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 362");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 363");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 364");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 365");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 366");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 367");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 368");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 369");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 370");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 371");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 372");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 373");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 374");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 375");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 376");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 377");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 378");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 379");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 380");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 381");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 382");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 383");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 384");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 385");
+ se = st.getEndingState("locked", "disabled", "null", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 386");
+ se = st.getEndingState("locked", "disabled", "null", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 387");
+ se = st.getEndingState("locked", "disabled", "null", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 388");
+ se = st.getEndingState("locked", "disabled", "null", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 389");
+ se = st.getEndingState("locked", "disabled", "null", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 390");
+ se = st.getEndingState("locked", "disabled", "null", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 391");
+ se = st.getEndingState("locked", "disabled", "null", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 392");
+ se = st.getEndingState("locked", "disabled", "null", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 393");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 394");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 395");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 396");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 397");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 398");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 399");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 400");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 401");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 402");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 403");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 404");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 405");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 406");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 407");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 408");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 409");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 410");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 411");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 412");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 413");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 414");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 415");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 416");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 417");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 418");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 419");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 420");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 421");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 422");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 423");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 424");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 425");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 426");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 427");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 428");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 429");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 430");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 431");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 432");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 433");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 434");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 435");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 436");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 437");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 438");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 439");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 440");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 441");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 442");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 443");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 444");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 445");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 446");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 447");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 448");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 449");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 450");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 451");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 452");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 453");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 454");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 455");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 456");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 457");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 458");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 459");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 460");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 461");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 462");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 463");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 464");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 465");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 466");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 467");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 468");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 469");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 470");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 471");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 472");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 473");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 474");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 475");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 476");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 477");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 478");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 479");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 480");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 481");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 482");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 483");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 484");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 485");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 486");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 487");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 488");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 489");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 490");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 491");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 492");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 493");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 494");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 495");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 496");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 497");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 498");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 499");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 500");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 501");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 502");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 503");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 504");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 505");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 506");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "unlock");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 507");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "disableFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 508");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "enableNotFailed");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 509");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "disableDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 510");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "enableNoDependency");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 511");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "promote");
+ if (se != null) displayEndingState(se);
+
+ logger.info("??? StateTransition testcase 512");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "demote");
+ if (se != null) displayEndingState(se);
+
+ } catch (Exception ex) {
+ logger.error("EndingState NOT found");
+ throw new Exception("EndingState NOT found. " + ex);
+ }
+
+ //if (emf.isOpen()) {
+ //emf.close();
+ //}
+ } catch(Exception ex) {
+ logger.error("Exception: " + ex.toString());
+ throw new Exception("Failure getting ending state. " + ex );
+ } finally {
+ if (emf != null && emf.isOpen()) {
+ emf.close();
+ }
+ }
+
+ logger.info("\n\nStateTransitionTest: Exit\n\n");
+ }
+
+ private void displayEndingState(StateElement se)
+ {
+ String endingStandbyStatus = se.getEndingStandbyStatus();
+ if (endingStandbyStatus != null) {
+ endingStandbyStatus.replace(".", ",");
+ }
+ logger.info("EndingAdminState = [" + se.getEndingAdminState() +"]");
+ logger.info("EndingOpState = [" + se.getEndingOpState() +"]");
+ logger.info("EndingAvailStatus = [" + se.getEndingAvailStatus() +"]");
+ logger.info("EndingStandbyStatus= [" + endingStandbyStatus +"]");
+ logger.info("Exception = [" + se.getException() +"]");
+ }
+} \ No newline at end of file