summaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@ericsson.com>2018-08-17 20:38:03 +0100
committerramverma <ram.krishna.verma@ericsson.com>2018-08-22 13:33:36 +0100
commit7de549e5589d5e98a798e65752396627f6990fe1 (patch)
tree95ebd6d2d1cd9694f139c03cd4d6df31d1bc3e8d /main/src
parent742c4b2ed82860e2a74f3db3b2048173fbc530d8 (diff)
Adding health check endpoint to distribution
* Adding health check REST endpoint to distribution service. * Adding isAlive field to DistributionActivator to fetch the health status. * Adding parameter group for rest server parameters. * Adding DistributionRestController for hosting all the rest endpoints in distribution service. * Adding DistributionRestServer to manage lifecycle of distribution rest server. * Adding ParameterValidationUtils utility class for common validations. Plan is to move this class to policy-common for wider use later. * Adding test cases for all new code added. * Refering common classes from policy/common Change-Id: I246d57133ed1f0c3548bcdee173d7b64fb368abc Issue-ID: POLICY-1035 Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java23
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/parameters/RestServerParameters.java137
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java60
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestServer.java140
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java52
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java52
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/startstop/package-info.java25
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java37
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java40
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java68
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java116
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java2
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyDecoder.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyForwarder.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandler.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidName.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerHost.json53
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPassword.json53
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPort.json53
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerUser.json53
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyDecoder.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyForwarder.json6
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_NoReceptionHandler.json8
-rw-r--r--main/src/test/resources/parameters/MinimumParameters.json6
-rw-r--r--main/src/test/resources/parameters/NoParameters.json6
32 files changed, 1006 insertions, 56 deletions
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java
index df0a272c..dc114c1d 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java
@@ -26,6 +26,7 @@ import java.util.Map.Entry;
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.utils.validation.ParameterValidationUtils;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
/**
@@ -35,6 +36,7 @@ import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParamet
*/
public class DistributionParameterGroup implements ParameterGroup {
private String name;
+ private RestServerParameters restServerParameters;
private Map<String, ReceptionHandlerParameters> receptionHandlerParameters;
/**
@@ -42,9 +44,10 @@ public class DistributionParameterGroup implements ParameterGroup {
*
* @param name the parameter group name
*/
- public DistributionParameterGroup(final String name,
+ public DistributionParameterGroup(final String name, final RestServerParameters restServerParameters,
final Map<String, ReceptionHandlerParameters> receptionHandlerParameters) {
this.name = name;
+ this.restServerParameters = restServerParameters;
this.receptionHandlerParameters = receptionHandlerParameters;
}
@@ -68,6 +71,15 @@ public class DistributionParameterGroup implements ParameterGroup {
}
/**
+ * Return the restServerParameters of this parameter group instance.
+ *
+ * @return the restServerParameters
+ */
+ public RestServerParameters getRestServerParameters() {
+ return restServerParameters;
+ }
+
+ /**
* Validate the parameter group.
*
* @return the result of the validation
@@ -75,11 +87,16 @@ public class DistributionParameterGroup implements ParameterGroup {
@Override
public GroupValidationResult validate() {
final GroupValidationResult validationResult = new GroupValidationResult(this);
- if (name == null || name.trim().length() == 0) {
+ if (!ParameterValidationUtils.validateStringParameter(name)) {
validationResult.setResult("name", ValidationStatus.INVALID, "must be a non-blank string");
+ }
+ if (restServerParameters == null) {
+ validationResult.setResult("restServerParameters", ValidationStatus.INVALID,
+ "must have restServerParameters to configure distribution rest server");
} else {
- validateReceptionHandlers(validationResult);
+ validationResult.setResult("restServerParameters", restServerParameters.validate());
}
+ validateReceptionHandlers(validationResult);
return validationResult;
}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/RestServerParameters.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/RestServerParameters.java
new file mode 100644
index 00000000..89a264ab
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/RestServerParameters.java
@@ -0,0 +1,137 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.distribution.main.parameters;
+
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.utils.validation.ParameterValidationUtils;
+
+/**
+ * Class to hold all parameters needed for distribution rest server.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class RestServerParameters implements ParameterGroup {
+ private String name;
+ private String host;
+ private int port;
+ private String userName;
+ private String password;
+
+ /**
+ * Constructor for instantiating RestServerParameters.
+ *
+ * @param host the host name
+ * @param port the port
+ * @param userName the user name
+ * @param password the password
+ */
+ public RestServerParameters(final String host, final int port, final String userName, final String password) {
+ super();
+ this.host = host;
+ this.port = port;
+ this.userName = userName;
+ this.password = password;
+ }
+
+ /**
+ * Return the name of this RestServerParameters instance.
+ *
+ * @return name the name of this RestServerParameters
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Return the host of this RestServerParameters instance.
+ *
+ * @return the host
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * Return the port of this RestServerParameters instance.
+ *
+ * @return the port
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * Return the user name of this RestServerParameters instance.
+ *
+ * @return the userName
+ */
+ public String getUserName() {
+ return userName;
+ }
+
+ /**
+ * Return the password of this RestServerParameters instance.
+ *
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * Set the name of this RestServerParameters instance.
+ *
+ * @param name the name to set
+ */
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Validate the rest server parameters.
+ *
+ * @return the result of the validation
+ */
+ @Override
+ public GroupValidationResult validate() {
+ final GroupValidationResult validationResult = new GroupValidationResult(this);
+ if (!ParameterValidationUtils.validateStringParameter(host)) {
+ validationResult.setResult("host", ValidationStatus.INVALID,
+ "must be a non-blank string containing hostname/ipaddress of the distribution rest server");
+ }
+ if (!ParameterValidationUtils.validateStringParameter(userName)) {
+ validationResult.setResult("userName", ValidationStatus.INVALID,
+ "must be a non-blank string containing userName for distribution rest server credentials");
+ }
+ if (!ParameterValidationUtils.validateStringParameter(password)) {
+ validationResult.setResult("password", ValidationStatus.INVALID,
+ "must be a non-blank string containing password for distribution rest server credentials");
+ }
+ if (!ParameterValidationUtils.validateIntParameter(port)) {
+ validationResult.setResult("port", ValidationStatus.INVALID,
+ "must be a positive integer containing port of the distribution rest server");
+ }
+ return validationResult;
+ }
+}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java
new file mode 100644
index 00000000..95cfdd5c
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.distribution.main.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.Info;
+import io.swagger.annotations.SwaggerDefinition;
+import io.swagger.annotations.Tag;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.onap.policy.common.endpoints.report.HealthCheckReport;
+
+/**
+ * Class to provide distribution REST services.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+@Path("/")
+@Api
+@Produces(MediaType.APPLICATION_JSON)
+@SwaggerDefinition(
+ info = @Info(description = "Policy Distribution Service", version = "v1.0", title = "Policy Distribution"),
+ consumes = { MediaType.APPLICATION_JSON }, produces = { MediaType.APPLICATION_JSON },
+ schemes = { SwaggerDefinition.Scheme.HTTP },
+ tags = { @Tag(name = "policy-distribution", description = "Policy Distribution Service Operations") })
+public class DistributionRestController {
+
+ @GET
+ @Path("healthcheck")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Perform a system healthcheck",
+ notes = "Provides healthy status of the Policy Distribution component", response = HealthCheckReport.class)
+ public Response healthcheck() {
+ return Response.status(Response.Status.OK).entity(new HealthCheckProvider().performHealthCheck()).build();
+ }
+}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestServer.java b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestServer.java
new file mode 100644
index 00000000..fa786bda
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestServer.java
@@ -0,0 +1,140 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.distribution.main.rest;
+
+import java.util.ArrayList;
+import java.util.List;
+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.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.distribution.main.parameters.RestServerParameters;
+
+/**
+ * Class to manage life cycle of distribution rest server.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class DistributionRestServer implements Startable {
+
+ private static final String SEPARATOR = ".";
+ private static final String HTTP_SERVER_SERVICES = "http.server.services";
+ private static final Logger LOGGER = FlexLogger.getLogger(DistributionRestServer.class);
+
+ private List<HttpServletServer> servers = new ArrayList<>();
+
+ private RestServerParameters restServerParameters;
+
+ /**
+ * Constructor for instantiating DistributionRestServer.
+ *
+ * @param restServerParameters the rest server parameters
+ */
+ public DistributionRestServer(final RestServerParameters restServerParameters) {
+ this.restServerParameters = restServerParameters;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean start() {
+ try {
+ servers = HttpServletServer.factory.build(getServerProperties());
+ for (final HttpServletServer server : servers) {
+ server.start();
+ }
+ } catch (final Exception exp) {
+ LOGGER.error("Failed to start distribution http server", exp);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Creates the server properties object using restServerParameters.
+ *
+ * @return the properties object
+ */
+ private Properties getServerProperties() {
+ final Properties props = new Properties();
+ props.setProperty(HTTP_SERVER_SERVICES, restServerParameters.getName());
+ props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".host",
+ restServerParameters.getHost());
+ props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".port",
+ Integer.toString(restServerParameters.getPort()));
+ props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".restClasses",
+ DistributionRestController.class.getCanonicalName());
+ props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".managed", "false");
+ props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".swagger", "true");
+ props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".userName",
+ restServerParameters.getUserName());
+ props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".password",
+ restServerParameters.getPassword());
+ return props;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean stop() {
+ for (final HttpServletServer server : servers) {
+ try {
+ server.stop();
+ } catch (final Exception exp) {
+ LOGGER.error("Failed to stop distribution http server", exp);
+ }
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void shutdown() {
+ stop();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAlive() {
+ return !servers.isEmpty();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("DistributionRestServer [servers=");
+ builder.append(servers);
+ builder.append("]");
+ return builder.toString();
+ }
+
+}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java b/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java
new file mode 100644
index 00000000..a22d0857
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.distribution.main.rest;
+
+import org.onap.policy.common.endpoints.report.HealthCheckReport;
+import org.onap.policy.distribution.main.startstop.DistributionActivator;
+
+/**
+ * Class to fetch health check of distribution service.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class HealthCheckProvider {
+
+ private static final String NOT_ALIVE = "not alive";
+ private static final String ALIVE = "alive";
+ private static final String URL = "self";
+ private static final String NAME = "Policy SSD";
+
+ /**
+ * Performs the health check of distribution service.
+ *
+ * @return Report containing health check status
+ */
+ public HealthCheckReport performHealthCheck() {
+ final HealthCheckReport report = new HealthCheckReport();
+ report.setName(NAME);
+ report.setUrl(URL);
+ report.setHealthy(DistributionActivator.isAlive());
+ report.setCode(DistributionActivator.isAlive() ? 200 : 500);
+ report.setMessage(DistributionActivator.isAlive() ? ALIVE : NOT_ALIVE);
+ return report;
+ }
+}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
index 4f650719..62314bdf 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
@@ -29,6 +29,7 @@ import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.forwarding.PolicyForwardingException;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.parameters.DistributionParameterGroup;
+import org.onap.policy.distribution.main.rest.DistributionRestServer;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
@@ -47,6 +48,10 @@ public class DistributionActivator {
// The map of reception handlers initialized by this distribution activator
private final Map<String, AbstractReceptionHandler> receptionHandlersMap = new HashMap<>();
+ private static boolean alive = false;
+
+ private DistributionRestServer restServer;
+
/**
* Instantiate the activator for policy distribution as a complete service.
*
@@ -64,15 +69,17 @@ public class DistributionActivator {
@SuppressWarnings("unchecked")
public void initialize() throws PolicyDistributionException {
LOGGER.debug("Policy distribution starting as a service . . .");
+ startDistributionRestServer();
registerToParameterService(distributionParameterGroup);
- for (final ReceptionHandlerParameters rHParameters : distributionParameterGroup.getReceptionHandlerParameters()
- .values()) {
+ for (final ReceptionHandlerParameters receptionHandlerParameters : distributionParameterGroup
+ .getReceptionHandlerParameters().values()) {
try {
- final Class<AbstractReceptionHandler> receptionHandlerClass =
- (Class<AbstractReceptionHandler>) Class.forName(rHParameters.getReceptionHandlerClassName());
+ final Class<AbstractReceptionHandler> receptionHandlerClass = (Class<AbstractReceptionHandler>) Class
+ .forName(receptionHandlerParameters.getReceptionHandlerClassName());
final AbstractReceptionHandler receptionHandler = receptionHandlerClass.newInstance();
- receptionHandler.initialize(rHParameters.getName());
- receptionHandlersMap.put(rHParameters.getName(), receptionHandler);
+ receptionHandler.initialize(receptionHandlerParameters.getName());
+ receptionHandlersMap.put(receptionHandlerParameters.getName(), receptionHandler);
+ alive = true;
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
| PolicyDecodingException | PolicyForwardingException exp) {
throw new PolicyDistributionException(exp.getMessage(), exp);
@@ -82,6 +89,20 @@ public class DistributionActivator {
}
/**
+ * Starts the distribution rest server using configuration parameters.
+ *
+ * @throws PolicyDistributionException if server start fails
+ */
+ private void startDistributionRestServer() throws PolicyDistributionException {
+ distributionParameterGroup.getRestServerParameters().setName(distributionParameterGroup.getName());
+ restServer = new DistributionRestServer(distributionParameterGroup.getRestServerParameters());
+ if (!restServer.start()) {
+ throw new PolicyDistributionException(
+ "Failed to start distribution rest server. Check log for more details...");
+ }
+ }
+
+ /**
* Terminate policy distribution.
*
* @throws PolicyDistributionException on termination errors
@@ -93,6 +114,10 @@ public class DistributionActivator {
}
receptionHandlersMap.clear();
deregisterToParameterService(distributionParameterGroup);
+ alive = false;
+
+ // Stop the distribution rest server
+ restServer.stop();
} catch (final Exception exp) {
LOGGER.error("Policy distribution service termination failed", exp);
throw new PolicyDistributionException(exp.getMessage(), exp);
@@ -111,7 +136,7 @@ public class DistributionActivator {
/**
* Method to register the parameters to Common Parameter Service.
*
- * @param distributionParameterGroup
+ * @param distributionParameterGroup the distribution parameter group
*/
public void registerToParameterService(final DistributionParameterGroup distributionParameterGroup) {
ParameterService.register(distributionParameterGroup);
@@ -129,17 +154,24 @@ public class DistributionActivator {
/**
* Method to deregister the parameters from Common Parameter Service.
*
- * @param distributionParameterGroup
+ * @param distributionParameterGroup the distribution parameter group
*/
public void deregisterToParameterService(final DistributionParameterGroup distributionParameterGroup) {
ParameterService.deregister(distributionParameterGroup.getName());
for (final ReceptionHandlerParameters params : distributionParameterGroup.getReceptionHandlerParameters()
.values()) {
- params.setName(distributionParameterGroup.getName());
- params.getPluginHandlerParameters().setName(distributionParameterGroup.getName());
ParameterService.deregister((params.getName()));
ParameterService.deregister((params.getPSSDConfigurationParametersGroup().getName()));
ParameterService.deregister((params.getPluginHandlerParameters().getName()));
}
}
+
+ /**
+ * Returns the alive status of distribution service.
+ *
+ * @return the alive
+ */
+ public static boolean isAlive() {
+ return alive;
+ }
}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/package-info.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/package-info.java
deleted file mode 100644
index 19b9f951..00000000
--- a/main/src/main/java/org/onap/policy/distribution/main/startstop/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-/**
- * Provides ONAP policy distribution as a complete service together with all its reception and forwarding support.
- * A main method to allow ONAP policy distribution execution from the command line is also provided.
- */
-package org.onap.policy.distribution.main.startstop;
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 0903b070..59f551cf 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
@@ -38,6 +38,10 @@ import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParamet
*/
public class CommonTestData {
+ private static final String REST_SERVER_PASSWORD = "zb!XztG34";
+ private static final String REST_SERVER_USER = "healthcheck";
+ private static final int REST_SERVER_PORT = 6969;
+ private static final String REST_SERVER_HOST = "0.0.0.0";
public static final String DISTRIBUTION_GROUP_NAME = "SDCDistributionGroup";
public static final String DECODER_TYPE = "TOSCA";
public static final String DECODER_CLASS_NAME =
@@ -56,6 +60,23 @@ public class CommonTestData {
* Returns an instance of ReceptionHandlerParameters for test cases.
*
* @param isEmpty boolean value to represent that object created should be empty or not
+ * @return the restServerParameters object
+ */
+ public RestServerParameters getRestServerParameters(final boolean isEmpty) {
+ final RestServerParameters restServerParameters;
+ if (!isEmpty) {
+ restServerParameters = new RestServerParameters(REST_SERVER_HOST, REST_SERVER_PORT, REST_SERVER_USER,
+ REST_SERVER_PASSWORD);
+ } else {
+ restServerParameters = new RestServerParameters(null, 0, null, null);
+ }
+ return restServerParameters;
+ }
+
+ /**
+ * Returns an instance of ReceptionHandlerParameters for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
* @return the receptionHandlerParameters object
*/
public Map<String, ReceptionHandlerParameters> getReceptionHandlerParameters(final boolean isEmpty) {
@@ -66,9 +87,8 @@ public class CommonTestData {
final Map<String, PolicyForwarderParameters> policyForwarders = getPolicyForwarders(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);
+ final ReceptionHandlerParameters rhParameters = new ReceptionHandlerParameters(RECEPTION_HANDLER_TYPE,
+ RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
receptionHandlerParameters.put(SDC_RECEPTION_HANDLER_KEY, rhParameters);
}
return receptionHandlerParameters;
@@ -88,12 +108,11 @@ public class CommonTestData {
final List<String> artifactTypes = new ArrayList<>();
artifactTypes.add("TOSCA_CSAR");
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();
+ .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();
}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java
index 70317971..f6ed0f98 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java
@@ -41,13 +41,20 @@ public class TestDistributionParameterGroup {
@Test
public void testDistributionParameterGroup() {
+ final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
commonTestData.getReceptionHandlerParameters(false);
- final DistributionParameterGroup distributionParameters =
- new DistributionParameterGroup(CommonTestData.DISTRIBUTION_GROUP_NAME, receptionHandlerParameters);
+ final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
+ CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters);
final GroupValidationResult validationResult = distributionParameters.validate();
assertTrue(validationResult.isValid());
+ assertEquals(restServerParameters.getHost(), distributionParameters.getRestServerParameters().getHost());
+ assertEquals(restServerParameters.getPort(), distributionParameters.getRestServerParameters().getPort());
+ assertEquals(restServerParameters.getUserName(),
+ distributionParameters.getRestServerParameters().getUserName());
+ assertEquals(restServerParameters.getPassword(),
+ distributionParameters.getRestServerParameters().getPassword());
assertEquals(CommonTestData.DISTRIBUTION_GROUP_NAME, distributionParameters.getName());
assertEquals(receptionHandlerParameters.get(CommonTestData.SDC_RECEPTION_HANDLER_KEY).getReceptionHandlerType(),
distributionParameters.getReceptionHandlerParameters().get(CommonTestData.SDC_RECEPTION_HANDLER_KEY)
@@ -64,11 +71,12 @@ public class TestDistributionParameterGroup {
@Test
public void testDistributionParameterGroup_NullName() {
+ final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
commonTestData.getReceptionHandlerParameters(false);
final DistributionParameterGroup distributionParameters =
- new DistributionParameterGroup(null, receptionHandlerParameters);
+ new DistributionParameterGroup(null, restServerParameters, receptionHandlerParameters);
final GroupValidationResult validationResult = distributionParameters.validate();
assertFalse(validationResult.isValid());
assertEquals(null, distributionParameters.getName());
@@ -89,11 +97,12 @@ public class TestDistributionParameterGroup {
@Test
public void testDistributionParameterGroup_EmptyName() {
+ final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
commonTestData.getReceptionHandlerParameters(false);
final DistributionParameterGroup distributionParameters =
- new DistributionParameterGroup("", receptionHandlerParameters);
+ new DistributionParameterGroup("", restServerParameters, receptionHandlerParameters);
final GroupValidationResult validationResult = distributionParameters.validate();
assertFalse(validationResult.isValid());
assertEquals("", distributionParameters.getName());
@@ -114,9 +123,10 @@ public class TestDistributionParameterGroup {
@Test
public void testDistributionParameterGroup_NullReceptionHandlerParameters() {
+ final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
try {
final DistributionParameterGroup distributionParameters =
- new DistributionParameterGroup(CommonTestData.DISTRIBUTION_GROUP_NAME, null);
+ new DistributionParameterGroup(CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, null);
distributionParameters.validate();
fail("test should throw an exception here");
} catch (final Exception e) {
@@ -127,11 +137,12 @@ public class TestDistributionParameterGroup {
@Test
public void testDistributionParameterGroup_EmptyReceptionHandlerParameters() {
+ final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
commonTestData.getReceptionHandlerParameters(true);
try {
- final DistributionParameterGroup distributionParameters =
- new DistributionParameterGroup(CommonTestData.DISTRIBUTION_GROUP_NAME, receptionHandlerParameters);
+ final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
+ CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters);
distributionParameters.validate();
fail("test should throw an exception here");
} catch (final Exception e) {
@@ -139,4 +150,19 @@ public class TestDistributionParameterGroup {
}
}
+
+ @Test
+ public void testDistributionParameterGroup_EmptyRestServerParameters() {
+ final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(true);
+ final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
+ commonTestData.getReceptionHandlerParameters(false);
+
+ final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
+ CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters);
+ final GroupValidationResult validationResult = distributionParameters.validate();
+ assertFalse(validationResult.isValid());
+ assertTrue(validationResult.getResult()
+ .contains("\"org.onap.policy.distribution.main.parameters.RestServerParameters\" INVALID, "
+ + "parameter group has status INVALID"));
+ }
}
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 79b12243..69ff0f14 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
@@ -357,4 +357,72 @@ public class TestDistributionParameterHandler {
assertTrue(e.getMessage().contains("policy forwarder class not found in classpath"));
}
}
+
+ @Test
+ public void testDistributionParameterGroup_InvalidRestServerHost() throws PolicyDistributionException {
+ final String[] distributionConfigParameters =
+ { "-c", "parameters/DistributionConfigParameters_InvalidRestServerHost.json" };
+
+ final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
+ arguments.parse(distributionConfigParameters);
+
+ try {
+ new DistributionParameterHandler().getParameters(arguments);
+ fail("test should throw an exception here");
+ } catch (final Exception e) {
+ assertTrue(e.getMessage().contains(
+ "must be a non-blank string containing hostname/ipaddress of the distribution rest server"));
+ }
+ }
+
+ @Test
+ public void testDistributionParameterGroup_InvalidRestServerPort() throws PolicyDistributionException {
+ final String[] distributionConfigParameters =
+ { "-c", "parameters/DistributionConfigParameters_InvalidRestServerPort.json" };
+
+ final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
+ arguments.parse(distributionConfigParameters);
+
+ try {
+ new DistributionParameterHandler().getParameters(arguments);
+ fail("test should throw an exception here");
+ } catch (final Exception e) {
+ assertTrue(e.getMessage()
+ .contains("must be a positive integer containing port of the distribution rest server"));
+ }
+ }
+
+ @Test
+ public void testDistributionParameterGroup_InvalidRestServerUser() throws PolicyDistributionException {
+ final String[] distributionConfigParameters =
+ { "-c", "parameters/DistributionConfigParameters_InvalidRestServerUser.json" };
+
+ final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
+ arguments.parse(distributionConfigParameters);
+
+ try {
+ new DistributionParameterHandler().getParameters(arguments);
+ fail("test should throw an exception here");
+ } catch (final Exception e) {
+ assertTrue(e.getMessage().contains(
+ "must be a non-blank string containing userName for distribution rest server credentials"));
+ }
+ }
+
+ @Test
+ public void testDistributionParameterGroup_InvalidRestServerPassword() throws PolicyDistributionException {
+ final String[] distributionConfigParameters =
+ { "-c", "parameters/DistributionConfigParameters_InvalidRestServerPassword.json" };
+
+ final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
+ arguments.parse(distributionConfigParameters);
+
+ try {
+ new DistributionParameterHandler().getParameters(arguments);
+ fail("test should throw an exception here");
+ } catch (final Exception e) {
+ assertTrue(e.getMessage().contains(
+ "must be a non-blank string containing password for distribution rest server credentials"));
+ }
+ }
}
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
new file mode 100644
index 00000000..df585574
--- /dev/null
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.distribution.main.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+
+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.distribution.main.PolicyDistributionException;
+import org.onap.policy.distribution.main.parameters.CommonTestData;
+import org.onap.policy.distribution.main.parameters.RestServerParameters;
+import org.onap.policy.distribution.main.startstop.Main;
+
+/**
+ * Class to perform unit test of HealthCheckMonitor.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class TestDistributionRestServer {
+
+ private static final String NOT_ALIVE = "not alive";
+ private static final String ALIVE = "alive";
+ private static final String SELF = "self";
+ private static final String NAME = "Policy SSD";
+
+ @Test
+ public void testHealthCheckSuccess() throws PolicyDistributionException, InterruptedException {
+ final String reportString = "Report [name=Policy SSD, url=self, healthy=true, code=200, message=alive]";
+ final Main main = startDistributionService();
+ final HealthCheckReport report = performHealthCheck();
+ validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
+ stopDistributionService(main);
+ }
+
+ @Test
+ public void testHealthCheckFailure() throws InterruptedException {
+ final String reportString = "Report [name=Policy SSD, url=self, healthy=false, code=500, message=not alive]";
+ final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
+ restServerParams.setName(CommonTestData.DISTRIBUTION_GROUP_NAME);
+ final DistributionRestServer restServer = new DistributionRestServer(restServerParams);
+ restServer.start();
+ final HealthCheckReport report = performHealthCheck();
+ validateReport(NAME, SELF, false, 500, NOT_ALIVE, reportString, report);
+ assertTrue(restServer.isAlive());
+ assertTrue(restServer.toString().startsWith("DistributionRestServer [servers="));
+ restServer.shutdown();
+ }
+
+ private Main startDistributionService() {
+ final String[] distributionConfigParameters = { "-c", "parameters/DistributionConfigParameters.json" };
+ return new Main(distributionConfigParameters);
+ }
+
+ private void stopDistributionService(final Main main) throws PolicyDistributionException {
+ main.shutdown();
+ }
+
+ private HealthCheckReport performHealthCheck() throws InterruptedException {
+ HealthCheckReport response;
+ final ClientConfig clientConfig = new ClientConfig();
+
+ final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
+ clientConfig.register(feature);
+
+ final Client client = ClientBuilder.newClient(clientConfig);
+ 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);
+ }
+
+ return response;
+ }
+
+ private void validateReport(final String name, final String url, final boolean healthy, final int code,
+ final String message, final String reportString, final HealthCheckReport report) {
+ assertEquals(name, report.getName());
+ assertEquals(url, report.getUrl());
+ assertEquals(healthy, report.isHealthy());
+ assertEquals(code, report.getCode());
+ assertEquals(message, report.getMessage());
+ assertEquals(reportString, report.toString());
+ }
+}
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 6d1f83bf..25133cfe 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
@@ -60,6 +60,6 @@ public class TestDistributionActivator {
activator.getParameterGroup().getReceptionHandlerParameters()
.get(CommonTestData.SDC_RECEPTION_HANDLER_KEY).getPluginHandlerParameters()
.getPolicyForwarders().get(CommonTestData.PAP_ENGINE_FORWARDER_KEY).getForwarderType());
- activator.deregisterToParameterService(parGroup);
+ activator.terminate();
}
}
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters.json b/main/src/test/resources/parameters/DistributionConfigParameters.json
index bcf8b263..7ebab314 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyDecoder.json b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyDecoder.json
index a53dc05f..940f9018 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyDecoder.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyDecoder.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyForwarder.json b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyForwarder.json
index b88fda2a..b596f064 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyForwarder.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyForwarder.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandler.json b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandler.json
index 45368be1..74733007 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandler.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandler.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
}
} \ No newline at end of file
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidName.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidName.json
index aae53f50..f31a396b 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidName.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidName.json
@@ -1,5 +1,11 @@
{
"name":" ",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json
index c1ad0a9e..cc43e378 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json
index 26f470ea..c4c73eea 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json
index a194e958..899fccab 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json
index 895e7d55..5e262c05 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json
index a368a5b6..4ff308c2 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json
index bf0db3e6..a6be01ee 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":" ",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerHost.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerHost.json
new file mode 100644
index 00000000..b59074d2
--- /dev/null
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerHost.json
@@ -0,0 +1,53 @@
+{
+ "name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
+ "receptionHandlerParameters":{
+ "SDCReceptionHandler":{
+ "receptionHandlerType":"SDC",
+ "receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
+ "pluginHandlerParameters":{
+ "policyDecoders":{
+ "TOSCADecoder":{
+ "decoderType":"TOSCA",
+ "decoderClassName":"org.onap.policy.distribution.reception.decoding.pdpx.PolicyDecoderToscaPdpx"
+ }
+ },
+ "policyForwarders":{
+ "PAPEngineForwarder":{
+ "forwarderType":"PAPEngine",
+ "forwarderClassName":"org.onap.policy.distribution.forwarding.pap.engine.XacmlPapServletPolicyForwarder"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPassword.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPassword.json
new file mode 100644
index 00000000..7161dee3
--- /dev/null
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPassword.json
@@ -0,0 +1,53 @@
+{
+ "name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":""
+ },
+ "receptionHandlerParameters":{
+ "SDCReceptionHandler":{
+ "receptionHandlerType":"SDC",
+ "receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
+ "pluginHandlerParameters":{
+ "policyDecoders":{
+ "TOSCADecoder":{
+ "decoderType":"TOSCA",
+ "decoderClassName":"org.onap.policy.distribution.reception.decoding.pdpx.PolicyDecoderToscaPdpx"
+ }
+ },
+ "policyForwarders":{
+ "PAPEngineForwarder":{
+ "forwarderType":"PAPEngine",
+ "forwarderClassName":"org.onap.policy.distribution.forwarding.pap.engine.XacmlPapServletPolicyForwarder"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPort.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPort.json
new file mode 100644
index 00000000..aa480745
--- /dev/null
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPort.json
@@ -0,0 +1,53 @@
+{
+ "name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":-1,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
+ "receptionHandlerParameters":{
+ "SDCReceptionHandler":{
+ "receptionHandlerType":"SDC",
+ "receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
+ "pluginHandlerParameters":{
+ "policyDecoders":{
+ "TOSCADecoder":{
+ "decoderType":"TOSCA",
+ "decoderClassName":"org.onap.policy.distribution.reception.decoding.pdpx.PolicyDecoderToscaPdpx"
+ }
+ },
+ "policyForwarders":{
+ "PAPEngineForwarder":{
+ "forwarderType":"PAPEngine",
+ "forwarderClassName":"org.onap.policy.distribution.forwarding.pap.engine.XacmlPapServletPolicyForwarder"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerUser.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerUser.json
new file mode 100644
index 00000000..d58c035b
--- /dev/null
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerUser.json
@@ -0,0 +1,53 @@
+{
+ "name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"",
+ "password":"zb!XztG34"
+ },
+ "receptionHandlerParameters":{
+ "SDCReceptionHandler":{
+ "receptionHandlerType":"SDC",
+ "receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
+ "pluginHandlerParameters":{
+ "policyDecoders":{
+ "TOSCADecoder":{
+ "decoderType":"TOSCA",
+ "decoderClassName":"org.onap.policy.distribution.reception.decoding.pdpx.PolicyDecoderToscaPdpx"
+ }
+ },
+ "policyForwarders":{
+ "PAPEngineForwarder":{
+ "forwarderType":"PAPEngine",
+ "forwarderClassName":"org.onap.policy.distribution.forwarding.pap.engine.XacmlPapServletPolicyForwarder"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyDecoder.json b/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyDecoder.json
index 06d18674..530a86d8 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyDecoder.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyDecoder.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyForwarder.json b/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyForwarder.json
index d8343b19..6b6d6771 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyForwarder.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyForwarder.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_NoReceptionHandler.json b/main/src/test/resources/parameters/DistributionConfigParameters_NoReceptionHandler.json
index 8b0997ca..b91e95d8 100644
--- a/main/src/test/resources/parameters/DistributionConfigParameters_NoReceptionHandler.json
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_NoReceptionHandler.json
@@ -1,3 +1,9 @@
{
- "name":"SDCDistributionGroup"
+ "name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ }
} \ No newline at end of file
diff --git a/main/src/test/resources/parameters/MinimumParameters.json b/main/src/test/resources/parameters/MinimumParameters.json
index 18cd529c..95359b88 100644
--- a/main/src/test/resources/parameters/MinimumParameters.json
+++ b/main/src/test/resources/parameters/MinimumParameters.json
@@ -1,5 +1,11 @@
{
"name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
"receptionHandlerParameters":{
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
diff --git a/main/src/test/resources/parameters/NoParameters.json b/main/src/test/resources/parameters/NoParameters.json
index 7a73a41b..6b0805d3 100644
--- a/main/src/test/resources/parameters/NoParameters.json
+++ b/main/src/test/resources/parameters/NoParameters.json
@@ -1,2 +1,8 @@
{
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ }
} \ No newline at end of file