Removing deprecated DMAAP library
[policy/drools-pdp.git] / policy-management / src / test / java / org / onap / policy / drools / server / restful / test / RestManagerTest.java
index ad0d1af..65447d8 100644 (file)
@@ -21,7 +21,7 @@
 
 package org.onap.policy.drools.server.restful.test;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 import java.nio.file.Files;
@@ -44,11 +44,11 @@ import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.http.server.YamlJacksonHandler;
 import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
@@ -60,7 +60,7 @@ import org.onap.policy.drools.system.PolicyEngineConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@TestMethodOrder(MethodOrderer.DisplayName.class)
 public class RestManagerTest {
     private static final int DEFAULT_TELEMETRY_PORT = 7887;
     private static final String HOST = "localhost";
@@ -71,31 +71,19 @@ public class RestManagerTest {
     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 KAFKA_TOPIC = "kafka-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 KAFKA_SOURCE_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_KAFKA_SOURCE_TOPICS
+            + "." + KAFKA_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
+    private static final String KAFKA_SINK_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_KAFKA_SINK_TOPICS + "."
+            + KAFKA_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 KAFKA_SERVER = "localhost:9092";
 
     private static final String FOO_CONTROLLER_FILE = FOO_CONTROLLER + "-controller.properties";
     private static final String FOO_CONTROLLER_FILE_BAK = FOO_CONTROLLER_FILE + ".bak";
@@ -111,7 +99,7 @@ public class RestManagerTest {
      *
      * @throws IOException throws an IO exception
      */
-    @BeforeClass
+    @BeforeAll
     public static void setUp() throws IOException, InterruptedException {
         cleanUpWorkingDirs();
 
@@ -122,10 +110,6 @@ public class RestManagerTest {
         engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
                         + PolicyEngineConstants.TELEMETRY_SERVER_DEFAULT_NAME
                         + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX, "" + DEFAULT_TELEMETRY_PORT);
-        engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
-                + PolicyEngineConstants.TELEMETRY_SERVER_DEFAULT_NAME
-                + PolicyEndPointProperties.PROPERTY_HTTP_FILTER_CLASSES_SUFFIX,
-                TestAafTelemetryAuthFilter.class.getName());
         engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
                 + PolicyEngineConstants.TELEMETRY_SERVER_DEFAULT_NAME
                 + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX,
@@ -142,16 +126,12 @@ public class RestManagerTest {
         /* 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(PolicyEndPointProperties.PROPERTY_KAFKA_SOURCE_TOPICS, KAFKA_TOPIC);
+        engineProps.put(PolicyEndPointProperties.PROPERTY_KAFKA_SINK_TOPICS, KAFKA_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(KAFKA_SOURCE_SERVER_PROPERTY, KAFKA_SERVER);
+        engineProps.put(KAFKA_SINK_SERVER_PROPERTY, KAFKA_SERVER);
 
         PolicyEngineConstants.getManager().configure(engineProps);
         PolicyEngineConstants.getManager().start();
@@ -181,7 +161,7 @@ public class RestManagerTest {
      *
      * @throws IOException IO exception
      */
-    @AfterClass
+    @AfterAll
     public static void tearDown() throws IOException {
         try {
             client.close();
@@ -198,7 +178,7 @@ public class RestManagerTest {
 
 
     @Test
-    public void testPutDelete() throws IOException {
+    void testPutDelete() throws IOException {
         putTest(HOST_URL + "/engine/switches/lock", 406);
         deleteTest(HOST_URL + "/engine/switches/lock", 406);
 
@@ -218,24 +198,24 @@ public class RestManagerTest {
 
     private void putDeleteTopicSwitches() throws IOException {
         putDeleteSwitch("/engine/topics/sources/ueb/", UEB_TOPIC, "lock");
-        putDeleteSwitch("/engine/topics/sources/dmaap/", DMAAP_TOPIC, "lock");
+        putDeleteSwitch("/engine/topics/sources/kafka/", KAFKA_TOPIC, "lock");
         putDeleteSwitch("/engine/topics/sources/noop/", NOOP_TOPIC, "lock");
         putDeleteSwitch("/engine/topics/sinks/ueb/", UEB_TOPIC, "lock");
-        putDeleteSwitch("/engine/topics/sinks/dmaap/", DMAAP_TOPIC, "lock");
+        putDeleteSwitch("/engine/topics/sinks/kafka/", KAFKA_TOPIC, "lock");
         putDeleteSwitch("/engine/topics/sinks/noop/", NOOP_TOPIC, "lock");
 
         putDeleteSwitch("/engine/topics/sources/ueb/", UEB_TOPIC, "activation");
-        putDeleteSwitch("/engine/topics/sources/dmaap/", DMAAP_TOPIC, "activation");
+        putDeleteSwitch("/engine/topics/sources/kafka/", KAFKA_TOPIC, "activation");
         putDeleteSwitch("/engine/topics/sources/noop/", NOOP_TOPIC, "activation");
         putDeleteSwitch("/engine/topics/sinks/ueb/", UEB_TOPIC, "activation");
-        putDeleteSwitch("/engine/topics/sinks/dmaap/", DMAAP_TOPIC, "activation");
+        putDeleteSwitch("/engine/topics/sinks/kafka/", KAFKA_TOPIC, "activation");
         putDeleteSwitch("/engine/topics/sinks/noop/", NOOP_TOPIC, "activation");
 
         putSwitch("/engine/topics/sources/ueb/", UEB_TOPIC, "activation");
-        putSwitch("/engine/topics/sources/dmaap/", DMAAP_TOPIC, "activation");
+        putSwitch("/engine/topics/sources/kafka/", KAFKA_TOPIC, "activation");
         putSwitch("/engine/topics/sources/noop/", NOOP_TOPIC, "activation");
         putSwitch("/engine/topics/sinks/ueb/", UEB_TOPIC, "activation");
-        putSwitch("/engine/topics/sinks/dmaap/", DMAAP_TOPIC, "activation");
+        putSwitch("/engine/topics/sinks/kafka/", KAFKA_TOPIC, "activation");
         putSwitch("/engine/topics/sinks/noop/", NOOP_TOPIC, "activation");
     }
 
@@ -244,15 +224,15 @@ public class RestManagerTest {
                 "{x:y}", ContentType.TEXT_PLAIN);
         putTest(HOST_URL + "/engine/topics/sources/noop/" + NOOP_TOPIC + "/events", 200,
             "{x:y}", ContentType.TEXT_PLAIN);
-        putTest(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events", 200,
+        putTest(HOST_URL + "/engine/topics/sources/kafka/" + KAFKA_TOPIC + "/events", 200,
                 "FOOOO", ContentType.TEXT_PLAIN);
         putTest(HOST_URL + "/engine/topics/sources/ueb/fiznits/events", 406, "FOOOO", ContentType.TEXT_PLAIN);
-        putTest(HOST_URL + "/engine/topics/sources/dmaap/fiznits/events", 406,
+        putTest(HOST_URL + "/engine/topics/sources/kafka/fiznits/events", 406,
                 "FOOOO", ContentType.TEXT_PLAIN);
         putTest(HOST_URL + "/engine/topics/switches/lock", 200);
         putTest(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/events",
                 406, "FOOOO", ContentType.TEXT_PLAIN);
-        putTest(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events",
+        putTest(HOST_URL + "/engine/topics/sources/kafka/" + KAFKA_TOPIC + "/events",
                 406, "FOOOO", ContentType.TEXT_PLAIN);
         deleteTest(HOST_URL + "/engine/topics/switches/lock", 200);
     }
@@ -311,7 +291,7 @@ public class RestManagerTest {
     }
 
     @Test
-    public void testPost() throws IOException {
+    void testPost() throws IOException {
         postTest(HOST_URL + "/engine/inputs/configuration", 406,
                 Files.readString(Paths.get(PDP_CONFIGURATION_JSON)),
                 ContentType.APPLICATION_JSON);
@@ -338,7 +318,7 @@ public class RestManagerTest {
     }
 
     @Test
-    public void testGetSwagger() throws IOException {
+    void testGetSwagger() throws IOException {
         HttpGet httpGet;
         CloseableHttpResponse response;
         httpGet = new HttpGet(HOST_URL + "/engine/swagger");
@@ -349,7 +329,7 @@ public class RestManagerTest {
     }
 
     @Test
-    public void testGet() throws IOException {
+    void testGet() throws IOException {
         HttpGet httpGet;
         CloseableHttpResponse response;
 
@@ -630,13 +610,13 @@ public class RestManagerTest {
 
         /*
          * 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
+         * /engine/topics/sinks/ueb /engine/topics/sources/ueb /engine/topics/sinks/kafka
+         * /engine/topics/sources/kafka /engine/topics/sinks/ueb/topic
+         * /engine/topics/sources/ueb/topic /engine/topics/sinks/kafka/topic
+         * /engine/topics/sources/kafka/topic /engine/topics/sinks/ueb/topic/events
+         * /engine/topics/sources/ueb/topic/events /engine/topics/sinks/kafka/topic/events
+         * /engine/topics/sources/kafka/topic/events /engine/topics/sources/ueb/topic/switches
+         * /engine/topics/sources/kafka/topic/switches
          */
         httpGet = new HttpGet(HOST_URL + "/engine/topics");
         response = client.execute(httpGet);
@@ -674,13 +654,13 @@ public class RestManagerTest {
         assertEquals(200, response.getStatusLine().getStatusCode());
         httpGet.releaseConnection();
 
-        httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap");
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka");
         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");
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka");
         response = client.execute(httpGet);
         logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
         assertEquals(200, response.getStatusLine().getStatusCode());
@@ -722,25 +702,25 @@ public class RestManagerTest {
         assertEquals(500, response.getStatusLine().getStatusCode());
         httpGet.releaseConnection();
 
-        httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC);
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka/" + KAFKA_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");
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka/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);
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka/" + KAFKA_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");
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka/foobar");
         response = client.execute(httpGet);
         logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
         assertEquals(500, response.getStatusLine().getStatusCode());
@@ -794,25 +774,25 @@ public class RestManagerTest {
         assertEquals(500, response.getStatusLine().getStatusCode());
         httpGet.releaseConnection();
 
-        httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events");
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka/" + KAFKA_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");
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka/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");
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka/" + KAFKA_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");
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka/foobar/events");
         response = client.execute(httpGet);
         logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
         assertEquals(500, response.getStatusLine().getStatusCode());
@@ -848,7 +828,7 @@ public class RestManagerTest {
         assertEquals(200, response.getStatusLine().getStatusCode());
         httpGet.releaseConnection();
 
-        httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/switches");
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka/" + KAFKA_TOPIC + "/switches");
         response = client.execute(httpGet);
         logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
         assertEquals(200, response.getStatusLine().getStatusCode());
@@ -866,7 +846,7 @@ public class RestManagerTest {
         assertEquals(200, response.getStatusLine().getStatusCode());
         httpGet.releaseConnection();
 
-        httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/" + DMAAP_TOPIC + "/switches");
+        httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka/" + KAFKA_TOPIC + "/switches");
         response = client.execute(httpGet);
         logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
         assertEquals(200, response.getStatusLine().getStatusCode());