summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java23
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java4
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java112
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/DmaapTopicSourceFactory.java3
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/UebTopicSourceFactory.java3
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java2
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java83
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java106
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java100
-rw-r--r--policy-management/src/test/resources/echo.drl36
-rw-r--r--policy-management/src/test/resources/echo.kmodule26
-rw-r--r--policy-management/src/test/resources/echo.pom31
13 files changed, 511 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore
index 30e60521..eb32cca6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,8 +8,10 @@
*.log
*.out
.metadata/
+.idea/
target/
*/logs/
*/sql/
*/testingLogs/
*/config/
+**/*.iml
diff --git a/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java b/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java
index 70ad3719..107b207e 100644
--- a/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java
+++ b/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java
@@ -25,7 +25,6 @@ import java.util.Observer;
import javax.validation.constraints.NotNull;
import org.onap.policy.common.im.AllSeemsWellException;
-import org.onap.policy.common.im.StandbyStatusException;
import org.onap.policy.common.im.StateManagement;
import org.onap.policy.drools.properties.Lockable;
import org.onap.policy.drools.utils.OrderedService;
@@ -42,7 +41,7 @@ import org.onap.policy.drools.utils.OrderedServiceImpl;
public interface StateManagementFeatureAPI extends OrderedService, Lockable
{
- public static final String LOCKED = StateManagement.LOCKED;
+ public static final String LOCKED = StateManagement.LOCKED;
public static final String UNLOCKED = StateManagement.UNLOCKED;
public static final String ENABLED = StateManagement.ENABLED;
public static final String DISABLED = StateManagement.DISABLED;
@@ -54,10 +53,10 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable
public static final String DISABLE_DEPENDENCY = StateManagement.DISABLE_DEPENDENCY;
public static final String ENABLE_NO_DEPENDENCY = StateManagement.ENABLE_NO_DEPENDENCY;
public static final String NULL_VALUE = StateManagement.NULL_VALUE;
- public static final String LOCK = StateManagement.LOCK;
- public static final String UNLOCK = StateManagement.UNLOCK;
- public static final String PROMOTE = StateManagement.PROMOTE;
- public static final String DEMOTE = StateManagement.DEMOTE;
+ public static final String DO_LOCK = StateManagement.LOCK;
+ public static final String DO_UNLOCK = StateManagement.UNLOCK;
+ public static final String DO_PROMOTE = StateManagement.PROMOTE;
+ public static final String DO_DEMOTE = StateManagement.DEMOTE;
public static final String HOT_STANDBY = StateManagement.HOT_STANDBY;
public static final String COLD_STANDBY = StateManagement.COLD_STANDBY;
public static final String PROVIDING_SERVICE = StateManagement.PROVIDING_SERVICE;
@@ -67,8 +66,8 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable
public static final String AVAILABLE_STATUS= StateManagement.AVAILABLE_STATUS;
public static final String STANDBY_STATUS = StateManagement.STANDBY_STATUS;
- static public final Boolean ALLSEEMSWELL = Boolean.TRUE;
- static public final Boolean ALLNOTWELL = Boolean.FALSE;
+ public static final Boolean ALLSEEMSWELL_STATE = Boolean.TRUE;
+ public static final Boolean ALLNOTWELL_STATE = Boolean.FALSE;
public static final int SEQ_NUM = 0;
/**
@@ -95,11 +94,10 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable
* @param asw - This is the indicator of health. See constants: ALLSEEMSWELL or ALLNOTWELL
* @param msg - A message is required. It should indicate why all is not well or a message indicating
* that a component has been restored to health (perhaps indicating the problem that has resolved).
- * @throws IllegalArgumentException
* @throws AllSeemsWellException
*/
public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
- throws IllegalArgumentException, AllSeemsWellException;
+ throws AllSeemsWellException;
/**
* This method is called to add an Observer to receive notifications of state changes
@@ -168,10 +166,9 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable
* to providingservice. If the current value is coldstandby, no change is made.
* If the current value is null, it will move to providingservice assuming the
* Operational State is enabled and Administrative State is unlocked.
- * @throws Exception
- * @throws StandbyStatusException
+ * @throws Exception
*/
- public void promote() throws StandbyStatusException, Exception;
+ public void promote() throws Exception;
/**
* This method moves the X.731 Standby Status for this resource from providingservice
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
index 13348c78..2836f92f 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
@@ -955,7 +955,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
logger.debug("checkWaitTimer: calling allSeemsWell with ALLNOTWELL param");
}
stateManagementFeature.allSeemsWell(this.getClass().getName(),
- StateManagementFeatureAPI.ALLNOTWELL,
+ StateManagementFeatureAPI.ALLNOTWELL_STATE,
"DesignationWaiter/ElectionHandler has STALLED");
}
logger.error("checkWaitTimer: nowMs - waitTimerMs = {}"
@@ -964,7 +964,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
}else if(allSeemsWell==null || !allSeemsWell){
allSeemsWell = true;
stateManagementFeature.allSeemsWell(this.getClass().getName(),
- StateManagementFeatureAPI.ALLSEEMSWELL,
+ StateManagementFeatureAPI.ALLSEEMSWELL_STATE,
"DesignationWaiter/ElectionHandler has RESUMED");
logger.info("DesignationWaiter/ElectionHandler has RESUMED");
}
diff --git a/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java b/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java
new file mode 100644
index 00000000..59ee5119
--- /dev/null
+++ b/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import org.drools.compiler.kie.builder.impl.InternalKieModule;
+import org.drools.compiler.kproject.models.KieModuleModelImpl;
+import org.kie.api.KieServices;
+import org.kie.api.builder.KieBuilder;
+import org.kie.api.builder.KieFileSystem;
+import org.kie.api.builder.Message;
+import org.kie.api.builder.ReleaseId;
+import org.kie.api.builder.model.KieModuleModel;
+import org.kie.scanner.MavenRepository;
+
+/**
+ * Kie related utilities
+ */
+public class KieUtils {
+
+ /**
+ * Installs a rules artifact in the local maven repository
+ *
+ * @param kmodule kmodule specification
+ * @param pom pom
+ * @param drlKJarPath path used in kjar drl to the actual drl
+ * @param drl rules in drl language
+ *
+ * @return releaseId result o a sucessful installation
+ * @throws IOException error accessing necessary resources
+ */
+ public static ReleaseId installArtifact(String kmodule, String pom, String drlKJarPath, String drl) throws IOException {
+ KieModuleModel kieModule = KieModuleModelImpl.fromXML(kmodule);
+
+ final KieFileSystem kieFileSystem = KieServices.Factory.get().newKieFileSystem();
+ kieFileSystem.writeKModuleXML(kieModule.toXML());
+ kieFileSystem.writePomXML(pom);
+ kieFileSystem.write(drlKJarPath, drl);
+
+ KieBuilder kieBuilder = kieBuild(kieFileSystem);
+
+ Path pomPath = Files.createTempFile("policy-core-", ".pom");
+ Files.write(pomPath, pom.getBytes(StandardCharsets.UTF_8));
+ File pomFile = pomPath.toFile();
+ pomFile.deleteOnExit();
+
+ ReleaseId releaseId = kieBuilder.getKieModule().getReleaseId();
+ MavenRepository.getMavenRepository().
+ installArtifact(releaseId,
+ (InternalKieModule) kieBuilder.getKieModule(),
+ pomFile);
+ return releaseId;
+ }
+
+ /**
+ * Installs a rules artifact in the local maven repository
+ *
+ * @param kmodule kmodule specification
+ * @param pom pom
+ * @param drlKJarPath path used in kjar drl to the actual drl
+ * @param drl rules in drl language
+ *
+ * @return releaseId result o a sucessful installation
+ * @throws IOException error accessing necessary resources
+ */
+ public static ReleaseId installArtifact(File kmodule, File pom, String drlKJarPath, File drl) throws IOException {
+ KieModuleModel kieModule = KieModuleModelImpl.fromXML(kmodule);
+
+ final KieFileSystem kieFileSystem = KieServices.Factory.get().newKieFileSystem();
+ kieFileSystem.writeKModuleXML(kieModule.toXML());
+ kieFileSystem.writePomXML(new String(Files.readAllBytes(pom.toPath())));
+ kieFileSystem.write(drlKJarPath, new String(Files.readAllBytes(drl.toPath())));
+
+ KieBuilder kieBuilder = kieBuild(kieFileSystem);
+
+ ReleaseId releaseId = kieBuilder.getKieModule().getReleaseId();
+ MavenRepository.getMavenRepository().
+ installArtifact(releaseId, (InternalKieModule) kieBuilder.getKieModule(), pom);
+ return releaseId;
+ }
+
+ private static KieBuilder kieBuild(KieFileSystem kieFileSystem) {
+ KieBuilder kieBuilder = KieServices.Factory.get().newKieBuilder(kieFileSystem);
+ List<Message> messages = kieBuilder.buildAll().getResults().getMessages();
+ if (messages != null && !messages.isEmpty())
+ throw new IllegalArgumentException(messages.toString());
+ return kieBuilder;
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/DmaapTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/DmaapTopicSourceFactory.java
index 13808329..d5894d5e 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/DmaapTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/DmaapTopicSourceFactory.java
@@ -158,7 +158,6 @@ public interface DmaapTopicSourceFactory {
/**
* Instantiates a new DMAAP Topic Source
*
- * @param uebTopicReaderType Implementation type
* @param servers list of servers
* @param topic topic name
*
@@ -445,7 +444,7 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
String fetchLimitString = properties.getProperty(PolicyProperties.PROPERTY_DMAAP_SOURCE_TOPICS +
"." + topic +
- PolicyProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX);
+ PolicyProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX);
int fetchLimit = DmaapTopicSource.DEFAULT_LIMIT_FETCH;
if (fetchLimitString != null && !fetchLimitString.isEmpty()) {
try {
diff --git a/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/UebTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/UebTopicSourceFactory.java
index d2aa6710..d614d100 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/UebTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/UebTopicSourceFactory.java
@@ -96,7 +96,6 @@ public interface UebTopicSourceFactory {
/**
* Instantiates a new UEB Topic Source
*
- * @param uebTopicSourceType Implementation type
* @param servers list of servers
* @param topic topic name
*
@@ -261,7 +260,7 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
String fetchLimitString = properties.getProperty(PolicyProperties.PROPERTY_UEB_SOURCE_TOPICS +
"." + topic +
- PolicyProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX);
+ PolicyProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX);
int fetchLimit = UebTopicSource.DEFAULT_LIMIT_FETCH;
if (fetchLimitString != null && !fetchLimitString.isEmpty()) {
try {
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java
index 31b7cec7..0b9f9887 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java
@@ -212,7 +212,7 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
List<TopicCoderFilterConfiguration>
topics2DecodedClasses2Filters = new ArrayList<>();
- if (topicEntities.isEmpty())
+ if (topicEntities == null || topicEntities.isEmpty())
return topics2DecodedClasses2Filters;
for (Topic topic: topicEntities) {
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java
new file mode 100644
index 00000000..3db2e7c7
--- /dev/null
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * policy-management
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Properties;
+import org.junit.Test;
+
+public class DroolsControllerFactoryTest {
+
+ @Test
+ public void buildNullController() {
+ Properties droolsProps = new Properties();
+ DroolsController droolsController =
+ DroolsController.factory.build(droolsProps, null, null);
+
+ assertNullController(droolsController);
+ }
+
+ @Test
+ public void getNullController() {
+ DroolsController controller =
+ DroolsController.factory.get(DroolsController.NO_GROUP_ID,
+ DroolsController.NO_ARTIFACT_ID, DroolsController.NO_VERSION);
+
+ assertNotNull(controller);
+ assertEquals(controller.getGroupId(), DroolsController.NO_GROUP_ID);
+ assertEquals(controller.getArtifactId(), DroolsController.NO_ARTIFACT_ID);
+ assertEquals(controller.getVersion(), DroolsController.NO_VERSION);
+ }
+
+ @Test
+ public void inventory() {
+ List<DroolsController> controllers = DroolsController.factory.inventory();
+ assertNotNull(controllers);
+ assertTrue(controllers.size() == 1);
+ assertNullController(controllers.get(0));
+ }
+
+ @Test
+ public void shutdown() {
+ DroolsControllerFactory droolsFactory = new IndexedDroolsControllerFactory();
+ droolsFactory.shutdown();
+ assertTrue(droolsFactory.inventory().isEmpty());
+ }
+
+ @Test
+ public void destroy() {
+ DroolsControllerFactory droolsFactory = new IndexedDroolsControllerFactory();
+ droolsFactory.destroy();
+ assertTrue(droolsFactory.inventory().isEmpty());
+ }
+
+ private void assertNullController(DroolsController droolsController) {
+ assertNotNull(droolsController);
+ assertEquals(droolsController.getGroupId(), DroolsController.NO_GROUP_ID);
+ assertEquals(droolsController.getArtifactId(), DroolsController.NO_ARTIFACT_ID);
+ assertEquals(droolsController.getVersion(), DroolsController.NO_VERSION);
+ }
+
+}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java
new file mode 100644
index 00000000..a938bf20
--- /dev/null
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * policy-management
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.controller.internal;
+
+import java.io.IOException;
+import java.nio.file.Paths;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.kie.api.builder.ReleaseId;
+import org.onap.policy.drools.controller.DroolsController;
+import org.onap.policy.drools.util.KieUtils;
+
+public class MavenDroolsControllerTest {
+
+ private static final String JUNIT_ECHO_KSESSION = "echo";
+ private static final String JUNIT_ECHO_KMODULE_DRL_PATH = "src/test/resources/echo.drl";
+ private static final String JUNIT_ECHO_KMODULE_POM_PATH = "src/test/resources/echo.pom";
+ private static final String JUNIT_ECHO_KMODULE_PATH = "src/test/resources/echo.kmodule";
+ private static final String JUNIT_ECHO_KJAR_DRL_PATH =
+ "src/main/resources/kbEcho/org/onap/policy/drools/test/echo.drl";
+
+ private static volatile ReleaseId releaseId;
+
+ @BeforeClass
+ public static void setUp() throws IOException {
+ releaseId =
+ KieUtils.installArtifact(Paths.get(JUNIT_ECHO_KMODULE_PATH).toFile(),
+ Paths.get(JUNIT_ECHO_KMODULE_POM_PATH).toFile(),
+ JUNIT_ECHO_KJAR_DRL_PATH,
+ Paths.get(JUNIT_ECHO_KMODULE_DRL_PATH).toFile());
+ }
+
+ @Test
+ public void stop() throws IOException, InterruptedException {
+ createDroolsController(10000L).stop();
+ }
+
+ @Test
+ public void shutdown() throws IOException, InterruptedException {
+ createDroolsController(10000L).shutdown();
+ }
+
+ @Test
+ public void lock() throws IOException, InterruptedException {
+ DroolsController controller = createDroolsController(30000L);
+
+ controller.lock();
+ Assert.assertTrue(controller.isLocked());
+
+ controller.unlock();
+ Assert.assertFalse(controller.isLocked());
+
+ controller.halt();
+ Assert.assertFalse(controller.isAlive());
+ }
+
+ private DroolsController createDroolsController(long courtesyStartTimeMs) throws InterruptedException {
+ DroolsController controller = new MavenDroolsController(releaseId.getGroupId(),
+ releaseId.getArtifactId(), releaseId.getVersion(), null, null);
+
+ Assert.assertFalse(controller.isAlive());
+ Assert.assertTrue(controller.isBrained());
+
+ controller.start();
+
+ Assert.assertTrue(controller.isAlive());
+ Assert.assertTrue(controller.isBrained());
+
+ Assert.assertEquals(releaseId.getGroupId(), controller.getGroupId());
+ Assert.assertEquals(releaseId.getArtifactId(), controller.getArtifactId());
+ Assert.assertEquals(releaseId.getVersion(), controller.getVersion());
+
+ Assert.assertEquals(releaseId.getGroupId(), controller.getContainer().getGroupId());
+ Assert.assertEquals(releaseId.getArtifactId(), controller.getContainer().getArtifactId());
+ Assert.assertEquals(releaseId.getVersion(), controller.getContainer().getVersion());
+
+ /* courtesy timer to allow full initialization from local maven repository */
+ Thread.sleep(courtesyStartTimeMs);
+
+ Assert.assertTrue(controller.getSessionNames().size() == 1);
+ Assert.assertEquals(JUNIT_ECHO_KSESSION, controller.getSessionNames().get(0));
+ Assert.assertTrue(controller.getCanonicalSessionNames().size() == 1);
+ Assert.assertTrue(controller.getCanonicalSessionNames().get(0).contains(JUNIT_ECHO_KSESSION));
+
+ return controller;
+ }
+}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java
new file mode 100644
index 00000000..a56bb5f2
--- /dev/null
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.protocol.coders;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Properties;
+
+
+import org.junit.Test;
+import org.onap.policy.drools.event.comm.TopicEndpoint;
+import org.onap.policy.drools.properties.PolicyProperties;
+import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
+
+/**
+ * Tests Coders
+ */
+public class EventProtocolCoderTest {
+
+ /**
+ * 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";
+
+ /**
+ * Event Test Class
+ */
+ public static class EventTest {
+
+ private String field;
+
+ public EventTest(String field) {
+ super();
+ this.field = field;
+ }
+
+ public String getField() {
+ return this.field;
+ }
+
+ public void setField(String field) {
+ this.field = field;
+ }
+ }
+
+ @Test
+ public void test() {
+
+ final Properties noopSinkProperties = new Properties();
+ noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, NOOP_TOPIC);
+
+ TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
+
+ EventProtocolCoder.manager.addEncoder(ENCODER_GROUP, ENCODER_ARTIFACT, NOOP_TOPIC,
+ DroolsConfiguration.class.getCanonicalName(), new JsonProtocolFilter(), null, null,
+ DroolsConfiguration.class.getName().hashCode());
+
+ final String json = EventProtocolCoder.manager.encode(NOOP_TOPIC,
+ new DroolsConfiguration(ENCODER_GROUP, ENCODER_ARTIFACT, ENCODER_VERSION));
+
+ assertTrue(json.contains(ENCODER_GROUP));
+ assertTrue(json.contains(ENCODER_ARTIFACT));
+
+ EventProtocolCoder.manager.removeEncoders(ENCODER_GROUP, ENCODER_ARTIFACT, NOOP_TOPIC);
+ }
+}
diff --git a/policy-management/src/test/resources/echo.drl b/policy-management/src/test/resources/echo.drl
new file mode 100644
index 00000000..664df639
--- /dev/null
+++ b/policy-management/src/test/resources/echo.drl
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.test;
+
+rule "INIT"
+lock-on-active
+when
+then
+ insert(new String("hello,I am up"));
+end
+
+rule "ECHO"
+when
+ $o : Object();
+then
+ System.out.println("ECHO: " + $o.toString());
+ retract($o);
+end
diff --git a/policy-management/src/test/resources/echo.kmodule b/policy-management/src/test/resources/echo.kmodule
new file mode 100644
index 00000000..437a91ca
--- /dev/null
+++ b/policy-management/src/test/resources/echo.kmodule
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ archetype-closed-loop-demo-rules
+ ================================================================================
+ Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
+ <kbase name="kbEcho">
+ <ksession name="echo"/>
+ </kbase>
+</kmodule>
diff --git a/policy-management/src/test/resources/echo.pom b/policy-management/src/test/resources/echo.pom
new file mode 100644
index 00000000..eec12af1
--- /dev/null
+++ b/policy-management/src/test/resources/echo.pom
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP
+ ================================================================================
+ Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.onap.policy.drools.test</groupId>
+ <artifactId>echo</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+
+</project>