summaryrefslogtreecommitdiffstats
path: root/integrity-monitor/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'integrity-monitor/src/test')
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java459
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementEntityTest.java91
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementTest.java111
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateTransitionTest.java18
4 files changed, 357 insertions, 322 deletions
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java
index 743fd26a..2fcc1c01 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java
@@ -46,8 +46,8 @@ import org.onap.policy.common.im.StateManagement;
import org.onap.policy.common.im.jpa.ForwardProgressEntity;
import org.onap.policy.common.im.jpa.ResourceRegistrationEntity;
import org.onap.policy.common.im.jpa.StateManagementEntity;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/*
* All JUnits are designed to run in the local development environment
@@ -55,7 +55,7 @@ import org.onap.policy.common.logging.flexlogger.Logger;
* tasks.
*/
public class IntegrityMonitorTest {
- private static Logger logger = FlexLogger.getLogger(IntegrityMonitorTest.class);
+ private static Logger logger = LoggerFactory.getLogger(IntegrityMonitorTest.class);
private static Properties myProp;
private static EntityManagerFactory emf;
private static EntityManager em;
@@ -133,7 +133,7 @@ public class IntegrityMonitorTest {
* Unlock restart
*/
public void testSanityJmx() throws Exception {
- System.out.println("\nIntegrityMonitorTest: Entering testSanityJmx\n\n");
+ logger.debug("\nIntegrityMonitorTest: Entering testSanityJmx\n\n");
String dependent = "group1_logparser";
@@ -143,12 +143,11 @@ public class IntegrityMonitorTest {
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");
+ logger.debug("\n\ntestSanityJmx starting im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ im.getStateManager().getAdminState(),
+ im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(),
+ im.getStateManager().getStandbyStatus());
// add an entry to Resource registration table in the DB for the dependent resource
@@ -162,7 +161,7 @@ public class IntegrityMonitorTest {
ResourceRegistrationEntity rrx = null;
if(rrList.isEmpty()){
// register resource by adding entry to table in DB
- System.out.println("Adding resource " + dependent + " to ResourceRegistration table");
+ logger.debug("Adding resource {} to ResourceRegistration table", dependent);
rrx = new ResourceRegistrationEntity();
// set columns in entry
rrx.setResourceName(dependent);
@@ -183,7 +182,7 @@ public class IntegrityMonitorTest {
try {
im.evaluateSanity();
} catch (Exception e) {
- System.out.println("evaluateSanity exception: " + e);
+ logger.error("evaluateSanity exception: ", e);
sanityPass = false;
}
assertFalse(sanityPass); // expect sanity test to fail
@@ -193,32 +192,31 @@ public class IntegrityMonitorTest {
myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
IntegrityMonitor.updateProperties(myProp);
- System.out.println("\ntestSantityJmx ending properties: " + myProp);
+ logger.debug("\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");
+ logger.debug("\n\ntestSanityJmx ending im state\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ im.getStateManager().getAdminState(),
+ im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(),
+ im.getStateManager().getStandbyStatus());
//Destroy the instance
- System.out.println("\ntestSanityJmx restarting the IntegrityMonitor");
+ logger.debug("\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");
+ logger.debug("\n\ntestSanityJmx state after creating new im\n"+
+ "AdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ im.getStateManager().getAdminState(),
+ im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(),
+ im.getStateManager().getStandbyStatus());
//Verify the state
assertEquals(im.getStateManager().getAdminState(), StateManagement.UNLOCKED);
@@ -231,60 +229,59 @@ public class IntegrityMonitorTest {
// Verify lock state
sm.lock();
- System.out.println("\n\nsm.lock()"
- + "\nAdminState = " + sm.getAdminState()
- + "\nOpState() = " + sm.getOpState()
- + "\nAvailStatus = " + sm.getAvailStatus()
- + "\nStandbyStatus = " + sm.getStandbyStatus()
- + "\n");
+ logger.debug("\n\nsm.lock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
assert(sm.getAdminState().equals(StateManagement.LOCKED));
//Verify lock persists across a restart
//Destroy the instance
- System.out.println("\ntestSanityJmx restarting the IntegrityMonitor");
+ logger.debug("\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");
+ logger.debug("\n\ntestSanityJmx restart with AdminState=locked"+
+ "\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
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");
+ logger.debug("\n\ntestSanityJmx sm.unlock\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
assert(sm.getAdminState().equals(StateManagement.UNLOCKED));
// Verify unlock restart
//Destroy the instance
- System.out.println("\ntestSanityJmx restarting the IntegrityMonitor");
+ logger.debug("\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");
+ logger.debug("\n\ntestSanityJmx restart with AdminState=unlocked\n" +
+ "AdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
assert(sm.getAdminState().equals(StateManagement.UNLOCKED));
- System.out.println("\n\ntestSanityJmx: Exit\n\n");
+ logger.debug("\n\ntestSanityJmx: Exit\n\n");
}
public void testIM() throws Exception {
- System.out.println("\nIntegrityMonitorTest: Entering testIM\n\n");
+ logger.debug("\nIntegrityMonitorTest: Entering testIM\n\n");
// parameters are passed via a properties file
@@ -295,29 +292,27 @@ public class IntegrityMonitorTest {
*/
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");
+ logger.debug("\n\nim before sleep\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ im.getStateManager().getAdminState(),
+ im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(),
+ im.getStateManager().getStandbyStatus());
// 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");
+ logger.debug("\n\nim after sleep\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ im.getStateManager().getAdminState(),
+ im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(),
+ im.getStateManager().getStandbyStatus());
// test evaluate sanity
boolean sanityPass = true;
try {
im.evaluateSanity();
} catch (Exception e) {
- System.out.println("evaluateSanity exception: " + e);
+ logger.error("evaluateSanity exception: ", e);
sanityPass = false;
}
assertTrue(sanityPass); // expect sanity test to pass
@@ -327,7 +322,7 @@ public class IntegrityMonitorTest {
try{
im.startTransaction();
} catch (Exception e){
- System.out.println("startTransaction exception: " + e);
+ logger.error("startTransaction exception: ", e);
transPass = false;
}
assertTrue(transPass);
@@ -336,12 +331,12 @@ public class IntegrityMonitorTest {
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");
+ logger.debug("\n\nsm.lock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
assert(sm.getAdminState().equals(StateManagement.LOCKED));
//test startTransaction. It should fail since it is locked
@@ -349,18 +344,17 @@ public class IntegrityMonitorTest {
try{
im.startTransaction();
} catch (Exception e){
- System.out.println("startTransaction exception: " + e);
+ logger.error("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");
+ logger.debug("\n\nsm.unlock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
assert(sm.getAdminState().equals(StateManagement.UNLOCKED));
//test startTransaction. It should succeed
@@ -368,18 +362,18 @@ public class IntegrityMonitorTest {
try{
im.startTransaction();
} catch (Exception e){
- System.out.println("startTransaction exception: " + e);
+ logger.error("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");
+ logger.debug("\n\nsm.disableDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
assert(sm.getOpState().equals(StateManagement.DISABLED));
assert(sm.getAvailStatus().equals(StateManagement.DEPENDENCY));
@@ -388,18 +382,18 @@ public class IntegrityMonitorTest {
try{
im.startTransaction();
} catch (Exception e){
- System.out.println("startTransaction exception: " + e);
+ logger.error("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");
+
+ logger.debug("\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
assert(sm.getOpState().equals(StateManagement.ENABLED));
//test startTransaction. It should succeed since standby status is null and unlocked
transPass = true;
@@ -413,12 +407,12 @@ public class IntegrityMonitorTest {
sm.disableFailed();
- System.out.println("\n\nsm.disableFailed()"
- + "\nAdminState = " + sm.getAdminState()
- + "\nOpState() = " + sm.getOpState()
- + "\nAvailStatus = " + sm.getAvailStatus()
- + "\nStandbyStatus = " + sm.getStandbyStatus()
- + "\n");
+ logger.debug("\n\nsm.disableFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
assert(sm.getOpState().equals(StateManagement.DISABLED));
assert(sm.getAvailStatus().equals(StateManagement.FAILED));
//test startTransaction. It should succeed since standby status is null and unlocked
@@ -432,30 +426,32 @@ public class IntegrityMonitorTest {
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");
+
+ logger.debug("\n\nsm.enabledNotFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
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);
+ logger.error("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");
+
+ logger.debug("\n\nsm.demote()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
assert(sm.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
//test startTransaction. It should fail since it is standby
@@ -463,18 +459,19 @@ public class IntegrityMonitorTest {
try{
im.startTransaction();
} catch (Exception e){
- System.out.println("startTransaction exception: " + e);
+ logger.error("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");
+
+ logger.debug("\n\nsm.promote()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
assert(sm.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
//test startTransaction. It should succeed since it is providing service
@@ -482,7 +479,7 @@ public class IntegrityMonitorTest {
try{
im.startTransaction();
} catch (Exception e){
- System.out.println("startTransaction exception: " + e);
+ logger.error("startTransaction exception: ", e);
transPass = false;
}
assertTrue(transPass); //expect it to succeed
@@ -491,12 +488,13 @@ public class IntegrityMonitorTest {
//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");
+
+ logger.debug("\n\nsm.disableDependency(), sm.disableFailed\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
assert(sm.getAvailStatus().equals(StateManagement.DEPENDENCY_FAILED));
//Test startTransaction. Should fail since standby status is cold standby
@@ -504,72 +502,72 @@ public class IntegrityMonitorTest {
try{
im.startTransaction();
} catch (Exception e){
- System.out.println("startTransaction exception: " + e);
+ logger.error("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");
+
+ logger.debug("\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
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);
+ logger.error("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");
+
+ logger.debug("\n\nsm.disableDependency(),sm.enableNotFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
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);
+ logger.error("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");
+ logger.debug("\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
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);
+ logger.error("startTransaction exception: ", e);
transPass = false;
}
assertTrue(!transPass); //expect it to fail
- System.out.println("\n\ntestIM: Exit\n\n");
+ logger.debug("\n\ntestIM: Exit\n\n");
}
public void testSanityState() throws Exception {
- System.out.println("\nIntegrityMonitorTest: Entering testSanityState\n\n");
+ logger.debug("\nIntegrityMonitorTest: Entering testSanityState\n\n");
// parameters are passed via a properties file
myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "group1_dep1,group1_dep2; group2_dep1");
@@ -605,7 +603,7 @@ public class IntegrityMonitorTest {
try {
im.evaluateSanity();
} catch (Exception e) {
- System.out.println("evaluateSanity exception: " + e);
+ logger.error("evaluateSanity exception: ", e);
sanityPass = false;
}
assertFalse(sanityPass); // expect sanity test to fail
@@ -626,7 +624,7 @@ public class IntegrityMonitorTest {
em.flush();
et.commit();
- System.out.println("\n\ntestSanityState: Exit\n\n");
+ logger.debug("\n\ntestSanityState: Exit\n\n");
}
public void testRefreshStateAudit() throws Exception {
@@ -668,12 +666,13 @@ public class IntegrityMonitorTest {
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());
+ logger.debug("??? -- Retrieve StateManagementEntity from database --\nsme.getResourceName() = {}\n"+
+ "sme.getAdminState() = {}\nsme.getOpState() = {}\nsme.getAvailStatus() = {}\nsme.getStandbyStatus() = {}",
+ sme.getResourceName(),
+ sme.getAdminState(),
+ sme.getOpState(),
+ sme.getAvailStatus(),
+ sme.getStandbyStatus());
assertTrue(sme.getAdminState().equals(StateManagement.UNLOCKED));
assertTrue(sme.getOpState().equals(StateManagement.ENABLED));
@@ -709,12 +708,13 @@ public class IntegrityMonitorTest {
// 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());
+ logger.debug("??? -- Retrieve StateManagementEntity from database --\nsme1.getResourceName() = {}\n" +
+ "sme1.getAdminState() = {}\nsme1.getOpState() = {}\nsme1.getAvailStatus() = {}\nsme1.getStandbyStatus() = {}",
+ sme1.getResourceName(),
+ sme1.getAdminState(),
+ sme1.getOpState(),
+ sme1.getAvailStatus(),
+ sme1.getStandbyStatus());
assertTrue(sme1.getAdminState().equals(StateManagement.UNLOCKED));
assertTrue(sme1.getOpState().equals(StateManagement.ENABLED));
@@ -743,7 +743,7 @@ public class IntegrityMonitorTest {
}
public void testStateCheck() throws Exception {
- System.out.println("\nIntegrityMonitorTest: Entering testStateCheck\n\n");
+ logger.debug("\nIntegrityMonitorTest: Entering testStateCheck\n\n");
// parameters are passed via a properties file
myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "group1_dep1");
@@ -791,7 +791,7 @@ public class IntegrityMonitorTest {
try {
im.evaluateSanity();
} catch (Exception e) {
- System.out.println("testStateCheck: After 15 sec sleep - evaluateSanity exception: " + e);
+ logger.error("testStateCheck: After 15 sec sleep - evaluateSanity exception: ", e);
sanityPass = false;
}
assertTrue(sanityPass); // expect sanity test to pass
@@ -804,7 +804,7 @@ public class IntegrityMonitorTest {
try {
im.evaluateSanity();
} catch (Exception e) {
- System.out.println("testStateCheck: After 10 sec sleep - evaluateSanity exception: " + e);
+ logger.error("testStateCheck: After 10 sec sleep - evaluateSanity exception: ", e);
sanityPass = false;
}
assertFalse(sanityPass); // expect sanity test to fail
@@ -827,11 +827,10 @@ public class IntegrityMonitorTest {
em.flush();
et.commit();
- System.out.println("\n\ntestStateCheck: Exit\n\n");
+ logger.debug("\n\ntestStateCheck: Exit\n\n");
}
public void testGetAllForwardProgressEntity() throws Exception{
- System.out.println("\nIntegrityMonitorTest: Entering testGetAllForwardProgressEntity\n\n");
logger.debug("\nIntegrityMonitorTest: Entering testGetAllForwardProgressEntity\n\n");
// parameters are passed via a properties file
@@ -889,11 +888,9 @@ public class IntegrityMonitorTest {
et.commit();
logger.debug("\nIntegrityMonitorTest: Exit testGetAllForwardProgressEntity\n\n");
- System.out.println("\n\ntestGetAllForwardProgressEntity: Exit\n\n");
}
public void testStateAudit() throws Exception{
- System.out.println("\nIntegrityMonitorTest: Entering testStateAudit\n\n");
logger.debug("\nIntegrityMonitorTest: Entering testStateAudit\n\n");
// parameters are passed via a properties file
@@ -975,8 +972,10 @@ public class IntegrityMonitorTest {
logger.debug("\n\n");
logger.debug("IntegrityMonitorTest:testStateAudit:ForwardProgressEntity entries");
for(ForwardProgressEntity myFpe : fpeList){
- logger.debug("\n ResourceName: " + myFpe.getResourceName()
- + "\n LastUpdated: " + myFpe.getLastUpdated());
+ logger.debug("\n ResourceName: {}" +
+ "\n LastUpdated: {}",
+ myFpe.getResourceName(),
+ myFpe.getLastUpdated());
}
logger.debug("\n\n");
@@ -989,11 +988,16 @@ public class IntegrityMonitorTest {
for(Object mySme : smeList){
StateManagementEntity tmpSme = (StateManagementEntity) mySme;
em.refresh(tmpSme);
- logger.debug("\n ResourceName: " + tmpSme.getResourceName()
- + "\n AdminState: " + tmpSme.getAdminState()
- + "\n OpState: " + tmpSme.getOpState()
- + "\n AvailStatus: " + tmpSme.getAvailStatus()
- + "\n StandbyStatus: " + tmpSme.getStandbyStatus()
+ logger.debug("\n ResourceName: {}" +
+ "\n AdminState: {}" +
+ "\n OpState: {}" +
+ "\n AvailStatus: {}" +
+ "\n StandbyStatus: {}",
+ tmpSme.getResourceName(),
+ tmpSme.getAdminState(),
+ tmpSme.getOpState(),
+ tmpSme.getAvailStatus(),
+ tmpSme.getStandbyStatus()
);
}
logger.debug("\n\n");
@@ -1010,11 +1014,16 @@ public class IntegrityMonitorTest {
for(Object mySme : smeList){
StateManagementEntity tmpSme = (StateManagementEntity) mySme;
em.refresh(tmpSme);
- logger.debug("\n ResourceName: " + tmpSme.getResourceName()
- + "\n AdminState: " + tmpSme.getAdminState()
- + "\n OpState: " + tmpSme.getOpState()
- + "\n AvailStatus: " + tmpSme.getAvailStatus()
- + "\n StandbyStatus: " + tmpSme.getStandbyStatus()
+ logger.debug("\n ResourceName: {}" +
+ "\n AdminState: {}" +
+ "\n OpState: {}" +
+ "\n AvailStatus: {}" +
+ "\n StandbyStatus: {}",
+ tmpSme.getResourceName(),
+ tmpSme.getAdminState(),
+ tmpSme.getOpState(),
+ tmpSme.getAvailStatus(),
+ tmpSme.getStandbyStatus()
);
}
logger.debug("\n\n");
@@ -1051,11 +1060,16 @@ public class IntegrityMonitorTest {
for(Object mySme : smeList){
StateManagementEntity tmpSme = (StateManagementEntity) mySme;
em.refresh(tmpSme);
- logger.debug("\n 2nd ResourceName: " + tmpSme.getResourceName()
- + "\n AdminState: " + tmpSme.getAdminState()
- + "\n OpState: " + tmpSme.getOpState()
- + "\n AvailStatus: " + tmpSme.getAvailStatus()
- + "\n StandbyStatus: " + tmpSme.getStandbyStatus()
+ logger.debug("\n 2nd ResourceName: {}" +
+ "\n AdminState: {}" +
+ "\n OpState: {}" +
+ "\n AvailStatus: {}" +
+ "\n StandbyStatus: {}",
+ tmpSme.getResourceName(),
+ tmpSme.getAdminState(),
+ tmpSme.getOpState(),
+ tmpSme.getAvailStatus(),
+ tmpSme.getStandbyStatus()
);
}
logger.debug("\n\n");
@@ -1088,12 +1102,19 @@ public class IntegrityMonitorTest {
for(Object mySme : smeList){
StateManagementEntity tmpSme = (StateManagementEntity) mySme;
em.refresh(tmpSme);
- logger.debug("\n (restart) ResourceName: " + tmpSme.getResourceName()
- + "\n AdminState: " + tmpSme.getAdminState()
- + "\n OpState: " + tmpSme.getOpState()
- + "\n AvailStatus: " + tmpSme.getAvailStatus()
- + "\n StandbyStatus: " + tmpSme.getStandbyStatus()
+
+ logger.debug("\n (restart) ResourceName: {}" +
+ "\n AdminState: {}" +
+ "\n OpState: {}" +
+ "\n AvailStatus: {}" +
+ "\n StandbyStatus: {}",
+ tmpSme.getResourceName(),
+ tmpSme.getAdminState(),
+ tmpSme.getOpState(),
+ tmpSme.getAvailStatus(),
+ tmpSme.getStandbyStatus()
);
+
}
logger.debug("\n\n");
@@ -1125,11 +1146,17 @@ public class IntegrityMonitorTest {
for(Object mySme : smeList){
StateManagementEntity tmpSme = (StateManagementEntity) mySme;
em.refresh(tmpSme);
- logger.debug("\n (restart2) ResourceName: " + tmpSme.getResourceName()
- + "\n AdminState: " + tmpSme.getAdminState()
- + "\n OpState: " + tmpSme.getOpState()
- + "\n AvailStatus: " + tmpSme.getAvailStatus()
- + "\n StandbyStatus: " + tmpSme.getStandbyStatus()
+
+ logger.debug("\n (restart2) ResourceName: {}" +
+ "\n AdminState: {}" +
+ "\n OpState: {}" +
+ "\n AvailStatus: {}" +
+ "\n StandbyStatus: {}",
+ tmpSme.getResourceName(),
+ tmpSme.getAdminState(),
+ tmpSme.getOpState(),
+ tmpSme.getAvailStatus(),
+ tmpSme.getStandbyStatus()
);
}
logger.debug("\n\n");
@@ -1155,11 +1182,17 @@ public class IntegrityMonitorTest {
for(Object mySme : smeList){
StateManagementEntity tmpSme = (StateManagementEntity) mySme;
em.refresh(tmpSme);
- logger.debug("\n (restart3) ResourceName: " + tmpSme.getResourceName()
- + "\n AdminState: " + tmpSme.getAdminState()
- + "\n OpState: " + tmpSme.getOpState()
- + "\n AvailStatus: " + tmpSme.getAvailStatus()
- + "\n StandbyStatus: " + tmpSme.getStandbyStatus()
+
+ logger.debug("\n (restart3) ResourceName: {}" +
+ "\n AdminState: {}" +
+ "\n OpState: {}" +
+ "\n AvailStatus: {}" +
+ "\n StandbyStatus: {}",
+ tmpSme.getResourceName(),
+ tmpSme.getAdminState(),
+ tmpSme.getOpState(),
+ tmpSme.getAvailStatus(),
+ tmpSme.getStandbyStatus()
);
}
logger.debug("\n\n");
@@ -1196,11 +1229,17 @@ public class IntegrityMonitorTest {
for(Object mySme : smeList){
StateManagementEntity tmpSme = (StateManagementEntity) mySme;
em.refresh(tmpSme);
- logger.debug("\n (restart4) ResourceName: " + tmpSme.getResourceName()
- + "\n AdminState: " + tmpSme.getAdminState()
- + "\n OpState: " + tmpSme.getOpState()
- + "\n AvailStatus: " + tmpSme.getAvailStatus()
- + "\n StandbyStatus: " + tmpSme.getStandbyStatus()
+
+ logger.debug("\n (restart4) ResourceName: {}" +
+ "\n AdminState: {}" +
+ "\n OpState: {}" +
+ "\n AvailStatus: {}" +
+ "\n StandbyStatus: {}",
+ tmpSme.getResourceName(),
+ tmpSme.getAdminState(),
+ tmpSme.getOpState(),
+ tmpSme.getAvailStatus(),
+ tmpSme.getStandbyStatus()
);
}
logger.debug("\n\n");
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementEntityTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementEntityTest.java
index 68e53dbe..852a04f6 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementEntityTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementEntityTest.java
@@ -34,16 +34,14 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-//import org.apache.commons.logging.Log;
-//import org.apache.commons.logging.LogFactory;
import org.onap.policy.common.im.StateManagement;
import org.onap.policy.common.im.jpa.StateManagementEntity;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class StateManagementEntityTest {
- private static Logger logger = FlexLogger.getLogger(StateManagementEntityTest.class);
+ private static Logger logger = LoggerFactory.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";
@@ -83,7 +81,7 @@ public class StateManagementEntityTest {
//@Ignore
@Test
public void testJPA() throws Exception {
- System.out.println("\n??? logger.infor StateManagementEntityTest: Entering\n\n");
+ logger.debug("\n??? logger.infor StateManagementEntityTest: Entering\n\n");
Properties myProp = new Properties();
myProp.put(DB_DRIVER, DEFAULT_DB_DRIVER);
@@ -91,62 +89,62 @@ public class StateManagementEntityTest {
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);
+ logger.debug("??? {} = {}", DB_DRIVER, DEFAULT_DB_DRIVER);
+ logger.debug("??? {} = {}", DB_URL, DEFAULT_DB_URL);
+ logger.debug("??? {} = {}", DB_USER, DEFAULT_DB_USER);
+ logger.debug("??? {} = {}", DB_PWD, DEFAULT_DB_PWD);
//Create the data schema and entity manager factory
- System.out.println("??? createEntityManagerFactory for schemaPU");
+ logger.debug("??? createEntityManagerFactory for schemaPU");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("schemaPU", myProp);
// Create an entity manager to use the DB
- System.out.println("??? createEntityManager");
+ logger.debug("??? createEntityManager");
EntityManager em = emf.createEntityManager();
- System.out.println("??? getTransaction");
+ logger.debug("??? getTransaction");
EntityTransaction et = em.getTransaction();
et.begin();
// Make sure the DB is clean
- System.out.println("??? clean StateManagementEntity");
+ logger.debug("??? 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");
+ logger.debug("Create StateManagementEntity, resourceName: {}", resourceName);
+ logger.debug("??? instantiate StateManagementEntity object");
StateManagementEntity sme = new StateManagementEntity();
- System.out.println("??? setResourceName : " + resourceName);
+ logger.debug("??? setResourceName : {}", resourceName);
sme.setResourceName(resourceName);
- System.out.println("??? getResourceName : " + sme.getResourceName());
+ logger.debug("??? getResourceName : {}", sme.getResourceName());
- System.out.println("??? setAdminState : " + StateManagement.UNLOCKED);
+ logger.debug("??? setAdminState : {}", StateManagement.UNLOCKED);
sme.setAdminState(StateManagement.UNLOCKED);
- System.out.println("??? getAdminState : " + sme.getAdminState());
+ logger.debug("??? getAdminState : {}", sme.getAdminState());
- System.out.println("??? setOpState : " + StateManagement.ENABLED);
+ logger.debug("??? setOpState : {}", StateManagement.ENABLED);
sme.setOpState(StateManagement.ENABLED);
- System.out.println("??? getOpState : " + sme.getOpState());
+ logger.debug("??? getOpState : {}", sme.getOpState());
- System.out.println("??? setAvailStatus : " + StateManagement.NULL_VALUE);
+ logger.debug("??? setAvailStatus : {}", StateManagement.NULL_VALUE);
sme.setAvailStatus(StateManagement.NULL_VALUE);
- System.out.println("??? getAvailStatus : " + sme.getAvailStatus());
+ logger.debug("??? getAvailStatus : {}", sme.getAvailStatus());
- System.out.println("??? setStandbyStatus: " + StateManagement.COLD_STANDBY);
+ logger.debug("??? setStandbyStatus: {}", StateManagement.COLD_STANDBY);
sme.setStandbyStatus(StateManagement.COLD_STANDBY);
- System.out.println("??? getStandbyStatus: " + sme.getStandbyStatus());
+ logger.debug("??? getStandbyStatus: {}", sme.getStandbyStatus());
- System.out.println("??? before persist");
+ logger.debug("??? before persist");
em.persist(sme);
- System.out.println("??? after persist");
+ logger.debug("??? after persist");
em.flush();
- System.out.println("??? after flush");
+ logger.debug("??? after flush");
et.commit();
- System.out.println("??? after commit");
+ logger.debug("??? after commit");
try {
Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
@@ -159,17 +157,20 @@ public class StateManagementEntityTest {
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());
+ logger.debug("??? -- Retrieve StateManagementEntity from database --\n\nsme.getResourceName() = {}\n" +
+ "sme2getResourceName() = {}\n\nsme.getAdminState() = {}\nsme2.getAdminState() = {}\n\n" +
+ "sme.getOpState() = {}\nsme2.getOpState() = {}\n\nsme.getAvailStatus() = {}\n" +
+ "sme2.getAvailStatus() = {}\n\nsme.getStandbyStatus() = {}\nsme2.getStandbyStatus() = {}",
+ sme.getResourceName(),
+ sme2.getResourceName(),
+ sme.getAdminState(),
+ sme2.getAdminState(),
+ sme.getOpState(),
+ sme2.getOpState(),
+ sme.getAvailStatus(),
+ sme.getAvailStatus(),
+ sme.getStandbyStatus(),
+ sme2.getStandbyStatus());
assert(sme2.getResourceName().equals(sme.getResourceName()));
@@ -177,16 +178,16 @@ public class StateManagementEntityTest {
assert(sme2.getOpState().equals(sme.getOpState()));
assert(sme2.getAvailStatus().equals(sme.getAvailStatus()));
assert(sme2.getStandbyStatus().equals(sme.getStandbyStatus()));
- System.out.println("--");
+ logger.debug("--");
} else {
- System.out.println("Record not found, resourceName: " + resourceName);
+ logger.debug("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");
+ logger.debug("\n??? after close");
+ logger.debug("\n\nJpaTest: Exit\n\n");
}
}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementTest.java
index 53e0825b..a3c0fcd7 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementTest.java
@@ -31,8 +31,8 @@ import org.junit.Test;
import org.onap.policy.common.im.StateManagement;
import org.onap.policy.common.im.StandbyStatusException;
import org.onap.policy.common.im.StateChangeNotifier;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/*
* All JUnits are designed to run in the local development environment
@@ -40,7 +40,7 @@ import org.onap.policy.common.logging.flexlogger.Logger;
* tasks.
*/
public class StateManagementTest {
- private static Logger logger = FlexLogger.getLogger(StateManagementTest.class);
+ private static Logger logger = LoggerFactory.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";
@@ -90,47 +90,47 @@ public class StateManagementTest {
emf = Persistence.createEntityManagerFactory("schemaPU", myProp);
StateManagement sm = new StateManagement(emf, resourceName);
- System.out.println("\n\ntest lock()");
+ logger.info("\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());
+ logger.info("{} before adminState = {}", resourceName, sm.getAdminState());
+ logger.info("{} before opState = {}", resourceName, sm.getOpState());
+ logger.info("{} before availStatus = {}", resourceName, sm.getAvailStatus());
+ logger.info("{} before standbyStatus= {}", resourceName, 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("{} after adminState = {}", resourceName, sm.getAdminState());
+ logger.info("{} after opState = {}", resourceName, sm.getOpState());
+ logger.info("{} after availStatus = {}", resourceName, sm.getAvailStatus());
+ logger.info("{} after standbyStatus= {}", resourceName, 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("{} adminState = {}", resourceName, sm.getAdminState());
+ logger.info("{} opState = {}", resourceName, sm.getOpState());
+ logger.info("{} availStatus = {}", resourceName, sm.getAvailStatus());
+ logger.info("{} standbyStatus= {}", resourceName, 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("{} adminState = {}", resourceName, sm.getAdminState());
+ logger.info("{} opState = {}", resourceName, sm.getOpState());
+ logger.info("{} availStatus = {}", resourceName, sm.getAvailStatus());
+ logger.info("{} standbyStatus= {}", resourceName, 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());
+ logger.info("{} adminState = {}", resourceName, sm.getAdminState());
+ logger.info("{} opState = {}", resourceName, sm.getOpState());
+ logger.info("{} availStatus = {}", resourceName, sm.getAvailStatus());
+ logger.info("{} standbyStatus= {}", resourceName, 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
@@ -140,9 +140,9 @@ public class StateManagementTest {
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());
+ logger.info("{} adminState = {}", resourceName, sm.getAdminState());
+ logger.info("{} opState = {}", resourceName, sm.getOpState());
+ logger.info("{} standbyStatus= {}", resourceName, sm.getStandbyStatus());
sm.promote();
System.out.println("\n\nafter promote");
displayState(resourceName, sm);
@@ -170,7 +170,7 @@ public class StateManagementTest {
}
assert(standbyExceptionThrown);
assert(sm.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
- System.out.println("\n\nP3 after promote()");
+ logger.info("\n\nP3 after promote()");
displayState(resourceName, sm);
standbyExceptionThrown = false;
@@ -181,13 +181,13 @@ public class StateManagementTest {
StateManagement sm2 = new StateManagement(emf, resourceName);
sm2.enableNotFailed();
sm2.unlock();
- System.out.println("\n\nafter sm2.enableNotFailed() and sm2.unlock()");
+ logger.info("\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());
+ logger.info("{} adminState = {}", resourceName, sm2.getAdminState());
+ logger.info("{} opState = {}", resourceName, sm2.getOpState());
+ logger.info("{} standbyStatus= {}", resourceName, sm2.getStandbyStatus());
sm2.promote();
- System.out.println("\n\nP2 after sm2.promote");
+ logger.info("\n\nP2 after sm2.promote");
displayState(resourceName, sm2);
assert(sm2.getAdminState().equals(StateManagement.UNLOCKED));
assert(sm2.getOpState().equals(StateManagement.ENABLED));
@@ -197,7 +197,7 @@ public class StateManagementTest {
logger.info("\n??? promote() test case P5");
logger.info(resourceName + " standbyStatus= " + sm2.getStandbyStatus());
sm2.promote();
- System.out.println("\n\nP5 after sm2.promote()");
+ logger.info("\n\nP5 after sm2.promote()");
displayState(resourceName, sm2);
assert(sm2.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
@@ -205,7 +205,7 @@ public class StateManagementTest {
logger.info("\n??? demote() test case D1");
logger.info(resourceName + " standbyStatus= " + sm2.getStandbyStatus());
sm2.demote();
- System.out.println("\n\nD1 after sm2.demote()");
+ logger.info("\n\nD1 after sm2.demote()");
displayState(resourceName, sm2);
assert(sm2.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
@@ -213,7 +213,7 @@ public class StateManagementTest {
logger.info("\n??? demote() test case D4");
logger.info(resourceName + " standbyStatus= " + sm2.getStandbyStatus());
sm2.demote();
- System.out.println("\n\nD4 after sm2.demote()");
+ logger.info("\n\nD4 after sm2.demote()");
displayState(resourceName, sm2);
assert(sm2.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
@@ -224,13 +224,13 @@ public class StateManagementTest {
StateManagement sm3 = new StateManagement(emf, resourceName);
sm3.lock();
sm3.disableFailed();
- System.out.println("\n\nD3 after sm3.lock() and sm3.disableFailed()");
+ logger.info("\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());
+ logger.info("{} adminState = {}", resourceName, sm3.getAdminState());
+ logger.info("{} opState = {}", resourceName, sm3.getOpState());
+ logger.info("{} standbyStatus= {}", resourceName, sm3.getStandbyStatus());
sm3.demote();
- System.out.println("\n\nD3 after sm3.demote()");
+ logger.info("\n\nD3 after sm3.demote()");
displayState(resourceName, sm3);
assert(sm3.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
@@ -238,7 +238,7 @@ public class StateManagementTest {
logger.info("\n??? demote() test case D5");
logger.info(resourceName + " standbyStatus= " + sm3.getStandbyStatus());
sm3.demote();
- System.out.println("\n\nD5 after sm3.demote()");
+ logger.info("\n\nD5 after sm3.demote()");
displayState(resourceName, sm3);
assert(sm3.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
@@ -249,11 +249,11 @@ public class StateManagementTest {
StateManagement sm4 = new StateManagement(emf, resourceName);
sm4.unlock();
sm4.enableNotFailed();
- System.out.println("\n\nD2 after sm4.unlock() and sm4.enableNotFailed()");
+ logger.info("\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());
+ logger.info("{} adminState = {}", resourceName, sm4.getAdminState());
+ logger.info("{} opState = {}", resourceName, sm4.getOpState());
+ logger.info("{} standbyStatus= {}", resourceName, sm4.getStandbyStatus());
sm4.demote();
assert(sm4.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
@@ -261,7 +261,7 @@ public class StateManagementTest {
logger.info("\n??? promote() test case P1");
logger.info(resourceName + " standbyStatus= " + sm4.getStandbyStatus());
sm4.promote();
- System.out.println("\n\nP1 after sm4.promote()");
+ logger.info("\n\nP1 after sm4.promote()");
displayState(resourceName, sm4);
assert(sm4.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
@@ -287,14 +287,14 @@ public class StateManagementTest {
try {
sm.promote();
} catch(Exception ex) {
- logger.info("Exception from promote(): " + ex.toString());
+ logger.info("Exception from promote(): {}", ex.toString());
}
if (emf.isOpen()) {
emf.close();
}
} catch(Exception ex) {
- logger.error("Exception: " + ex.toString());
+ logger.error("Exception: {}", ex.toString());
} finally {
if (emf.isOpen()) {
emf.close();
@@ -306,15 +306,10 @@ public class StateManagementTest {
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());
+ logger.info("{} adminState = {}", resourceName, sm.getAdminState());
+ logger.info("{} opState = {}", resourceName, sm.getOpState());
+ logger.info("{} availStatus = {}", resourceName, sm.getAvailStatus());
+ logger.info("{} standbyStatus= {}", resourceName, sm.getStandbyStatus());
}
}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateTransitionTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateTransitionTest.java
index ee8ea10f..6d4dc7c6 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateTransitionTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateTransitionTest.java
@@ -30,15 +30,15 @@ import org.junit.Test;
import org.onap.policy.common.im.StateTransition;
import org.onap.policy.common.im.StateElement;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/*
* All JUnits are designed to run in the local development environment
* where they have write privileges and can execute time-sensitive
* tasks.
*/
public class StateTransitionTest {
- private static Logger logger = FlexLogger.getLogger(StateTransitionTest.class);
+ private static Logger logger = LoggerFactory.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";
@@ -2146,7 +2146,7 @@ public class StateTransitionTest {
//emf.close();
//}
} catch(Exception ex) {
- logger.error("Exception: " + ex.toString());
+ logger.error("Exception: {}" + ex.toString());
throw new Exception("Failure getting ending state. " + ex );
} finally {
if (emf != null && emf.isOpen()) {
@@ -2163,10 +2163,10 @@ public class StateTransitionTest {
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() +"]");
+ 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