diff options
Diffstat (limited to 'policy-management/src/test/java')
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"); |