Allow topics to be registered with lower case for kafka compability 58/136858/1
authoradheli.tavares <adheli.tavares@est.tech>
Mon, 18 Dec 2023 17:52:52 +0000 (17:52 +0000)
committeradheli.tavares <adheli.tavares@est.tech>
Mon, 18 Dec 2023 17:53:45 +0000 (17:53 +0000)
Issue-ID: POLICY-4402
Change-Id: Ia2fabc3eed64bc8ecbdf1ab048a2101ee31daf04
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java
main/src/test/java/org/onap/policy/pap/main/parameters/CommonTestData.java

index 4d90d7e..91fc21a 100644 (file)
@@ -68,15 +68,15 @@ public class PapActivator extends ServiceManagerContainer {
     // topic names
     @Getter
     @Value("${pap.topic.pdp-pap.name}")
-    private String topicPolicyPdpPap = "POLICY-PDP-PAP";
+    private String topicPolicyPdpPap = "policy-pdp-pap";
 
     @Getter
     @Value("${pap.topic.notification.name}")
-    private String topicPolicyNotification = "POLICY-NOTIFICATION";
+    private String topicPolicyNotification = "policy-notification";
 
     @Getter
     @Value("${pap.topic.heartbeat.name}")
-    private String topicPolicyHeartbeat = "POLICY-HEARTBEAT";
+    private String topicPolicyHeartbeat = "policy-heartbeat";
 
     private static final String[] MSG_TYPE_NAMES = { "messageName" };
     private static final String[] REQ_ID_NAMES = { "response", "responseTo" };
@@ -267,6 +267,7 @@ public class PapActivator extends ServiceManagerContainer {
      * @param topic topic of interest
      */
     private void registerMsgDispatcher(TopicListener dispatcher, String topic) {
+        topic = topic.toLowerCase();
         for (final TopicSource source : TopicEndpointManager.getManager().getTopicSources(List.of(topic))) {
             source.register(dispatcher);
         }
@@ -278,6 +279,7 @@ public class PapActivator extends ServiceManagerContainer {
      * @param topic topic of interest
      */
     private void unregisterMsgDispatcher(TopicListener dispatcher, String topic) {
+        topic = topic.toLowerCase();
         for (final TopicSource source : TopicEndpointManager.getManager().getTopicSources(List.of(topic))) {
             source.unregister(dispatcher);
         }
index 6ef828b..4eeeae1 100644 (file)
@@ -58,7 +58,7 @@ public class PublisherTest extends Threaded {
     private static final String JSON1;
     private static final String JSON2;
 
-    protected static final String PDP_PAP_TOPIC = "POLICY-PDP-PAP";
+    protected static final String PDP_PAP_TOPIC = "policy-pdp-pap";
 
     static {
         try {
index 130f1ef..fad82c7 100644 (file)
@@ -25,7 +25,6 @@ package org.onap.policy.pap.main.parameters;
 
 import java.io.File;
 import java.io.IOException;
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import org.onap.policy.common.utils.coder.Coder;
@@ -75,7 +74,7 @@ public class CommonTestData {
 
         try {
             File file = new File(getParamFile());
-            String json = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
+            String json = Files.readString(file.toPath());
 
             json = json.replace("${port}", String.valueOf(port));
             json = json.replace("${dbName}", "jdbc:h2:mem:testdb" + dbNum);
@@ -110,8 +109,8 @@ public class CommonTestData {
     }
 
     /**
-     * Gets the full path to the parameter file, which may vary depending on whether or
-     * not this is an end-to-end test.
+     * Gets the full path to the parameter file, which may vary depending on whether
+     * this is an end-to-end test.
      *
      * @return the parameter file name
      */