aboutsummaryrefslogtreecommitdiffstats
path: root/BRMSGateway/src
diff options
context:
space:
mode:
Diffstat (limited to 'BRMSGateway/src')
-rw-r--r--BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsGateway.java43
-rw-r--r--BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java21
-rw-r--r--BRMSGateway/src/main/resources/logback.xml150
-rw-r--r--BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java26
-rw-r--r--BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsGatewayTest.java91
-rw-r--r--BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java15
-rw-r--r--BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java14
-rw-r--r--BRMSGateway/src/test/resources/config.properties2
8 files changed, 217 insertions, 145 deletions
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsGateway.java b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsGateway.java
index e743794ec..093bf4bae 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsGateway.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsGateway.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -20,6 +20,7 @@
package org.onap.policy.brms.api;
+import java.util.concurrent.CountDownLatch;
import org.onap.policy.api.NotificationScheme;
import org.onap.policy.api.PolicyEngine;
import org.onap.policy.api.PolicyException;
@@ -31,7 +32,7 @@ import org.onap.policy.xacml.api.XACMLErrorConstants;
* BRMSGateway: This application acts as the Gateway interface between the PDP XACML and PDP Drools.
* The listens for BRMS based policies and pushes them to the specified Policy Repository, from
* where the PDP Drools reads the Rule Jar.
- *
+ *
* @version 0.1
*/
public class BrmsGateway {
@@ -41,6 +42,9 @@ public class BrmsGateway {
private static PolicyEngine policyEngine = null;
+ // may be overridden by junit tests
+ private static Factory factory = new Factory();
+
private BrmsGateway() {
// Default private constructor
}
@@ -68,7 +72,7 @@ public class BrmsGateway {
logger.info("Initializing BRMS Handler");
BrmsHandler brmsHandler = null;
try {
- brmsHandler = new BrmsHandler(configFile);
+ brmsHandler = factory.makeBrmsHandler(configFile);
} catch (final PolicyException e) {
String errorString = "Check your property file: " + e.getMessage();
logger.error(errorString);
@@ -85,21 +89,34 @@ public class BrmsGateway {
}
// Keep Running....
+ CountDownLatch latch = new CountDownLatch(1);
final Runnable runnable = () -> {
- while (true) {
- try {
- Thread.sleep(30000);
- } catch (final InterruptedException e) {
- logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Thread Exception " + e.getMessage());
- Thread.currentThread().interrupt();
- }
+ try {
+ // wait until interrupted
+ latch.await();
+ } catch (final InterruptedException e) {
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Thread Exception " + e.getMessage());
+ Thread.currentThread().interrupt();
}
};
- final Thread thread = new Thread(runnable);
+ final Thread thread = factory.makeThread(runnable);
thread.start();
}
public static PolicyEngine getPolicyEngine() {
return policyEngine;
}
+
+ /**
+ * Factory to provide various data. May be overridden by junit tests.
+ */
+ public static class Factory {
+ public BrmsHandler makeBrmsHandler(String configFile) throws PolicyException {
+ return new BrmsHandler(configFile);
+ }
+
+ public Thread makeThread(Runnable runnable) {
+ return new Thread(runnable);
+ }
+ }
}
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
index 97e225890..e321811a3 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
@@ -60,7 +60,7 @@ import javax.persistence.Persistence;
import javax.persistence.TypedQuery;
import javax.ws.rs.ProcessingException;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.DistributionManagement;
@@ -117,7 +117,7 @@ public class BrmsPush {
private static final Logger LOGGER = FlexLogger.getLogger(BrmsPush.class.getName());
private static final String PROJECTSLOCATION = "RuleProjects";
private static final String[] GOALS = {"clean", "deploy"};
- private static final String DEFAULT_VERSION = "1.4.1-SNAPSHOT";
+ private static final String DEFAULT_VERSION = "1.6.3-SNAPSHOT";
private static final String DEPENDENCY_FILE = "dependency.json";
private static final String PROP_AES_KEY = "org.onap.policy.encryption.aes.key";
public static final String BRMSPERSISTENCE = "brmsEclipselink.persistencexml";
@@ -256,8 +256,8 @@ public class BrmsPush {
repUrlList = new ArrayList<>();
repUrlList.add(repUrl);
}
- repUserName = config.getProperty("repositoryUsername");
- repPassword = PeCryptoUtils.decrypt(config.getProperty("repositoryPassword"));
+ repUserName = getValue(config.getProperty("repositoryUsername"));
+ repPassword = PeCryptoUtils.decrypt(getValue(config.getProperty("repositoryPassword")));
if (repUserName == null || repPassword == null) {
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE
+ "repostoryUserName and respositoryPassword properties are required.");
@@ -367,6 +367,13 @@ public class BrmsPush {
}
+ private String getValue(final String value) {
+ if (value != null && value.matches("[$][{].*[}]$")) {
+ return System.getenv(value.substring(2, value.length() - 1));
+ }
+ return value;
+ }
+
private static void setBackupMonitor(final BackUpMonitor instance) {
bm = instance;
}
@@ -1049,12 +1056,6 @@ public class BrmsPush {
msoDependency.setArtifactId("controlloop.common.model-impl.so");
msoDependency.setVersion(version);
dependencyList.add(msoDependency);
-
- final Dependency trafficgeneratorDependency = new Dependency();
- trafficgeneratorDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
- trafficgeneratorDependency.setArtifactId("controlloop.common.model-impl.trafficgenerator");
- trafficgeneratorDependency.setVersion(version);
- dependencyList.add(trafficgeneratorDependency);
return dependencyList;
}
diff --git a/BRMSGateway/src/main/resources/logback.xml b/BRMSGateway/src/main/resources/logback.xml
index b9e12a7b3..07a587212 100644
--- a/BRMSGateway/src/main/resources/logback.xml
+++ b/BRMSGateway/src/main/resources/logback.xml
@@ -2,14 +2,14 @@
============LICENSE_START=======================================================
ONAP Policy Engine
================================================================================
- Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2017-2019 AT&T Intellectual Property. 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.
@@ -22,73 +22,73 @@
<!--<jmxConfigurator /> -->
<!-- directory path for all other type logs -->
<property name="logDir" value="${POLICY_LOGS}" />
-
+
<!-- directory path for debugging type logs -->
<property name="debugDir" value="${POLICY_LOGS}" />
-
- <!-- specify the component name
+
+ <!-- specify the component name
<ONAP-component-name>::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" -->
<property name="componentName" value="policy"></property>
<property name="subComponentName" value="brmsgw"></property>
-
+
<!-- log file names -->
<property name="errorLogName" value="error" />
<property name="metricsLogName" value="metrics" />
<property name="auditLogName" value="audit" />
<property name="debugLogName" value="debug" />
-
-
+
+
<!-- modified time stamp format -->
-
- <!-- A U D I T
- <property name="defaultAuditPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+
+ <!-- A U D I T
+ <property name="defaultAuditPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
<property name="defaultAuditPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{ElapsedTime}|%X{server}|%X{clientIpAddress}|%c||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
-->
<property name="defaultAuditPattern" value="%X{TransactionBeginTimestamp}|%X{TransactionEndTimestamp}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{TransactionElapsedTime}|%X{server}|%X{clientIpAddress}|%c||%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
-
-
-
- <!-- M E T R I C
- <property name="defaultMetricPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+
+
+
+ <!-- M E T R I C
+ <property name="defaultMetricPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
-->
<property name="defaultMetricPattern" value="%X{MetricBeginTimestamp}|%X{MetricEndTimestamp}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%p|%X{severity}|%X{serverIpAddress}|%X{MetricElapsedTime}|%X{server}|%X{clientIpAddress}|%c||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
-
-
-
-
+
+
+
+
<!-- E R R O R
<property name="defaultErrorPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDesciption}|%msg%n" />
-->
<property name="defaultErrorPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{requestId}|%t|%X{serviceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDesciption}|%msg%n" />
-
-
-
+
+
+
<!-- D E B U G
- <property name="debugLoggerPatternOld" value="%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|[%caller{3}]|%msg%n" />
- <property name="debugLoggerPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" /> -->
+ <property name="debugLoggerPatternOld" value="%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|[%caller{3}]|%msg%n" />
+ <property name="debugLoggerPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" /> -->
-->
- <property name="debugLoggerPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{RequestId}|%msg%n" />
-
-
-
- <!-- D E F A U L T
- <property name="defaultPatternOld" value="%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}|%msg%n" />
- <property name="defaultPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+ <property name="debugLoggerPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{RequestId}|%msg%n" />
+
+
+
+ <!-- D E F A U L T
+ <property name="defaultPatternOld" value="%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}|%msg%n" />
+ <property name="defaultPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
-->
<property name="defaultPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}|%c||%msg%n" />
-
-
-
+
+
+
<!-- P A T H
<property name="logDirectory" value="${catalina.base}/${logDir}/${componentName}/${subComponentName}" />
- <property name="debugLogDirectory" value="${catalina.base}/${debugDir}/${componentName}/${subComponentName}" />
- -->
+ <property name="debugLogDirectory" value="${catalina.base}/${debugDir}/${componentName}/${subComponentName}" />
+ -->
<property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" />
<property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" />
-
-
-
+
+
+
<!-- Example evaluator filter applied against console appender -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
@@ -100,28 +100,28 @@
<!-- EELF Appenders -->
<!-- ============================================================================ -->
- <!-- The EELFAppender is used to record events to the general application
+ <!-- The EELFAppender is used to record events to the general application
log -->
-
- <!-- EELF Audit Appender. This appender is used to record audit engine
- related logging events. The audit logger and appender are specializations
- of the EELF application root logger and appender. This can be used to segregate
- Policy engine events from other components, or it can be eliminated to record
+
+ <!-- EELF Audit Appender. This appender is used to record audit engine
+ related logging events. The audit logger and appender are specializations
+ of the EELF application root logger and appender. This can be used to segregate
+ Policy engine events from other components, or it can be eliminated to record
these events as part of the application root log. -->
-
+
<appender name="EELFAudit"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logDirectory}/${auditLogName}.log</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${logDirectory}/${auditLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
+
+ <!-- keep 30 days' worth of history capped at 3GB total size -->
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>10GB</totalSizeCap>
</rollingPolicy>
-
+
<encoder>
<pattern>${defaultAuditPattern}</pattern>
</encoder>
@@ -141,18 +141,18 @@
<rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${logDirectory}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
+
+ <!-- keep 30 days' worth of history capped at 3GB total size -->
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>10GB</totalSizeCap>
</rollingPolicy>
-
+
<encoder>
<pattern>${defaultMetricPattern}</pattern>
</encoder>
</appender>
-
+
<appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>256</queueSize>
<appender-ref ref="EELFMetrics"/>
@@ -160,15 +160,15 @@
-
+
<appender name="EELFError"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logDirectory}/${errorLogName}.log</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${logDirectory}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
+
+ <!-- keep 30 days' worth of history capped at 3GB total size -->
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>10GB</totalSizeCap>
@@ -176,27 +176,27 @@
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
-
+
<encoder>
<pattern>${defaultErrorPattern}</pattern>
</encoder>
</appender>
-
+
<appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>256</queueSize>
<appender-ref ref="EELFError"/>
</appender>
-
+
<appender name="EELFDebug"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${debugLogDirectory}/${debugLogName}.log</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${debugLogDirectory}/${debugLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
+
+ <!-- keep 30 days' worth of history capped at 3GB total size -->
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>10GB</totalSizeCap>
@@ -204,44 +204,44 @@
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
-
+
<encoder>
<pattern>${debugLoggerPattern}</pattern>
</encoder>
</appender>
-
+
<appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>256</queueSize>
<appender-ref ref="EELFDebug" />
<includeCallerData>true</includeCallerData>
</appender>
-
-
+
+
<!-- ============================================================================ -->
<!-- EELF loggers -->
<!-- ============================================================================ -->
-
+
<logger name="com.att.eelf.audit" level="info" additivity="false">
<appender-ref ref="asyncEELFAudit" />
</logger>
-
+
<logger name="com.att.eelf.metrics" level="info" additivity="false">
<appender-ref ref="asyncEELFMetrics" />
</logger>
-
+
<logger name="com.att.eelf.error" level="error" additivity="false">
<appender-ref ref="asyncEELFError" />
</logger>
-
+
<logger name="com.att.eelf.debug" level="info" additivity="false">
<appender-ref ref="asyncEELFDebug" />
</logger>
-
-
-
+
+
+
<root level="INFO">
<appender-ref ref="asyncEELFDebug" />
<appender-ref ref="asyncEELFError" />
</root>
-</configuration> \ No newline at end of file
+</configuration>
diff --git a/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java b/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java
index de1a7d6eb..994e97368 100644
--- a/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java
+++ b/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2020 AT&T Intellectual Property. 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.
@@ -81,7 +81,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest2() throws PolicyException {
+ public void testBrmsHandlerFail2() throws PolicyException {
final PropertyChange prop = new PropertyChange();
prop.key = "defaultName";
prop.remove = true;
@@ -92,7 +92,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest3() throws PolicyException {
+ public void testBrmsHandlerFail3() throws PolicyException {
PropertyChange prop = new PropertyChange();
prop.key = "repositoryID";
prop.remove = true;
@@ -107,7 +107,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest4() throws PolicyException {
+ public void testBrmsHandlerFail4() throws PolicyException {
final PropertyChange prop = new PropertyChange();
prop.key = "repositoryURL";
prop.remove = true;
@@ -118,7 +118,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest5() throws PolicyException {
+ public void testBrmsHandlerFail5() throws PolicyException {
final PropertyChange prop = new PropertyChange();
prop.key = "repositoryName";
prop.remove = true;
@@ -129,7 +129,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest6() throws PolicyException {
+ public void testBrmsHandlerFail6() throws PolicyException {
PropertyChange prop = new PropertyChange();
prop.key = "repositoryURL";
prop.value = "http://nexus:8081/nexus/content/repositories/releases,"
@@ -146,7 +146,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest7() throws PolicyException {
+ public void testBrmsHandlerFail7() throws PolicyException {
final PropertyChange prop = new PropertyChange();
prop.key = "repositoryPassword";
prop.remove = true;
@@ -157,7 +157,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest8() throws PolicyException {
+ public void testBrmsHandlerFail8() throws PolicyException {
final PropertyChange prop = new PropertyChange();
prop.key = "policyKeyID";
prop.remove = true;
@@ -168,7 +168,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest9() throws PolicyException {
+ public void testBrmsHandlerFail9() throws PolicyException {
PropertyChange prop = new PropertyChange();
prop.key = "sync";
prop.value = "true";
@@ -188,7 +188,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest10() throws PolicyException {
+ public void testBrmsHandlerFail10() throws PolicyException {
final PropertyChange prop = new PropertyChange();
prop.key = "groupNames";
prop.value = "";
@@ -200,7 +200,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest11() throws PolicyException {
+ public void testBrmsHandlerFail11() throws PolicyException {
final PropertyChange prop = new PropertyChange();
prop.key = "default.groupID";
prop.remove = true;
@@ -211,7 +211,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest12() throws PolicyException {
+ public void testBrmsHandlerFail12() throws PolicyException {
final PropertyChange prop = new PropertyChange();
prop.key = "default.artifactID";
prop.remove = true;
@@ -222,7 +222,7 @@ public class BrmsPushTest {
}
@Test(expected = PolicyException.class)
- public void brmsHandlerFailTest13() throws PolicyException {
+ public void testBrmsHandlerFail13() throws PolicyException {
PropertyChange prop = new PropertyChange();
prop.key = "NOTIFICATION_TYPE";
prop.value = "dmaap";
diff --git a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsGatewayTest.java b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsGatewayTest.java
index fd8a7ed3b..f5a4fff8a 100644
--- a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsGatewayTest.java
+++ b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsGatewayTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. 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.
@@ -20,37 +20,88 @@
package org.onap.policy.brms.api;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.onap.policy.api.PolicyException;
+import org.onap.policy.brms.api.BrmsGateway.Factory;
+import org.powermock.reflect.Whitebox;
-@RunWith(PowerMockRunner.class)
public class BrmsGatewayTest {
+ private static final String FACTORY_FIELD = "factory";
+
+ private static Factory saveFactory;
+
+ private Thread thread;
+
+ @BeforeClass
+ public static void setUpBeforeClass() {
+ saveFactory = Whitebox.getInternalState(BrmsGateway.class, FACTORY_FIELD);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ Whitebox.setInternalState(BrmsGateway.class, FACTORY_FIELD, saveFactory);
+ }
+
+ /**
+ * Installs a factory.
+ */
+ @Before
+ public void setUp() {
+ thread = null;
+
+ Factory factory = new Factory() {
+ @Override
+ public BrmsHandler makeBrmsHandler(String configFile) throws PolicyException {
+ // Mock handler
+ return Mockito.mock(BrmsHandler.class);
+ }
+
+ @Override
+ public Thread makeThread(Runnable runnable) {
+ thread = super.makeThread(runnable);
+ return thread;
+ }
+
+ };
+
+ Whitebox.setInternalState(BrmsGateway.class, FACTORY_FIELD, factory);
+ }
+
+ /**
+ * Interrupts the thread, if there is one.
+ */
+ @After
+ public void tearDown() throws InterruptedException {
+ if (thread != null) {
+ thread.interrupt();
+ thread.join(5000L);
+ assertFalse(thread.isAlive());
+ }
+ }
+
+ @Test
+ public void testFactory() throws InterruptedException {
+ assertNotNull(saveFactory);
+ assertNotNull(saveFactory.makeThread(() -> { }));
+ }
+
@Test
public void testGet() {
assertNull(BrmsGateway.getPolicyEngine());
}
- @PrepareForTest({Thread.class, BrmsGateway.class})
@Test
public void testMain() throws Exception {
- // Mock Thread
- PowerMockito.spy(Thread.class);
- PowerMockito.doNothing().when(Thread.class);
- Thread.sleep(1000);
-
- // Mock handler
- final BrmsHandler handler = Mockito.mock(BrmsHandler.class);
- PowerMockito.whenNew(BrmsHandler.class).withArguments(any()).thenReturn(handler);
-
- // Run app
try {
final String[] args = new String[0];
BrmsGateway.main(args);
diff --git a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java
index 1a6dc4719..079db2109 100644
--- a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java
+++ b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 2020 AT&T Intellectual Property. 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.
@@ -23,13 +23,12 @@ package org.onap.policy.brms.api;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
-import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.junit.Test;
@@ -39,14 +38,16 @@ import org.onap.policy.api.NotificationType;
import org.onap.policy.std.StdPDPNotification;
import org.onap.policy.utils.BackUpMonitor;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"})
+@PrepareForTest({Persistence.class, BackUpMonitor.class})
public class BrmsHandlerTest {
- @PrepareForTest({Persistence.class, BackUpMonitor.class})
@Test
- public void negativeTestNotifications() throws Exception {
+ public void testNegativeTestNotifications() throws Exception {
// Mock emf, persistence, and query
final EntityManagerFactory emf = Mockito.mock(EntityManagerFactory.class);
final EntityManager em = Mockito.mock(EntityManager.class);
diff --git a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java
index 2c76a2eff..3adc55700 100644
--- a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java
+++ b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 AT&T Intellectual Property. 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.
@@ -23,7 +23,7 @@ package org.onap.policy.brms.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import java.util.HashMap;
import java.util.List;
@@ -46,15 +46,17 @@ import org.onap.policy.utils.BackUpHandler;
import org.onap.policy.utils.BackUpMonitor;
import org.onap.policy.utils.BackUpMonitorException;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"})
+@PrepareForTest({Persistence.class, BackUpMonitor.class})
public class BrmsPushTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- @PrepareForTest({Persistence.class, BackUpMonitor.class})
@Test
public void testPush() throws BackUpMonitorException, PolicyException {
// Mock emf, persistence, and query
@@ -108,7 +110,7 @@ public class BrmsPushTest {
// Test misc methods
final String controllerName = "testController";
final List<Dependency> deps = push.defaultDependencies(controllerName);
- assertEquals(deps.size(), 7);
+ assertEquals(deps.size(), 6);
assertNotNull(BrmsPush.getBackUpMonitor());
assertEquals(push.urlListSize(), 1);
diff --git a/BRMSGateway/src/test/resources/config.properties b/BRMSGateway/src/test/resources/config.properties
index 48d9bc5a5..ce937dff0 100644
--- a/BRMSGateway/src/test/resources/config.properties
+++ b/BRMSGateway/src/test/resources/config.properties
@@ -81,6 +81,6 @@ ping_interval=30000
#
#
#
-brms.dependency.version=1.4.1-SNAPSHOT
+brms.dependency.version=1.6.3-SNAPSHOT
ENVIRONMENT = DEVL