From 27f6bacd9c7ef76557a8a653142ed8e67a091a5a Mon Sep 17 00:00:00 2001 From: jrh3 Date: Mon, 8 Jul 2019 15:30:51 -0400 Subject: Fix pap due to sonar changes in common Fixed breakages due to changes made in policy/common to satisfy sonar. Issue-ID: POLICY-1791 Signed-off-by: jrh3 Change-Id: If8685462e1dd5cbbe58c329defff74ff2accf559 --- .../java/org/onap/policy/pap/main/rest/PapRestServer.java | 3 ++- .../org/onap/policy/pap/main/startstop/PapActivator.java | 14 +++++++------- .../java/org/onap/policy/pap/main/comm/PublisherTest.java | 14 +++++++------- .../org/onap/policy/pap/main/rest/CommonPapRestServer.java | 8 ++++---- .../org/onap/policy/pap/main/rest/e2e/End2EndContext.java | 8 ++++---- .../java/org/onap/policy/pap/main/startstop/TestMain.java | 4 ++-- .../onap/policy/pap/main/startstop/TestPapActivator.java | 4 ++-- 7 files changed, 28 insertions(+), 27 deletions(-) diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PapRestServer.java b/main/src/main/java/org/onap/policy/pap/main/rest/PapRestServer.java index c86cb81e..a4727d00 100644 --- a/main/src/main/java/org/onap/policy/pap/main/rest/PapRestServer.java +++ b/main/src/main/java/org/onap/policy/pap/main/rest/PapRestServer.java @@ -27,6 +27,7 @@ import java.util.Properties; import org.onap.policy.common.capabilities.Startable; import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.common.gson.GsonMessageBodyHandler; @@ -63,7 +64,7 @@ public class PapRestServer implements Startable { @Override public boolean start() { try { - servers = HttpServletServer.factory.build(getServerProperties()); + servers = HttpServletServerFactoryInstance.getServerFactory().build(getServerProperties()); for (final HttpServletServer server : servers) { if (server.isAaf()) { server.addFilterClass(null, PapAafFilter.class.getName()); diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java index e1ad80e2..5ceb55a1 100644 --- a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java +++ b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java @@ -24,7 +24,7 @@ package org.onap.policy.pap.main.startstop; import java.util.Arrays; import java.util.Properties; import java.util.concurrent.atomic.AtomicReference; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicSource; import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher; import org.onap.policy.common.endpoints.listeners.RequestIdDispatcher; @@ -90,8 +90,8 @@ public class PapActivator extends ServiceManagerContainer { public PapActivator(final PapParameterGroup papParameterGroup, final Properties topicProperties) { super("Policy PAP"); - TopicEndpoint.manager.addTopicSinks(topicProperties); - TopicEndpoint.manager.addTopicSources(topicProperties); + TopicEndpointManager.getManager().addTopicSinks(topicProperties); + TopicEndpointManager.getManager().addTopicSources(topicProperties); try { this.papParameterGroup = papParameterGroup; @@ -142,8 +142,8 @@ public class PapActivator extends ServiceManagerContainer { this::unregisterMsgDispatcher); addAction("topics", - TopicEndpoint.manager::start, - TopicEndpoint.manager::shutdown); + TopicEndpointManager.getManager()::start, + TopicEndpointManager.getManager()::shutdown); addAction("PAP statistics", () -> Registry.register(PapConstants.REG_STATISTICS_MANAGER, new PapStatisticsManager()), @@ -240,7 +240,7 @@ public class PapActivator extends ServiceManagerContainer { * Registers the dispatcher with the topic source(s). */ private void registerMsgDispatcher() { - for (final TopicSource source : TopicEndpoint.manager + for (final TopicSource source : TopicEndpointManager.getManager() .getTopicSources(Arrays.asList(PapConstants.TOPIC_POLICY_PDP_PAP))) { source.register(msgDispatcher); } @@ -250,7 +250,7 @@ public class PapActivator extends ServiceManagerContainer { * Unregisters the dispatcher from the topic source(s). */ private void unregisterMsgDispatcher() { - for (final TopicSource source : TopicEndpoint.manager + for (final TopicSource source : TopicEndpointManager.getManager() .getTopicSources(Arrays.asList(PapConstants.TOPIC_POLICY_PDP_PAP))) { source.unregister(msgDispatcher); } diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java index cadae12b..d399f635 100644 --- a/main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java @@ -36,7 +36,7 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.utils.ParameterUtils; import org.onap.policy.common.utils.coder.Coder; @@ -91,15 +91,15 @@ public class PublisherTest extends Threaded { final PapCommandLineArguments arguments = new PapCommandLineArguments(papConfigParameters); final PapParameterGroup parameterGroup = new PapParameterHandler().getParameters(arguments); Properties props = ParameterUtils.getTopicProperties(parameterGroup.getTopicParameterGroup()); - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); - TopicEndpoint.manager.addTopics(props); - TopicEndpoint.manager.start(); + TopicEndpointManager.getManager().addTopics(props); + TopicEndpointManager.getManager().start(); } @AfterClass public static void tearDownAfterClass() throws Exception { - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); } /** @@ -114,7 +114,7 @@ public class PublisherTest extends Threaded { pub = new Publisher(PapConstants.TOPIC_POLICY_PDP_PAP); listener = new MyListener(); - TopicEndpoint.manager.getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).register(listener); + TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).register(listener); } /** @@ -124,7 +124,7 @@ public class PublisherTest extends Threaded { */ @After public void tearDown() throws Exception { - TopicEndpoint.manager.getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).unregister(listener); + TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).unregister(listener); super.tearDown(); } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/CommonPapRestServer.java b/main/src/test/java/org/onap/policy/pap/main/rest/CommonPapRestServer.java index 4abe6f10..91245084 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/CommonPapRestServer.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/CommonPapRestServer.java @@ -43,8 +43,8 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.gson.GsonMessageBodyHandler; import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.common.utils.services.Registry; @@ -94,8 +94,8 @@ public class CommonPapRestServer { makeConfigFile(); - HttpServletServer.factory.destroy(); - TopicEndpoint.manager.shutdown(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); + TopicEndpointManager.getManager().shutdown(); CommonTestData.newDb(); diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndContext.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndContext.java index fe0f682a..38ffe8db 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndContext.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndContext.java @@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.LinkedBlockingQueue; import lombok.Getter; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSource; import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher; @@ -129,9 +129,9 @@ public class End2EndContext { * Constructs the object. */ public End2EndContext() { - toPapTopic = TopicEndpoint.manager.getNoopTopicSource(PapConstants.TOPIC_POLICY_PDP_PAP); + toPapTopic = TopicEndpointManager.getManager().getNoopTopicSource(PapConstants.TOPIC_POLICY_PDP_PAP); - TopicEndpoint.manager.getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).register(topicListener); + TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).register(topicListener); dispatcher = new MessageTypeDispatcher("messageName"); dispatcher.register(PdpMessageType.PDP_UPDATE.name(), new UpdateListener()); @@ -200,7 +200,7 @@ public class End2EndContext { toPap.clear(); pdps.forEach(pdp -> toPap.add(DONE)); - TopicEndpoint.manager.getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).unregister(topicListener); + TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).unregister(topicListener); } /** diff --git a/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java index 016e120d..2658b36c 100644 --- a/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java +++ b/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java @@ -28,7 +28,7 @@ import static org.junit.Assert.assertTrue; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.pap.main.PapConstants; import org.onap.policy.pap.main.PolicyPapException; @@ -48,7 +48,7 @@ public class TestMain { @Before public void setUp() { Registry.newRegistry(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); } /** diff --git a/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java b/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java index fe2e8374..2ebd234c 100644 --- a/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java +++ b/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java @@ -32,7 +32,7 @@ import java.util.Properties; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.utils.ParameterUtils; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.pap.main.PapConstants; @@ -61,7 +61,7 @@ public class TestPapActivator { @Before public void setUp() throws Exception { Registry.newRegistry(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters.json"}; final PapCommandLineArguments arguments = new PapCommandLineArguments(papConfigParameters); -- cgit 1.2.3-korg