summaryrefslogtreecommitdiffstats
path: root/policy-management/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'policy-management/src/test')
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/persistence/test/SystemPersistenceTest.java4
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java15
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java128
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java1756
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/test/PolicyEngineTest.java385
5 files changed, 1062 insertions, 1226 deletions
diff --git a/policy-management/src/test/java/org/onap/policy/drools/persistence/test/SystemPersistenceTest.java b/policy-management/src/test/java/org/onap/policy/drools/persistence/test/SystemPersistenceTest.java
index 56fab7fd..9b2e6161 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/persistence/test/SystemPersistenceTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/persistence/test/SystemPersistenceTest.java
@@ -38,7 +38,7 @@ import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.onap.policy.drools.persistence.FileSystemPersistence;
import org.onap.policy.drools.persistence.SystemPersistence;
-import org.onap.policy.drools.properties.PolicyProperties;
+import org.onap.policy.drools.properties.DroolsProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -149,7 +149,7 @@ public class SystemPersistenceTest {
assertTrue(Files.notExists(controllerBakPath));
Properties properties = new Properties();
- properties.put(PolicyProperties.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
+ properties.put(DroolsProperties.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
SystemPersistence.manager.storeController(TEST_CONTROLLER_NAME, properties);
assertTrue(Files.exists(controllerPath));
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
index a56bb5f2..a23820cf 100644
--- 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
@@ -25,10 +25,9 @@ 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.common.endpoints.event.comm.impl.ProxyTopicEndpointManager;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
/**
@@ -81,16 +80,16 @@ public class EventProtocolCoderTest {
public void test() {
final Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, NOOP_TOPIC);
+ noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, NOOP_TOPIC);
- TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
+ ProxyTopicEndpointManager.getInstance().addTopicSinks(noopSinkProperties);
EventProtocolCoder.manager.addEncoder(ENCODER_GROUP, ENCODER_ARTIFACT, NOOP_TOPIC,
- DroolsConfiguration.class.getCanonicalName(), new JsonProtocolFilter(), null, null,
- DroolsConfiguration.class.getName().hashCode());
+ 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));
+ new DroolsConfiguration(ENCODER_GROUP, ENCODER_ARTIFACT, ENCODER_VERSION));
assertTrue(json.contains(ENCODER_GROUP));
assertTrue(json.contains(ENCODER_ARTIFACT));
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
index c7113cd4..02b09bb1 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
@@ -20,6 +20,11 @@
package org.onap.policy.drools.protocol.coders;
+import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -31,11 +36,12 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.kie.api.builder.ReleaseId;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.impl.ProxyTopicEndpointManager;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.controller.internal.MavenDroolsControllerTest;
-import org.onap.policy.drools.event.comm.TopicEndpoint;
-import org.onap.policy.drools.event.comm.TopicSink;
-import org.onap.policy.drools.properties.PolicyProperties;
+import org.onap.policy.drools.properties.DroolsProperties;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
import org.onap.policy.drools.protocol.coders.JsonProtocolFilter.FilterRule;
import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomGsonCoder;
@@ -44,11 +50,6 @@ import org.onap.policy.drools.utils.Triple;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
/**
* ProtocolCoder Toolset JUNITs
*/
@@ -57,8 +58,7 @@ public class ProtocolCoderToolsetTest {
public static final String JUNIT_PROTOCOL_CODER_TOPIC = JUNIT_PROTOCOL_CODER_ARTIFACT_ID;
public static final String CONTROLLER_ID = "blah";
public static final String ARTIFACT_ID_ECHO = "echo";
- public static final String ARTIFACT_ID_POM_LINE =
- "<artifactId>" + ARTIFACT_ID_ECHO + "</artifactId>";
+ public static final String ARTIFACT_ID_POM_LINE = "<artifactId>" + ARTIFACT_ID_ECHO + "</artifactId>";
private static Logger logger = LoggerFactory.getLogger(ProtocolCoderToolset.class);
@@ -68,26 +68,23 @@ public class ProtocolCoderToolsetTest {
@Before
public void setUp() throws IOException {
- if (releaseId != null)
+ if (releaseId != null) {
return;
+ }
- String pom = new String(Files.readAllBytes
- (Paths.get(MavenDroolsControllerTest.JUNIT_ECHO_KMODULE_POM_PATH)));
+ String pom = new String(Files.readAllBytes(Paths.get(MavenDroolsControllerTest.JUNIT_ECHO_KMODULE_POM_PATH)));
- if (!pom.contains(ARTIFACT_ID_POM_LINE))
+ if (!pom.contains(ARTIFACT_ID_POM_LINE)) {
throw new IllegalArgumentException("unexpected junit test pom");
+ }
- String newPom = pom.replace(ARTIFACT_ID_ECHO, JUNIT_PROTOCOL_CODER_ARTIFACT_ID);
+ String newPom = pom.replace(ARTIFACT_ID_ECHO, JUNIT_PROTOCOL_CODER_ARTIFACT_ID);
- String kmodule = new String(Files.readAllBytes
- (Paths.get(MavenDroolsControllerTest.JUNIT_ECHO_KMODULE_PATH)));
+ String kmodule = new String(Files.readAllBytes(Paths.get(MavenDroolsControllerTest.JUNIT_ECHO_KMODULE_PATH)));
- String drl = new String(Files.readAllBytes
- (Paths.get(MavenDroolsControllerTest.JUNIT_ECHO_KMODULE_DRL_PATH)));
+ String drl = new String(Files.readAllBytes(Paths.get(MavenDroolsControllerTest.JUNIT_ECHO_KMODULE_DRL_PATH)));
- releaseId =
- KieUtils.installArtifact(kmodule, newPom,
- MavenDroolsControllerTest.JUNIT_ECHO_KJAR_DRL_PATH, drl);
+ releaseId = KieUtils.installArtifact(kmodule, newPom, MavenDroolsControllerTest.JUNIT_ECHO_KJAR_DRL_PATH, drl);
}
@Test
@@ -98,15 +95,9 @@ public class ProtocolCoderToolsetTest {
}
public void testGsonToolset(JsonProtocolFilter protocolFilter) {
- GsonProtocolCoderToolset gsonToolset =
- new GsonProtocolCoderToolset(JUNIT_PROTOCOL_CODER_TOPIC,
- CONTROLLER_ID,
- this.releaseId.getGroupId(),
- this.releaseId.getArtifactId(),
- Triple.class.getCanonicalName(),
- protocolFilter,
- null,
- 12345678);
+ GsonProtocolCoderToolset gsonToolset = new GsonProtocolCoderToolset(JUNIT_PROTOCOL_CODER_TOPIC, CONTROLLER_ID,
+ this.releaseId.getGroupId(), this.releaseId.getArtifactId(), Triple.class.getCanonicalName(),
+ protocolFilter, null, 12345678);
Assert.assertNotNull(gsonToolset.getEncoder());
Assert.assertNotNull(gsonToolset.getDecoder());
@@ -114,8 +105,7 @@ public class ProtocolCoderToolsetTest {
testToolset(protocolFilter, gsonToolset);
Triple<String, String, String> triple = createTriple();
- gsonToolset.setCustomCoder(new CustomGsonCoder(this.getClass().getCanonicalName(),
- "customCoder"));
+ gsonToolset.setCustomCoder(new CustomGsonCoder(this.getClass().getCanonicalName(), "customCoder"));
String tripleEncoded = encode(gsonToolset, triple);
decode(protocolFilter, gsonToolset, triple, tripleEncoded);
}
@@ -125,15 +115,9 @@ public class ProtocolCoderToolsetTest {
}
public void testJacksonToolset(JsonProtocolFilter protocolFilter) {
- JacksonProtocolCoderToolset jacksonToolset =
- new JacksonProtocolCoderToolset(JUNIT_PROTOCOL_CODER_TOPIC,
- CONTROLLER_ID,
- this.releaseId.getGroupId(),
- this.releaseId.getArtifactId(),
- Triple.class.getCanonicalName(),
- protocolFilter,
- null,
- 12345678);
+ JacksonProtocolCoderToolset jacksonToolset = new JacksonProtocolCoderToolset(JUNIT_PROTOCOL_CODER_TOPIC,
+ CONTROLLER_ID, this.releaseId.getGroupId(), this.releaseId.getArtifactId(),
+ Triple.class.getCanonicalName(), protocolFilter, null, 12345678);
jacksonToolset.getEncoder().setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
jacksonToolset.getDecoder().setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
@@ -160,14 +144,13 @@ public class ProtocolCoderToolsetTest {
}
@SuppressWarnings("unchecked")
- private void decode(JsonProtocolFilter protocolFilter, ProtocolCoderToolset coderToolset,
- Triple<String, String, String> triple, String tripleEncoded) {
+ private void decode(JsonProtocolFilter protocolFilter, ProtocolCoderToolset coderToolset,
+ Triple<String, String, String> triple, String tripleEncoded) {
Triple<String, String, String> tripleDecoded = null;
try {
- tripleDecoded =
- (Triple<String, String, String>) coderToolset.decode(tripleEncoded);
- } catch(UnsupportedOperationException e){
+ tripleDecoded = (Triple<String, String, String>) coderToolset.decode(tripleEncoded);
+ } catch (UnsupportedOperationException e) {
/* OK */
logger.trace("Junit expected exception - decode does not pass filtering", e);
}
@@ -181,8 +164,7 @@ public class ProtocolCoderToolsetTest {
coderFilters.getFilter().getRules("second").get(0).setRegex("^v2$");
coderFilters.getFilter().getRules("third").get(0).setRegex(".*v3.*");
- tripleDecoded =
- (Triple<String, String, String>) coderToolset.decode(tripleEncoded);
+ tripleDecoded = (Triple<String, String, String>) coderToolset.decode(tripleEncoded);
Assert.assertTrue(tripleDecoded.first().equals(triple.first()));
Assert.assertTrue(tripleDecoded.second().equals(triple.second()));
@@ -191,8 +173,7 @@ public class ProtocolCoderToolsetTest {
coderFilters.getFilter().deleteRules("third");
Assert.assertTrue(coderFilters.getFilter().getRules("third").isEmpty());
- tripleDecoded =
- (Triple<String, String, String>) coderToolset.decode(tripleEncoded);
+ tripleDecoded = (Triple<String, String, String>) coderToolset.decode(tripleEncoded);
Assert.assertTrue(tripleDecoded.first().equals(triple.first()));
Assert.assertTrue(tripleDecoded.second().equals(triple.second()));
@@ -211,7 +192,7 @@ public class ProtocolCoderToolsetTest {
List<FilterRule> filters = new ArrayList<>();
filters.add(new FilterRule("second", ".*"));
- coderToolset.addCoder(this.getClass().getCanonicalName(), new JsonProtocolFilter(filters),654321);
+ coderToolset.addCoder(this.getClass().getCanonicalName(), new JsonProtocolFilter(filters), 654321);
Assert.assertTrue(coderToolset.getCoders().size() == 2);
coderToolset.removeCoders(this.getClass().getCanonicalName());
@@ -221,26 +202,20 @@ public class ProtocolCoderToolsetTest {
private void updateCoderFilterRule(ProtocolCoderToolset coderToolset) {
List<FilterRule> filters = new ArrayList<>();
filters.add(new FilterRule("third", ".*"));
- coderToolset.addCoder(Triple.class.getCanonicalName(),
- new JsonProtocolFilter(filters), 654321);
+ coderToolset.addCoder(Triple.class.getCanonicalName(), new JsonProtocolFilter(filters), 654321);
Assert.assertTrue(coderToolset.getCoders().size() == 1);
- Assert.assertTrue
- (coderToolset.getCoder(Triple.class.getCanonicalName()).
- getModelClassLoaderHash() == 654321);
+ Assert.assertTrue(coderToolset.getCoder(Triple.class.getCanonicalName()).getModelClassLoaderHash() == 654321);
- Assert.assertTrue
- (coderToolset.getCoder(Triple.class.getCanonicalName()).
- getFilter().getRules("third").size() == 1);
+ Assert.assertTrue(
+ coderToolset.getCoder(Triple.class.getCanonicalName()).getFilter().getRules("third").size() == 1);
- Assert.assertTrue
- (coderToolset.getCoder(Triple.class.getCanonicalName()).
- getFilter().getRules("third").size() == 1);
+ Assert.assertTrue(
+ coderToolset.getCoder(Triple.class.getCanonicalName()).getFilter().getRules("third").size() == 1);
- Assert.assertTrue
- (".*".equals(coderToolset.getCoder(Triple.class.getCanonicalName()).
- getFilter().getRules("third").get(0).getRegex()));
+ Assert.assertTrue(".*".equals(coderToolset.getCoder(Triple.class.getCanonicalName()).getFilter()
+ .getRules("third").get(0).getRegex()));
}
private void validateInitialization(JsonProtocolFilter protocolFilter, ProtocolCoderToolset coderToolset) {
@@ -261,22 +236,21 @@ public class ProtocolCoderToolsetTest {
}
private void createController() {
- if (releaseId == null)
+ if (releaseId == null) {
throw new IllegalStateException("no prereq artifact installed in maven repository");
+ }
Properties sinkConfig = new Properties();
- sinkConfig.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, JUNIT_PROTOCOL_CODER_TOPIC);
- List<? extends TopicSink> noopTopics =
- TopicEndpoint.manager.addTopicSinks(sinkConfig);
+ sinkConfig.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, JUNIT_PROTOCOL_CODER_TOPIC);
+ List<? extends TopicSink> noopTopics = ProxyTopicEndpointManager.getInstance().addTopicSinks(sinkConfig);
Properties droolsControllerConfig = new Properties();
- droolsControllerConfig.put(PolicyProperties.RULES_GROUPID, releaseId.getGroupId());
- droolsControllerConfig.put(PolicyProperties.RULES_ARTIFACTID, releaseId.getArtifactId());
- droolsControllerConfig.put(PolicyProperties.RULES_VERSION, releaseId.getVersion());
- droolsControllerConfig.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS + "." +
- JUNIT_PROTOCOL_CODER_TOPIC + PolicyProperties.PROPERTY_TOPIC_EVENTS_SUFFIX,
- Triple.class.getCanonicalName());
-
+ droolsControllerConfig.put(DroolsProperties.RULES_GROUPID, releaseId.getGroupId());
+ droolsControllerConfig.put(DroolsProperties.RULES_ARTIFACTID, releaseId.getArtifactId());
+ droolsControllerConfig.put(DroolsProperties.RULES_VERSION, releaseId.getVersion());
+ droolsControllerConfig.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS + "." + JUNIT_PROTOCOL_CODER_TOPIC
+ + PolicyEndPointProperties.PROPERTY_TOPIC_EVENTS_SUFFIX, Triple.class.getCanonicalName());
+
DroolsController.factory.build(droolsControllerConfig, null, noopTopics);
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
index ba64d2f1..0f57cd97 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.drools.server.restful.test;
import static org.junit.Assert.assertEquals;
+
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -42,9 +43,9 @@ import org.junit.BeforeClass;
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.common.endpoints.event.comm.impl.ProxyTopicEndpointManager;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.drools.persistence.SystemPersistence;
-import org.onap.policy.drools.properties.PolicyProperties;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
@@ -52,956 +53,815 @@ import org.slf4j.LoggerFactory;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RestManagerTest {
- public static final int DEFAULT_TELEMETRY_PORT = 7887;
- private static final String HOST = "localhost";
- private static final String REST_MANAGER_PATH = "/policy/pdp";
- private static final String HOST_URL =
- "http://" + HOST + ":" + DEFAULT_TELEMETRY_PORT + REST_MANAGER_PATH;
- private static final String FOO_CONTROLLER = "foo";
-
- private static final String UEB_TOPIC = "UEB-TOPIC-TEST";
- private static final String DMAAP_TOPIC = "DMAAP-TOPIC-TEST";
- private static final String NOOP_TOPIC = "NOOP_TOPIC";
-
- private static final String UEB_SOURCE_SERVER_PROPERTY =
- PolicyProperties.PROPERTY_UEB_SOURCE_TOPICS + "." + UEB_TOPIC
- + PolicyProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
- private static final String UEB_SINK_SERVER_PROPERTY = PolicyProperties.PROPERTY_UEB_SINK_TOPICS
- + "." + UEB_TOPIC + PolicyProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
- private static final String DMAAP_SOURCE_SERVER_PROPERTY =
- PolicyProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "." + DMAAP_TOPIC
- + PolicyProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
- private static final String DMAAP_SINK_SERVER_PROPERTY =
- PolicyProperties.PROPERTY_DMAAP_SINK_TOPICS + "." + DMAAP_TOPIC
- + PolicyProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
- private static final String UEB_SERVER = "localhost";
- private static final String DMAAP_SERVER = "localhost";
- private static final String DMAAP_MECHID = "blah";
- private static final String DMAAP_PASSWD = "blah";
-
- private static final String DMAAP_SOURCE_MECHID_KEY =
- PolicyProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "." + DMAAP_TOPIC
- + PolicyProperties.PROPERTY_TOPIC_AAF_MECHID_SUFFIX;
- private static final String DMAAP_SOURCE_PASSWD_KEY =
- PolicyProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "." + DMAAP_TOPIC
- + PolicyProperties.PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX;
-
- private static final String DMAAP_SINK_MECHID_KEY = PolicyProperties.PROPERTY_DMAAP_SINK_TOPICS
- + "." + DMAAP_TOPIC + PolicyProperties.PROPERTY_TOPIC_AAF_MECHID_SUFFIX;
- private static final String DMAAP_SINK_PASSWD_KEY = PolicyProperties.PROPERTY_DMAAP_SINK_TOPICS
- + "." + DMAAP_TOPIC + PolicyProperties.PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX;
-
-
- private static final String FOO_CONTROLLER_FILE = FOO_CONTROLLER + "-controller.properties";
- private static final String FOO_CONTROLLER_FILE_BAK = FOO_CONTROLLER_FILE + ".bak";
-
- private static CloseableHttpClient client;
-
- private static final Logger logger = LoggerFactory.getLogger(RestManagerTest.class);
-
- @BeforeClass
- public static void setUp() throws IOException {
- cleanUpWorkingDirs();
-
- SystemPersistence.manager.setConfigurationDir(null);
-
- /* override default port */
- final Properties engineProps = PolicyEngine.manager.defaultTelemetryConfig();
- engineProps.put(PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME + PolicyProperties.PROPERTY_HTTP_PORT_SUFFIX,
- "" + DEFAULT_TELEMETRY_PORT);
-
- /* other properties */
- engineProps.put(PolicyProperties.PROPERTY_UEB_SOURCE_TOPICS, UEB_TOPIC);
- engineProps.put(PolicyProperties.PROPERTY_UEB_SINK_TOPICS, UEB_TOPIC);
- engineProps.put(PolicyProperties.PROPERTY_DMAAP_SOURCE_TOPICS, DMAAP_TOPIC);
- engineProps.put(PolicyProperties.PROPERTY_DMAAP_SINK_TOPICS, DMAAP_TOPIC);
- engineProps.put(UEB_SOURCE_SERVER_PROPERTY, UEB_SERVER);
- engineProps.put(UEB_SINK_SERVER_PROPERTY, UEB_SERVER);
- engineProps.put(DMAAP_SOURCE_SERVER_PROPERTY, DMAAP_SERVER);
- engineProps.put(DMAAP_SINK_SERVER_PROPERTY, DMAAP_SERVER);
- engineProps.put(DMAAP_SOURCE_MECHID_KEY, DMAAP_MECHID);
- engineProps.put(DMAAP_SOURCE_PASSWD_KEY, DMAAP_PASSWD);
- engineProps.put(DMAAP_SINK_MECHID_KEY, DMAAP_MECHID);
- engineProps.put(DMAAP_SINK_PASSWD_KEY, DMAAP_PASSWD);
- engineProps.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, NOOP_TOPIC);
-
- PolicyEngine.manager.configure(engineProps);
- PolicyEngine.manager.start();
-
- Properties controllerProps = new Properties();
- PolicyEngine.manager.createPolicyController(FOO_CONTROLLER, controllerProps);
-
-
- client = HttpClients.createDefault();
-
-
- }
-
- @AfterClass
- public static void tearDown() throws IOException, InterruptedException {
- /* Shutdown managed resources */
- PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
- PolicyEngine.manager.stop();
- Thread.sleep(10000L);
- client.close();
- cleanUpWorkingDirs();
- }
-
-
- @Test
- public void putDeleteTest() throws ClientProtocolException, IOException, InterruptedException {
- HttpPut httpPut;
- HttpDelete httpDelete;
- CloseableHttpResponse response;
-
- /*
- * DELETE:
- * /engine/controllers/controllerName/drools/facts/session/factType
- *
- */
- httpDelete = new HttpDelete(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/drools/facts/session/factType");
- response = client.execute(httpDelete);
- logger.info(httpDelete.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpDelete.releaseConnection();
-
- httpDelete = new HttpDelete(HOST_URL + "/engine/controllers/controllerName/drools/facts/session/factType");
- response = client.execute(httpDelete);
- logger.info(httpDelete.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpDelete.releaseConnection();
-
- /*
- * PUT:
- * /engine/switches/lock
- * /engine/controllers/controllername/switches/lock
- * DELETE:
- * /engine/switches/lock
- * /engine/controllers/controllername
- */
- httpPut = new HttpPut(HOST_URL + "/engine/switches/lock");
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(406, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpDelete = new HttpDelete(HOST_URL + "/engine/switches/lock");
- response = client.execute(httpDelete);
- logger.info(httpDelete.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(406, response.getStatusLine().getStatusCode());
- httpDelete.releaseConnection();
-
- httpDelete = new HttpDelete(HOST_URL + "/engine/controllers/");
- response = client.execute(httpDelete);
- logger.info(httpDelete.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(405, response.getStatusLine().getStatusCode());
- httpDelete.releaseConnection();
-
- httpDelete = new HttpDelete(HOST_URL + "/engine/controllers/" + null);
- response = client.execute(httpDelete);
- logger.info(httpDelete.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(400, response.getStatusLine().getStatusCode());
- httpDelete.releaseConnection();
-
- httpPut = new HttpPut(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/switches/lock");
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() +" response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(406, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpDelete = new HttpDelete(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER);
- response = client.execute(httpDelete);
- logger.info(httpDelete.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpDelete.releaseConnection();
-
- httpPut = new HttpPut(HOST_URL + "/engine/switches/lock");
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpDelete = new HttpDelete(HOST_URL + "/engine/switches/lock");
- response = client.execute(httpDelete);
- logger.info(httpDelete.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpDelete.releaseConnection();
-
- /*
- * PUT:
- * /engine/topics/sources/ueb/topic/events
- * /engine/topics/sources/dmaap/topic/events
- * /engine/topics/switches/lock
- * DELETE:
- * /engine/topics/switches/lock
- */
- httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/events");
- httpPut.addHeader("Content-Type", "text/plain");
- httpPut.addHeader("Accept", "application/json");
- httpPut.setEntity(new StringEntity("FOOOO"));
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events");
- httpPut.addHeader("Content-Type", "text/plain");
- httpPut.addHeader("Accept", "application/json");
- httpPut.setEntity(new StringEntity("FOOOO"));
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/ueb/fiznits/events");
- httpPut.addHeader("Content-Type", "text/plain");
- httpPut.addHeader("Accept", "application/json");
- httpPut.setEntity(new StringEntity("FOOOO"));
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(406, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/dmaap/fiznits/events");
- httpPut.addHeader("Content-Type", "text/plain");
- httpPut.addHeader("Accept", "application/json");
- httpPut.setEntity(new StringEntity("FOOOO"));
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpPut = new HttpPut(HOST_URL + "/engine/topics/switches/lock");
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/events");
- httpPut.addHeader("Content-Type", "text/plain");
- httpPut.addHeader("Accept", "application/json");
- httpPut.setEntity(new StringEntity("FOOOO"));
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(406, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events");
- httpPut.addHeader("Content-Type", "text/plain");
- httpPut.addHeader("Accept", "application/json");
- httpPut.setEntity(new StringEntity("FOOOO"));
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(406, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpDelete = new HttpDelete(HOST_URL + "/engine/topics/switches/lock");
- response = client.execute(httpDelete);
- logger.info(httpDelete.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpDelete.releaseConnection();
-
- /*
- * PUT:
- * /engine/topics/sources/ueb/topic/switches/lock
- * /engine/topics/sources/dmaap/topic/switches/lock
- * DELETE:
- * /engine/topics/sources/ueb/topic/switches/lock
- * /engine/topics/sources/dmaap/topic/switches/lock
- */
- httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/switches/lock");
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpDelete =
- new HttpDelete(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/switches/lock");
- response = client.execute(httpDelete);
- logger.info(httpDelete.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpDelete.releaseConnection();
-
- httpPut =
- new HttpPut(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/switches/lock");
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpDelete =
- new HttpDelete(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/switches/lock");
- response = client.execute(httpDelete);
- logger.info(httpDelete.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpDelete.releaseConnection();
-
- /*
- * PUT:
- * /engine/switches/activation
- * DELETE:
- * /engine/switches/activation
- */
- /* httpPut = new HttpPut(HOST_URL + "/engine/switches/activation");
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- httpDelete = new HttpDelete(HOST_URL + "/engine/switches/activation");
- response = client.execute(httpDelete);
- logger.info(httpDelete.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpDelete.releaseConnection();*/
-
- /*
- * PUT:
- * /engine/tools/loggers/logger/level
- */
- httpPut = new HttpPut(HOST_URL + "/engine/tools/loggers/ROOT/debug");
- response = client.execute(httpPut);
- logger.info(httpPut.getRequestLine() + "response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpPut.releaseConnection();
-
- }
-
-
- @Test
- public void getTest() throws ClientProtocolException, IOException, InterruptedException {
- HttpGet httpGet;
- CloseableHttpResponse response;
- String responseBody;
-
- /*
- * GET:
- * /engine
- * /engine/features
- * /engine/features/inventory
- * /engine/features/featurename
- * /engine/inputs
- * /engine/properties
- * /engine/environment
- * /engine/switches
- * /engine/controllers
- */
- httpGet = new HttpGet(HOST_URL + "/engine");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/features");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/features/inventory");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/features/foobar");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/inputs");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/properties");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/environment");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- PolicyEngine.manager.setEnvironmentProperty("foo", "bar");
- httpGet = new HttpGet(HOST_URL + "/engine/environment/foo");
- response = client.execute(httpGet);
- responseBody = this.getResponseBody(response);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- logger.info(httpGet.getRequestLine() + " response body: {}", responseBody);
- assertEquals(200, response.getStatusLine().getStatusCode());
- assertEquals("bar", responseBody);
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/switches");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers");
- response = client.execute(httpGet);
- responseBody = this.getResponseBody(response);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- logger.info(httpGet.getRequestLine() + " response body: {}", responseBody);
- assertEquals(200, response.getStatusLine().getStatusCode());
- assertEquals("[\"" + FOO_CONTROLLER + "\"]", responseBody);
- httpGet.releaseConnection();
-
- /*
- * GET:
- * /engine/controllers/inventory
- * /engine/controllers/features
- * /engine/controllers/features/inventory
- * /engine/controllers/features/featureName
- * /engine/controllers/controllerName
- *
- */
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/inventory");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/features");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/features/inventory");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/features/dummy");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER);
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- /*
- * GET:
- * /engine/controllers/controllerName/properties
- * /engine/controllers/controllerName/inputs
- * /engine/controllers/controllerName/switches
- * /engine/controllers/controllerName/drools
- */
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/properties");
- response = client.execute(httpGet);
- responseBody = this.getResponseBody(response);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- logger.info(httpGet.getRequestLine() + " response code: {}", responseBody);
- assertEquals(200, response.getStatusLine().getStatusCode());
- assertEquals("{}", responseBody);
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller/properties");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/inputs");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/switches");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/drools");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller/drools");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- /*
- * GET:
- * /engine/controllers/controllerName/drools/facts
- * /engine/controllers/controllerName/drools/facts/session
- * /engine/controllers/controllerName/drools/facts/session/factType
- * /engine/controllers/controllerName/drools/facts/session/query/queriedEntity
- *
- */
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/drools/facts");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller/drools/facts");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet =
- new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/drools/facts/session");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(
- HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/drools/facts/session/factType");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER
- + "/drools/facts/session/query/queriedEntity");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/dummy"
- + "/drools/facts/session/query/queriedEntity");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
-
- /*
- * GET:
- * /engine/controllers/controllerName/decoders
- * /engine/controllers/controllerName/decoders/filters
- * /engine/controllers/controllerName/decoders/topic
- * /engine/controllers/controllerName/decoders/topic/filters
- * /engine/controllers/controllerName/decoders/topic/filters/factType
- * /engine/controllers/controllerName/decoders/topic/filters/factType/rules
- * /engine/controllers/controllerName/decoders/topic/filtes/factType/rules/ruleName
- * /engine/controllers/controllerName/encoders
- */
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller/decoders");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders/filters");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller/decoders/filters");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders/topic");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet =
- new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders/topic/filters");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(
- HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders/topic/filters/factType");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER
- + "/decoders/topic/filters/factType/rules");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER
- + "/decoders/topic/filters/factType/rules/ruleName");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(404, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/encoders");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- /*
- * GET:
- * /engine/topics
- * /engine/topics/switches
- * /engine/topics/sources
- * /engine/topics/sinks
- * /engine/topics/sinks/ueb
- * /engine/topics/sources/ueb
- * /engine/topics/sinks/dmaap
- * /engine/topics/sources/dmaap
- * /engine/topics/sinks/ueb/topic
- * /engine/topics/sources/ueb/topic
- * /engine/topics/sinks/dmaap/topic
- * /engine/topics/sources/dmaap/topic
- * /engine/topics/sinks/ueb/topic/events
- * /engine/topics/sources/ueb/topic/events
- * /engine/topics/sinks/dmaap/topic/events
- * /engine/topics/sources/dmaap/topic/events
- * /engine/topics/sources/ueb/topic/switches
- * /engine/topics/sources/dmaap/topic/switches
- */
- httpGet = new HttpGet(HOST_URL + "/engine/topics");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/switches");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/ueb");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC);
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb/foobar");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(500, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/ueb/" + UEB_TOPIC);
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/ueb/foobar");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(500, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC);
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/foobar");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(500, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/" + DMAAP_TOPIC);
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/foobar");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(500, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/events");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb/foobar/events");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(500, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/ueb/" + UEB_TOPIC + "/events");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/ueb/foobar/events");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(500, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/foobar/events");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(500, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/" + DMAAP_TOPIC + "/events");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/foobar/events");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(500, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/switches");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/switches");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- /*
- * GET:
- * /engine/topics/sinks/noop
- * /engine/topics/sinks/noop/topic
- * /engine/topics/sinks/noop/topic/events
- */
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/noop");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/noop/" + NOOP_TOPIC);
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/noop/" + NOOP_TOPIC + "/events");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- /*
- * GET:
- * /engine/tools/uuid
- * /engine/tools/loggers
- * /engine/tools/loggers/loggerName
- */
- httpGet = new HttpGet(HOST_URL + "/engine/tools/uuid");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/tools/loggers");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- httpGet = new HttpGet(HOST_URL + "/engine/tools/loggers/ROOT");
- response = client.execute(httpGet);
- logger.info(httpGet.getRequestLine() + " response code: {}",
- response.getStatusLine().getStatusCode());
- assertEquals(200, response.getStatusLine().getStatusCode());
- httpGet.releaseConnection();
-
- }
-
-
- public String getResponseBody(CloseableHttpResponse response) {
-
- HttpEntity entity;
- try {
- entity = response.getEntity();
- return EntityUtils.toString(entity);
-
- } catch (final IOException e) {
+ public static final int DEFAULT_TELEMETRY_PORT = 7887;
+ private static final String HOST = "localhost";
+ private static final String REST_MANAGER_PATH = "/policy/pdp";
+ private static final String HOST_URL = "http://" + HOST + ":" + DEFAULT_TELEMETRY_PORT + REST_MANAGER_PATH;
+ private static final String FOO_CONTROLLER = "foo";
+
+ private static final String UEB_TOPIC = "UEB-TOPIC-TEST";
+ private static final String DMAAP_TOPIC = "DMAAP-TOPIC-TEST";
+ private static final String NOOP_TOPIC = "NOOP_TOPIC";
+
+ private static final String UEB_SOURCE_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_UEB_SOURCE_TOPICS + "."
+ + UEB_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
+ private static final String UEB_SINK_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_UEB_SINK_TOPICS + "." + UEB_TOPIC
+ + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
+ private static final String DMAAP_SOURCE_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "."
+ + DMAAP_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
+ private static final String DMAAP_SINK_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS + "."
+ + DMAAP_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
+ private static final String UEB_SERVER = "localhost";
+ private static final String DMAAP_SERVER = "localhost";
+ private static final String DMAAP_MECHID = "blah";
+ private static final String DMAAP_PASSWD = "blah";
+
+ private static final String DMAAP_SOURCE_MECHID_KEY = PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "."
+ + DMAAP_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_AAF_MECHID_SUFFIX;
+ private static final String DMAAP_SOURCE_PASSWD_KEY = PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "."
+ + DMAAP_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX;
+
+ private static final String DMAAP_SINK_MECHID_KEY = PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS + "." + DMAAP_TOPIC
+ + PolicyEndPointProperties.PROPERTY_TOPIC_AAF_MECHID_SUFFIX;
+ private static final String DMAAP_SINK_PASSWD_KEY = PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS + "." + DMAAP_TOPIC
+ + PolicyEndPointProperties.PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX;
+
+
+ private static final String FOO_CONTROLLER_FILE = FOO_CONTROLLER + "-controller.properties";
+ private static final String FOO_CONTROLLER_FILE_BAK = FOO_CONTROLLER_FILE + ".bak";
+
+ private static CloseableHttpClient client;
+
+ private static final Logger logger = LoggerFactory.getLogger(RestManagerTest.class);
+
+ @BeforeClass
+ public static void setUp() throws IOException {
+ cleanUpWorkingDirs();
+
+ SystemPersistence.manager.setConfigurationDir(null);
+
+ /* override default port */
+ final Properties engineProps = PolicyEngine.manager.defaultTelemetryConfig();
+ engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
+ + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX,
+ "" + DEFAULT_TELEMETRY_PORT);
+
+ /* other properties */
+ engineProps.put(PolicyEndPointProperties.PROPERTY_UEB_SOURCE_TOPICS, UEB_TOPIC);
+ engineProps.put(PolicyEndPointProperties.PROPERTY_UEB_SINK_TOPICS, UEB_TOPIC);
+ engineProps.put(PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS, DMAAP_TOPIC);
+ engineProps.put(PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS, DMAAP_TOPIC);
+ engineProps.put(UEB_SOURCE_SERVER_PROPERTY, UEB_SERVER);
+ engineProps.put(UEB_SINK_SERVER_PROPERTY, UEB_SERVER);
+ engineProps.put(DMAAP_SOURCE_SERVER_PROPERTY, DMAAP_SERVER);
+ engineProps.put(DMAAP_SINK_SERVER_PROPERTY, DMAAP_SERVER);
+ engineProps.put(DMAAP_SOURCE_MECHID_KEY, DMAAP_MECHID);
+ engineProps.put(DMAAP_SOURCE_PASSWD_KEY, DMAAP_PASSWD);
+ engineProps.put(DMAAP_SINK_MECHID_KEY, DMAAP_MECHID);
+ engineProps.put(DMAAP_SINK_PASSWD_KEY, DMAAP_PASSWD);
+ engineProps.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, NOOP_TOPIC);
+
+ PolicyEngine.manager.configure(engineProps);
+ PolicyEngine.manager.start();
+
+ Properties controllerProps = new Properties();
+ PolicyEngine.manager.createPolicyController(FOO_CONTROLLER, controllerProps);
+
+
+ client = HttpClients.createDefault();
+
+
+ }
+
+ @AfterClass
+ public static void tearDown() throws IOException, InterruptedException {
+ /* Shutdown managed resources */
+ PolicyController.factory.shutdown();
+ ProxyTopicEndpointManager.getInstance().shutdown();
+ PolicyEngine.manager.stop();
+ Thread.sleep(10000L);
+ client.close();
+ cleanUpWorkingDirs();
+ }
+
+
+ @Test
+ public void putDeleteTest() throws ClientProtocolException, IOException, InterruptedException {
+ HttpPut httpPut;
+ HttpDelete httpDelete;
+ CloseableHttpResponse response;
+
+ /*
+ * DELETE: /engine/controllers/controllerName/drools/facts/session/factType
+ *
+ */
+ httpDelete =
+ new HttpDelete(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/drools/facts/session/factType");
+ response = client.execute(httpDelete);
+ logger.info(httpDelete.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/controllers/controllerName/drools/facts/session/factType");
+ response = client.execute(httpDelete);
+ logger.info(httpDelete.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ /*
+ * PUT: /engine/switches/lock /engine/controllers/controllername/switches/lock DELETE:
+ * /engine/switches/lock /engine/controllers/controllername
+ */
+ httpPut = new HttpPut(HOST_URL + "/engine/switches/lock");
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(406, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/switches/lock");
+ response = client.execute(httpDelete);
+ logger.info(httpDelete.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(406, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/controllers/");
+ response = client.execute(httpDelete);
+ logger.info(httpDelete.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(405, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/controllers/" + null);
+ response = client.execute(httpDelete);
+ logger.info(httpDelete.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(400, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/switches/lock");
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(406, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER);
+ response = client.execute(httpDelete);
+ logger.info(httpDelete.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/switches/lock");
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/switches/lock");
+ response = client.execute(httpDelete);
+ logger.info(httpDelete.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ /*
+ * PUT: /engine/topics/sources/ueb/topic/events /engine/topics/sources/dmaap/topic/events
+ * /engine/topics/switches/lock DELETE: /engine/topics/switches/lock
+ */
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/events");
+ httpPut.addHeader("Content-Type", "text/plain");
+ httpPut.addHeader("Accept", "application/json");
+ httpPut.setEntity(new StringEntity("FOOOO"));
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events");
+ httpPut.addHeader("Content-Type", "text/plain");
+ httpPut.addHeader("Accept", "application/json");
+ httpPut.setEntity(new StringEntity("FOOOO"));
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/ueb/fiznits/events");
+ httpPut.addHeader("Content-Type", "text/plain");
+ httpPut.addHeader("Accept", "application/json");
+ httpPut.setEntity(new StringEntity("FOOOO"));
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(406, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/dmaap/fiznits/events");
+ httpPut.addHeader("Content-Type", "text/plain");
+ httpPut.addHeader("Accept", "application/json");
+ httpPut.setEntity(new StringEntity("FOOOO"));
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/switches/lock");
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/events");
+ httpPut.addHeader("Content-Type", "text/plain");
+ httpPut.addHeader("Accept", "application/json");
+ httpPut.setEntity(new StringEntity("FOOOO"));
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(406, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events");
+ httpPut.addHeader("Content-Type", "text/plain");
+ httpPut.addHeader("Accept", "application/json");
+ httpPut.setEntity(new StringEntity("FOOOO"));
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(406, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/topics/switches/lock");
+ response = client.execute(httpDelete);
+ logger.info(httpDelete.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ /*
+ * PUT: /engine/topics/sources/ueb/topic/switches/lock
+ * /engine/topics/sources/dmaap/topic/switches/lock DELETE:
+ * /engine/topics/sources/ueb/topic/switches/lock
+ * /engine/topics/sources/dmaap/topic/switches/lock
+ */
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/switches/lock");
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/switches/lock");
+ response = client.execute(httpDelete);
+ logger.info(httpDelete.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/switches/lock");
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/switches/lock");
+ response = client.execute(httpDelete);
+ logger.info(httpDelete.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ /*
+ * PUT: /engine/switches/activation DELETE: /engine/switches/activation
+ */
+ /*
+ * httpPut = new HttpPut(HOST_URL + "/engine/switches/activation"); response =
+ * client.execute(httpPut); logger.info(httpPut.getRequestLine() + " response code: {}",
+ * response.getStatusLine().getStatusCode()); assertEquals(200,
+ * response.getStatusLine().getStatusCode()); httpPut.releaseConnection();
+ *
+ * httpDelete = new HttpDelete(HOST_URL + "/engine/switches/activation"); response =
+ * client.execute(httpDelete); logger.info(httpDelete.getRequestLine() +
+ * " response code: {}", response.getStatusLine().getStatusCode()); assertEquals(200,
+ * response.getStatusLine().getStatusCode()); httpDelete.releaseConnection();
+ */
+
+ /*
+ * PUT: /engine/tools/loggers/logger/level
+ */
+ httpPut = new HttpPut(HOST_URL + "/engine/tools/loggers/ROOT/debug");
+ response = client.execute(httpPut);
+ logger.info(httpPut.getRequestLine() + "response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
}
- return null;
- }
- private static void cleanUpWorkingDirs() throws IOException {
- final Path testControllerPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), FOO_CONTROLLER_FILE);
- final Path testControllerBakPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), FOO_CONTROLLER_FILE_BAK);
+ @Test
+ public void getTest() throws ClientProtocolException, IOException, InterruptedException {
+ HttpGet httpGet;
+ CloseableHttpResponse response;
+ String responseBody;
+
+ /*
+ * GET: /engine /engine/features /engine/features/inventory /engine/features/featurename
+ * /engine/inputs /engine/properties /engine/environment /engine/switches
+ * /engine/controllers
+ */
+ httpGet = new HttpGet(HOST_URL + "/engine");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/features");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/features/inventory");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/features/foobar");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/inputs");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/properties");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/environment");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ PolicyEngine.manager.setEnvironmentProperty("foo", "bar");
+ httpGet = new HttpGet(HOST_URL + "/engine/environment/foo");
+ response = client.execute(httpGet);
+ responseBody = this.getResponseBody(response);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ logger.info(httpGet.getRequestLine() + " response body: {}", responseBody);
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertEquals("bar", responseBody);
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/switches");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers");
+ response = client.execute(httpGet);
+ responseBody = this.getResponseBody(response);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ logger.info(httpGet.getRequestLine() + " response body: {}", responseBody);
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertEquals("[\"" + FOO_CONTROLLER + "\"]", responseBody);
+ httpGet.releaseConnection();
+
+ /*
+ * GET: /engine/controllers/inventory /engine/controllers/features
+ * /engine/controllers/features/inventory /engine/controllers/features/featureName
+ * /engine/controllers/controllerName
+ *
+ */
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/inventory");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/features");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/features/inventory");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/features/dummy");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER);
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ /*
+ * GET: /engine/controllers/controllerName/properties
+ * /engine/controllers/controllerName/inputs /engine/controllers/controllerName/switches
+ * /engine/controllers/controllerName/drools
+ */
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/properties");
+ response = client.execute(httpGet);
+ responseBody = this.getResponseBody(response);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ logger.info(httpGet.getRequestLine() + " response code: {}", responseBody);
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertEquals("{}", responseBody);
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller/properties");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/inputs");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/switches");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/drools");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller/drools");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ /*
+ * GET: /engine/controllers/controllerName/drools/facts
+ * /engine/controllers/controllerName/drools/facts/session
+ * /engine/controllers/controllerName/drools/facts/session/factType
+ * /engine/controllers/controllerName/drools/facts/session/query/queriedEntity
+ *
+ */
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/drools/facts");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller/drools/facts");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/drools/facts/session");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/drools/facts/session/factType");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(
+ HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/drools/facts/session/query/queriedEntity");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/dummy" + "/drools/facts/session/query/queriedEntity");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+
+ /*
+ * GET: /engine/controllers/controllerName/decoders
+ * /engine/controllers/controllerName/decoders/filters
+ * /engine/controllers/controllerName/decoders/topic
+ * /engine/controllers/controllerName/decoders/topic/filters
+ * /engine/controllers/controllerName/decoders/topic/filters/factType
+ * /engine/controllers/controllerName/decoders/topic/filters/factType/rules
+ * /engine/controllers/controllerName/decoders/topic/filtes/factType/rules/ruleName
+ * /engine/controllers/controllerName/encoders
+ */
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller/decoders");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders/filters");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/nonexistantcontroller/decoders/filters");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders/topic");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders/topic/filters");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders/topic/filters/factType");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(
+ HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders/topic/filters/factType/rules");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(
+ HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/decoders/topic/filters/factType/rules/ruleName");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(404, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/controllers/" + FOO_CONTROLLER + "/encoders");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ /*
+ * GET: /engine/topics /engine/topics/switches /engine/topics/sources /engine/topics/sinks
+ * /engine/topics/sinks/ueb /engine/topics/sources/ueb /engine/topics/sinks/dmaap
+ * /engine/topics/sources/dmaap /engine/topics/sinks/ueb/topic
+ * /engine/topics/sources/ueb/topic /engine/topics/sinks/dmaap/topic
+ * /engine/topics/sources/dmaap/topic /engine/topics/sinks/ueb/topic/events
+ * /engine/topics/sources/ueb/topic/events /engine/topics/sinks/dmaap/topic/events
+ * /engine/topics/sources/dmaap/topic/events /engine/topics/sources/ueb/topic/switches
+ * /engine/topics/sources/dmaap/topic/switches
+ */
+ httpGet = new HttpGet(HOST_URL + "/engine/topics");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/switches");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/ueb");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC);
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb/foobar");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(500, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/ueb/" + UEB_TOPIC);
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/ueb/foobar");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(500, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC);
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/foobar");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(500, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/" + DMAAP_TOPIC);
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/foobar");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(500, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/events");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb/foobar/events");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(500, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/ueb/" + UEB_TOPIC + "/events");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/ueb/foobar/events");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(500, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/foobar/events");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(500, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/" + DMAAP_TOPIC + "/events");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/foobar/events");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(500, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/switches");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/switches");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ /*
+ * GET: /engine/topics/sinks/noop /engine/topics/sinks/noop/topic
+ * /engine/topics/sinks/noop/topic/events
+ */
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/noop");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/noop/" + NOOP_TOPIC);
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/noop/" + NOOP_TOPIC + "/events");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ /*
+ * GET: /engine/tools/uuid /engine/tools/loggers /engine/tools/loggers/loggerName
+ */
+ httpGet = new HttpGet(HOST_URL + "/engine/tools/uuid");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/tools/loggers");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ httpGet = new HttpGet(HOST_URL + "/engine/tools/loggers/ROOT");
+ response = client.execute(httpGet);
+ logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
+ }
- Files.deleteIfExists(testControllerPath);
- Files.deleteIfExists(testControllerBakPath);
- }
+
+ public String getResponseBody(CloseableHttpResponse response) {
+
+ HttpEntity entity;
+ try {
+ entity = response.getEntity();
+ return EntityUtils.toString(entity);
+
+ } catch (final IOException e) {
+
+ }
+
+ return null;
+ }
+
+ private static void cleanUpWorkingDirs() throws IOException {
+ final Path testControllerPath =
+ Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), FOO_CONTROLLER_FILE);
+ final Path testControllerBakPath =
+ Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), FOO_CONTROLLER_FILE_BAK);
+
+ Files.deleteIfExists(testControllerPath);
+ Files.deleteIfExists(testControllerBakPath);
+ }
}
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 38f4e9b8..88d25563 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.drools.system.test;
import static org.junit.Assert.assertFalse;
@@ -33,11 +34,12 @@ import org.junit.BeforeClass;
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.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.bus.impl.IndexedNoopTopicSinkFactory;
+import org.onap.policy.common.endpoints.event.comm.impl.ProxyTopicEndpointManager;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.drools.persistence.SystemPersistence;
-import org.onap.policy.drools.properties.PolicyProperties;
+import org.onap.policy.drools.properties.DroolsProperties;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
@@ -52,236 +54,237 @@ import org.slf4j.LoggerFactory;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class PolicyEngineTest {
- /**
- * Default Telemetry port for JUnits
- */
- public static final int DEFAULT_TELEMETRY_PORT = 9698;
-
- /**
- * Test JUnit Controller Name
- */
- public static final String TEST_CONTROLLER_NAME = "foo";
-
- /**
- * Controller Configuration File
- */
- public static final String TEST_CONTROLLER_FILE = TEST_CONTROLLER_NAME + "-controller.properties";
-
- /**
- * Controller Configuration Backup File
- */
- 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);
-
- /**
- * clean up working directory
- */
- protected static void cleanUpWorkingDir() {
- final Path testControllerPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
- try {
- Files.deleteIfExists(testControllerPath);
- } catch (final Exception e) {
- logger.info("Problem cleaning {}", testControllerPath, e);
- }
-
- final Path testControllerBakPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
- try {
- Files.deleteIfExists(testControllerBakPath);
- } catch (final Exception e) {
- logger.info("Problem cleaning {}", testControllerBakPath, e);
+ /**
+ * Default Telemetry port for JUnits
+ */
+ public static final int DEFAULT_TELEMETRY_PORT = 9698;
+
+ /**
+ * Test JUnit Controller Name
+ */
+ public static final String TEST_CONTROLLER_NAME = "foo";
+
+ /**
+ * Controller Configuration File
+ */
+ public static final String TEST_CONTROLLER_FILE = TEST_CONTROLLER_NAME + "-controller.properties";
+
+ /**
+ * Controller Configuration Backup File
+ */
+ 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);
+
+ /**
+ * clean up working directory
+ */
+ protected static void cleanUpWorkingDir() {
+ final Path testControllerPath =
+ Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
+ try {
+ Files.deleteIfExists(testControllerPath);
+ } catch (final Exception e) {
+ logger.info("Problem cleaning {}", testControllerPath, e);
+ }
+
+ final Path testControllerBakPath =
+ Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
+ try {
+ Files.deleteIfExists(testControllerBakPath);
+ } catch (final Exception e) {
+ logger.info("Problem cleaning {}", testControllerBakPath, e);
+ }
}
- }
- @BeforeClass
- public static void startUp() throws IOException {
- logger.info("enter");
+ @BeforeClass
+ public static void startUp() throws IOException {
+ logger.info("enter");
- cleanUpWorkingDir();
+ cleanUpWorkingDir();
- /* ensure presence of config directory */
- final Path configDir = Paths.get(SystemPersistence.DEFAULT_CONFIGURATION_DIR);
- if (Files.notExists(configDir))
- Files.createDirectories(configDir);
- }
+ /* ensure presence of config directory */
+ final Path configDir = Paths.get(SystemPersistence.DEFAULT_CONFIGURATION_DIR);
+ if (Files.notExists(configDir)) {
+ Files.createDirectories(configDir);
+ }
+ }
- @AfterClass
- public static void tearDown() throws IOException {
- logger.info("enter");
- cleanUpWorkingDir();
- }
+ @AfterClass
+ public static void tearDown() throws IOException {
+ logger.info("enter");
+ cleanUpWorkingDir();
+ }
- @Test
- public void test100Configure() {
- logger.info("enter");
+ @Test
+ public void test100Configure() {
+ logger.info("enter");
- final Properties engineProps = PolicyEngine.manager.defaultTelemetryConfig();
+ final Properties engineProps = PolicyEngine.manager.defaultTelemetryConfig();
- /* override default port */
- engineProps.put(PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME + PolicyProperties.PROPERTY_HTTP_PORT_SUFFIX,
- "" + DEFAULT_TELEMETRY_PORT);
+ /* override default port */
+ engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
+ + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX,
+ "" + DEFAULT_TELEMETRY_PORT);
- assertFalse(PolicyEngine.manager.isAlive());
- PolicyEngine.manager.configure(engineProps);
- assertFalse(PolicyEngine.manager.isAlive());
+ assertFalse(PolicyEngine.manager.isAlive());
+ PolicyEngine.manager.configure(engineProps);
+ assertFalse(PolicyEngine.manager.isAlive());
- logger.info("policy-engine {} has configuration {}", PolicyEngine.manager, engineProps);
- }
+ logger.info("policy-engine {} has configuration {}", PolicyEngine.manager, engineProps);
+ }
- @Test
- public void test200Start() {
- logger.info("enter");
+ @Test
+ public void test200Start() {
+ logger.info("enter");
- PolicyEngine.manager.start();
+ PolicyEngine.manager.start();
- assertTrue(PolicyEngine.manager.isAlive());
- assertFalse(PolicyEngine.manager.isLocked());
- assertFalse(PolicyEngine.manager.getHttpServers().isEmpty());
- assertTrue(PolicyEngine.manager.getHttpServers().get(0).isAlive());
- }
+ assertTrue(PolicyEngine.manager.isAlive());
+ assertFalse(PolicyEngine.manager.isLocked());
+ assertFalse(PolicyEngine.manager.getHttpServers().isEmpty());
+ assertTrue(PolicyEngine.manager.getHttpServers().get(0).isAlive());
+ }
- @Test
- public void test300Lock() {
- logger.info("enter");
+ @Test
+ public void test300Lock() {
+ logger.info("enter");
- PolicyEngine.manager.lock();
+ PolicyEngine.manager.lock();
- assertTrue(PolicyEngine.manager.isAlive());
- assertTrue(PolicyEngine.manager.isLocked());
- assertFalse(PolicyEngine.manager.getHttpServers().isEmpty());
- assertTrue(PolicyEngine.manager.getHttpServers().get(0).isAlive());
- }
+ assertTrue(PolicyEngine.manager.isAlive());
+ assertTrue(PolicyEngine.manager.isLocked());
+ assertFalse(PolicyEngine.manager.getHttpServers().isEmpty());
+ assertTrue(PolicyEngine.manager.getHttpServers().get(0).isAlive());
+ }
- @Test
- public void test301Unlock() {
- logger.info("enter");
+ @Test
+ public void test301Unlock() {
+ logger.info("enter");
- PolicyEngine.manager.unlock();
+ PolicyEngine.manager.unlock();
- assertTrue(PolicyEngine.manager.isAlive());
- assertFalse(PolicyEngine.manager.isLocked());
- assertFalse(PolicyEngine.manager.getHttpServers().isEmpty());
- assertTrue(PolicyEngine.manager.getHttpServers().get(0).isAlive());
- }
+ assertTrue(PolicyEngine.manager.isAlive());
+ assertFalse(PolicyEngine.manager.isLocked());
+ assertFalse(PolicyEngine.manager.getHttpServers().isEmpty());
+ assertTrue(PolicyEngine.manager.getHttpServers().get(0).isAlive());
+ }
- @Test
- public void test350TopicDeliver() {
- final Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, NOOP_TOPIC);
+ @Test
+ public void test350TopicDeliver() {
+ final Properties noopSinkProperties = new Properties();
+ noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, NOOP_TOPIC);
- TopicEndpoint.manager.addTopicSinks(noopSinkProperties).get(0).start();
+ ProxyTopicEndpointManager.getInstance().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());
+ 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)));
+ 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));
+ final TopicSink sink = IndexedNoopTopicSinkFactory.getInstance().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);
- }
+ EventProtocolCoder.manager.removeEncoders(ENCODER_GROUP, ENCODER_ARTIFACT, NOOP_TOPIC);
+ }
- @Test
- public void test400ControllerAdd() throws Exception {
- logger.info("enter");
+ @Test
+ public void test400ControllerAdd() throws Exception {
+ logger.info("enter");
- final Properties controllerProperties = new Properties();
- controllerProperties.put(PolicyProperties.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
- PolicyEngine.manager.createPolicyController(TEST_CONTROLLER_NAME, controllerProperties);
+ final Properties controllerProperties = new Properties();
+ controllerProperties.put(DroolsProperties.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
+ PolicyEngine.manager.createPolicyController(TEST_CONTROLLER_NAME, controllerProperties);
- assertTrue(PolicyController.factory.inventory().size() == 1);
- }
+ assertTrue(PolicyController.factory.inventory().size() == 1);
+ }
- @Test
- public void test401ControllerVerify() {
- logger.info("enter");
+ @Test
+ public void test401ControllerVerify() {
+ logger.info("enter");
- final PolicyController testController = PolicyController.factory.get(TEST_CONTROLLER_NAME);
+ final PolicyController testController = PolicyController.factory.get(TEST_CONTROLLER_NAME);
- assertFalse(testController.isAlive());
- assertFalse(testController.isLocked());
+ assertFalse(testController.isAlive());
+ assertFalse(testController.isLocked());
- testController.start();
+ testController.start();
- assertTrue(testController.isAlive());
- assertFalse(testController.isLocked());
- }
+ assertTrue(testController.isAlive());
+ assertFalse(testController.isLocked());
+ }
- @Test
- public void test500Deactivate() throws Exception {
- logger.info("enter");
+ @Test
+ public void test500Deactivate() throws Exception {
+ logger.info("enter");
- PolicyEngine.manager.deactivate();
+ PolicyEngine.manager.deactivate();
- final PolicyController testController = PolicyController.factory.get(TEST_CONTROLLER_NAME);
- assertFalse(testController.isAlive());
- assertTrue(testController.isLocked());
- assertTrue(PolicyEngine.manager.isLocked());
- assertTrue(PolicyEngine.manager.isAlive());
- }
+ final PolicyController testController = PolicyController.factory.get(TEST_CONTROLLER_NAME);
+ assertFalse(testController.isAlive());
+ assertTrue(testController.isLocked());
+ assertTrue(PolicyEngine.manager.isLocked());
+ assertTrue(PolicyEngine.manager.isAlive());
+ }
- @Test
- public void test501Activate() throws Exception {
- logger.info("enter");
+ @Test
+ public void test501Activate() throws Exception {
+ logger.info("enter");
- PolicyEngine.manager.activate();
+ PolicyEngine.manager.activate();
- final PolicyController testController = PolicyController.factory.get(TEST_CONTROLLER_NAME);
- assertTrue(testController.isAlive());
- assertFalse(testController.isLocked());
- assertFalse(PolicyEngine.manager.isLocked());
- assertTrue(PolicyEngine.manager.isAlive());
- }
+ final PolicyController testController = PolicyController.factory.get(TEST_CONTROLLER_NAME);
+ assertTrue(testController.isAlive());
+ assertFalse(testController.isLocked());
+ assertFalse(PolicyEngine.manager.isLocked());
+ assertTrue(PolicyEngine.manager.isAlive());
+ }
- @Test
- public void test900ControllerRemove() throws Exception {
- logger.info("enter");
+ @Test
+ public void test900ControllerRemove() throws Exception {
+ logger.info("enter");
- PolicyEngine.manager.removePolicyController(TEST_CONTROLLER_NAME);
- assertTrue(PolicyController.factory.inventory().isEmpty());
- }
+ PolicyEngine.manager.removePolicyController(TEST_CONTROLLER_NAME);
+ assertTrue(PolicyController.factory.inventory().isEmpty());
+ }
- @Test
- public void test901Stop() throws InterruptedException {
- logger.info("enter");
+ @Test
+ public void test901Stop() throws InterruptedException {
+ logger.info("enter");
- /* Shutdown managed resources */
- PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
- PolicyEngine.manager.stop();
+ /* Shutdown managed resources */
+ PolicyController.factory.shutdown();
+ ProxyTopicEndpointManager.getInstance().shutdown();
+ PolicyEngine.manager.stop();
- Thread.sleep(10000L);
- assertFalse(PolicyEngine.manager.isAlive());
- }
+ Thread.sleep(10000L);
+ assertFalse(PolicyEngine.manager.isAlive());
+ }
}