summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-08-28 22:16:36 +0000
committerGerrit Code Review <gerrit@onap.org>2017-08-28 22:16:36 +0000
commit5d7908a75107dcd18e7dd2f8a2d3e6528f5f830d (patch)
tree48f3fd34db7bf8ca5714474773d2a86cedce3a95
parent98d04b5c4e9aa3f7dd40cd40cbd1b00689b0bc22 (diff)
parent11e0afc41aa47b9b5fe36c6c654c5b7493e4ba46 (diff)
Merge "Removal of sys.out/err with logger messages"
-rw-r--r--controlloop/common/actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/Test.java13
-rw-r--r--controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/ActorService.java9
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java4
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java12
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java21
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java30
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java17
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java17
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java11
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java8
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java9
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java26
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java6
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java16
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java7
-rw-r--r--controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java12
-rw-r--r--controlloop/common/model-impl/mso/src/test/java/org/onap/policy/mso/TestDemo.java12
-rw-r--r--controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java20
-rw-r--r--controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java6
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java23
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java10
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java6
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java10
-rw-r--r--controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestAPPCPayload.java5
-rw-r--r--controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestFirewallDemo.java47
-rw-r--r--controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestMSO.java10
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java57
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java5
28 files changed, 242 insertions, 187 deletions
diff --git a/controlloop/common/actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/Test.java b/controlloop/common/actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/Test.java
index f6eba49af..e526abd41 100644
--- a/controlloop/common/actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/Test.java
+++ b/controlloop/common/actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/Test.java
@@ -24,23 +24,26 @@ import static org.junit.Assert.*;
import org.onap.policy.controlloop.actorServiceProvider.ActorService;
import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Test {
-
+ private static final Logger logger = LoggerFactory.getLogger(Test.class);
+
@org.junit.Test
public void test() {
- System.out.println("Dumping actors");
+ logger.debug("Dumping actors");
ActorService actorService = ActorService.getInstance();
assertNotNull(actorService);
int num = 0;
for (Actor actor : actorService.actors()) {
- System.out.println(actor.actor());
+ logger.debug(actor.actor());
for (String recipe : actor.recipes()) {
- System.out.println("\t" + recipe + " " + actor.recipeTargets(recipe) + " " + actor.recipePayloads(recipe));
+ logger.debug("\t {} {} {}", recipe, actor.recipeTargets(recipe), actor.recipePayloads(recipe));
}
num++;
}
- System.out.println("Found " + num + " actors");
+ logger.debug("Found {} actors", num);
}
}
diff --git a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/ActorService.java b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/ActorService.java
index 2632d0752..330b1f97c 100644
--- a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/ActorService.java
+++ b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/ActorService.java
@@ -24,10 +24,13 @@ import java.util.Iterator;
import java.util.ServiceLoader;
import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableList;
public class ActorService {
-
+
+ private static final Logger logger = LoggerFactory.getLogger(ActorService.class);
private static ActorService service;
private ServiceLoader<Actor> loader;
@@ -45,9 +48,9 @@ public class ActorService {
public ImmutableList<Actor> actors() {
Iterator<Actor> iter = loader.iterator();
- System.out.println("returning actors");
+ logger.debug("returning actors");
while (iter.hasNext()) {
- System.out.println("Got " + iter.next().actor());
+ logger.debug("Got {}", iter.next().actor());
}
return ImmutableList.copyOf(loader.iterator());
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index 3feab7d7c..b61eabc4b 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -341,7 +341,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
// PLD - this is simply comparing the policy. Do we want to equals the whole object?
//
if (this.currentOperation.policy.equals(operation.policy)) {
- System.out.println("Finishing " + this.currentOperation.policy.getRecipe() + " result is " + this.currentOperation.getOperationResult());
+ logger.debug("Finishing {} result is {}", this.currentOperation.policy.getRecipe(), this.currentOperation.getOperationResult());
//
// Save history
//
@@ -359,7 +359,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
//
return;
}
- System.out.println("Cannot finish current operation " + this.currentOperation.policy + " does not match given operation " + operation.policy);
+ logger.debug("Cannot finish current operation {} does not match given operation {}", this.currentOperation.policy, operation.policy);
return;
}
throw new ControlLoopException("No operation to finish.");
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
index 0df58be06..09f69fb0b 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
@@ -211,7 +211,7 @@ public class ControlLoopOperationManager implements Serializable {
//
// We are not supporting MSO interface at the moment
//
- System.out.println("We are not supporting MSO actor in the latest release.");
+ logger.debug("We are not supporting MSO actor in the latest release.");
return null;
case "VFC":
this.operationRequest = VFCActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, operation.operation, this.policy);
@@ -315,10 +315,10 @@ public class ControlLoopOperationManager implements Serializable {
// Sanity check
//
if (this.policy == null) {
- System.out.println("getOperationTimeout returning 0");
+ logger.debug("getOperationTimeout returning 0");
return 0;
}
- System.out.println("getOperationTimeout returning " + this.policy.getTimeout());
+ logger.debug("getOperationTimeout returning {}", this.policy.getTimeout());
return this.policy.getTimeout();
}
@@ -485,7 +485,7 @@ public class ControlLoopOperationManager implements Serializable {
private void completeOperation(Integer attempt, String message, PolicyResult result) {
if (attempt == null) {
- System.out.println("attempt cannot be null (i.e. subRequestID)");
+ logger.debug("attempt cannot be null (i.e. subRequestID)");
return;
}
if (this.currentOperation != null) {
@@ -509,7 +509,7 @@ public class ControlLoopOperationManager implements Serializable {
this.currentOperation = null;
return;
}
- System.out.println("not current");
+ logger.debug("not current");
}
for (Operation op : this.operationHistory) {
if (op.attempt == attempt.intValue()) {
@@ -520,7 +520,7 @@ public class ControlLoopOperationManager implements Serializable {
return;
}
}
- System.out.println("Could not find associated operation");
+ logger.debug("Could not find associated operation");
}
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java
index 5c019c487..bb5cec8da 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java
@@ -28,29 +28,32 @@ import java.util.Queue;
import org.onap.policy.appc.Request;
import org.onap.policy.controlloop.ControlLoopNotification;
import org.onap.policy.controlloop.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.onap.policy.drools.PolicyEngine;
public class PolicyEngineJUnitImpl implements PolicyEngine {
+ private static final Logger logger = LoggerFactory.getLogger(PolicyEngineJUnitImpl.class);
private Map<String, Map<String, Queue<Object>>> busMap = new HashMap<String, Map<String, Queue<Object>>>();
@Override
public boolean deliver(String busType, String topic, Object obj) {
if (obj instanceof ControlLoopNotification) {
ControlLoopNotification notification = (ControlLoopNotification) obj;
- //System.out.println("Notification: " + notification.notification + " " + (notification.message == null ? "" : notification.message) + " " + notification.history);
- System.out.println(Serialization.gsonPretty.toJson(notification));
+ //logger.debug("Notification: " + notification.notification + " " + (notification.message == null ? "" : notification.message) + " " + notification.history);
+ logger.debug(Serialization.gsonPretty.toJson(notification));
}
if (obj instanceof Request) {
Request request = (Request) obj;
- System.out.println("Request: " + request.Action + " subrequest " + request.CommonHeader.SubRequestID);
+ logger.debug("Request: {} subrequst {}", request.Action, request.CommonHeader.SubRequestID);
}
//
// Does the bus exist?
//
if (busMap.containsKey(busType) == false) {
- System.out.println("creating new bus type " + busType);
+ logger.debug("creating new bus type {}", busType);
//
// Create the bus
//
@@ -64,7 +67,7 @@ public class PolicyEngineJUnitImpl implements PolicyEngine {
// Does the topic exist?
//
if (topicMap.containsKey(topic) == false) {
- System.out.println("creating new topic " + topic);
+ logger.debug("creating new topic {}", topic);
//
// Create the topic
//
@@ -73,7 +76,7 @@ public class PolicyEngineJUnitImpl implements PolicyEngine {
//
// Get the topic queue
//
- System.out.println("queueing");
+ logger.debug("queueing");
return topicMap.get(topic).add(obj);
}
@@ -90,13 +93,13 @@ public class PolicyEngineJUnitImpl implements PolicyEngine {
// Does the topic exist?
//
if (topicMap.containsKey(topic)) {
- System.out.println("The queue has " + topicMap.get(topic).size());
+ logger.debug("The queue has {}", topicMap.get(topic).size());
return topicMap.get(topic).poll();
} else {
- System.err.println("No topic exists " + topic);
+ logger.error("No topic exists {}", topic);
}
} else {
- System.err.println("No bus exists " + busType);
+ logger.error("No bus exists {}", busType);
}
return null;
}
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
index fd7540ae7..6116d987e 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
@@ -42,9 +42,11 @@ import org.onap.policy.controlloop.Util;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.controlloop.processor.ControlLoopProcessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ControlLoopOperationManagerTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopOperationManagerTest.class);
private static VirtualControlLoopEvent onset;
static {
onset = new VirtualControlLoopEvent();
@@ -77,7 +79,7 @@ public class ControlLoopOperationManagerTest {
ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID);
ControlLoopOperationManager manager = new ControlLoopOperationManager(onset, processor.getCurrentPolicy(), eventManager);
- System.out.println(manager);
+ logger.debug("{}",manager);
//
//
//
@@ -87,7 +89,7 @@ public class ControlLoopOperationManagerTest {
// Start
//
Object request = manager.startOperation(onset);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertNotNull(request);
assertTrue(request instanceof Request);
assertTrue(((Request)request).CommonHeader.SubRequestID.contentEquals("1"));
@@ -103,7 +105,7 @@ public class ControlLoopOperationManagerTest {
//
//
PolicyResult result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result == null);
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
@@ -115,7 +117,7 @@ public class ControlLoopOperationManagerTest {
response.Status.Value = ResponseValue.FAILURE.toString();
response.Status.Description = "AppC failed for some reason";
result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result.equals(PolicyResult.FAILURE));
assertFalse(manager.isOperationComplete());
assertFalse(manager.isOperationRunning());
@@ -123,7 +125,7 @@ public class ControlLoopOperationManagerTest {
// Retry it
//
request = manager.startOperation(onset);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertNotNull(request);
assertTrue(request instanceof Request);
assertTrue(((Request)request).CommonHeader.SubRequestID.contentEquals("2"));
@@ -133,14 +135,14 @@ public class ControlLoopOperationManagerTest {
//
//
response = new Response((Request) request);
- System.out.println(manager);
+ logger.debug("{}",manager);
response.Status.Code = ResponseCode.ACCEPT.getValue();
response.Status.Value = ResponseValue.ACCEPT.toString();
//
//
//
result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result == null);
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
@@ -152,7 +154,7 @@ public class ControlLoopOperationManagerTest {
response.Status.Value = ResponseValue.FAILURE.toString();
response.Status.Description = "AppC failed for some reason";
result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result.equals(PolicyResult.FAILURE));
//
// Should be complete now
@@ -188,14 +190,14 @@ public class ControlLoopOperationManagerTest {
//
//
//
- System.out.println(manager);
+ logger.debug("{}",manager);
assertFalse(manager.isOperationComplete());
assertFalse(manager.isOperationRunning());
//
// Start
//
Object request = manager.startOperation(onset);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertNotNull(request);
assertTrue(request instanceof Request);
assertTrue(((Request)request).CommonHeader.SubRequestID.contentEquals("1"));
@@ -211,7 +213,7 @@ public class ControlLoopOperationManagerTest {
//
//
PolicyResult result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result == null);
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
@@ -219,7 +221,7 @@ public class ControlLoopOperationManagerTest {
// Now we are going to simulate Timeout
//
manager.setOperationHasTimedOut();
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(manager.isOperationComplete());
assertFalse(manager.isOperationRunning());
assertTrue(manager.getHistory().size() == 1);
@@ -232,7 +234,7 @@ public class ControlLoopOperationManagerTest {
response.Status.Value = ResponseValue.FAILURE.toString();
response.Status.Description = "AppC failed for some reason";
result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
//
//
//
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java
index 6000ca831..7bd18a3ff 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java
@@ -36,9 +36,12 @@ import org.onap.policy.controlloop.ControlLoopException;
import org.onap.policy.controlloop.policy.FinalResult;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.policy.PolicyResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ControlLoopProcessorTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopProcessorTest.class);
+
@Test
public void test() {
try (InputStream is = new FileInputStream(new File("src/test/resources/test.yaml"))) {
@@ -59,32 +62,32 @@ public class ControlLoopProcessorTest {
public void testSuccess(String yaml) throws ControlLoopException {
ControlLoopProcessor processor = new ControlLoopProcessor(yaml);
- System.out.println("testSuccess: " + processor.getControlLoop().toString());
+ logger.debug("testSuccess: {}", processor.getControlLoop());
while (true) {
FinalResult result = processor.checkIsCurrentPolicyFinal();
if (result != null) {
- System.out.println(result);
+ logger.debug("{}", result);
break;
}
Policy policy = processor.getCurrentPolicy();
assertNotNull(policy);
- System.out.println("current policy is: " + policy.getId() + " " + policy.getName());
+ logger.debug("current policy is: {} {}", policy.getId(), policy.getName());
processor.nextPolicyForResult(PolicyResult.SUCCESS);
}
}
public void testFailure(String yaml) throws ControlLoopException {
ControlLoopProcessor processor = new ControlLoopProcessor(yaml);
- System.out.println("testFailure: " + processor.getControlLoop().toString());
+ logger.debug("testFailure: {}", processor.getControlLoop());
while (true) {
FinalResult result = processor.checkIsCurrentPolicyFinal();
if (result != null) {
- System.out.println(result);
+ logger.debug("{}", result);
break;
}
Policy policy = processor.getCurrentPolicy();
assertNotNull(policy);
- System.out.println("current policy is: " + policy.getId() + " " + policy.getName());
+ logger.debug("current policy is: {} {}", policy.getId(), policy.getName());
processor.nextPolicyForResult(PolicyResult.FAILURE);
}
}
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
index 53e972941..6b311bf45 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
@@ -63,19 +63,19 @@ public class CallGuardTask implements Runnable {
try {
request = RequestParser.parseRequest(xacmlReq);
} catch (IllegalArgumentException | IllegalAccessException | DataTypeException e) {
- logger.error("CallGuardTask.run threw: ", e);
+ logger.error("CallGuardTask.run threw: {}", e);
}
- System.out.println("\n********** XACML REQUEST START ********");
- System.out.println(request);
- System.out.println("********** XACML REQUEST END ********\n");
+ logger.debug("\n********** XACML REQUEST START ********");
+ logger.debug("{}", request);
+ logger.debug("********** XACML REQUEST END ********\n");
com.att.research.xacml.api.Response xacmlResponse = PolicyGuardXacmlHelper.callPDP(embeddedPdpEngine, "", request, false);
- System.out.println("\n********** XACML RESPONSE START ********");
- System.out.println(xacmlResponse);
- System.out.println("********** XACML RESPONSE END ********\n");
+ logger.debug("\n********** XACML RESPONSE START ********");
+ logger.debug("{}", xacmlResponse);
+ logger.debug("********** XACML RESPONSE END ********\n");
PolicyGuardResponse guardResponse = PolicyGuardXacmlHelper.ParseXacmlPdpResponse(xacmlResponse);
@@ -88,7 +88,8 @@ public class CallGuardTask implements Runnable {
}
long estimatedTime = System.nanoTime() - startTime;
- System.out.println("\n\n============ Guard inserted with decision "+ guardResponse.result + " !!! =========== time took: " +(double)estimatedTime/1000/1000 +" mili sec \n\n");
+ logger.debug("\n\n============ Guard inserted with decision {} !!! =========== time took: {} mili sec \n\n",
+ guardResponse.result, (double)estimatedTime/1000/1000);
workingMemory.insert(guardResponse);
}
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java
index 67ac170db..9e8ed9db0 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java
@@ -134,7 +134,7 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
else{
//Notice, we are checking here for the base issuer prefix.
if (!string.contains(this.getIssuer())) {
- logger.debug("Requested issuer '{}' does not match {}", string, (this.getIssuer() == null ? "null" : "'" + this.getIssuer() + "'"));
+ logger.debug("Requested issuer '{}' does not match {}", string, getIssuer());
logger.debug("FeqLimiter PIP - Issuer {} does not match with: ", string, this.getIssuer());
return StdPIPResponse.PIP_RESPONSE_EMPTY;
}
@@ -187,11 +187,16 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
pipResponse = pipFinder.getMatchingAttributes(pipRequest, this);
if (pipResponse != null) {
if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) {
- logger.debug("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
pipResponse = null;
}
if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
- logger.debug("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
+ pipResponse = null;
+ }
+ if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
pipResponse = null;
}
}
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
index b4aee2fda..fabc48511 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
@@ -26,11 +26,13 @@ import java.util.UUID;
import org.onap.policy.controlloop.policy.TargetType;
import org.onap.policy.guard.impl.PNFTargetLock;
import org.onap.policy.guard.impl.VMTargetLock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PolicyGuard {
private static Map<String, TargetLock> activeLocks = new HashMap<String, TargetLock>();
-
+ private static final Logger logger = LoggerFactory.getLogger(PolicyGuard.class);
public static class LockResult<A, B> {
private A a;
private B b;
@@ -86,7 +88,7 @@ public class PolicyGuard {
//
// Return result
//
- System.out.println("Locking " + lock);
+ logger.debug("Locking {}", lock);
return LockResult.createLockResult(GuardResult.LOCK_ACQUIRED, lock);
}
}
@@ -94,7 +96,7 @@ public class PolicyGuard {
public static boolean unlockTarget(TargetLock lock) {
synchronized(activeLocks) {
if (activeLocks.containsKey(lock.getTargetInstance())) {
- System.out.println("Unlocking " + lock);
+ logger.debug("Unlocking {}", lock);
return (activeLocks.remove(lock.getTargetInstance()) != null);
}
return false;
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
index c0ed80086..dbaf711c4 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
@@ -61,7 +61,7 @@ public class PolicyGuardXacmlHelper {
//
response = (com.att.research.xacml.api.Response) callRESTfulPDP(new ByteArrayInputStream(jsonString.getBytes()), new URL(restfulPdpUrl/*"https://localhost:8443/pdp/"*/));
} catch (Exception e) {
- System.err.println("Error in sending RESTful request: " + e);
+ logger.error("Error in sending RESTful request: ", e);
}
} else if(xacmlEmbeddedPdpEngine != null){
//
@@ -71,10 +71,10 @@ public class PolicyGuardXacmlHelper {
try {
response = (com.att.research.xacml.api.Response) xacmlEmbeddedPdpEngine.decide((com.att.research.xacml.api.Request) request);
} catch (PDPException e) {
- System.err.println(e);
+ logger.error(e.getMessage(), e);
}
long lTimeEnd = System.currentTimeMillis();
- System.out.println("Elapsed Time: " + (lTimeEnd - lTimeStart) + "ms");
+ logger.debug("Elapsed Time: {} ms", (lTimeEnd - lTimeStart));
}
return response;
}
@@ -178,16 +178,13 @@ public class PolicyGuardXacmlHelper {
while(it_attr.hasNext()){
Attribute current_attr = it_attr.next();
String s = current_attr.getAttributeId().stringValue();
- //System.out.println("ATTR ID = " + s);
if(s.equals("urn:oasis:names:tc:xacml:1.0:request:request-id")){
Iterator<AttributeValue<?>> it_values = current_attr.getValues().iterator();
req_id_from_xacml_response = UUID.fromString(it_values.next().getValue().toString());
- //System.out.println("UUID = " + req_id_from_xacml_response);
}
if(s.equals("urn:oasis:names:tc:xacml:1.0:operation:operation-id")){
Iterator<AttributeValue<?>> it_values = current_attr.getValues().iterator();
operation_from_xacml_response = it_values.next().getValue().toString();
- //System.out.println("OPERATION = " + operation_from_xacml_response);
}
}
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java
index 21584f0b5..72b723c1f 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java
@@ -42,12 +42,12 @@ public class PolicyGuardYamlToXacml {
public static void fromYamlToXacml(String yamlFile, String xacmlTemplate, String xacmlPolicyOutput){
ControlLoopGuard yamlGuardObject = Util.loadYamlGuard(yamlFile);
- System.out.println("clname: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getControlLoopName());
- System.out.println("actor: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor());
- System.out.println("recipe: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe());
- System.out.println("num: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target());
- System.out.println("duration: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window());
- System.out.println("time_in_range: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range());
+ logger.debug("clname: {}", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getControlLoopName());
+ logger.debug("actor: {}", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor());
+ logger.debug("recipe: {}", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe());
+ logger.debug("num: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target());
+ logger.debug("duration: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window());
+ logger.debug("time_in_range: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range());
Path xacmlTemplatePath = Paths.get(xacmlTemplate);
String xacmlTemplateContent;
@@ -142,7 +142,7 @@ public class PolicyGuardYamlToXacml {
p = Pattern.compile("\\$\\{guardActiveEnd\\}");
m = p.matcher(xacmlFileContent);
xacmlFileContent = m.replaceAll(guardActiveEnd);
- System.out.println(xacmlFileContent);
+ logger.debug(xacmlFileContent);
return xacmlFileContent;
}
@@ -175,11 +175,11 @@ public class PolicyGuardYamlToXacml {
public static void fromYamlToXacmlBlacklist(String yamlFile, String xacmlTemplate, String xacmlPolicyOutput){
ControlLoopGuard yamlGuardObject = Util.loadYamlGuard(yamlFile);
- System.out.println("actor: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor());
- System.out.println("recipe: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe());
- System.out.println("freq_limit_per_target: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target());
- System.out.println("time_window: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window());
- System.out.println("active_time_range: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range());
+ logger.debug("actor: {}", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor());
+ logger.debug("recipe: {}", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe());
+ logger.debug("freq_limit_per_target: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target());
+ logger.debug("time_window: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window());
+ logger.debug("active_time_range: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range());
Path xacmlTemplatePath = Paths.get(xacmlTemplate);
String xacmlTemplateContent;
@@ -236,7 +236,7 @@ public class PolicyGuardYamlToXacml {
p = Pattern.compile("\\$\\{guardActiveEnd\\}");
m = p.matcher(xacmlFileContent);
xacmlFileContent = m.replaceAll(guardActiveEnd);
- System.out.println(xacmlFileContent);
+ logger.debug(xacmlFileContent);
for(String target : blacklist){
p = Pattern.compile("\\$\\{blackListElement\\}");
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
index 702f27ccb..6018c2cab 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
@@ -35,10 +35,12 @@ import org.yaml.snakeyaml.constructor.Constructor;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class Util {
+ private static final Logger logger = LoggerFactory.getLogger(Util.class);
public static class Pair<A, B> {
public final A a;
public final B b;
@@ -59,7 +61,7 @@ public final class Util {
Object obj = yaml.load(contents);
//String ttt = ((ControlLoopPolicy)obj).policies.getFirst().payload.get("asdas");
- System.out.println(contents);
+ logger.debug(contents);
//for(Policy policy : ((ControlLoopPolicy)obj).policies){
return new Pair<ControlLoopPolicy, String>((ControlLoopPolicy) obj, contents);
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java
index b079122e4..fd999fb5f 100644
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java
@@ -48,13 +48,13 @@ public final class AAINQF199Manager {
Pair<Integer, String> httpDetails = RESTManager.post(url, username, password, headers, "application/json", Serialization.gsonPretty.toJson(request));
if (httpDetails == null) {
- System.out.println("AAI POST Null Response to " + url);
+ logger.debug("AAI POST Null Response to {}", url);
return null;
}
- System.out.println(url);
- System.out.println(httpDetails.a);
- System.out.println(httpDetails.b);
+ logger.debug(url);
+ logger.debug("{}", httpDetails.a);
+ logger.debug("{}", httpDetails.b);
if (httpDetails.a == 200) {
try {
AAINQF199Response response = Serialization.gsonPretty.fromJson(httpDetails.b, AAINQF199Response.class);
@@ -83,13 +83,13 @@ public final class AAINQF199Manager {
Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
if (httpDetailsGet == null) {
- System.out.println("AAI GET Null Response to " + urlGet);
+ logger.debug("AAI GET Null Response to {}", urlGet);
return null;
}
- System.out.println(urlGet);
- System.out.println(httpDetailsGet.a);
- System.out.println(httpDetailsGet.b);
+ logger.debug(urlGet);
+ logger.debug("{}", httpDetailsGet.a);
+ logger.debug("{}", httpDetailsGet.b);
if (httpDetailsGet.a == 200) {
try {
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
index 9e6d1afc0..9578d9ac2 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
@@ -27,6 +27,8 @@ import java.time.format.DateTimeFormatter;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.ControlLoopTargetType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -38,10 +40,12 @@ import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
+
public final class Serialization {
public static class notificationTypeAdapter implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> {
+
@Override
public JsonElement serialize(ControlLoopNotificationType src, Type typeOfSrc,
JsonSerializationContext context) {
@@ -73,6 +77,7 @@ public final class Serialization {
}
public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+ private static final Logger logger = LoggerFactory.getLogger(gsonUTCAdapter.class);
public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
@@ -80,7 +85,7 @@ public final class Serialization {
try {
return ZonedDateTime.parse(element.getAsString(), format);
} catch (Exception e) {
- System.err.println(e);
+ logger.error(e.getMessage(), e);
}
return null;
}
diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java
index 9f4fe5bbc..c23935586 100644
--- a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java
+++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java
@@ -60,8 +60,8 @@ public final class MSOManager {
MSOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, MSOResponse.class);
String body = Serialization.gsonPretty.toJson(response);
- System.out.println("***** Response to post:");
- System.out.println(body);
+ logger.debug("***** Response to post:");
+ logger.debug(body);
String requestId = response.requestReferences.requestId;
int attemptsLeft = 20;
@@ -75,24 +75,26 @@ public final class MSOManager {
Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, MSOResponse.class);
body = Serialization.gsonPretty.toJson(responseGet);
- System.out.println("***** Response to get:");
- System.out.println(body);
+ logger.debug("***** Response to get:");
+ logger.debug(body);
if(httpDetailsGet.a == 200){
if(responseGet.request.requestStatus.requestState.equalsIgnoreCase("COMPLETE") ||
responseGet.request.requestStatus.requestState.equalsIgnoreCase("FAILED")){
- System.out.println("***** ######## VF Module Creation "+responseGet.request.requestStatus.requestState);
+ logger.debug("***** ######## VF Module Creation "+responseGet.request.requestStatus.requestState);
return responseGet;
}
}
Thread.sleep(20000);
}
+
if (responseGet != null
&& responseGet.request != null
&& responseGet.request.requestStatus != null
&& responseGet.request.requestStatus.requestState != null) {
logger.warn("***** ######## VF Module Creation timeout. Status: ( {})", responseGet.request.requestStatus.requestState);
}
+
return responseGet;
} catch (JsonSyntaxException e) {
logger.error("Failed to deserialize into MSOResponse: ", e);
diff --git a/controlloop/common/model-impl/mso/src/test/java/org/onap/policy/mso/TestDemo.java b/controlloop/common/model-impl/mso/src/test/java/org/onap/policy/mso/TestDemo.java
index c840894e8..2c8253f0b 100644
--- a/controlloop/common/model-impl/mso/src/test/java/org/onap/policy/mso/TestDemo.java
+++ b/controlloop/common/model-impl/mso/src/test/java/org/onap/policy/mso/TestDemo.java
@@ -33,9 +33,11 @@ import org.onap.policy.mso.MSORequestDetails;
import org.onap.policy.mso.MSORequestInfo;
import org.onap.policy.mso.MSORequestParameters;
import org.onap.policy.mso.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestDemo {
-
+ private static final Logger logger = LoggerFactory.getLogger(TestDemo.class);
@Test
public void test() {
@@ -102,19 +104,19 @@ public class TestDemo {
request.requestDetails.requestParameters.userParams.add(userParam2);
String body = Serialization.gsonPretty.toJson(request);
- System.out.println(body);
+ logger.debug(body);
//MSOResponse response = MSOManager.createModuleInstance("http://localhost:7780/", "my_username", "my_passwd", request);
//body = Serialization.gsonPretty.toJson(response);
- //System.out.println(body);
+ //logger.debug(body);
}
@Test
public void testHack() {
- System.out.println("** HACK **");
+ logger.debug("** HACK **");
MSORequest request = new MSORequest();
//
@@ -166,7 +168,7 @@ public class TestDemo {
request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
String body = Serialization.gsonPretty.toJson(request);
- System.out.println(body);
+ logger.debug(body);
}
}
diff --git a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
index c38c1076c..9ea480981 100644
--- a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
+++ b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
@@ -55,14 +55,14 @@ public final class RESTManager {
CredentialsProvider credentials = new BasicCredentialsProvider();
credentials.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
- System.out.println("HTTP REQUEST: " + url + " -> " + username + ((password!=null)?password.length():"-") + " -> " + contentType);
+ logger.debug("HTTP REQUEST: {} -> {} {} -> {}", url, username, ((password!=null)?password.length():"-"), contentType);
if (headers != null) {
- System.out.println("Headers: ");
+ logger.debug("Headers: ");
headers.forEach((name, value) -> {
- System.out.println(name + " -> " + value);
+ logger.debug("{} -> {}", name, value);
});
}
- System.out.println(body);
+ logger.debug(body);
try (CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) {
@@ -81,9 +81,9 @@ public final class RESTManager {
HttpResponse response = client.execute(post);
String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
- System.out.println("HTTP POST Response Status Code: " + response.getStatusLine().getStatusCode());
- System.out.println("HTTP POST Response Body:");
- System.out.println(returnBody);
+ logger.debug("HTTP POST Response Status Code: {}", response.getStatusLine().getStatusCode());
+ logger.debug("HTTP POST Response Body:");
+ logger.debug(returnBody);
return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
} catch (IOException e) {
@@ -111,8 +111,10 @@ public final class RESTManager {
HttpResponse response = client.execute(get);
String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
- logger.debug("HTTP GET Response Status Code: " + response.getStatusLine().getStatusCode());
- logger.debug("HTTP GET Response Body: " + returnBody);
+
+ logger.debug("HTTP GET Response Status Code: {}", response.getStatusLine().getStatusCode());
+ logger.debug("HTTP GET Response Body:");
+ logger.debug(returnBody);
return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
} catch (IOException e) {
diff --git a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java
index 656234ca2..4b3599d43 100644
--- a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java
+++ b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java
@@ -26,9 +26,11 @@ import org.onap.policy.vnf.trafficgenerator.PGRequest;
import org.onap.policy.vnf.trafficgenerator.PGStream;
import org.onap.policy.vnf.trafficgenerator.PGStreams;
import org.onap.policy.vnf.trafficgenerator.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestDemo {
-
+ private static final Logger logger = LoggerFactory.getLogger(TestDemo.class);
@Test
public void test() {
PGRequest request = new PGRequest();
@@ -43,7 +45,7 @@ public class TestDemo {
}
String body = Serialization.gsonPretty.toJson(request);
- System.out.println(body);
+ logger.debug(body);
// fail("Not yet implemented");
}
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
index 44f9905b2..0aade0744 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
@@ -24,6 +24,8 @@ import java.util.Map;
import org.onap.policy.vfc.util.Serialization;
import org.onap.policy.rest.RESTManager;
import org.onap.policy.rest.RESTManager.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.JsonSyntaxException;
@@ -33,7 +35,8 @@ public final class VFCManager implements Runnable {
private String username;
private String password;
private VFCRequest vfcRequest;
-
+ private static final Logger logger = LoggerFactory.getLogger(VFCManager.class);
+
public VFCManager(VFCRequest request) {
vfcRequest = request;
// TODO: Get base URL, username and password from MSB?
@@ -67,8 +70,8 @@ public final class VFCManager implements Runnable {
VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
String body = Serialization.gsonPretty.toJson(response);
- System.out.println("Response to VFC Heal post:");
- System.out.println(body);
+ logger.debug("Response to VFC Heal post:");
+ logger.debug(body);
String jobId = response.jobId;
int attemptsLeft = 20;
@@ -81,27 +84,27 @@ public final class VFCManager implements Runnable {
Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, VFCResponse.class);
body = Serialization.gsonPretty.toJson(responseGet);
- System.out.println("Response to VFC Heal get:");
- System.out.println(body);
+ logger.debug("Response to VFC Heal get:");
+ logger.debug(body);
if (httpDetailsGet.a == 200) {
if (responseGet.responseDescriptor.status.equalsIgnoreCase("finished") ||
responseGet.responseDescriptor.status.equalsIgnoreCase("error")) {
- System.out.println("VFC Heal Status " + responseGet.responseDescriptor.status);
+ logger.debug("VFC Heal Status {}", responseGet.responseDescriptor.status);
break;
}
}
Thread.sleep(20000);
}
if (attemptsLeft <= 0)
- System.out.println("VFC timeout. Status: (" + responseGet.responseDescriptor.status + ")");
+ logger.debug("VFC timeout. Status: ({})", responseGet.responseDescriptor.status);
} catch (JsonSyntaxException e) {
- System.err.println("Failed to deserialize into VFCResponse" + e.getLocalizedMessage());
+ logger.error("Failed to deserialize into VFCResponse {}",e.getLocalizedMessage(),e);
} catch (InterruptedException e) {
- System.err.println("Interrupted exception: " + e.getLocalizedMessage());
+ logger.error("Interrupted exception: {}", e.getLocalizedMessage(), e);
}
} else {
- System.out.println("VFC Heal Restcall failed");
+ logger.warn("VFC Heal Restcall failed");
}
}
}
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java
index b0d15463d..b847009cc 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java
@@ -29,6 +29,8 @@ import java.io.IOException;
import java.io.InputStream;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.Yaml;
@@ -36,7 +38,7 @@ import org.yaml.snakeyaml.constructor.Constructor;
public class ControlLoopPolicyTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopPolicyTest.class);
@Test
public void test() {
this.test("src/test/resources/v1.0.0/policy_Test.yaml");
@@ -91,7 +93,7 @@ public class ControlLoopPolicyTest {
options.setPrettyFlow(true);
yaml = new Yaml(options);
String dumpedYaml = yaml.dump(obj);
- System.out.println(dumpedYaml);
+ logger.debug(dumpedYaml);
//
// Read that string back into our java object
//
@@ -112,7 +114,7 @@ public class ControlLoopPolicyTest {
}
public void dump(Object obj) {
- System.out.println("Dumping " + obj.getClass().getCanonicalName());
- System.out.println(obj.toString());
+ logger.debug("Dumping ", obj.getClass().getCanonicalName());
+ logger.debug("{}", obj);
}
}
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
index da81db394..36cf34e5f 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
@@ -40,11 +40,13 @@ import org.onap.policy.controlloop.policy.builder.Message;
import org.onap.policy.controlloop.policy.builder.MessageLevel;
import org.onap.policy.controlloop.policy.builder.Results;
import org.onap.policy.controlloop.policy.guard.builder.ControlLoopGuardBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
public class ControlLoopGuardBuilderTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopGuardBuilderTest.class);
@Test
public void testControlLoopGuard() {
try {
@@ -190,7 +192,7 @@ public class ControlLoopGuardBuilderTest {
//
// Print out the specification
//
- System.out.println(results.getSpecification());
+ logger.debug(results.getSpecification());
//
} catch (FileNotFoundException e) {
fail(e.getLocalizedMessage());
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java
index 61ad4dfbf..d1a35413e 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java
@@ -29,6 +29,8 @@ import java.io.IOException;
import java.io.InputStream;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.Yaml;
@@ -36,7 +38,7 @@ import org.yaml.snakeyaml.constructor.Constructor;
public class ControlLoopGuardTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopGuardTest.class);
@Test
public void testGuardvDNS() {
this.test("src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml");
@@ -66,7 +68,7 @@ public class ControlLoopGuardTest {
options.setPrettyFlow(true);
yaml = new Yaml(options);
String dumpedYaml = yaml.dump(obj);
- System.out.println(dumpedYaml);
+ logger.debug(dumpedYaml);
//
// Read that string back into our java object
//
@@ -87,7 +89,7 @@ public class ControlLoopGuardTest {
}
public void dump(Object obj) {
- System.out.println("Dumping " + obj.getClass().getCanonicalName());
- System.out.println(obj.toString());
+ logger.debug("Dumping {}", obj.getClass().getCanonicalName());
+ logger.debug("{}", obj);
}
}
diff --git a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestAPPCPayload.java b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestAPPCPayload.java
index 73501bce5..42b28d2f4 100644
--- a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestAPPCPayload.java
+++ b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestAPPCPayload.java
@@ -30,9 +30,12 @@ import org.onap.policy.appc.util.Serialization;
import org.onap.policy.vnf.trafficgenerator.PGRequest;
import org.onap.policy.vnf.trafficgenerator.PGStream;
import org.onap.policy.vnf.trafficgenerator.PGStreams;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestAPPCPayload {
+ private static final Logger logger = LoggerFactory.getLogger(TestAPPCPayload.class);
@Test
public void test() {
PGRequest request = new PGRequest();
@@ -52,7 +55,7 @@ public class TestAPPCPayload {
appc.Action = "ModifyConfig";
appc.Payload = new HashMap<String, Object>();
appc.Payload.put("pg-streams", request);
- System.out.println(Serialization.gsonPretty.toJson(appc));
+ logger.debug(Serialization.gsonPretty.toJson(appc));
}
}
diff --git a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestFirewallDemo.java b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestFirewallDemo.java
index e48aafdad..2cfead157 100644
--- a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestFirewallDemo.java
+++ b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestFirewallDemo.java
@@ -50,12 +50,13 @@ import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.appc.util.Serialization;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestFirewallDemo {
-
+ private static final Logger logger = LoggerFactory.getLogger(TestFirewallDemo.class);
@Test
public void testvDNS() throws IOException {
//
@@ -105,8 +106,8 @@ public class TestFirewallDemo {
invalidEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
invalidEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- System.out.println("----- Invalid ONSET -----");
- System.out.println(Serialization.gsonPretty.toJson(invalidEvent));
+ logger.debug("----- Invalid ONSET -----");
+ logger.debug(Serialization.gsonPretty.toJson(invalidEvent));
//
// Insert invalid DCAE Event into memory
@@ -131,8 +132,8 @@ public class TestFirewallDemo {
onsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- System.out.println("----- ONSET -----");
- System.out.println(Serialization.gsonPretty.toJson(onsetEvent));
+ logger.debug("----- ONSET -----");
+ logger.debug(Serialization.gsonPretty.toJson(onsetEvent));
//
// Insert first DCAE ONSET Event into memory
@@ -221,8 +222,8 @@ public class TestFirewallDemo {
invalidEvent.AAI.put("generic-vnf.vnf-id", "foo");
invalidEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- System.out.println("----- Invalid ONSET -----");
- System.out.println(Serialization.gsonPretty.toJson(invalidEvent));
+ logger.debug("----- Invalid ONSET -----");
+ logger.debug(Serialization.gsonPretty.toJson(invalidEvent));
//
// Insert invalid DCAE Event into memory
@@ -248,8 +249,8 @@ public class TestFirewallDemo {
//onsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- System.out.println("----- ONSET -----");
- System.out.println(Serialization.gsonPretty.toJson(onsetEvent));
+ logger.debug("----- ONSET -----");
+ logger.debug(Serialization.gsonPretty.toJson(onsetEvent));
//
// Insert first DCAE ONSET Event into memory
@@ -282,8 +283,8 @@ public class TestFirewallDemo {
//subOnsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
subOnsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- System.out.println("----- Subsequent ONSET -----");
- System.out.println(Serialization.gsonPretty.toJson(subOnsetEvent));
+ logger.debug("----- Subsequent ONSET -----");
+ logger.debug(Serialization.gsonPretty.toJson(subOnsetEvent));
//
// Insert subsequent DCAE ONSET Event into memory
@@ -320,8 +321,8 @@ public class TestFirewallDemo {
responseStatus1.Code = 100;
response1.Status = responseStatus1;
//
- System.out.println("----- APP-C RESPONSE 100 -----");
- System.out.println(Serialization.gsonPretty.toJson(response1));
+ logger.debug("----- APP-C RESPONSE 100 -----");
+ logger.debug(Serialization.gsonPretty.toJson(response1));
//
// Insert APPC Response into memory
//
@@ -347,8 +348,8 @@ public class TestFirewallDemo {
responseStatus2.Code = 400;
response2.Status = responseStatus2;
//
- System.out.println("----- APP-C RESPONSE 400 -----");
- System.out.println(Serialization.gsonPretty.toJson(response2));
+ logger.debug("----- APP-C RESPONSE 400 -----");
+ logger.debug(Serialization.gsonPretty.toJson(response2));
//
// Insert APPC Response into memory
//
@@ -385,9 +386,9 @@ public class TestFirewallDemo {
}
public static void dumpFacts(KieSession kieSession) {
- System.out.println("Fact Count: " + kieSession.getFactCount());
+ logger.debug("Fact Count: {}", kieSession.getFactCount());
for (FactHandle handle : kieSession.getFactHandles()) {
- System.out.println("FACT: " + handle);
+ logger.debug("FACT: {}", handle);
}
}
@@ -414,7 +415,7 @@ public class TestFirewallDemo {
KieModuleModel kModule = ks.newKieModuleModel();
- System.out.println("KMODULE:" + System.lineSeparator() + kModule.toXML());
+ logger.debug("KMODULE: {} {}", System.lineSeparator(), kModule.toXML());
//
// Generate our drools rule from our template
@@ -452,18 +453,18 @@ public class TestFirewallDemo {
Results results = builder.getResults();
if (results.hasMessages(Message.Level.ERROR)) {
for (Message msg : results.getMessages()) {
- System.err.println(msg.toString());
+ logger.error("{}", msg);
}
throw new RuntimeException("Drools Rule has Errors");
}
for (Message msg : results.getMessages()) {
- System.out.println(msg.toString());
+ logger.debug("{}", msg);
}
//
// Create our kie Session and container
//
ReleaseId releaseId = ks.getRepository().getDefaultReleaseId();
- System.out.println(releaseId);
+ logger.debug("{}", releaseId);
KieContainer kContainer = ks.newKieContainer(releaseId);
return kContainer.newKieSession();
@@ -585,7 +586,7 @@ public class TestFirewallDemo {
ruleContents = m.replaceAll(appcTopic);
}
- System.out.println(ruleContents);
+ logger.debug(ruleContents);
return ruleContents;
}
diff --git a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestMSO.java b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestMSO.java
index a960661ee..fab0961c5 100644
--- a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestMSO.java
+++ b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestMSO.java
@@ -36,19 +36,23 @@ import org.onap.policy.mso.MSORequestParameters;
import org.onap.policy.aai.AAINQF199.AAINQF199Response;
import org.onap.policy.aai.AAINQF199.AAINQF199ResponseWrapper;
import org.onap.policy.mso.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
public class TestMSO {
+ private static final Logger logger = LoggerFactory.getLogger(TestMSO.class);
+
@Test
public void test() throws FileNotFoundException {
Gson gson = new Gson();
JsonReader reader = new JsonReader(new FileReader("src/test/resources/aairesponse.json"));
AAINQF199Response response = gson.fromJson(reader, AAINQF199Response.class);
- System.out.println(Serialization.gsonPretty.toJson(response));
+ logger.debug(Serialization.gsonPretty.toJson(response));
AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper(UUID.randomUUID(), response);
@@ -152,8 +156,8 @@ public class TestMSO {
//
// print MSO request for debug
//
- System.out.println("MSO request sent:");
- System.out.println(Serialization.gsonPretty.toJson(request));
+ logger.debug("MSO request sent:");
+ logger.debug(Serialization.gsonPretty.toJson(request));
}
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java
index 18c0a2098..1fce83d2c 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java
@@ -78,6 +78,8 @@ import org.onap.policy.controlloop.policy.TargetType;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
import org.onap.policy.guard.PolicyGuard;
import org.onap.policy.guard.PolicyGuardYamlToXacml;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.research.xacml.api.pdp.PDPEngine;
import com.att.research.xacml.api.pdp.PDPEngineFactory;
import com.att.research.xacml.util.FactoryException;
@@ -87,7 +89,7 @@ import com.att.research.xacml.util.XACMLProperties;
public class ControlLoopXacmlGuardTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopXacmlGuardTest.class);
@Test
public void test() {
@@ -129,9 +131,9 @@ public class ControlLoopXacmlGuardTest {
- System.out.println("============");
- System.out.println(URLEncoder.encode(pair.b, "UTF-8"));
- System.out.println("============");
+ logger.debug("============");
+ logger.debug(URLEncoder.encode(pair.b, "UTF-8"));
+ logger.debug("============");
kieSession.addEventListener(new RuleRuntimeEventListener() {
@@ -152,7 +154,7 @@ public class ControlLoopXacmlGuardTest {
@Override
public void matchCreated(MatchCreatedEvent event) {
- //System.out.println("matchCreated: " + event.getMatch().getRule());
+ //logger.debug("matchCreated: " + event.getMatch().getRule());
}
@Override
@@ -161,7 +163,7 @@ public class ControlLoopXacmlGuardTest {
@Override
public void beforeMatchFired(BeforeMatchFiredEvent event) {
- //System.out.println("beforeMatchFired: " + event.getMatch().getRule() + event.getMatch().getObjects());
+ //logger.debug("beforeMatchFired: " + event.getMatch().getRule() + event.getMatch().getObjects());
}
@Override
@@ -222,7 +224,6 @@ public class ControlLoopXacmlGuardTest {
//
// Insert our globals
//
- final ControlLoopLogger logger = new ControlLoopLoggerStdOutImpl();
kieSession.setGlobal("Logger", logger);
final PolicyEngineJUnitImpl engine = new PolicyEngineJUnitImpl();
kieSession.setGlobal("Engine", engine);
@@ -283,8 +284,8 @@ public class ControlLoopXacmlGuardTest {
// "About to query Guard" notification (Querying about Restart)
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("\n\n####################### GOING TO QUERY GUARD about Restart!!!!!!");
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("\n\n####################### GOING TO QUERY GUARD about Restart!!!!!!");
+ logger.debug("Rule: {} Message {}", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
@@ -292,7 +293,7 @@ public class ControlLoopXacmlGuardTest {
// "Response from Guard" notification
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("Rule: {} Message {}", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
@@ -302,8 +303,8 @@ public class ControlLoopXacmlGuardTest {
// "About to query Guard" notification (Querying about Rebuild)
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("\n\n####################### GOING TO QUERY GUARD about Rebuild!!!!!!");
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("\n\n####################### GOING TO QUERY GUARD about Rebuild!!!!!!");
+ logger.debug("Rule: {} Message", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
@@ -312,7 +313,7 @@ public class ControlLoopXacmlGuardTest {
// "Response from Guard" notification
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("Rule: {} Message {}", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
@@ -322,8 +323,8 @@ public class ControlLoopXacmlGuardTest {
// "About to query Guard" notification (Querying about Migrate)
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("\n\n####################### GOING TO QUERY GUARD!!!!!!");
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("\n\n####################### GOING TO QUERY GUARD!!!!!!");
+ logger.debug("Rule: {} Message {}", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
@@ -332,7 +333,7 @@ public class ControlLoopXacmlGuardTest {
// "Response from Guard" notification
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
@@ -351,7 +352,7 @@ public class ControlLoopXacmlGuardTest {
if(true == ((VirtualControlLoopNotification)obj).message.contains("Guard result: Permit")){
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("Rule: {} Message {}", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
@@ -362,7 +363,7 @@ public class ControlLoopXacmlGuardTest {
assertTrue(obj instanceof Request);
assertTrue(((Request)obj).CommonHeader.SubRequestID.equals("1"));
- System.out.println("\n============ APP-C Got request!!! ===========\n");
+ logger.debug("\n============ APP-C Got request!!! ===========\n");
//
// Ok - let's simulate ACCEPT
//
@@ -402,12 +403,12 @@ public class ControlLoopXacmlGuardTest {
} catch (InterruptedException e) {
- System.err.println("Test thread got InterruptedException " + e.getLocalizedMessage());
+ logger.error("Test thread got InterruptedException ", e.getLocalizedMessage());
} catch (AssertionError e) {
- System.err.println("Test thread got AssertionError " + e.getLocalizedMessage());
+ logger.error("Test thread got AssertionError ", e.getLocalizedMessage());
e.printStackTrace();
} catch (Exception e) {
- System.err.println("Test thread got Exception " + e.getLocalizedMessage());
+ logger.error("Test thread got Exception ", e.getLocalizedMessage());
e.printStackTrace();
}
kieSession.halt();
@@ -437,9 +438,9 @@ public class ControlLoopXacmlGuardTest {
public static void dumpFacts(KieSession kieSession) {
- System.out.println("Fact Count: " + kieSession.getFactCount());
+ logger.debug("Fact Count: {}", kieSession.getFactCount());
for (FactHandle handle : kieSession.getFactHandles()) {
- System.out.println("FACT: " + handle);
+ logger.debug("FACT: {}", handle);
}
}
@@ -559,7 +560,7 @@ public class ControlLoopXacmlGuardTest {
p = Pattern.compile("\\$\\{controlLoopYaml\\}");
m = p.matcher(ruleContents);
ruleContents = m.replaceAll(controlLoopYaml);
- System.out.println(ruleContents);
+ logger.debug(ruleContents);
return ruleContents;
}
@@ -572,7 +573,7 @@ public class ControlLoopXacmlGuardTest {
KieModuleModel kModule = ks.newKieModuleModel();
- System.out.println("KMODULE:" + System.lineSeparator() + kModule.toXML());
+ logger.debug("KMODULE: {} {}", System.lineSeparator(), kModule.toXML());
//
// Generate our drools rule from our template
@@ -599,18 +600,18 @@ public class ControlLoopXacmlGuardTest {
Results results = builder.getResults();
if (results.hasMessages(Message.Level.ERROR)) {
for (Message msg : results.getMessages()) {
- System.err.println(msg.toString());
+ logger.error("{}", msg);
}
throw new RuntimeException("Drools Rule has Errors");
}
for (Message msg : results.getMessages()) {
- System.out.println(msg.toString());
+ logger.debug("{}", msg);
}
//
// Create our kie Session and container
//
ReleaseId releaseId = ks.getRepository().getDefaultReleaseId();
- System.out.println(releaseId);
+ logger.debug("{}", releaseId);
KieContainer kContainer = ks.newKieContainer(releaseId);
return kContainer.newKieSession();
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
index 2793f9aa2..62e7341a5 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
@@ -35,9 +35,12 @@ import org.yaml.snakeyaml.constructor.Constructor;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class Util {
+ private static final Logger logger = LoggerFactory.getLogger(Util.class);
public static class Pair<A, B> {
public final A a;
public final B b;
@@ -58,7 +61,7 @@ public final class Util {
Object obj = yaml.load(contents);
//String ttt = ((ControlLoopPolicy)obj).policies.getFirst().payload.get("asdas");
- System.out.println(contents);
+ logger.debug(contents);
//for(Policy policy : ((ControlLoopPolicy)obj).policies){
return new Pair<ControlLoopPolicy, String>((ControlLoopPolicy) obj, contents);