summaryrefslogtreecommitdiffstats
path: root/controlloop/templates
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/templates')
-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
5 files changed, 68 insertions, 56 deletions
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 bad984bc9..20565c296 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);
@Ignore
@Test
@@ -130,9 +132,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() {
@@ -153,7 +155,7 @@ public class ControlLoopXacmlGuardTest {
@Override
public void matchCreated(MatchCreatedEvent event) {
- //System.out.println("matchCreated: " + event.getMatch().getRule());
+ //logger.debug("matchCreated: " + event.getMatch().getRule());
}
@Override
@@ -162,7 +164,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
@@ -223,7 +225,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);
@@ -284,8 +285,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));
@@ -293,7 +294,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));
@@ -303,8 +304,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));
@@ -313,7 +314,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));
@@ -323,8 +324,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));
@@ -333,7 +334,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));
@@ -352,7 +353,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));
@@ -363,7 +364,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
//
@@ -403,12 +404,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();
@@ -438,9 +439,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);
}
}
@@ -560,7 +561,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;
}
@@ -573,7 +574,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
@@ -600,18 +601,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);