aboutsummaryrefslogtreecommitdiffstats
path: root/feature-healthcheck/src/test
diff options
context:
space:
mode:
authormmis <michael.morris@ericsson.com>2018-07-19 13:21:08 +0100
committermmis <michael.morris@ericsson.com>2018-07-25 09:14:33 +0100
commit64f53ef14f5a9ea98208fd2b835bfb01fda9a5f9 (patch)
tree60afa251c126287a85c89e0b1dc7fd5d1a766439 /feature-healthcheck/src/test
parente8f1b7235f8338fbb9eba28d8cff29d3d6adf6e7 (diff)
Copy policy-endpoints from drools-pdp to common
Removed policy-endpoints, and 3 classes from policy-core. Replaced refenences to the deleted classes with references to the corresponding classes in policy-common Issue-ID: POLICY-967 Change-Id: I547cde4894424b8f40b7ddd4e2342ebb729cb588 Signed-off-by: mmis <michael.morris@ericsson.com>
Diffstat (limited to 'feature-healthcheck/src/test')
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java225
1 files changed, 107 insertions, 118 deletions
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
index a56483c4..578ce5d5 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
@@ -34,10 +34,10 @@ import java.util.Properties;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.drools.healthcheck.HealthCheck.Report;
import org.onap.policy.drools.healthcheck.HealthCheck.Reports;
import org.onap.policy.drools.persistence.SystemPersistence;
-import org.onap.policy.drools.properties.PolicyProperties;
import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,74 +48,63 @@ public class HealthCheckFeatureTest {
* Healthcheck Configuration File
*/
private static final String HEALTH_CHECK_PROPERTIES_FILE = "feature-healthcheck.properties";
-
- private static final Path healthCheckPropsPath = Paths.get(SystemPersistence.manager.getConfigurationPath().toString(),
- HEALTH_CHECK_PROPERTIES_FILE);
-
- private static final Path healthCheckPropsBackupPath = Paths.get(SystemPersistence.manager.getConfigurationPath().toString(),
- HEALTH_CHECK_PROPERTIES_FILE + ".bak");
-
-
+
+ private static final Path healthCheckPropsPath =
+ Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), HEALTH_CHECK_PROPERTIES_FILE);
+
+ private static final Path healthCheckPropsBackupPath = Paths
+ .get(SystemPersistence.manager.getConfigurationPath().toString(), HEALTH_CHECK_PROPERTIES_FILE + ".bak");
+
+
/**
* logger
*/
private static Logger logger = LoggerFactory.getLogger(HealthCheckFeatureTest.class);
private static Properties httpProperties = new Properties();
-
-
+
+
@BeforeClass
- public static void setup(){
-
- httpProperties.setProperty(PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES, "HEALTHCHECK");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_HTTP_HOST_SUFFIX,
- "localhost");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_HTTP_PORT_SUFFIX,
- "7777");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX,
- "username");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX,
- "password");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_HTTP_REST_CLASSES_SUFFIX,
- org.onap.policy.drools.healthcheck.RestMockHealthCheck.class.getName());
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_MANAGED_SUFFIX,
- "true");
-
-
- httpProperties.setProperty(PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES, "HEALTHCHECK");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_HTTP_HOST_SUFFIX,
- "localhost");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_HTTP_PORT_SUFFIX,
- "7777");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_HTTP_URL_SUFFIX,
- "healthcheck/test");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_HTTP_HTTPS_SUFFIX,
- "false");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX,
- "username");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX,
- "password");
- httpProperties.setProperty
- (PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK" + PolicyProperties.PROPERTY_MANAGED_SUFFIX,
- "true");
-
+ public static void setup() {
+
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES, "HEALTHCHECK");
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_HTTP_HOST_SUFFIX, "localhost");
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX, "7777");
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX, "username");
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX, "password");
+ httpProperties.setProperty(
+ PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_HTTP_REST_CLASSES_SUFFIX,
+ org.onap.policy.drools.healthcheck.RestMockHealthCheck.class.getName());
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true");
+
+
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES, "HEALTHCHECK");
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_HTTP_HOST_SUFFIX, "localhost");
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX, "7777");
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_HTTP_URL_SUFFIX, "healthcheck/test");
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX, "false");
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX, "username");
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX, "password");
+ httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "HEALTHCHECK"
+ + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true");
+
configDirSetup();
-
+
}
-
+
@AfterClass
public static void tearDown() {
logger.info("-- tearDown() --");
@@ -123,68 +112,68 @@ public class HealthCheckFeatureTest {
configDirCleanup();
}
- @Test
- public void test() {
-
- HealthCheckFeature feature = new HealthCheckFeature();
- feature.afterStart(PolicyEngine.manager);
-
- Reports reports = HealthCheck.monitor.healthCheck();
-
- for (Report rpt : reports.getDetails()) {
- if (rpt.getName() == "HEALTHCHECK") {
- assertTrue(rpt.isHealthy());
- assertEquals(200,rpt.getCode());
- assertEquals("All Alive", rpt.getMessage());
- break;
- }
- }
-
- feature.afterShutdown(PolicyEngine.manager);
-
- }
-
-
- /**
- * setup up config directory
- */
- protected static void configDirSetup() {
-
- File origPropsFile = new File(healthCheckPropsPath.toString());
- File backupPropsFile = new File(healthCheckPropsBackupPath.toString());
- Path configDir = Paths.get(SystemPersistence.DEFAULT_CONFIGURATION_DIR);
-
- try {
-
- if (Files.notExists(configDir)) {
- Files.createDirectories(configDir);
- }
-
- Files.deleteIfExists(healthCheckPropsBackupPath);
- origPropsFile.renameTo(backupPropsFile);
-
- FileWriter writer = new FileWriter(origPropsFile);
- httpProperties.store(writer,"Machine created healthcheck-feature Properties");
-
- } catch (final Exception e) {
- logger.info("Problem cleaning {}", healthCheckPropsPath, e);
- }
- }
-
- /**
- * cleanup up config directory
- */
- protected static void configDirCleanup() {
-
+ @Test
+ public void test() {
+
+ HealthCheckFeature feature = new HealthCheckFeature();
+ feature.afterStart(PolicyEngine.manager);
+
+ Reports reports = HealthCheck.monitor.healthCheck();
+
+ for (Report rpt : reports.getDetails()) {
+ if (rpt.getName() == "HEALTHCHECK") {
+ assertTrue(rpt.isHealthy());
+ assertEquals(200, rpt.getCode());
+ assertEquals("All Alive", rpt.getMessage());
+ break;
+ }
+ }
+
+ feature.afterShutdown(PolicyEngine.manager);
+
+ }
+
+
+ /**
+ * setup up config directory
+ */
+ protected static void configDirSetup() {
+
+ File origPropsFile = new File(healthCheckPropsPath.toString());
+ File backupPropsFile = new File(healthCheckPropsBackupPath.toString());
+ Path configDir = Paths.get(SystemPersistence.DEFAULT_CONFIGURATION_DIR);
+
+ try {
+
+ if (Files.notExists(configDir)) {
+ Files.createDirectories(configDir);
+ }
+
+ Files.deleteIfExists(healthCheckPropsBackupPath);
+ origPropsFile.renameTo(backupPropsFile);
+
+ FileWriter writer = new FileWriter(origPropsFile);
+ httpProperties.store(writer, "Machine created healthcheck-feature Properties");
+
+ } catch (final Exception e) {
+ logger.info("Problem cleaning {}", healthCheckPropsPath, e);
+ }
+ }
+
+ /**
+ * cleanup up config directory
+ */
+ protected static void configDirCleanup() {
+
File origPropsFile = new File(healthCheckPropsBackupPath.toString());
File backupPropsFile = new File(healthCheckPropsPath.toString());
-
+
try {
- Files.deleteIfExists(healthCheckPropsPath);
- origPropsFile.renameTo(backupPropsFile);
- } catch (final Exception e) {
- logger.info("Problem cleaning {}", healthCheckPropsPath, e);
- }
+ Files.deleteIfExists(healthCheckPropsPath);
+ origPropsFile.renameTo(backupPropsFile);
+ } catch (final Exception e) {
+ logger.info("Problem cleaning {}", healthCheckPropsPath, e);
}
+ }
}