summaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@ericsson.com>2018-08-23 13:50:31 +0100
committerramverma <ram.krishna.verma@ericsson.com>2018-08-24 10:04:31 +0100
commitef2ff6bae65870a4fccc25373c0cfae881e14a81 (patch)
tree2329de6759a3f74237b8a64dcbe63d7114f532ef /main/src/test
parent55e6bdc93d05f1c9673a4ecbe133207722216eb0 (diff)
Fix sonar and checkstyle issues in distribution
* Fixing all check style issues. * Fixing all sonar issues. * Adding maven check style plugin to fail at warning level. Change-Id: I791b8feef39a3a0c3e1e250efea7b6e78208bf07 Issue-ID: POLICY-1035 Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java16
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java55
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java71
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java18
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java4
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java14
6 files changed, 94 insertions, 84 deletions
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java
index 59f551cf..62ad0674 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java
@@ -26,9 +26,9 @@ import java.util.List;
import java.util.Map;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
-import org.onap.policy.distribution.reception.parameters.PSSDConfigurationParametersGroup;
import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters;
+import org.onap.policy.distribution.reception.parameters.PssdConfigurationParametersGroup;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
/**
@@ -85,7 +85,7 @@ public class CommonTestData {
if (!isEmpty) {
final Map<String, PolicyDecoderParameters> policyDecoders = getPolicyDecoders(isEmpty);
final Map<String, PolicyForwarderParameters> policyForwarders = getPolicyForwarders(isEmpty);
- final PSSDConfigurationParametersGroup pssdConfiguration = getPSSDConfigurationParametersGroup(isEmpty);;
+ final PssdConfigurationParametersGroup pssdConfiguration = getPssdConfigurationParametersGroup(isEmpty);;
final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
final ReceptionHandlerParameters rhParameters = new ReceptionHandlerParameters(RECEPTION_HANDLER_TYPE,
RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
@@ -95,26 +95,26 @@ public class CommonTestData {
}
/**
- * Returns an instance of PSSDConfigurationParametersGroup for test cases.
+ * Returns an instance of PssdConfigurationParametersGroup for test cases.
*
* @param isEmpty boolean value to represent that object created should be empty or not
- * @return the PSSDConfigurationParametersGroup object
+ * @return the PssdConfigurationParametersGroup object
*/
- public PSSDConfigurationParametersGroup getPSSDConfigurationParametersGroup(final boolean isEmpty) {
- final PSSDConfigurationParametersGroup pssdConfiguration;
+ public PssdConfigurationParametersGroup getPssdConfigurationParametersGroup(final boolean isEmpty) {
+ final PssdConfigurationParametersGroup pssdConfiguration;
if (!isEmpty) {
final List<String> messageBusAddress = new ArrayList<>();
messageBusAddress.add("localhost");
final List<String> artifactTypes = new ArrayList<>();
artifactTypes.add("TOSCA_CSAR");
- pssdConfiguration = new PSSDConfigurationParametersGroup.PSSDConfigurationBuilder()
+ pssdConfiguration = new PssdConfigurationParametersGroup.PssdConfigurationBuilder()
.setAsdcAddress("localhost").setMessageBusAddress(messageBusAddress).setUser("policy")
.setPassword("policy").setPollingInterval(20).setPollingTimeout(30).setConsumerId("policy-id")
.setArtifactTypes(artifactTypes).setConsumerGroup("policy-group").setEnvironmentName("TEST")
.setKeystorePath("").setKeystorePassword("").setActiveserverTlsAuth(false)
.setIsFilterinEmptyResources(true).setIsUseHttpsWithDmaap(false).build();
} else {
- pssdConfiguration = new PSSDConfigurationParametersGroup.PSSDConfigurationBuilder().build();
+ pssdConfiguration = new PssdConfigurationParametersGroup.PssdConfigurationBuilder().build();
}
return pssdConfiguration;
}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
index 69ff0f14..a324e3da 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
@@ -36,7 +36,8 @@ import org.onap.policy.distribution.main.startstop.DistributionCommandLineArgume
public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerNoParameterFile() throws PolicyDistributionException {
- final String[] noArgumentString = { "-c", "parameters/NoParameterFile.json" };
+ final String[] noArgumentString =
+ { "-c", "parameters/NoParameterFile.json" };
final DistributionCommandLineArguments noArguments = new DistributionCommandLineArguments();
noArguments.parse(noArgumentString);
@@ -51,7 +52,8 @@ public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerEmptyParameters() throws PolicyDistributionException {
- final String[] emptyArgumentString = { "-c", "parameters/EmptyParameters.json" };
+ final String[] emptyArgumentString =
+ { "-c", "parameters/EmptyParameters.json" };
final DistributionCommandLineArguments emptyArguments = new DistributionCommandLineArguments();
emptyArguments.parse(emptyArgumentString);
@@ -66,7 +68,8 @@ public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerBadParameters() throws PolicyDistributionException {
- final String[] badArgumentString = { "-c", "parameters/BadParameters.json" };
+ final String[] badArgumentString =
+ { "-c", "parameters/BadParameters.json" };
final DistributionCommandLineArguments badArguments = new DistributionCommandLineArguments();
badArguments.parse(badArgumentString);
@@ -83,7 +86,8 @@ public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerInvalidParameters() throws PolicyDistributionException {
- final String[] invalidArgumentString = { "-c", "parameters/InvalidParameters.json" };
+ final String[] invalidArgumentString =
+ { "-c", "parameters/InvalidParameters.json" };
final DistributionCommandLineArguments invalidArguments = new DistributionCommandLineArguments();
invalidArguments.parse(invalidArgumentString);
@@ -100,7 +104,8 @@ public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerNoParameters() throws PolicyDistributionException {
- final String[] noArgumentString = { "-c", "parameters/NoParameters.json" };
+ final String[] noArgumentString =
+ { "-c", "parameters/NoParameters.json" };
final DistributionCommandLineArguments noArguments = new DistributionCommandLineArguments();
noArguments.parse(noArgumentString);
@@ -115,7 +120,8 @@ public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerMinumumParameters() throws PolicyDistributionException {
- final String[] minArgumentString = { "-c", "parameters/MinimumParameters.json" };
+ final String[] minArgumentString =
+ { "-c", "parameters/MinimumParameters.json" };
final DistributionCommandLineArguments minArguments = new DistributionCommandLineArguments();
minArguments.parse(minArgumentString);
@@ -126,7 +132,8 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup() throws PolicyDistributionException {
- final String[] distributionConfigParameters = { "-c", "parameters/DistributionConfigParameters.json" };
+ final String[] distributionConfigParameters =
+ { "-c", "parameters/DistributionConfigParameters.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -148,7 +155,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidName() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidName.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidName.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -165,7 +172,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidReceptionHandlerType() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -183,7 +190,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidPolicyDecoderType() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -200,7 +207,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidPolicyForwarderType() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -217,7 +224,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_NoReceptionHandler() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_NoReceptionHandler.json" };
+ { "-c", "parameters/DistributionConfigParameters_NoReceptionHandler.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -233,7 +240,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_EmptyReceptionHandler() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_EmptyReceptionHandler.json" };
+ { "-c", "parameters/DistributionConfigParameters_EmptyReceptionHandler.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -249,7 +256,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_NoPolicyDecoder() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_NoPolicyDecoder.json" };
+ { "-c", "parameters/DistributionConfigParameters_NoPolicyDecoder.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -265,7 +272,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_NoPolicyForwarder() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_NoPolicyForwarder.json" };
+ { "-c", "parameters/DistributionConfigParameters_NoPolicyForwarder.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -281,7 +288,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_EmptyPolicyDecoder() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_EmptyPolicyDecoder.json" };
+ { "-c", "parameters/DistributionConfigParameters_EmptyPolicyDecoder.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -297,7 +304,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_EmptyPolicyForwarder() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_EmptyPolicyForwarder.json" };
+ { "-c", "parameters/DistributionConfigParameters_EmptyPolicyForwarder.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -313,7 +320,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidReceptionHandlerClass() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -329,7 +336,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidPolicyDecoderClass() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -345,7 +352,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidPolicyForwarderClass() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -361,7 +368,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidRestServerHost() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidRestServerHost.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidRestServerHost.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -378,7 +385,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidRestServerPort() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidRestServerPort.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidRestServerPort.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -395,7 +402,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidRestServerUser() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidRestServerUser.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidRestServerUser.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -412,7 +419,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidRestServerPassword() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidRestServerPassword.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidRestServerPassword.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java
index c902c9b5..960629e4 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java
@@ -27,8 +27,8 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.distribution.reception.parameters.PSSDConfigurationParametersGroup;
import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
+import org.onap.policy.distribution.reception.parameters.PssdConfigurationParametersGroup;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
/**
@@ -42,15 +42,15 @@ public class TestReceptionHandlerParameters {
@Test
public void testReceptionHandlerParameters() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PSSDConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPSSDConfigurationParametersGroup(false);
- final ReceptionHandlerParameters rHParameters =
- new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE,
- CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
+ final PssdConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPssdConfigurationParametersGroup(false);
+ final ReceptionHandlerParameters rHParameters =
+ new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE,
+ CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
- assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup());
+ assertEquals(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertTrue(validationResult.isValid());
}
@@ -58,15 +58,14 @@ public class TestReceptionHandlerParameters {
@Test
public void testReceptionHandlerParameters_NullReceptionHandlerType() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PSSDConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPSSDConfigurationParametersGroup(false);
- final ReceptionHandlerParameters rHParameters =
- new ReceptionHandlerParameters(null, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
- pssdConfiguration, pHParameters);
+ final PssdConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPssdConfigurationParametersGroup(false);
+ final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(null,
+ CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(null, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
- assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup());
+ assertEquals(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
@@ -77,15 +76,14 @@ public class TestReceptionHandlerParameters {
@Test
public void testReceptionHandlerParameters_NullReceptionHandlerClassName() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PSSDConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPSSDConfigurationParametersGroup(false);
- final ReceptionHandlerParameters rHParameters =
- new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE, null,
- pssdConfiguration, pHParameters);
+ final PssdConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPssdConfigurationParametersGroup(false);
+ final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
+ CommonTestData.RECEPTION_HANDLER_TYPE, null, pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(null, rHParameters.getReceptionHandlerClassName());
- assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup());
+ assertEquals(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
@@ -96,11 +94,10 @@ public class TestReceptionHandlerParameters {
@Test
public void testReceptionHandlerParameters_EmptyReceptionHandlerType() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PSSDConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPSSDConfigurationParametersGroup(false);
- final ReceptionHandlerParameters rHParameters =
- new ReceptionHandlerParameters("", CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
- pssdConfiguration, pHParameters);
+ final PssdConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPssdConfigurationParametersGroup(false);
+ final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters("",
+ CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals("", rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
@@ -114,14 +111,14 @@ public class TestReceptionHandlerParameters {
@Test
public void testReceptionHandlerParameters_EmptyReceptionHandlerClassName() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PSSDConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPSSDConfigurationParametersGroup(false);
+ final PssdConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPssdConfigurationParametersGroup(false);
final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
CommonTestData.RECEPTION_HANDLER_TYPE, "", pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals("", rHParameters.getReceptionHandlerClassName());
- assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup());
+ assertEquals(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
@@ -133,11 +130,11 @@ public class TestReceptionHandlerParameters {
public void testReceptionHandlerParameters_EmptyPluginHandler() {
try {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(true);
- final PSSDConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPSSDConfigurationParametersGroup(false);
- final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
- CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
- pssdConfiguration, pHParameters);
+ final PssdConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPssdConfigurationParametersGroup(false);
+ final ReceptionHandlerParameters rHParameters =
+ new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE,
+ CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
rHParameters.validate();
fail("test should throw an exception here");
} catch (final Exception e) {
@@ -148,16 +145,16 @@ public class TestReceptionHandlerParameters {
@Test
public void testReceptionHandlerParameters_InvalidReceptionHandlerClass() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PSSDConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPSSDConfigurationParametersGroup(false);
+ final PssdConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPssdConfigurationParametersGroup(false);
final ReceptionHandlerParameters rHParameters =
new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE,
CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid", pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
- assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid",
- rHParameters.getReceptionHandlerClassName());
- assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup());
+ assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid",
+ rHParameters.getReceptionHandlerClassName());
+ assertEquals(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult().contains("reception handler class not found in classpath"));
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
index df585574..d02139f2 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
@@ -33,6 +33,8 @@ import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.Test;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.parameters.CommonTestData;
import org.onap.policy.distribution.main.parameters.RestServerParameters;
@@ -45,6 +47,7 @@ import org.onap.policy.distribution.main.startstop.Main;
*/
public class TestDistributionRestServer {
+ private static final Logger LOGGER = FlexLogger.getLogger(TestDistributionRestServer.class);
private static final String NOT_ALIVE = "not alive";
private static final String ALIVE = "alive";
private static final String SELF = "self";
@@ -83,7 +86,7 @@ public class TestDistributionRestServer {
}
private HealthCheckReport performHealthCheck() throws InterruptedException {
- HealthCheckReport response;
+ HealthCheckReport response = null;
final ClientConfig clientConfig = new ClientConfig();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
@@ -93,14 +96,13 @@ public class TestDistributionRestServer {
final WebTarget webTarget = client.target("http://localhost:6969/healthcheck");
final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
- try {
- response = invocationBuilder.get(HealthCheckReport.class);
- } catch (final Exception exp) {
- // may be the server is not started yet. Wait for couple of seconds and retry.
- Thread.sleep(2000);
- response = invocationBuilder.get(HealthCheckReport.class);
+ while (response == null) {
+ try {
+ response = invocationBuilder.get(HealthCheckReport.class);
+ } catch (final Exception exp) {
+ LOGGER.info("the server is not started yet. We will retry again");
+ }
}
-
return response;
}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java
index 25133cfe..7cfb5ef3 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java
@@ -40,8 +40,8 @@ public class TestDistributionActivator {
public void testDistributionActivator() throws PolicyDistributionException {
final String[] distributionConfigParameters = { "-c", "parameters/DistributionConfigParameters.json" };
- final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
- arguments.parse(distributionConfigParameters);
+ final DistributionCommandLineArguments arguments =
+ new DistributionCommandLineArguments(distributionConfigParameters);
final DistributionParameterGroup parGroup = new DistributionParameterHandler().getParameters(arguments);
diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
index 124f49a6..e1c5d22b 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
@@ -36,7 +36,8 @@ public class TestMain {
@Test
public void testMain() throws PolicyDistributionException {
- final String[] distributionConfigParameters = { "-c", "parameters/DistributionConfigParameters.json" };
+ final String[] distributionConfigParameters =
+ { "-c", "parameters/DistributionConfigParameters.json" };
final Main main = new Main(distributionConfigParameters);
assertTrue(main.getParameters().isValid());
assertEquals(CommonTestData.DISTRIBUTION_GROUP_NAME, main.getParameters().getName());
@@ -45,28 +46,31 @@ public class TestMain {
@Test
public void testMain_NoArguments() {
- final String[] distributionConfigParameters = {};
+ final String[] distributionConfigParameters =
+ {};
final Main main = new Main(distributionConfigParameters);
assertTrue(main.getParameters() == null);
}
@Test
public void testMain_InvalidArguments() {
- final String[] distributionConfigParameters = { "parameters/DistributionConfigParameters.json" };
+ final String[] distributionConfigParameters =
+ { "parameters/DistributionConfigParameters.json" };
final Main main = new Main(distributionConfigParameters);
assertTrue(main.getParameters() == null);
}
@Test
public void testMain_Help() {
- final String[] distributionConfigParameters = { "-h" };
+ final String[] distributionConfigParameters =
+ { "-h" };
Main.main(distributionConfigParameters);
}
@Test
public void testMain_InvalidParameters() {
final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters_InvalidName.json" };
+ { "-c", "parameters/DistributionConfigParameters_InvalidName.json" };
final Main main = new Main(distributionConfigParameters);
assertTrue(main.getParameters() == null);
}