summaryrefslogtreecommitdiffstats
path: root/main/src/test/java
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@est.tech>2019-07-01 14:50:01 +0000
committera.sreekumar <ajith.sreekumar@est.tech>2019-07-01 14:50:01 +0000
commit9ef4186f69ef694e6251161622a33d7bc1400f39 (patch)
tree054b74bdc1699e85555e65c2341265c6daf2b758 /main/src/test/java
parentd848416090efd6850ab25011d8518b15525a1bdb (diff)
Remove topic.properties and incorporate into overall config file
1) The properties in the topic.properties file is moved into overall config json file and the topic.properties file is removed. 2) Common parameters such as RestServer and Topic related parameters from policy-common is used. Change-Id: I390bbe3cda101a69e7ce614404ecdfbf98598dd2 Issue-ID: POLICY-1744 Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
Diffstat (limited to 'main/src/test/java')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java17
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java7
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/CommonPapRestServer.java7
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java3
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java11
5 files changed, 19 insertions, 26 deletions
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 f15b2a04..cadae12b 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
@@ -26,8 +26,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.io.FileInputStream;
import java.util.Properties;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Semaphore;
@@ -40,14 +38,17 @@ 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.TopicListener;
+import org.onap.policy.common.endpoints.utils.ParameterUtils;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.pdp.concepts.PdpMessage;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.pap.main.PapConstants;
import org.onap.policy.pap.main.PolicyPapException;
+import org.onap.policy.pap.main.parameters.PapParameterGroup;
+import org.onap.policy.pap.main.parameters.PapParameterHandler;
+import org.onap.policy.pap.main.startstop.PapCommandLineArguments;
public class PublisherTest extends Threaded {
@@ -86,12 +87,10 @@ public class PublisherTest extends Threaded {
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
- Properties props = new Properties();
- File propFile = new File(ResourceUtils.getFilePath4Resource("parameters/topic.properties"));
- try (FileInputStream inp = new FileInputStream(propFile)) {
- props.load(inp);
- }
-
+ final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters.json"};
+ final PapCommandLineArguments arguments = new PapCommandLineArguments(papConfigParameters);
+ final PapParameterGroup parameterGroup = new PapParameterHandler().getParameters(arguments);
+ Properties props = ParameterUtils.getTopicProperties(parameterGroup.getTopicParameterGroup());
TopicEndpoint.manager.shutdown();
TopicEndpoint.manager.addTopics(props);
diff --git a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java
index 6a1fbba2..c22f5e1f 100644
--- a/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java
+++ b/main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java
@@ -26,6 +26,8 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -50,6 +52,7 @@ public class TestPapParameterGroup {
public void testPapParameterGroup() {
final PapParameterGroup papParameters = commonTestData.getPapParameterGroup(1);
final RestServerParameters restServerParameters = papParameters.getRestServerParameters();
+ final TopicParameterGroup topicParameterGroup = papParameters.getTopicParameterGroup();
final GroupValidationResult validationResult = papParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(CommonTestData.PAP_GROUP_NAME, papParameters.getName());
@@ -59,6 +62,8 @@ public class TestPapParameterGroup {
assertEquals(restServerParameters.getPassword(), papParameters.getRestServerParameters().getPassword());
assertTrue(papParameters.getRestServerParameters().isHttps());
assertFalse(papParameters.getRestServerParameters().isAaf());
+ assertEquals(topicParameterGroup.getTopicSinks(), papParameters.getTopicParameterGroup().getTopicSinks());
+ assertEquals(topicParameterGroup.getTopicSources(), papParameters.getTopicParameterGroup().getTopicSources());
}
@Test
@@ -99,7 +104,7 @@ public class TestPapParameterGroup {
final GroupValidationResult validationResult = papParameters.validate();
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
- .contains("\"org.onap.policy.pap.main.parameters.RestServerParameters\" INVALID, "
+ .contains("\"org.onap.policy.common.endpoints.parameters.RestServerParameters\" INVALID, "
+ "parameter group has status INVALID"));
}
}
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 d4b69f2e..4abe6f10 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
@@ -185,12 +185,7 @@ public class CommonPapRestServer {
systemProps.put("javax.net.ssl.keyStorePassword", "Pol1cy_0nap");
System.setProperties(systemProps);
- // @formatter:off
- final String[] papConfigParameters = {
- "-c", "src/test/resources/parameters/TestConfigParams.json",
- "-p", "src/test/resources/parameters/topic.properties"
- };
- // @formatter:on
+ final String[] papConfigParameters = { "-c", "src/test/resources/parameters/TestConfigParams.json" };
main = new Main(papConfigParameters);
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 5ed94a36..016e120d 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
@@ -66,8 +66,7 @@ public class TestMain {
@Test
public void testMain() throws PolicyPapException {
- final String[] papConfigParameters =
- {"-c", "parameters/PapConfigParameters.json", "-p", "parameters/topic.properties"};
+ final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters.json"};
main = new Main(papConfigParameters);
assertTrue(main.getParameters().isValid());
assertEquals(CommonTestData.PAP_GROUP_NAME, main.getParameters().getName());
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 f369488a..fe2e8374 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
@@ -28,12 +28,12 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import java.io.FileInputStream;
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.utils.ParameterUtils;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.pap.main.PapConstants;
import org.onap.policy.pap.main.PolicyPapException;
@@ -63,16 +63,11 @@ public class TestPapActivator {
Registry.newRegistry();
HttpServletServer.factory.destroy();
- final String[] papConfigParameters =
- {"-c", "parameters/PapConfigParameters.json", "-p", "parameters/topic.properties"};
+ final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters.json"};
final PapCommandLineArguments arguments = new PapCommandLineArguments(papConfigParameters);
final PapParameterGroup parGroup = new PapParameterHandler().getParameters(arguments);
- Properties props = new Properties();
- String propFile = arguments.getFullPropertyFilePath();
- try (FileInputStream stream = new FileInputStream(propFile)) {
- props.load(stream);
- }
+ Properties props = ParameterUtils.getTopicProperties(parGroup.getTopicParameterGroup());
activator = new PapActivator(parGroup, props);
}