aboutsummaryrefslogtreecommitdiffstats
path: root/policy-management/src/test
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-10-09 08:07:36 -0500
committerJorge Hernandez <jh1730@att.com>2017-10-09 08:07:36 -0500
commit86b60d8d28e4891259094fa1e936c6e579620b29 (patch)
tree7edb5f2a0cba0eab991db119589b24ee088d7a69 /policy-management/src/test
parent552048293a269ba961f526f45a89e433b7b073ea (diff)
send messages directly through topic
This work is needed for consolidating the amsterdam templates used both for junits and the official one from the archetype into one, so junits can run in the official one. This work revisits the functionality of when a drools controller cannot be found to check state before delivering a message from the drools application, it will use a standalone enconder (previously configured to do so). This was intended to work like this originally, but never tested nor used as all deliveries are send through the controllers so locked/alive state is checked (but there may ocassions where we want to take this default action). Change-Id: Ie23e4e13323f3ab9fd207f8a396c1af6564b7edf Issue-ID: POLICY-101 Signed-off-by: Jorge Hernandez <jh1730@att.com>
Diffstat (limited to 'policy-management/src/test')
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java11
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/test/PolicyEngineTest.java46
2 files changed, 47 insertions, 10 deletions
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java
index 17ed8653..682cbac3 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Configuration Test
+ * ONAP
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -25,24 +25,15 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
import org.junit.Test;
-
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
import org.onap.policy.drools.protocol.coders.JsonProtocolFilter.FilterRule;
-
import org.onap.policy.drools.utils.Pair;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class JsonProtocolFilterTest {
- private static final Logger logger = LoggerFactory.getLogger(JsonProtocolFilterTest.class);
-
private static final String NAME1 = "name1";
private static final String REGEX1 = "regex1";
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/test/PolicyEngineTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/test/PolicyEngineTest.java
index 9d52bc5c..38f4e9b8 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/test/PolicyEngineTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/test/PolicyEngineTest.java
@@ -34,8 +34,13 @@ import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.onap.policy.drools.event.comm.TopicEndpoint;
+import org.onap.policy.drools.event.comm.TopicSink;
+import org.onap.policy.drools.event.comm.bus.NoopTopicSink;
import org.onap.policy.drools.persistence.SystemPersistence;
import org.onap.policy.drools.properties.PolicyProperties;
+import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
+import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
+import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
@@ -68,6 +73,26 @@ public class PolicyEngineTest {
public static final String TEST_CONTROLLER_FILE_BAK = TEST_CONTROLLER_FILE + ".bak";
/**
+ * Coder Group
+ */
+ private static final String ENCODER_GROUP = "foo";
+
+ /**
+ * Coder Artifact
+ */
+ private static final String ENCODER_ARTIFACT = "bar";
+
+ /**
+ * Coder Version
+ */
+ private static final String ENCODER_VERSION = null;
+
+ /**
+ * noop topic
+ */
+ private static final String NOOP_TOPIC = "JUNIT";
+
+ /**
* logger
*/
private static Logger logger = LoggerFactory.getLogger(PolicyEngineTest.class);
@@ -166,6 +191,27 @@ public class PolicyEngineTest {
}
@Test
+ public void test350TopicDeliver() {
+ final Properties noopSinkProperties = new Properties();
+ noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, NOOP_TOPIC);
+
+ TopicEndpoint.manager.addTopicSinks(noopSinkProperties).get(0).start();
+
+ EventProtocolCoder.manager.addEncoder(ENCODER_GROUP, ENCODER_ARTIFACT, NOOP_TOPIC,
+ DroolsConfiguration.class.getCanonicalName(), new JsonProtocolFilter(), null, null,
+ DroolsConfiguration.class.getName().hashCode());
+
+ assertTrue(PolicyEngine.manager.deliver(NOOP_TOPIC,
+ new DroolsConfiguration(ENCODER_GROUP, ENCODER_ARTIFACT, ENCODER_VERSION)));
+
+ final TopicSink sink = NoopTopicSink.factory.get(NOOP_TOPIC);
+ assertTrue(sink.getRecentEvents()[0].contains(ENCODER_GROUP));
+ assertTrue(sink.getRecentEvents()[0].contains(ENCODER_ARTIFACT));
+
+ EventProtocolCoder.manager.removeEncoders(ENCODER_GROUP, ENCODER_ARTIFACT, NOOP_TOPIC);
+ }
+
+ @Test
public void test400ControllerAdd() throws Exception {
logger.info("enter");